JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwIntegratedRaster.h
Go to the documentation of this file.
1/*!
2 * \file QwIntegratedRaster.h
3 * \brief Integrated raster subsystem for beam position tracking
4 */
5
6#pragma once
7
8// System headers
9#include <vector>
10
11// ROOT headers
12#include "TTree.h"
13#ifdef HAS_RNTUPLE_SUPPORT
14#include "ROOT/RNTupleModel.hxx"
15#include "ROOT/RField.hxx"
16#endif // HAS_RNTUPLE_SUPPORT
17
18// Qweak headers
19#include "VQwSubsystemParity.h"
20
22#include "QwTypes.h"
23
24
25/**
26 * \class QwIntegratedRasterDetectorID
27 * \ingroup QwAnalysis_BL
28 * \brief Mapping info for integrated raster detectors
29 */
31
32 public:
33
38
40 int fWordInSubbank; //first word reported for this channel in the subbank
41 //(eg VQWK channel report 6 words for each event, scalers only report one word per event)
42 // The first word of the subbank gets fWordInSubbank=0
43
44 // EQwInstrumentType fTypeID; // type of detector
45 int fIndex; // index of this detector in the vector containing all the detector of same type
46 UInt_t fSubelement; // some detectors have many subelements (eg stripline have 4 antenas) some have only one sub element(eg lumis have one channel)
47
48 TString fmoduletype; // eg: VQWK, SCALER
50 TString fdetectortype; // IntegratedRasterChannel,fLumiCounter .. this string is encoded by fTypeID
51 // std::vector<TString> fCombinedChannelNames;
52 // std::vector<Double_t> fWeight;
53 void Print() const;
54
55};
56
57
58/*****************************************************************
59* Class:
60******************************************************************/
61/**
62 * \class QwIntegratedRaster
63 * \ingroup QwAnalysis_BL
64 * \brief Subsystem handling integrated raster X/Y channels
65 */
66class QwIntegratedRaster : public VQwSubsystemParity, public MQwSubsystemCloneable<QwIntegratedRaster> {
67 /////
68
69 private:
70 /// Private default constructor (not implemented, will throw linker error on use)
72
73 public:
74 /// Constructor with name
75 QwIntegratedRaster(const TString& name)
77 { };
78 /// Copy constructor
83 /// Virtual destructor
84 ~QwIntegratedRaster() override { };
85
86
87 /* derived from VQwSubsystem */
88
89 /// \brief Define options function
90 static void DefineOptions(QwOptions &options);
91
92
93 void ProcessOptions(QwOptions &options) override;//Handle command line options
94 Int_t LoadChannelMap(TString mapfile) override;
95 Int_t LoadInputParameters(TString pedestalfile) override;
96 Int_t LoadEventCuts(TString filename) override;//derived from VQwSubsystemParity
97 void IncrementErrorCounters() override;
98 Bool_t ApplySingleEventCuts() override;//derived from VQwSubsystemParity
99 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failures
100 UInt_t GetEventcutErrorFlag() override;//return the error flag
101
102 Bool_t CheckForBurpFail(const VQwSubsystem *subsys) override{
103 return kFALSE;
104 };
105
106 //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
107 void UpdateErrorFlag(const VQwSubsystem *ev_error) override{
108 };
109
110 void AccumulateRunningSum(VQwSubsystem* value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override;
111 //remove one entry from the running sums for devices
112 void DeaccumulateRunningSum(VQwSubsystem* value, Int_t ErrorMask=0xFFFFFFF) override{
113 };
114 void CalculateRunningAverage() override;
115
116 Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) override;
117 Int_t ProcessEvBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t* buffer, UInt_t num_words) override;
118 void PrintDetectorID() const;
119
120 void ClearEventData() override;
121 Bool_t IsGoodEvent();
122
123 void ProcessEvent() override;
124 void ExchangeProcessedData() override{};
125 void ProcessEvent_2() override{};
126
127 void SetRandomEventParameters(Double_t mean, Double_t sigma);
128 void SetRandomEventAsymmetry(Double_t asymmetry);
129 void RandomizeEventData(int helicity = 0, double time = 0.0) override;
130 void EncodeEventData(std::vector<UInt_t> &buffer) override;
131
135 void Sum(VQwSubsystem *value1, VQwSubsystem *value2) override;
136 void Difference(VQwSubsystem *value1, VQwSubsystem *value2) override;
137 void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override;
138 void Scale(Double_t factor) override;
139
141 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
142 void FillHistograms() override;
143
144 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override;
145 void ConstructBranch(TTree *tree, TString &prefix) override;
146 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file) override;
147 void FillTreeVector(QwRootTreeBranchVector &values) const override;
148
149#ifdef HAS_RNTUPLE_SUPPORT
150 // RNTuple methods
151 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs) override;
152 void FillNTupleVector(std::vector<Double_t>& values) const override;
153#endif
154#ifdef __USE_DATABASE__
155 void FillDB(QwParityDB *db, TString datatype);
156 void FillErrDB(QwParityDB *db, TString datatype);
157#endif // __USE_DATABASE__
158 void WritePromptSummary(QwPromptSummary *ps, TString type) override;
159
160 const VQwDataElement* GetChannel(const TString name) const;
161
162 Bool_t Compare(VQwSubsystem *source);
163
164 void PrintValue() const override;
165 void PrintInfo() const override;
166
167/////
168protected:
169
170 // EQwPMTInstrumentType GetDetectorTypeID(TString name);
171
172 Int_t GetDetectorIndex(TString name);
173
174 std::vector <QwIntegratedRasterChannel<QwVQWK_Channel> > fIntegratedRasterChannel;
175 std::vector <QwIntegratedRasterDetectorID> fDetectorIDs;
176
177protected:
178
179/////
180private:
182
183 static const Bool_t bDEBUG=kFALSE;
184
185};
Basic data types and constants used throughout the Qweak analysis framework.
ULong64_t BankID_t
Definition QwTypes.h:21
UInt_t ROCID_t
Definition QwTypes.h:20
Virtual base class for parity analysis subsystems.
Integrated raster channel template class for position data.
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.
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
VQwSubsystem(const TString &name)
Constructor with name.
static void DefineOptions(QwOptions &options)
Define options function.
void UpdateErrorFlag(const VQwSubsystem *ev_error) override
update the error flag in the subsystem level from the top level routines related to stability checks....
void ClearEventData() override
static const Bool_t bDEBUG
void PrintInfo() const override
Print some information about the subsystem.
Bool_t ApplySingleEventCuts() override
Apply the single event cuts.
void ProcessOptions(QwOptions &options) override
Process the command line options.
QwIntegratedRaster(const TString &name)
Constructor with name.
Int_t ProcessConfigurationBuffer(const ROCID_t roc_id, const BankID_t bank_id, UInt_t *buffer, UInt_t num_words) override
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values) override
Construct the branch and tree vector.
void FillTreeVector(QwRootTreeBranchVector &values) const override
Fill the tree vector.
VQwSubsystem & operator+=(VQwSubsystem *value) override
VQwSubsystem & operator=(VQwSubsystem *value) override
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
void ConstructBranch(TTree *tree, TString &prefix) override
Construct the branch and tree vector.
Int_t GetDetectorIndex(TString name)
void SetRandomEventAsymmetry(Double_t asymmetry)
const VQwDataElement * GetChannel(const TString name) const
VQwSubsystem & operator-=(VQwSubsystem *value) override
void IncrementErrorCounters() override
Increment the error counters.
void PrintDetectorID() const
QwIntegratedRaster()
Private default constructor (not implemented, will throw linker error on use)
void RandomizeEventData(int helicity=0, double time=0.0) override
Int_t LoadEventCuts(TString filename) override
Optional event cut file.
QwIntegratedRaster(const QwIntegratedRaster &source)
Copy constructor.
std::vector< QwIntegratedRasterChannel< QwVQWK_Channel > > fIntegratedRasterChannel
void PrintValue() const override
Print values of all channels.
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom) override
void WritePromptSummary(QwPromptSummary *ps, TString type) override
std::vector< QwIntegratedRasterDetectorID > fDetectorIDs
void Sum(VQwSubsystem *value1, VQwSubsystem *value2) override
UInt_t GetEventcutErrorFlag() override
Return the error flag to the top level routines related to stability checks and ErrorFlag updates.
void ProcessEvent() override
void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile &trim_file) override
Construct the branch and tree vector based on the trim file.
~QwIntegratedRaster() override
Virtual destructor.
void CalculateRunningAverage() override
Calculate the average for all good events.
void AccumulateRunningSum(VQwSubsystem *value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF) override
Update the running sums for devices.
Int_t LoadChannelMap(TString mapfile) override
Mandatory map file definition.
Bool_t CheckForBurpFail(const VQwSubsystem *subsys) override
Report the number of events failed due to HW and event cut failures.
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void Scale(Double_t factor) override
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms for this subsystem in a folder with a prefix.
void ProcessEvent_2() override
Process the event data again, including data from other subsystems. Not all derived classes will requ...
Int_t LoadInputParameters(TString pedestalfile) override
Mandatory parameter file definition.
void PrintErrorCounters() const 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...
void DeaccumulateRunningSum(VQwSubsystem *value, Int_t ErrorMask=0xFFFFFFF) override
remove one entry from the running sums for devices
void Difference(VQwSubsystem *value1, VQwSubsystem *value2) override
void FillHistograms() override
Fill the histograms for this subsystem.
void EncodeEventData(std::vector< UInt_t > &buffer) override
Bool_t Compare(VQwSubsystem *source)
void ExchangeProcessedData() override
Request processed data from other subsystems for internal use in the second event processing stage....
VQwSubsystemParity()
Private default constructor (not implemented, will throw linker error on use)
virtual void FillDB(QwParityDB *, TString)
Fill the database.
virtual void FillErrDB(QwParityDB *, TString)