JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwCombinedPMT.h
Go to the documentation of this file.
1/*!
2 * \file QwCombinedPMT.h
3 * \brief Combined PMT detector using Moller ADC channels
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 "QwMollerADC_Channel.h"
20#include "QwIntegrationPMT.h"
21
22// Forward declarations
23class QwBlinder;
24class QwDBInterface;
25
26/**
27 * \class QwCombinedPMT
28 * \ingroup QwAnalysis_ADC
29 * \brief Combines multiple integration PMTs into weighted sum/average
30 */
32/////
33 public:
35 InitializeChannel("", "derived");
36 };
37
38 QwCombinedPMT(TString name){
39 InitializeChannel(name, "derived");
40 };
41
42 QwCombinedPMT(TString subsystemname, TString name){
43 SetSubsystemName(subsystemname);
44 InitializeChannel(subsystemname, name, "derived");
45 };
47 : VQwDataElement(source),
49 fElement(source.fElement),
50 fWeights(source.fWeights),
51 fSumADC(source.fSumADC)
52 { }
53 ~QwCombinedPMT() override { };
54
55 void InitializeChannel(TString name, TString datatosave);
56 // new routine added to update necessary information for tree trimming
57 void InitializeChannel(TString subsystem, TString name, TString datatosave);
58 void LinkChannel(TString name);
59
60 const QwMollerADC_Channel* GetChannel(const TString name) const {
61 if (fSumADC.GetElementName() == name) return fSumADC.GetChannel(name);
62 else return 0;
63 };
64
65 void Add(QwIntegrationPMT* pmt, Double_t weight);
66
67 Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement=0) override;
68 void ClearEventData() override;
69
71
73
74 void SetRandomEventParameters(Double_t mean, Double_t sigma);
75 void SetRandomEventAsymmetry(Double_t asymmetry);
76 void RandomizeEventData(int helicity);
77 void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber = 0);
78 void SetEventData(Double_t* block, UInt_t sequencenumber);
79 void EncodeEventData(std::vector<UInt_t> &buffer);
80
81 void ProcessEvent();
82 Bool_t ApplyHWChecks();//Check for hardware errors in the devices
83 Bool_t ApplySingleEventCuts();//Check for good events by setting limits on the devices readings
84 void PrintErrorCounters() const override;// report number of events failed due to HW and event cut failure
85 /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
86 void SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability, Double_t burplevel);
87
88 void SetDefaultSampleSize(Int_t sample_size);
89 void SetEventCutMode(Int_t bcuts){
90 bEVENTCUTMODE=bcuts;
91 fSumADC.SetEventCutMode(bcuts);
92 }
93 UInt_t GetEventcutErrorFlag() override{//return the error flag
94 return fSumADC.GetEventcutErrorFlag();
95 }
96
98 fSumADC.IncrementErrorCounters();
99 }
100
101 Bool_t CheckForBurpFail(const VQwDataElement *ev_error);
102
103 UInt_t UpdateErrorFlag() override;
104 void UpdateErrorFlag(const QwCombinedPMT *ev_error);
105
106 void PrintInfo() const override;
107 void PrintValue() const override;
108
112 void Sum(const QwCombinedPMT &value1, const QwCombinedPMT &value2);
113 void Difference(const QwCombinedPMT &value1, const QwCombinedPMT &value2);
114 void Ratio(QwCombinedPMT &numer, QwCombinedPMT &denom);
115 void Scale(Double_t factor);
116 void Normalize(VQwDataElement* denom);
117 void AccumulateRunningSum(const QwCombinedPMT& value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF);
118 void DeaccumulateRunningSum(QwCombinedPMT& value, Int_t ErrorMask=0xFFFFFFF);
120
121 void SetBlindability(Bool_t isblindable){fSumADC.SetBlindability(isblindable);};
122 void SetNormalizability(Bool_t isnormalizable){fSumADC.SetNormalizability(isnormalizable);};
123
124 /// \brief Blind the asymmetry
125 void Blind(const QwBlinder *blinder);
126 /// \brief Blind the difference using the yield
127 void Blind(const QwBlinder *blinder, const QwCombinedPMT& yield);
128
129 void SetPedestal(Double_t ped);
130 void SetCalibrationFactor(Double_t calib);
131
132 void ConstructHistograms(TDirectory *folder, TString &prefix) override;
133 void FillHistograms() override;
134
135 void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values);
136 void ConstructBranch(TTree *tree, TString &prefix);
137 void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
138 void FillTreeVector(QwRootTreeBranchVector &values) const;
139
140#ifdef HAS_RNTUPLE_SUPPORT
141 // RNTuple methods
142 void ConstructNTupleAndVector(std::unique_ptr<ROOT::RNTupleModel>& model, TString& prefix, std::vector<Double_t>& values, std::vector<std::shared_ptr<Double_t>>& fieldPtrs);
143 void FillNTupleVector(std::vector<Double_t>& values) const;
144#endif // HAS_RNTUPLE_SUPPORT
145
146 std::vector<QwDBInterface> GetDBEntry();
147 std::vector<QwErrDBInterface> GetErrDBEntry();
148
149 protected:
150
151 private:
152
154 Double_t fCalibration;
155 Double_t fULimit, fLLimit;
157
158 Bool_t fGoodEvent; /// used to validate sequence number in the IsGoodEvent()
159
160 std::vector <QwIntegrationPMT*> fElement;
161 std::vector <Double_t> fWeights;
162
164 //QwIntegrationPMT fAvgADC;
165
166 Int_t fDevice_flag; /// sets the event cut level for the device
167 /// fDevice_flag=1 Event cuts & HW check,
168 /// fDevice_flag=0 HW check, fDevice_flag=-1 no check
169
170 Int_t fDeviceErrorCode; /// keep the device HW status using a unique code
171 /// from the QwMollerADC_Channel::fDeviceErrorCode
172
173 Bool_t bEVENTCUTMODE; /// If this set to kFALSE then Event cuts do not depend
174 /// on HW checks. This is set externally through the
175 /// qweak_beamline_eventcuts.map
176
177 const static Bool_t bDEBUG=kFALSE; /// debugging display purposes
178
179};
Decoding and management for Moller ADC channels (6x32-bit datawords)
Integration PMT detector for charge and asymmetry measurements.
const TString QwBPMStripline< T >::subelement[4]
Concrete hardware channel for Moller ADC modules (6x32-bit words)
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.
VQwDataElement()
Default constructor.
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
Data blinding utilities for parity violation analysis.
Definition QwBlinder.h:57
Combines multiple integration PMTs into weighted sum/average.
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t subelement=0) override
Process the CODA event buffer for this element.
void Sum(const QwCombinedPMT &value1, const QwCombinedPMT &value2)
void SetRandomEventAsymmetry(Double_t asymmetry)
void FillTreeVector(QwRootTreeBranchVector &values) const
void AccumulateRunningSum(const QwCombinedPMT &value, Int_t count=0, Int_t ErrorMask=0xFFFFFFF)
void PrintInfo() const override
Print multiple lines of information about this data element.
void DeaccumulateRunningSum(QwCombinedPMT &value, Int_t ErrorMask=0xFFFFFFF)
QwCombinedPMT & operator=(const QwCombinedPMT &value)
void SetNormalizability(Bool_t isnormalizable)
void Normalize(VQwDataElement *denom)
void ClearEventData() override
Clear event-scoped data for the sum channel.
void IncrementErrorCounters()
void CalculateRunningAverage()
void ConstructBranch(TTree *tree, TString &prefix)
void SetPedestal(Double_t ped)
void Blind(const QwBlinder *blinder)
Blind the asymmetry.
void SetEventCutMode(Int_t bcuts)
Bool_t CheckForBurpFail(const VQwDataElement *ev_error)
Check for burp failures by delegating to the sum ADC channel.
void ProcessEvent()
Process event by computing the weighted average of members.
void RandomizeEventData(int helicity)
void Scale(Double_t factor)
QwCombinedPMT(TString name)
UInt_t UpdateErrorFlag() override
Update the sum ADC error flag from member PMTs.
UInt_t GetEventcutErrorFlag() override
return the error flag on this channel/device
void LinkChannel(TString name)
Link internal sum channel names to the given detector name.
void SetBlindability(Bool_t isblindable)
void PrintErrorCounters()
QwCombinedPMT(const QwCombinedPMT &source)
Bool_t ApplyHWChecks()
Apply hardware checks (none needed at combiner level).
void Ratio(QwCombinedPMT &numer, QwCombinedPMT &denom)
void ConstructHistograms(TDirectory *folder, TString &prefix) override
Construct the histograms for this data element.
void InitializeChannel(TString name, TString datatosave)
Initialize the combined PMT with a name and data-saving mode.
static const Bool_t bDEBUG
QwIntegrationPMT fSumADC
void EncodeEventData(std::vector< UInt_t > &buffer)
std::vector< Double_t > fWeights
void PrintValue() const override
Print single line of value and error of this data element.
void SetCalibrationFactor(Double_t calib)
void SetEventData(Double_t *block, UInt_t sequencenumber)
Set the block data for the current event sequence.
const QwMollerADC_Channel * GetChannel(const TString name) const
Double_t fCalibration
void Difference(const QwCombinedPMT &value1, const QwCombinedPMT &value2)
void Add(QwIntegrationPMT *pmt, Double_t weight)
Add a PMT channel to this combination with a weight.
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
Set the hardware-level sum for a sequence (unused for combo).
~QwCombinedPMT() override
void SetDefaultSampleSize(Int_t sample_size)
Set default sample size on the sum ADC.
Double_t fSequenceNo_Prev
Bool_t ApplySingleEventCuts()
QwCombinedPMT & operator+=(const QwCombinedPMT &value)
QwCombinedPMT(TString subsystemname, TString name)
std::vector< QwIntegrationPMT * > fElement
used to validate sequence number in the IsGoodEvent()
void CalculateSumAndAverage()
Compute the weighted sum (and average) from member PMTs.
void FillHistograms() override
Fill the histograms for this data element.
std::vector< QwErrDBInterface > GetErrDBEntry()
void SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability, Double_t burplevel)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit),...
void ConstructBranchAndVector(TTree *tree, TString &prefix, QwRootTreeBranchVector &values)
std::vector< QwDBInterface > GetDBEntry()
QwCombinedPMT & operator-=(const QwCombinedPMT &value)
Integration PMT providing yield/diff/asym readout from Moller ADC.