JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwBPMCavity.h
Go to the documentation of this file.
1/*!
2 * \file QwBPMCavity.h
3 * \brief Cavity beam position monitor implementation
4 */
5
6#pragma once
7
8// System headers
9#include <vector>
10
11// ROOT headres
12#include <TTree.h>
13#ifdef HAS_RNTUPLE_SUPPORT
14#include <ROOT/RNTupleModel.hxx>
15#endif // HAS_RNTUPLE_SUPPORT
16
17// Qweak headers
18#include "QwVQWK_Channel.h"
19#include "VQwBPM.h"
20#include "QwParameterFile.h"
21#include "QwUtil.h"
22
23// Forward declarations
24class QwDBInterface;
26
27/*****************************************************************
28* Class:
29******************************************************************/
30/**
31 * \class QwBPMCavity
32 * \ingroup QwAnalysis_BL
33 * \brief Cavity-style BPM using VQWK channels
34 *
35 * Provides X/Y position and effective charge from cavity readouts, with
36 * utilities for cuts, histograms, and tree/NTuple output.
37 */
38class QwBPMCavity : public VQwBPM {
39 template <typename TT> friend class QwCombinedBPM;
40 friend class QwEnergyCalculator;
41
42 public:
44 static UInt_t GetSubElementIndex(TString subname);
45 static Bool_t ParseChannelName(const TString &channel, TString &detname,
46 TString &subname, UInt_t &localindex);
47 public:
49 QwBPMCavity(TString name):VQwBPM(name){
51 };
52 QwBPMCavity(TString subsystemname, TString name)
53 : VQwBPM(name) {
54 SetSubsystemName(subsystemname);
55 InitializeChannel(subsystemname, name);
56 };
57 QwBPMCavity(const QwBPMCavity& source)
58 : VQwBPM(source)
59 {
63 }
64 ~QwBPMCavity() override { };
65
66 void InitializeChannel(TString name);
67 // new routine added to update necessary information for tree trimming
68 void InitializeChannel(TString subsystem, TString name);
69 void ClearEventData() override;
70
71 void LoadChannelParameters(QwParameterFile &paramfile) override{
72 for(Short_t i=0;i<kNumElements;i++)
73 fElement[i].LoadChannelParameters(paramfile);
74 }
75
76 Int_t ProcessEvBuffer(UInt_t* buffer,
77 UInt_t word_position_in_buffer,UInt_t indexnumber) override;
78 void ProcessEvent() override;
79 void PrintValue() const override;
80 void PrintInfo() const override;
81
83 if (axis<0 || axis>2){
84 TString loc="QwBPMCavity::GetPosition for "
85 +this->GetElementName()+" failed for axis value "+Form("%d",axis);
86 throw std::out_of_range(loc.Data());
87 }
88 return &fAbsPos[axis];
89 }
90 const VQwHardwareChannel* GetEffectiveCharge() const override {return &fElement[kQElem];}
91
92 TString GetSubElementName(Int_t subindex) override;
93 void GetAbsolutePosition() override;
94
95 Bool_t ApplyHWChecks();//Check for hardware errors in the devices
96 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
97 //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
98 /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
99 void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel);
100 void SetEventCutMode(Int_t bcuts) override;
101 void IncrementErrorCounters() override;
102 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
103 UInt_t GetEventcutErrorFlag() override;
104 UInt_t UpdateErrorFlag() override;
105 void UpdateErrorFlag(const VQwBPM *ev_error) override;
106
107 Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override;
108
109 void SetDefaultSampleSize(Int_t sample_size) override;
110 void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override;
111 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
112 void SetEventData(Double_t* block, UInt_t sequencenumber);
113 void EncodeEventData(std::vector<UInt_t> &buffer) override;
114 void SetSubElementPedestal(Int_t j, Double_t value) override;
115 void SetSubElementCalibrationFactor(Int_t j, Double_t value) override;
116
117 void Ratio(QwBPMCavity &numer, QwBPMCavity &denom);
118 void Scale(Double_t factor) override;
119
120 VQwBPM& operator= (const VQwBPM &value) override;
121 VQwBPM& operator+= (const VQwBPM &value) override;
122 VQwBPM& operator-= (const VQwBPM &value) override;
123
124 virtual QwBPMCavity& operator= (const QwBPMCavity &value);
125 virtual QwBPMCavity& operator+= (const QwBPMCavity &value);
126 virtual QwBPMCavity& operator-= (const QwBPMCavity &value);
127
128 void AccumulateRunningSum(const VQwBPM &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
129 void AccumulateRunningSum(const QwBPMCavity &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF);
130 void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override;
131 void DeaccumulateRunningSum(QwBPMCavity &value, Int_t ErrorMask=0xFFFFFFF);
132 void CalculateRunningAverage() override;
133
134 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
135 void FillHistograms() override;
136
137 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
138 void FillTreeVector(QwRootTreeBranchVector &values) const override;
139 void ConstructBranch(TTree *tree, TString &prefix) override;
140 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist) override;
141#ifdef HAS_RNTUPLE_SUPPORT
142 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
143 void FillNTupleVector(std::vector<Double_t>& values) const override;
144#endif
145
146
147 std::vector<QwDBInterface> GetDBEntry();
148 std::vector<QwErrDBInterface> GetErrDBEntry();
149
150 protected:
151 VQwHardwareChannel* GetSubelementByName(TString ch_name) override;
152
153 /////
154 private:
155 /* Position calibration factor, transform ADC counts in mm */
156 static const Double_t kQwCavityCalibration;
157 static const TString subelement[kNumElements];
158
159
160
161 protected:
162 std::array<QwVQWK_Channel,kNumElements> fElement;//(kNumElements);
163 std::array<QwVQWK_Channel,kNumAxes> fRelPos;//(kNumAxes);
164
165 // These are the "real" data elements, to which the base class
166 // fAbsPos_base and fElement[kQElem]_base are pointers.
167 std::array<QwVQWK_Channel,kNumAxes> fAbsPos;//(kNumAxes);
168
169
170 private:
171 // Functions to be removed
172 void MakeBPMCavityList();
173 std::vector<QwVQWK_Channel> fBPMElementList;
174
175};
Parameter file parsing and management.
Decoding and management for VQWK ADC channels (6x32-bit datawords)
Helper functions and utilities for analysis operations.
void QwCopyArray(const T &a, T &b)
Definition QwUtil.h:15
Virtual base class for beam position monitors.
Configuration file parser with flexible tokenization and search capabilities.
A helper class to manage a vector of branch entries for ROOT trees.
Definition QwRootFile.h:53
The pure virtual base class of all data elements.
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
virtual const TString & GetElementName() const
Get the name of this element.
Abstract base for concrete hardware channels implementing dual-operator pattern.
Cavity-style BPM using VQWK channels.
Definition QwBPMCavity.h:38
friend class QwEnergyCalculator
Definition QwBPMCavity.h:40
static UInt_t GetSubElementIndex(TString subname)
void LoadChannelParameters(QwParameterFile &paramfile) override
Definition QwBPMCavity.h:71
std::vector< QwErrDBInterface > GetErrDBEntry()
void SetDefaultSampleSize(Int_t sample_size) override
void AccumulateRunningSum(const VQwBPM &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
void ProcessEvent() override
Bool_t ApplyHWChecks()
friend class QwCombinedBPM
Definition QwBPMCavity.h:39
const VQwHardwareChannel * GetEffectiveCharge() const override
Definition QwBPMCavity.h:90
void CalculateRunningAverage() override
Bool_t ApplySingleEventCuts() override
void GetAbsolutePosition() override
UInt_t GetEventcutErrorFlag() override
VQwHardwareChannel * GetSubelementByName(TString ch_name) override
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
QwBPMCavity(const QwBPMCavity &source)
Definition QwBPMCavity.h:57
std::array< QwVQWK_Channel, kNumAxes > fRelPos
void MakeBPMCavityList()
static const TString subelement[kNumElements]
Definition QwBPMCavity.h:34
void FillHistograms() override
TString GetSubElementName(Int_t subindex) override
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
QwBPMCavity(TString subsystemname, TString name)
Definition QwBPMCavity.h:52
void Ratio(QwBPMCavity &numer, QwBPMCavity &denom)
void SetEventData(Double_t *block, UInt_t sequencenumber)
void ClearEventData() override
std::vector< QwDBInterface > GetDBEntry()
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const override
Definition QwBPMCavity.h:82
void ConstructBranch(TTree *tree, TString &prefix) override
std::array< QwVQWK_Channel, kNumElements > fElement
std::array< QwVQWK_Channel, kNumAxes > fAbsPos
void EncodeEventData(std::vector< UInt_t > &buffer) override
void ConstructHistograms(TDirectory *folder, TString &prefix) override
~QwBPMCavity() override
Definition QwBPMCavity.h:64
VQwBPM & operator-=(const VQwBPM &value) override
void IncrementErrorCounters() override
void InitializeChannel(TString name)
void SetSingleEventCuts(TString ch_name, UInt_t errorflag, Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit),...
std::vector< QwVQWK_Channel > fBPMElementList
void SetEventCutMode(Int_t bcuts) override
static Bool_t ParseChannelName(const TString &channel, TString &detname, TString &subname, UInt_t &localindex)
void PrintValue() const override
void PrintInfo() const override
UInt_t UpdateErrorFlag() override
void PrintErrorCounters() const override
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber) override
void SetSubElementPedestal(Int_t j, Double_t value) override
void RandomizeEventData(int helicity=0, double time=0.0) override
VQwBPM & operator=(const VQwBPM &value) override
QwBPMCavity(TString name)
Definition QwBPMCavity.h:49
void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
static const Double_t kQwCavityCalibration
VQwBPM & operator+=(const VQwBPM &value) override
void Scale(Double_t factor) override
void FillTreeVector(QwRootTreeBranchVector &values) const override
Abstract base for beam position monitors (BPMs)
Definition VQwBPM.h:52
EBeamPositionMonitorAxis
Definition VQwBPM.h:72
static const TString axis[3]
Definition VQwBPM.h:333
VQwBPM()
Definition VQwBPM.h:76