JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwLinearDiodeArray.h
Go to the documentation of this file.
1/*!
2 * \file QwLinearDiodeArray.h
3 * \brief Linear diode array beam position monitor implementation
4 * \author B.Waidyawansa
5 * \date 2010-09-14
6 */
7
8#pragma once
9
10// System headers
11#include <vector>
12
13// ROOT headers
14#include <TTree.h>
15#ifdef HAS_RNTUPLE_SUPPORT
16#include "ROOT/RNTupleModel.hxx"
17#include "ROOT/RField.hxx"
18#endif // HAS_RNTUPLE_SUPPORT
19
20// Qweak headers
21#include "QwMollerADC_Channel.h"
22#include "QwVQWK_Channel.h"
23#include "VQwBPM.h"
24#include "QwParameterFile.h"
25#include "QwUtil.h"
26
27// Forward declarations
28#ifdef __USE_DATABASE__
29class QwDBInterface;
31#endif // __USE_DATABASE__
32
34
35/**
36 * \class QwLinearDiodeArray
37 * \ingroup QwAnalysis_BL
38 * \brief Linear diode array beam position monitor implementation
39 *
40 * Implements beam position monitoring using a linear array of photodiodes.
41 * Provides position calculation from diode array readouts with calibration
42 * and error handling for linear array detectors.
43 */
44template <typename ChannelType>
45class QwLinearDiodeArray : public VQwBPM {
46
47 public:
48 static UInt_t GetSubElementIndex(TString subname);
49
52 QwLinearDiodeArray(TString name):VQwBPM(name){
53 };
54 QwLinearDiodeArray(TString subsystemname, TString name):VQwBPM(name){
55 SetSubsystemName(subsystemname);
56 InitializeChannel(subsystemname, name);
57 };
58 QwLinearDiodeArray(TString subsystemname, TString name, TString type):VQwBPM(name){
59 SetSubsystemName(subsystemname);
60 SetModuleType(type);
61 InitializeChannel(subsystemname, name);
62 };
71 ~QwLinearDiodeArray() override { };
72
73 void InitializeChannel(TString name);
74 // new routine added to update necessary information for tree trimming
75 void InitializeChannel(TString subsystem, TString name);
76 void ClearEventData() override;
77
78 void LoadChannelParameters(QwParameterFile &paramfile) override{
79 for(size_t i=0;i<kMaxElements;i++)
81 }
82
83 Int_t ProcessEvBuffer(UInt_t* buffer,
84 UInt_t word_position_in_buffer,UInt_t indexnumber) override;
85 void ProcessEvent() override;
86 void PrintValue() const override;
87 void PrintInfo() const override;
88
90 if (axis<0 || axis>2){
91 TString loc="QwLinearDiodeArray::GetPosition for "
92 +this->GetElementName()+" failed for axis value "+Form("%d",axis);
93 throw std::out_of_range(loc.Data());
94 }
95 return &fAbsPos[axis];
96 }
97 const VQwHardwareChannel* GetEffectiveCharge() const override {return &fEffectiveCharge;}
98
99 TString GetSubElementName(Int_t subindex) override;
100 UInt_t SetSubElementName(TString subname);
101 void GetAbsolutePosition() override;
102
103 Bool_t ApplyHWChecks();//Check for hardware errors in the devices
104 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
105 //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
106 /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
107 void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel);
108 void SetEventCutMode(Int_t bcuts) override;
109 void IncrementErrorCounters() override;
110 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
111 UInt_t GetEventcutErrorFlag() override;
112 UInt_t UpdateErrorFlag() override;
113 void UpdateErrorFlag(const VQwBPM *ev_error) override;
114
115 Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override;
116
117 void SetDefaultSampleSize(Int_t sample_size) override;
118 void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override;
119 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
120 void SetEventData(Double_t* block, UInt_t sequencenumber);
121 void EncodeEventData(std::vector<UInt_t> &buffer) override;
122 void SetSubElementPedestal(Int_t j, Double_t value) override;
123 void SetSubElementCalibrationFactor(Int_t j, Double_t value) override;
124
125 void Ratio(VQwBPM &numer, VQwBPM &denom) override;
126 void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom);
127 void Scale(Double_t factor) override;
128
129
130 VQwBPM& operator= (const VQwBPM &value) override;
131 VQwBPM& operator+= (const VQwBPM &value) override;
132 VQwBPM& operator-= (const VQwBPM &value) override;
133
134 virtual QwLinearDiodeArray& operator= (const QwLinearDiodeArray &value);
137
138 void AccumulateRunningSum(const QwLinearDiodeArray& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF);
139 void AccumulateRunningSum(const VQwBPM& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
140 void DeaccumulateRunningSum(QwLinearDiodeArray& value, Int_t ErrorMask=0xFFFFFFF);
141 void DeaccumulateRunningSum(VQwBPM& value, Int_t ErrorMask=0xFFFFFFF) override;
142 void CalculateRunningAverage() override;
143
144 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
145 void FillHistograms() override;
146
147 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
148 void ConstructBranch(TTree *tree, TString &prefix) override;
149 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist) override;
150 void FillTreeVector(QwRootTreeBranchVector &values) const override;
151#ifdef HAS_RNTUPLE_SUPPORT
152 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
153 void FillNTupleVector(std::vector<Double_t>& values) const override;
154#endif
155
156
157#ifdef __USE_DATABASE__
158 std::vector<QwDBInterface> GetDBEntry() override;
159 std::vector<QwErrDBInterface> GetErrDBEntry() override;
160#endif
161
162 void MakeLinearArrayList();
163
164 protected:
165 VQwHardwareChannel* GetSubelementByName(TString ch_name) override;
166
167 /////
168 private:
169 static const size_t kMaxElements;
170 static const TString subelement[8];
171
172 /* Position calibration factor, transform ADC counts in mm */
173 static const Double_t kQwLinearDiodeArrayPadSize;
174
175
176
177 protected:
178 // std::vector<ChannelType> fPhotodiode;
179 std::array<ChannelType,8> fPhotodiode; //[8];
180 std::array<ChannelType,2> fRelPos; //[2];
181
182 // These are the "real" data elements, to which the base class
183 // fAbsPos_base and fEffectiveCharge_base are pointers.
184 std::array<ChannelType,2> fAbsPos; //[2];
185 ChannelType fEffectiveCharge;
186
187 std::vector<ChannelType> fLinearArrayElementList;
188
189};
Decoding and management for VQWK ADC channels (6x32-bit datawords)
Parameter file parsing and management.
Decoding and management for Moller 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.
std::shared_ptr< VQwBPM > VQwBPM_ptr
Definition VQwBPM.h:356
VQwBPM_ptr QwLinearDiodeArray_ptr
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
VQwDataElement()
Default constructor.
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
virtual const TString & GetElementName() const
Get the name of this element.
void SetModuleType(TString ModuleType)
set the type of the beam instrument
Abstract base for concrete hardware channels implementing dual-operator pattern.
VQwBPM & operator=(const VQwBPM &value) override
void ProcessEvent() override
void SetSubElementPedestal(Int_t j, Double_t value) override
std::vector< ChannelType > fLinearArrayElementList
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),...
void EncodeEventData(std::vector< UInt_t > &buffer) override
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
UInt_t UpdateErrorFlag() override
Update and return the aggregated event-cut error flag.
Bool_t ApplyHWChecks()
Apply hardware checks for all photodiode pads.
void FillHistograms() override
Fill the histograms for this data element.
TString GetSubElementName(Int_t subindex) override
void GetAbsolutePosition() override
void ConstructBranch(TTree *tree, TString &prefix) override
void DeaccumulateRunningSum(QwLinearDiodeArray &value, Int_t ErrorMask=0xFFFFFFF)
VQwBPM & operator-=(const VQwBPM &value) override
void SetEventCutMode(Int_t bcuts) override
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
Check for burp failures against another linear array of same type.
static const Double_t kQwLinearDiodeArrayPadSize
void FillTreeVector(QwRootTreeBranchVector &values) const override
void PrintErrorCounters() const override
Print error counters for all internal channels.
QwLinearDiodeArray(TString subsystemname, TString name, TString type)
QwLinearDiodeArray(TString subsystemname, TString name)
Bool_t ApplySingleEventCuts() override
Apply single-event cuts across photodiodes and derived channels.
std::array< ChannelType, 2 > fAbsPos
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
void PrintInfo() const override
Print multiple lines of information about this data element.
VQwHardwareChannel * GetSubelementByName(TString ch_name) override
Resolve an internal channel pointer by subelement name.
void PrintValue() const override
Print single line of value and error of this data element.
static const size_t kMaxElements
const VQwHardwareChannel * GetEffectiveCharge() const override
void RandomizeEventData(int helicity=0, double time=0.0) override
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const override
void AccumulateRunningSum(const QwLinearDiodeArray &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
static UInt_t GetSubElementIndex(TString subname)
std::array< ChannelType, 8 > fPhotodiode
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber) override
Process the CODA event buffer for this element.
static const TString subelement[8]
VQwBPM & operator+=(const VQwBPM &value) override
void IncrementErrorCounters() override
Increment error counters for all internal channels.
void SetDefaultSampleSize(Int_t sample_size) override
UInt_t SetSubElementName(TString subname)
void Ratio(VQwBPM &numer, VQwBPM &denom) override
void LoadChannelParameters(QwParameterFile &paramfile) override
void CalculateRunningAverage() override
void InitializeChannel(TString name)
Initialize this linear diode array with a detector name.
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms for this data element.
UInt_t GetEventcutErrorFlag() override
Aggregate and return the event-cut error flag for this array.
QwLinearDiodeArray(const QwLinearDiodeArray &source)
QwLinearDiodeArray(TString name)
std::array< ChannelType, 2 > fRelPos
void ClearEventData() override
Clear event-scoped data for all pads and derived channels.
void Scale(Double_t factor) override
void SetEventData(Double_t *block, UInt_t sequencenumber)
EBeamPositionMonitorAxis
Definition VQwBPM.h:72
static const TString axis[3]
Definition VQwBPM.h:335
VQwBPM()
Definition VQwBPM.h:76