JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwQPD.h
Go to the documentation of this file.
1/*!
2 * \file QwQPD.h
3 * \brief Quadrant photodiode beam position monitor implementation
4 *
5 * \author B.Waidyawansa
6 * \date 09-14-2010
7 */
8
9#pragma once
10
11// System headers
12#include <vector>
13
14// ROOT headers
15#include <TTree.h>
16#include <ROOT/RNTupleModel.hxx>
17
18// Qweak headers
19#include "QwVQWK_Channel.h"
20#include "VQwBPM.h"
21#include "QwParameterFile.h"
22#include "QwUtil.h"
23
24// Forward declarations
25#ifdef __USE_DATABASE__
26class QwDBInterface;
28#endif // __USE_DATABASE__
29
30/*****************************************************************
31* Class:
32******************************************************************/
33/**
34 * \class QwQPD
35 * \ingroup QwAnalysis_BL
36 * \brief Quadrant photodiode BPM computing X/Y and effective charge
37 */
38class QwQPD : public VQwBPM {
39
40 public:
41 static UInt_t GetSubElementIndex(TString subname);
42
44 };
45 QwQPD(TString name):VQwBPM(name){
47 };
48 QwQPD(TString subsystemname, TString name):VQwBPM(name){
49 SetSubsystemName(subsystemname);
50 InitializeChannel(subsystemname, name);
51 fQwQPDCalibration[0] = 1.0;
52 fQwQPDCalibration[1] = 1.0;
53 };
54 QwQPD(const QwQPD& source)
55 : VQwBPM(source),
57 {
61 }
62 ~QwQPD() override { };
63
64 void InitializeChannel(TString name);
65 // new routine added to update necessary information for tree trimming
66 void InitializeChannel(TString subsystem, TString name);
67
68 void LoadChannelParameters(QwParameterFile &paramfile) override{
69 for(Short_t i=0;i<4;i++)
71 }
72
73 void GetCalibrationFactors(Double_t AlphaX, Double_t AlphaY);
74
75 void ClearEventData() override;
76 Int_t ProcessEvBuffer(UInt_t* buffer,
77 UInt_t word_position_in_buffer,UInt_t indexnumber) override;
78 void ProcessEvent() override;
79
81 if (axis<0 || axis>2){
82 TString loc="QwQPD::GetPosition for "
83 +this->GetElementName()+" failed for axis value "+Form("%d",axis);
84 throw std::out_of_range(loc.Data());
85 }
86 return &fAbsPos[axis];
87 }
88 const VQwHardwareChannel* GetEffectiveCharge() const override {return &fEffectiveCharge;}
89
90 TString GetSubElementName(Int_t subindex) override;
91 void GetAbsolutePosition() override{};
92
93 Bool_t ApplyHWChecks();//Check for hardware errors in the devices
94 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
95 //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
96 /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
97 void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel);
98 void SetEventCutMode(Int_t bcuts) override;
99 void IncrementErrorCounters() override;
100 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
101 UInt_t GetEventcutErrorFlag() override;
102 UInt_t UpdateErrorFlag() override;
103 void UpdateErrorFlag(const VQwBPM *ev_error) override;
104
105 Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override;
106
107 void SetDefaultSampleSize(Int_t sample_size) override;
108 void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override;
109 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
110 void SetEventData(Double_t* block, UInt_t sequencenumber);
111 void EncodeEventData(std::vector<UInt_t> &buffer) override;
112 void SetSubElementPedestal(Int_t j, Double_t value) override;
113 void SetSubElementCalibrationFactor(Int_t j, Double_t value) override;
114
115 void Ratio(VQwBPM &numer, VQwBPM &denum) override;
116 void Ratio(QwQPD &numer, QwQPD &denom);
117 void Scale(Double_t factor) override;
118
119 VQwBPM& operator= (const VQwBPM &value) override;
120 VQwBPM& operator+= (const VQwBPM &value) override;
121 VQwBPM& operator-= (const VQwBPM &value) override;
122
123 virtual QwQPD& operator= (const QwQPD &value);
124 virtual QwQPD& operator+= (const QwQPD &value);
125 virtual QwQPD& operator-= (const QwQPD &value);
126
127 void AccumulateRunningSum(const QwQPD& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF);
128 void AccumulateRunningSum(const VQwBPM& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
129 void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override;
130 void DeaccumulateRunningSum(QwQPD& value, Int_t ErrorMask=0xFFFFFFF);
131 void CalculateRunningAverage() override;
132
133 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
134 void FillHistograms() override;
135
136 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
137 void ConstructBranch(TTree *tree, TString &prefix) override;
138 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist) override;
139 void FillTreeVector(QwRootTreeBranchVector &values) const override;
140#ifdef HAS_RNTUPLE_SUPPORT
141 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
142 void FillNTupleVector(std::vector<Double_t>& values) const override;
143#endif
144
145
146#ifdef __USE_DATABASE__
147 std::vector<QwDBInterface> GetDBEntry() override;
148 std::vector<QwErrDBInterface> GetErrDBEntry() override;
149#endif // __USE_DATABASE__
150
151 void MakeQPDList();
152
153
154 protected:
155 VQwHardwareChannel* GetSubelementByName(TString ch_name) override;
156
157
158 /////
159 private:
160
161
162 static const TString subelement[4];
163 /* Position calibration factor, transform ADC counts in mm */
164 Double_t fQwQPDCalibration[2];
165
166
167 protected:
168 std::array<QwVQWK_Channel,4> fPhotodiode;//[4];
169 std::array<QwVQWK_Channel,2> fRelPos;//[2];
170
171 // These are the "real" data elements, to which the base class
172 // fAbsPos_base and fEffectiveCharge_base are pointers.
173 std::array<QwVQWK_Channel,2> fAbsPos;//[2];
175
176 std::vector<QwVQWK_Channel> fQPDElementList;
177
178};
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.
const TString QwBPMStripline< T >::subelement[4]
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:55
Concrete hardware channel for VQWK ADC modules (6x32-bit words)
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.
Quadrant photodiode BPM computing X/Y and effective charge.
Definition QwQPD.h:38
static UInt_t GetSubElementIndex(TString subname)
Definition QwQPD.cc:584
QwQPD(const QwQPD &source)
Definition QwQPD.h:54
Bool_t ApplyHWChecks()
Definition QwQPD.cc:129
void ClearEventData() override
Definition QwQPD.cc:106
void AccumulateRunningSum(const QwQPD &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
Definition QwQPD.cc:705
void GetCalibrationFactors(Double_t AlphaX, Double_t AlphaY)
Definition QwQPD.cc:84
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
Definition QwQPD.cc:383
void ConstructBranch(TTree *tree, TString &prefix) override
Definition QwQPD.cc:810
void SetEventCutMode(Int_t bcuts) override
Definition QwQPD.cc:945
TString GetSubElementName(Int_t subindex) override
Definition QwQPD.cc:572
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms for this data element.
Definition QwQPD.cc:741
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Definition QwQPD.cc:784
std::array< QwVQWK_Channel, 4 > fPhotodiode
Definition QwQPD.h:168
void Scale(Double_t factor) override
Definition QwQPD.cc:675
~QwQPD() override
Definition QwQPD.h:62
void GetAbsolutePosition() override
Definition QwQPD.h:91
void LoadChannelParameters(QwParameterFile &paramfile) override
Definition QwQPD.h:68
std::array< QwVQWK_Channel, 2 > fAbsPos
Definition QwQPD.h:173
void ProcessEvent() override
Definition QwQPD.cc:453
void Ratio(VQwBPM &numer, VQwBPM &denum) override
Definition QwQPD.cc:670
UInt_t GetEventcutErrorFlag() override
Definition QwQPD.cc:173
VQwHardwareChannel * GetSubelementByName(TString ch_name) override
Definition QwQPD.cc:257
QwQPD()
Definition QwQPD.h:43
void SetDefaultSampleSize(Int_t sample_size) override
Definition QwQPD.cc:1052
VQwBPM & operator-=(const VQwBPM &value) override
Definition QwQPD.cc:638
QwQPD(TString name)
Definition QwQPD.h:45
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const override
Definition QwQPD.h:80
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber) override
Definition QwQPD.cc:557
QwVQWK_Channel fEffectiveCharge
Definition QwQPD.h:174
VQwBPM & operator+=(const VQwBPM &value) override
Definition QwQPD.cc:617
void SetSubElementPedestal(Int_t j, Double_t value) override
Definition QwQPD.cc:1059
std::vector< QwVQWK_Channel > fQPDElementList
Definition QwQPD.h:176
QwQPD(TString subsystemname, TString name)
Definition QwQPD.h:48
const VQwHardwareChannel * GetEffectiveCharge() const override
Definition QwQPD.h:88
UInt_t UpdateErrorFlag() override
Definition QwQPD.cc:193
Bool_t ApplySingleEventCuts() override
Definition QwQPD.cc:219
void CalculateRunningAverage() override
Definition QwQPD.cc:688
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
Definition QwQPD.cc:999
void PrintErrorCounters() const override
Definition QwQPD.cc:160
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
Definition QwQPD.cc:1065
void InitializeChannel(TString name)
Definition QwQPD.cc:31
Double_t fQwQPDCalibration[2]
Definition QwQPD.h:164
void EncodeEventData(std::vector< UInt_t > &buffer) override
Definition QwQPD.cc:1046
void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override
Definition QwQPD.cc:719
void FillHistograms() override
Fill the histograms for this data element.
Definition QwQPD.cc:765
void MakeQPDList()
Definition QwQPD.cc:958
VQwBPM & operator=(const VQwBPM &value) override
Definition QwQPD.cc:597
std::array< QwVQWK_Channel, 2 > fRelPos
Definition QwQPD.h:169
void IncrementErrorCounters() override
Definition QwQPD.cc:147
void FillTreeVector(QwRootTreeBranchVector &values) const override
Definition QwQPD.cc:875
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),...
Definition QwQPD.cc:334
void RandomizeEventData(int helicity=0, double time=0.0) override
Definition QwQPD.cc:1027
void SetEventData(Double_t *block, UInt_t sequencenumber)
Definition QwQPD.cc:1035
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