JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
VQwDetectorArray.h
Go to the documentation of this file.
1/**********************************************************\
2* File: VQwDetectorArray.h *
3* *
4* Author: Kevin Ward (Original code by P.M. King) *
5* Time-stamp: <2007-05-08 15:40> *
6\**********************************************************/
7
8///
9/// \ingroup QwAnalysis_ADC
10
11/*!
12 * \file VQwDetectorArray.h
13 * \brief Virtual base class for detector arrays (PMTs, etc.)
14 */
15
16#pragma once
17
18// System headers
19#include <vector>
20
21// ROOT headers
22#ifdef HAS_RNTUPLE_SUPPORT
23#include "ROOT/RNTupleModel.hxx"
24#endif // HAS_RNTUPLE_SUPPORT
25
26// Qweak headers
27#include "VQwSubsystemParity.h"
28#include "QwIntegrationPMT.h"
29#include "QwCombinedPMT.h"
30
31
33 /**
34 * \class QwDetectorArrayID
35 * \ingroup QwAnalysis_ADC
36 * \brief Identifier and mapping information for detector-array channels
37 *
38 * Encapsulates mapping metadata for channels in a detector array,
39 * including subbank indexing, subelement, type, and naming.
40 */
41
42 public:
43
47
49 int fWordInSubbank; //first word reported for this channel in the subbank
50 //(eg VQWK channel report 6 words for each event, scalers only report one word per event)
51 // The first word of the subbank gets fWordInSubbank=0
52
53 EQwPMTInstrumentType fTypeID; // type of detector
54 int fIndex; // index of this detector in the vector containing all the detector of same type
55 UInt_t fSubelement; // some detectors have many subelements (eg stripline have 4 antenas)
56 // some have only one sub element(eg lumis have one channel)
57
58 TString fmoduletype; // eg: VQWK, SCALER
60 TString fdetectortype; // stripline, IntegrationPMT, ... this string is encoded by fTypeID
61
62 std::vector<TString> fCombinedChannelNames;
63 std::vector<Double_t> fWeight;
64
65 void Print() const;
66
67};
68
69
70/**
71 * \class VQwDetectorArray
72 * \ingroup QwAnalysis_ADC
73 * \brief Abstract base for arrays of PMT-like detectors
74 *
75 * Provides common functionality for subsystems composed of multiple
76 * integration PMTs and combined PMTs, including normalization,
77 * histogram/NTuple construction, and running statistics.
78 */
79class VQwDetectorArray: virtual public VQwSubsystemParity {
80
81 /******************************************************************
82 * Class: QwDetectorArray
83 *
84 *
85 ******************************************************************/
86
87 private:
88
89 /// Private default constructor (not implemented, will throw linker error on use)
91
92 public:
93
94 /// Constructor with name
95 VQwDetectorArray(const TString& name)
97
98 fTargetCharge.InitializeChannel("q_targ","derived");
99 fTargetX.InitializeChannel("x_targ","derived");
100 fTargetY.InitializeChannel("y_targ","derived");
101 fTargetXprime.InitializeChannel("xp_targ","derived");
102 fTargetYprime.InitializeChannel("yp_targ","derived");
103 fTargetEnergy.InitializeChannel("e_targ","derived");
104
105 };
106
107 /// Copy constructor
108
114
115 /// Virtual destructor
116
117 ~VQwDetectorArray() override { };
118
119 /* Member functions derived from VQwSubsystemParity. */
120
121 /// \brief Define options function
122
123 static void DefineOptions(QwOptions &options);
124
125
126 void ProcessOptions(QwOptions &options) override;//Handle command line options
127 Int_t LoadChannelMap(TString mapfile) override;
128 Int_t LoadInputParameters(TString pedestalfile) override;
129 void LoadEventCuts_Init() override {};
130 void LoadEventCuts_Line(QwParameterFile &mapstr, TString &varvalue, Int_t &eventcut_flag) override;
131 void LoadEventCuts_Fin(Int_t &eventcut_flag) override;
132 Bool_t ApplySingleEventCuts() override;//Check for good events by setting limits on the devices readings
133
134 Bool_t CheckForBurpFail(const VQwSubsystem *subsys) override;
135
136 void IncrementErrorCounters() override;
137 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
138 UInt_t GetEventcutErrorFlag() override;//return the error flag
139
140 //update the error flag in the subsystem level from the top level routines related to stability checks. This will uniquely update the errorflag at each channel based on the error flag in the corresponding channel in the ev_error subsystem
141 void UpdateErrorFlag(const VQwSubsystem *ev_error) override;
142
143
144 Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) override;
145 Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) override;
146
147 void ClearEventData() override;
148 Bool_t IsGoodEvent();
149
150 void ProcessEvent() override;
151 void ExchangeProcessedData() override;
152 void ProcessEvent_2() override;
153
154 Bool_t PublishInternalValues() const override;
155 Bool_t PublishByRequest(TString device_name) override;
156
157 void SetRandomEventParameters(Double_t mean, Double_t sigma);
158 void SetRandomEventAsymmetry(Double_t asymmetry);
159 void RandomizeEventData(int helicity = 0, Double_t time = 0.0) override;
160 void EncodeEventData(std::vector<UInt_t> &buffer) override;
161 void RandomizeMollerEvent(int helicity/*, const QwBeamCharge& charge, const QwBeamPosition& xpos, const QwBeamPosition& ypos, const QwBeamAngle& xprime, const QwBeamAngle& yprime, const QwBeamEnergy& energy*/);
162
163 void ConstructHistograms(TDirectory *folder) override{
164
165 TString tmpstr("");
166 ConstructHistograms(folder,tmpstr);
167 };
168
170 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
171 void FillHistograms() override;
172
174 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
175 void ConstructBranch(TTree *tree, TString &prefix) override;
176 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file ) override;
177
178 void FillTreeVector(QwRootTreeBranchVector &values) const override;
179#ifdef HAS_RNTUPLE_SUPPORT
180 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
181 void FillNTupleVector(std::vector<Double_t>& values) const override;
182#endif // HAS_RNTUPLE_SUPPORT
183
184#ifdef __USE_DATABASE__
185 void FillDB(QwParityDB *db, TString datatype);
186 void FillErrDB(QwParityDB *db, TString datatype);
187#endif // __USE_DATABASE__
188
189 const QwIntegrationPMT* GetChannel(const TString name) const;
190
191 Bool_t Compare(VQwSubsystem* source);
192
193
194 VQwSubsystem& operator= ( VQwSubsystem *value) override;
195 VQwSubsystem& operator+= ( VQwSubsystem *value) override;
196 VQwSubsystem& operator-= ( VQwSubsystem *value) override;
197
198
199 void Ratio(VQwSubsystem* numer, VQwSubsystem* denom) override;
200 void Scale(Double_t factor) override;
201 void Normalize(VQwDataElement* denom);
202
203 void AccumulateRunningSum(VQwSubsystem* value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
204 //remove one entry from the running sums for devices
205 void DeaccumulateRunningSum(VQwSubsystem* value, Int_t ErrorMask=0xFFFFFFF) override;
206 void CalculateRunningAverage() override;
207
208 const QwIntegrationPMT* GetIntegrationPMT(const TString name) const;
209 const QwCombinedPMT* GetCombinedPMT(const TString name) const;
210
211 void DoNormalization(Double_t factor=1.0);
212
213 Bool_t ApplyHWChecks(){//Check for hardware errors in the devices
214
215 Bool_t status = kTRUE;
216
217 for (size_t i=0; i<fIntegrationPMT.size(); i++){
218
219 status &= fIntegrationPMT.at(i).ApplyHWChecks();
220
221 }
222
223 return status;
224
225 };
226
227 void LoadMockDataParameters(TString pedestalfile) override;
228
229 void PrintValue() const override;
230 void WritePromptSummary(QwPromptSummary *ps, TString type) override;
231 void PrintInfo() const override;
232 void PrintDetectorID() const;
233
234
235 protected:
236
237 Bool_t fDEBUG;
238
240
241 // when the type and the name is passed the detector index from appropriate vector
242 // will be returned. For example if TypeID is IntegrationPMT then the index of
243 // the detector from fIntegrationPMT vector for given name will be returned.
244 Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name);
245
246 std::vector <QwIntegrationPMT> fIntegrationPMT;
247 std::vector <QwCombinedPMT> fCombinedPMT;
248 std::vector <QwDetectorArrayID> fMainDetID;
249
250
251
252
253 /*
254 Maybe have an array of QwIntegrationPMT to describe the Sector, Ring, Slice structure? Maybe hold Ring 5 out and have it described as one list by Sector and slice?
255 Need a way to define the correlations to all beam parameters for each element.
256 Need a way to define asymmetries for each element.
257 Need a way to create the full event data buffers
258 Start with all channels and modules in a single ROC subbank: make a mock_moller_adc.map with 28 8-channel modules with names like we discussed
259 Make a new RandomizeEventData which will take the helicity and beam current and beam params, and fill the detector elements as we discussed.
260 */
261
262
263 protected:
264
271
273
276
277 private:
278
279 static const Bool_t bDEBUG=kFALSE;
281
282};
class QwMollerADC_Channel QwBeamCharge
Definition QwTypes.h:321
class QwMollerADC_Channel QwBeamEnergy
Definition QwTypes.h:324
static const UInt_t kInvalidSubelementIndex
Definition QwTypes.h:198
ULong64_t BankID_t
Definition QwTypes.h:21
class QwMollerADC_Channel QwBeamAngle
Definition QwTypes.h:323
EQwPMTInstrumentType
Definition QwTypes.h:135
@ kQwUnknownPMT
Definition QwTypes.h:136
UInt_t ROCID_t
Definition QwTypes.h:20
class QwMollerADC_Channel QwBeamPosition
Definition QwTypes.h:322
Combined PMT detector using Moller ADC channels.
Virtual base class for parity analysis subsystems.
Integration PMT detector for charge and asymmetry measurements.
Command-line and configuration file options processor.
Definition QwOptions.h:141
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.
Base class for subsystems implementing container-delegation pattern.
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
VQwSubsystem(const TString &name)
Constructor with name.
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)=0
Construct the branch and tree vector.
Combines multiple integration PMTs into weighted sum/average.
Integration PMT providing yield/diff/asym readout from Moller ADC.
std::vector< Double_t > fWeight
std::vector< TString > fCombinedChannelNames
EQwPMTInstrumentType fTypeID
Int_t LoadInputParameters(TString pedestalfile) override
Mandatory parameter file definition.
Bool_t ApplySingleEventCuts() override
Apply the single event cuts.
VQwDetectorArray(const VQwDetectorArray &source)
Copy constructor.
void LoadEventCuts_Fin(Int_t &eventcut_flag) override
const QwCombinedPMT * GetCombinedPMT(const TString name) const
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override
Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name)
void ProcessOptions(QwOptions &options) override
void ConstructHistograms(TDirectory *folder) override
Construct the histograms for this subsystem in a folder.
void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Update the running sums for devices.
QwBeamPosition fTargetX
const QwIntegrationPMT * GetChannel(const TString name) const
EQwPMTInstrumentType GetDetectorTypeID(TString name)
void DoNormalization(Double_t factor=1.0)
void LoadMockDataParameters(TString pedestalfile) override
VQwDetectorArray()
Private default constructor (not implemented, will throw linker error on use)
QwBeamAngle fTargetXprime
QwBeamPosition fTargetY
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill the tree vector.
Int_t LoadChannelMap(TString mapfile) override
void IncrementErrorCounters() override
Increment the error counters.
void DeaccumulateRunningSum(VQwSubsystem *value, Int_t ErrorMask=0xFFFFFFF) override
remove one entry from the running sums for devices
void ConstructBranch(TTree *tree, TString &prefix) override
Construct the branch and tree vector.
void WritePromptSummary(QwPromptSummary *ps, TString type) override
Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
std::vector< QwIntegrationPMT > fIntegrationPMT
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Bool_t CheckForBurpFail(const VQwSubsystem *subsys) override
Report the number of events failed due to HW and event cut failures.
void LoadEventCuts_Init() override
void LoadEventCuts_Line(QwParameterFile &mapstr, TString &varvalue, Int_t &eventcut_flag) override
Bool_t Compare(VQwSubsystem *source)
VQwSubsystem & operator-=(VQwSubsystem *value) override
void PrintDetectorID() const
void PrintErrorCounters() const override
QwBeamAngle fTargetYprime
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
static const Bool_t bDEBUG
VQwDetectorArray(const TString &name)
Constructor with name.
void ExchangeProcessedData() override
Bool_t PublishInternalValues() const override
std::vector< QwDetectorArrayID > fMainDetID
~VQwDetectorArray() override
Virtual destructor.
void EncodeEventData(std::vector< UInt_t > &buffer) override
void Normalize(VQwDataElement *denom)
VQwSubsystem & operator+=(VQwSubsystem *value) override
QwBeamCharge fTargetCharge
std::vector< QwCombinedPMT > fCombinedPMT
VQwSubsystem & operator=(VQwSubsystem *value) override
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
void PrintValue() const override
Print values of all channels.
void SetRandomEventAsymmetry(Double_t asymmetry)
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct the branch and tree vector.
UInt_t GetEventcutErrorFlag() override
Return the error flag to the top level routines related to stability checks and ErrorFlag updates.
Bool_t PublishByRequest(TString device_name) override
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void PrintInfo() const override
Print some information about the subsystem.
void CalculateRunningAverage() override
Calculate the average for all good events.
void Scale(Double_t factor) override
void ProcessEvent() override
void RandomizeMollerEvent(int helicity)
void ClearEventData() override
void ProcessEvent_2() override
Process the event data again, including data from other subsystems. Not all derived classes will requ...
const QwIntegrationPMT * GetIntegrationPMT(const TString name) const
void RandomizeEventData(int helicity=0, Double_t time=0.0) override
QwBeamEnergy fTargetEnergy
void FillHistograms() override
Fill the histograms for this subsystem.
VQwSubsystemParity()
Private default constructor (not implemented, will throw linker error on use)
virtual void FillDB(QwParityDB *, TString)
Fill the database.
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
virtual void FillErrDB(QwParityDB *, TString)