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#include <ROOT/RNTupleModel.hxx>
16
17// Qweak headers
18#include "QwVQWK_Channel.h"
19#include "VQwBPM.h"
20#include "QwParameterFile.h"
21
22// Forward declarations
23class QwDBInterface;
25
26/**
27 * \class QwLinearDiodeArray
28 * \ingroup QwAnalysis_BL
29 * \brief Linear diode array beam position monitor implementation
30 *
31 * Implements beam position monitoring using a linear array of photodiodes.
32 * Provides position calculation from diode array readouts with calibration
33 * and error handling for linear array detectors.
34 */
35class QwLinearDiodeArray : public VQwBPM {
36
37 public:
38 static UInt_t GetSubElementIndex(TString subname);
39
42 QwLinearDiodeArray(TString name):VQwBPM(name){
43 };
44 QwLinearDiodeArray(TString subsystemname, TString name):VQwBPM(name){
45 SetSubsystemName(subsystemname);
46 InitializeChannel(subsystemname, name);
47 };
49 : VQwBPM(source),
51 {
52 for (size_t i = 0; i < 2; i++) {
53 fRelPos[i] = source.fRelPos[i];
54 fAbsPos[i] = source.fAbsPos[i];
55 }
56 for (size_t i = 0; i < 8; i++) {
57 fPhotodiode[i] = source.fPhotodiode[i];
58 }
59 }
60 ~QwLinearDiodeArray() override { };
61
62 void InitializeChannel(TString name);
63 // new routine added to update necessary information for tree trimming
64 void InitializeChannel(TString subsystem, TString name);
65 void ClearEventData() override;
66
67 void LoadChannelParameters(QwParameterFile &paramfile) override{
68 for(size_t i=0;i<kMaxElements;i++)
70 }
71
72 Int_t ProcessEvBuffer(UInt_t* buffer,
73 UInt_t word_position_in_buffer,UInt_t indexnumber) override;
74 void ProcessEvent() override;
75 void PrintValue() const override;
76 void PrintInfo() const override;
77
79 if (axis<0 || axis>2){
80 TString loc="QwLinearDiodeArray::GetPosition for "
81 +this->GetElementName()+" failed for axis value "+Form("%d",axis);
82 throw std::out_of_range(loc.Data());
83 }
84 return &fAbsPos[axis];
85 }
86 const VQwHardwareChannel* GetEffectiveCharge() const override {return &fEffectiveCharge;}
87
88 TString GetSubElementName(Int_t subindex) override;
89 UInt_t SetSubElementName(TString subname);
90 void GetAbsolutePosition() override;
91
92 Bool_t ApplyHWChecks();//Check for hardware errors in the devices
93 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
94 //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
95 /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
96 void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t minX, Double_t maxX, Double_t stability, Double_t burplevel);
97 void SetEventCutMode(Int_t bcuts) override;
98 void IncrementErrorCounters() override;
99 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
100 UInt_t GetEventcutErrorFlag() override;
101 UInt_t UpdateErrorFlag() override;
102 void UpdateErrorFlag(const VQwBPM *ev_error) override;
103
104 Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override;
105
106 void SetDefaultSampleSize(Int_t sample_size) override;
107 void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override;
108 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
109 void SetEventData(Double_t* block, UInt_t sequencenumber);
110 void EncodeEventData(std::vector<UInt_t> &buffer) override;
111 void SetSubElementPedestal(Int_t j, Double_t value) override;
112 void SetSubElementCalibrationFactor(Int_t j, Double_t value) override;
113
114 void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom);
115 void Scale(Double_t factor) override;
116
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 QwLinearDiodeArray& operator= (const QwLinearDiodeArray &value);
125
126 void AccumulateRunningSum(const QwLinearDiodeArray& 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(QwLinearDiodeArray& value, Int_t ErrorMask=0xFFFFFFF);
129 void DeaccumulateRunningSum(VQwBPM& value, Int_t ErrorMask=0xFFFFFFF) override;
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
146 std::vector<QwDBInterface> GetDBEntry();
147 std::vector<QwErrDBInterface> GetErrDBEntry();
148
149 void MakeLinearArrayList();
150
151 protected:
152 VQwHardwareChannel* GetSubelementByName(TString ch_name) override;
153
154 /////
155 private:
156 static const size_t kMaxElements;
157 static const TString subelement[8];
158
159 /* Position calibration factor, transform ADC counts in mm */
160 static const Double_t kQwLinearDiodeArrayPadSize;
161
162
163
164 protected:
165 // std::vector<QwVQWK_Channel> fPhotodiode;
168
169 // These are the "real" data elements, to which the base class
170 // fAbsPos_base and fEffectiveCharge_base are pointers.
173
174 std::vector<QwVQWK_Channel> fLinearArrayElementList;
175
176};
Parameter file parsing and management.
Decoding and management for VQWK ADC channels (6x32-bit datawords)
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
Concrete hardware channel for VQWK ADC modules (6x32-bit words)
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.
Abstract base for concrete hardware channels implementing dual-operator pattern.
void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom)
QwLinearDiodeArray(TString name)
std::vector< QwDBInterface > GetDBEntry()
static UInt_t GetSubElementIndex(TString subname)
void SetSubElementCalibrationFactor(Int_t j, Double_t value) override
void ProcessEvent() override
std::vector< QwVQWK_Channel > fLinearArrayElementList
void FillTreeVector(QwRootTreeBranchVector &values) const override
Bool_t ApplySingleEventCuts() override
Apply single-event cuts across photodiodes and derived channels.
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 DeaccumulateRunningSum(QwLinearDiodeArray &value, Int_t ErrorMask=0xFFFFFFF)
std::vector< QwErrDBInterface > GetErrDBEntry()
VQwHardwareChannel * GetSubelementByName(TString ch_name) override
Resolve an internal channel pointer by subelement name.
void GetAbsolutePosition() override
Bool_t ApplyHWChecks()
Apply hardware checks for all photodiode pads.
void RandomizeEventData(int helicity=0, double time=0.0) override
void InitializeChannel(TString name)
Initialize this linear diode array with a detector name.
void ClearEventData() override
Clear event-scoped data for all pads and derived channels.
static const size_t kMaxElements
VQwBPM & operator-=(const VQwBPM &value) override
void PrintInfo() const override
Print multiple lines of information about this data element.
QwVQWK_Channel fRelPos[2]
void SetEventData(Double_t *block, UInt_t sequencenumber)
void EncodeEventData(std::vector< UInt_t > &buffer) override
void PrintValue() const override
Print single line of value and error of this data element.
void PrintErrorCounters() const override
Print error counters for all internal channels.
VQwBPM & operator+=(const VQwBPM &value) override
QwVQWK_Channel fAbsPos[2]
void IncrementErrorCounters() override
Increment error counters for all internal channels.
TString GetSubElementName(Int_t subindex) override
UInt_t UpdateErrorFlag() override
Update and return the aggregated event-cut error flag.
QwVQWK_Channel fPhotodiode[8]
UInt_t GetEventcutErrorFlag() override
Aggregate and return the event-cut error flag for this array.
static const TString subelement[8]
void SetDefaultSampleSize(Int_t sample_size) override
void CalculateRunningAverage() override
void SetEventCutMode(Int_t bcuts) override
void SetSubElementPedestal(Int_t j, Double_t value) override
UInt_t SetSubElementName(TString subname)
void LoadChannelParameters(QwParameterFile &paramfile) override
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY) override
QwLinearDiodeArray(TString subsystemname, TString name)
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 Double_t kQwLinearDiodeArrayPadSize
VQwBPM & operator=(const VQwBPM &value) override
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms for this data element.
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const override
void AccumulateRunningSum(const QwLinearDiodeArray &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
void Scale(Double_t factor) override
void FillHistograms() override
Fill the histograms for this data element.
const VQwHardwareChannel * GetEffectiveCharge() const override
void ConstructBranch(TTree *tree, TString &prefix) override
QwLinearDiodeArray(const QwLinearDiodeArray &source)
Bool_t CheckForBurpFail(const VQwDataElement *ev_error) override
Check for burp failures against another linear array of same type.
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
QwVQWK_Channel fEffectiveCharge
EBeamPositionMonitorAxis
Definition VQwBPM.h:72
static const TString axis[3]
Definition VQwBPM.h:333
VQwBPM()
Definition VQwBPM.h:76