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(QwQPD &numer, QwQPD &denom);
116 void Scale(Double_t factor) override;
117
118 VQwBPM& operator= (const VQwBPM &value) override;
119 VQwBPM& operator+= (const VQwBPM &value) override;
120 VQwBPM& operator-= (const VQwBPM &value) override;
121
122 virtual QwQPD& operator= (const QwQPD &value);
123 virtual QwQPD& operator+= (const QwQPD &value);
124 virtual QwQPD& operator-= (const QwQPD &value);
125
126 void AccumulateRunningSum(const QwQPD& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF);
127 void AccumulateRunningSum(const VQwBPM& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
128 void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override;
129 void DeaccumulateRunningSum(QwQPD& value, Int_t ErrorMask=0xFFFFFFF);
130 void CalculateRunningAverage() override;
131
132 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
133 void FillHistograms() override;
134
135 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
136 void ConstructBranch(TTree *tree, TString &prefix) override;
137 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist) override;
138 void FillTreeVector(QwRootTreeBranchVector &values) const override;
139#ifdef HAS_RNTUPLE_SUPPORT
140 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
141 void FillNTupleVector(std::vector<Double_t>& values) const override;
142#endif
143
144
145#ifdef __USE_DATABASE__
146 std::vector<QwDBInterface> GetDBEntry();
147 std::vector<QwErrDBInterface> GetErrDBEntry();
148#endif // __USE_DATABASE__
149
150 void MakeQPDList();
151
152
153 protected:
154 VQwHardwareChannel* GetSubelementByName(TString ch_name) override;
155
156
157 /////
158 private:
159
160
161 static const TString subelement[4];
162 /* Position calibration factor, transform ADC counts in mm */
163 Double_t fQwQPDCalibration[2];
164
165
166 protected:
167 std::array<QwVQWK_Channel,4> fPhotodiode;//[4];
168 std::array<QwVQWK_Channel,2> fRelPos;//[2];
169
170 // These are the "real" data elements, to which the base class
171 // fAbsPos_base and fEffectiveCharge_base are pointers.
172 std::array<QwVQWK_Channel,2> fAbsPos;//[2];
174
175 std::vector<QwVQWK_Channel> fQPDElementList;
176
177};
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:53
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:702
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:807
void SetEventCutMode(Int_t bcuts) override
Definition QwQPD.cc:942
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:738
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Definition QwQPD.cc:781
std::array< QwVQWK_Channel, 4 > fPhotodiode
Definition QwQPD.h:167
void Scale(Double_t factor) override
Definition QwQPD.cc:672
~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:172
void ProcessEvent() override
Definition QwQPD.cc:453
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:1049
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:173
VQwBPM & operator+=(const VQwBPM &value) override
Definition QwQPD.cc:617
void SetSubElementPedestal(Int_t j, Double_t value) override
Definition QwQPD.cc:1056
std::vector< QwVQWK_Channel > fQPDElementList
Definition QwQPD.h:175
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:685
void Ratio(QwQPD &numer, QwQPD &denom)
Definition QwQPD.cc:660
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
Definition QwQPD.cc:996
void PrintErrorCounters() const override
Definition QwQPD.cc:160
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
Definition QwQPD.cc:1062
void InitializeChannel(TString name)
Definition QwQPD.cc:31
Double_t fQwQPDCalibration[2]
Definition QwQPD.h:163
void EncodeEventData(std::vector< UInt_t > &buffer) override
Definition QwQPD.cc:1043
void DeaccumulateRunningSum(VQwBPM &value, Int_t ErrorMask=0xFFFFFFF) override
Definition QwQPD.cc:716
void FillHistograms() override
Fill the histograms for this data element.
Definition QwQPD.cc:762
void MakeQPDList()
Definition QwQPD.cc:955
VQwBPM & operator=(const VQwBPM &value) override
Definition QwQPD.cc:597
std::array< QwVQWK_Channel, 2 > fRelPos
Definition QwQPD.h:168
void IncrementErrorCounters() override
Definition QwQPD.cc:147
void FillTreeVector(QwRootTreeBranchVector &values) const override
Definition QwQPD.cc:872
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:1024
void SetEventData(Double_t *block, UInt_t sequencenumber)
Definition QwQPD.cc:1032
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