QwAnalysis
QwCombinedPMT.h
Go to the documentation of this file.
1 
2 #ifndef __QwVQWK_COMBINEDPMT__
3 #define __QwVQWK_COMBINEDPMT__
4 
5 // System headers
6 #include <vector>
7 
8 // ROOT headers
9 #include <TTree.h>
10 
11 // Qweak headers
12 #include "QwVQWK_Channel.h"
13 #include "QwIntegrationPMT.h"
14 
15 // Forward declarations
16 class QwBlinder;
17 class QwDBInterface;
18 
19 class QwCombinedPMT : public VQwDataElement {
20 /////
21  public:
23  InitializeChannel("", "derived");
24  };
25 
26  QwCombinedPMT(TString name){
27  InitializeChannel(name, "derived");
28  };
29 
30  QwCombinedPMT(TString subsystemname, TString name){
31  SetSubsystemName(subsystemname);
32  InitializeChannel(subsystemname, name, "derived");
33  };
35  : VQwDataElement(source),
36  fCalibration(source.fCalibration),
37  fElement(source.fElement),
38  fWeights(source.fWeights),
39  fSumADC(source.fSumADC)
40  { }
41  virtual ~QwCombinedPMT() { };
42 
43  void InitializeChannel(TString name, TString datatosave);
44  // new routine added to update necessary information for tree trimming
45  void InitializeChannel(TString subsystem, TString name, TString datatosave);
46  void LinkChannel(TString name);
47 
48  const QwVQWK_Channel* GetChannel(const TString name) const {
49  if (fSumADC.GetElementName() == name) return fSumADC.GetChannel(name);
50  else return 0;
51  };
52 
53  void Add(QwIntegrationPMT* pmt, Double_t weight);
54 
55  Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement=0);
56  void ClearEventData();
57 
58  void PrintErrorCounters();
59 
61 
62  void SetRandomEventParameters(Double_t mean, Double_t sigma);
63  void SetRandomEventAsymmetry(Double_t asymmetry);
64  void RandomizeEventData(int helicity);
65  void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber = 0);
66  void SetEventData(Double_t* block, UInt_t sequencenumber);
67  void EncodeEventData(std::vector<UInt_t> &buffer);
68 
69  void ProcessEvent();
70  Bool_t ApplyHWChecks();//Check for harware errors in the devices
71  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
72  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
73  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
74  void SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability);
75 
76  void SetDefaultSampleSize(Int_t sample_size);
77  void SetEventCutMode(Int_t bcuts){
78  bEVENTCUTMODE=bcuts;
79  fSumADC.SetEventCutMode(bcuts);
80  }
81  UInt_t GetEventcutErrorFlag(){//return the error flag
83  }
84 
87  }
88 
89  UInt_t UpdateErrorFlag();
90  void UpdateErrorFlag(const QwCombinedPMT *ev_error);
91 
92  void PrintInfo() const;
93  void PrintValue() const;
94 
95  QwCombinedPMT& operator= (const QwCombinedPMT &value);
98  void Sum(QwCombinedPMT &value1, QwCombinedPMT &value2);
99  void Difference(QwCombinedPMT &value1, QwCombinedPMT &value2);
100  void Ratio(QwCombinedPMT &numer, QwCombinedPMT &denom);
101  void Scale(Double_t factor);
102  void Normalize(VQwDataElement* denom);
103  void AccumulateRunningSum(const QwCombinedPMT& value);
106 
107  void SetBlindability(Bool_t isblindable){fSumADC.SetBlindability(isblindable);};
108  void SetNormalizability(Bool_t isnormalizable){fSumADC.SetNormalizability(isnormalizable);};
109 
110  /// \brief Blind the asymmetry
111  void Blind(const QwBlinder *blinder);
112  /// \brief Blind the difference using the yield
113  void Blind(const QwBlinder *blinder, const QwCombinedPMT& yield);
114 
115  void SetPedestal(Double_t ped);
116  void SetCalibrationFactor(Double_t calib);
117 
118  void ConstructHistograms(TDirectory *folder, TString &prefix);
119  void FillHistograms();
120 
121  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
122  void ConstructBranch(TTree *tree, TString &prefix);
123  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
124  void FillTreeVector(std::vector<Double_t> &values) const;
125 
126  std::vector<QwDBInterface> GetDBEntry();
127  std::vector<QwErrDBInterface> GetErrDBEntry();
128 
129  protected:
130 
131  private:
132 
133  Int_t fDataToSave;
134  Double_t fCalibration;
135  Double_t fULimit, fLLimit;
137 
138  Bool_t fGoodEvent; /// used to validate sequence number in the IsGoodEvent()
139 
140  std::vector <QwIntegrationPMT*> fElement;
141  std::vector <Double_t> fWeights;
142 
144  //QwIntegrationPMT fAvgADC;
145 
146  Int_t fDevice_flag; /// sets the event cut level for the device
147  /// fDevice_flag=1 Event cuts & HW check,
148  /// fDevice_flag=0 HW check, fDevice_flag=-1 no check
149 
150  Int_t fDeviceErrorCode; /// keep the device HW status using a unique code
151  /// from the QwVQWK_Channel::fDeviceErrorCode
152 
153  Bool_t bEVENTCUTMODE; /// If this set to kFALSE then Event cuts do not depend
154  /// on HW ckecks. This is set externally through the
155  /// qweak_beamline_eventcuts.map
156 
157  const static Bool_t bDEBUG=kFALSE; /// debugging display purposes
158 
159 };
160 
161 #endif
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
QwCombinedPMT & operator-=(const QwCombinedPMT &value)
virtual ~QwCombinedPMT()
Definition: QwCombinedPMT.h:41
void InitializeChannel(TString name, TString datatosave)
void AccumulateRunningSum(const QwCombinedPMT &value)
void SetNormalizability(Bool_t isnormalizable)
void SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
static const Bool_t bDEBUG
Bool_t bEVENTCUTMODE
Class for blinding data, adapted from G0 blinder class.
Definition: QwBlinder.h:64
void PrintValue() const
Print single line of value and error of this data element.
void ClearEventData()
Clear the event data in this element.
void Scale(Double_t factor)
void SetEventData(Double_t *block, UInt_t sequencenumber)
void DeaccumulateRunningSum(QwCombinedPMT &value)
void IncrementErrorCounters()
void Ratio(QwCombinedPMT &numer, QwCombinedPMT &denom)
void ConstructBranch(TTree *tree, TString &prefix)
void Normalize(VQwDataElement *denom)
void SetDefaultSampleSize(Int_t sample_size)
void LinkChannel(TString name)
void Difference(QwCombinedPMT &value1, QwCombinedPMT &value2)
void FillHistograms()
Fill the histograms for this data element.
Double_t fULimit
void CalculateRunningAverage()
The pure virtual base class of all data elements.
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t subelement=0)
Process the CODA event buffer for this element.
void Blind(const QwBlinder *blinder)
Blind the asymmetry.
Double_t fSequenceNo_Prev
Double_t fLLimit
void PrintErrorCounters()
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
std::vector< QwDBInterface > GetDBEntry()
void SetBlindability(Bool_t isblindable)
void SetBlindability(Bool_t isblindable)
std::vector< QwIntegrationPMT * > fElement
used to validate sequence number in the IsGoodEvent()
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Bool_t ApplyHWChecks()
void EncodeEventData(std::vector< UInt_t > &buffer)
QwCombinedPMT(TString subsystemname, TString name)
Definition: QwCombinedPMT.h:30
void RandomizeEventData(int helicity)
void IncrementErrorCounters()
Definition: QwCombinedPMT.h:85
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
Definition: QwCombinedPMT.h:81
QwCombinedPMT & operator=(const QwCombinedPMT &value)
QwIntegrationPMT fSumADC
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
void SetNormalizability(Bool_t isnormalizable)
std::vector< Double_t > fWeights
void CalculateSumAndAverage()
virtual const TString & GetElementName() const
Get the name of this element.
void SetCalibrationFactor(Double_t calib)
Bool_t ApplySingleEventCuts()
const QwVQWK_Channel * GetChannel(const TString name) const
Definition: QwCombinedPMT.h:48
Int_t fDeviceErrorCode
void SetPedestal(Double_t ped)
std::vector< QwErrDBInterface > GetErrDBEntry()
void FillTreeVector(std::vector< Double_t > &values) const
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
QwCombinedPMT(TString name)
Definition: QwCombinedPMT.h:26
const QwVQWK_Channel * GetChannel(const TString name) const
void PrintInfo() const
Print multiple lines of information about this data element.
void Add(QwIntegrationPMT *pmt, Double_t weight)
Double_t fCalibration
void Sum(QwCombinedPMT &value1, QwCombinedPMT &value2)
void SetEventCutMode(Int_t bcuts)
Definition: QwCombinedPMT.h:77
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
void SetRandomEventAsymmetry(Double_t asymmetry)
QwCombinedPMT(const QwCombinedPMT &source)
Definition: QwCombinedPMT.h:34
QwCombinedPMT & operator+=(const QwCombinedPMT &value)
void SetEventCutMode(Int_t bcuts)