QwAnalysis
QwIntegrationPMT.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwIntegrationPMT.h *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #ifndef __QwVQWK_IntegrationPMT__
9 #define __QwVQWK_IntegrationPMT__
10 
11 // System headers
12 #include <vector>
13 
14 // ROOT headers
15 #include <TTree.h>
16 
17 // Qweak headers
18 #include "QwVQWK_Channel.h"
19 #include "QwParameterFile.h"
20 
21 // Forward declarations
22 class QwBlinder;
23 class QwDBInterface;
24 
25 
26 /*****************************************************************
27 * Class:
28 ******************************************************************/
29 ///
30 /// \ingroup QwAnalysis_BL
32 /////
33  public:
35  InitializeChannel("","raw");
36  };
37  QwIntegrationPMT(TString name){
38  InitializeChannel(name,"raw");
39  };
40  QwIntegrationPMT(TString subsystemname, TString name){
41  SetSubsystemName(subsystemname);
42  InitializeChannel(subsystemname, name,"raw");
43  };
45  : VQwDataElement(source),
46  fPedestal(source.fPedestal),
47  fCalibration(source.fCalibration),
48  fTriumf_ADC(source.fTriumf_ADC),
49  fIsBlindable(source.fIsBlindable),
51  { }
52  virtual ~QwIntegrationPMT() { };
53 
55 
56  Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement=0);
57 
58  void InitializeChannel(TString name, TString datatosave);
59  // new routine added to update necessary information for tree trimming
60  void InitializeChannel(TString subsystem, TString name, TString datatosave);
61  // same purpose as above but this was needed to accormodate combinedPMT. Unlike Beamline combined devices where they have VQWK channels, Combined PMT has integration PMT
62  void InitializeChannel(TString subsystem, TString module, TString name, TString datatosave);
63  void SetElementName(const TString &name) { fElementName = name; fTriumf_ADC.SetElementName(name);};
64 
65  const QwVQWK_Channel* GetChannel(const TString name) const {
66  if (fTriumf_ADC.GetElementName() == name) return &fTriumf_ADC;
67  else return 0;
68  };
69 
70 
71 
72  void ClearEventData();
73  void PrintErrorCounters();
74 /********************************************************/
75 
76  void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
77  void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency);
78  void SetRandomEventParameters(Double_t mean, Double_t sigma);
79  void SetRandomEventAsymmetry(Double_t asymmetry);
80  void RandomizeEventData(int helicity = 0, double time = 0.0);
81  void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber = 0);
82  void SetEventData(Double_t* block, UInt_t sequencenumber);
83  void EncodeEventData(std::vector<UInt_t> &buffer);
84 
86  void SetExternalRandomVariable(Double_t random_variable);
87 
88  Double_t GetValue();
89  Double_t GetValue(Int_t blocknum);
90 
91  void ProcessEvent();
92  Bool_t ApplyHWChecks();//Check for harware errors in the devices
93  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
96  }
97  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
98  Int_t SetSingleEventCuts(Double_t, Double_t);//set two limts
99  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
100  void SetSingleEventCuts(UInt_t errorflag, Double_t LL, Double_t UL, Double_t stability);
101  void SetDefaultSampleSize(Int_t sample_size);
102  UInt_t GetEventcutErrorFlag(){//return the error flag
104  }
105 
106  UInt_t UpdateErrorFlag() {return GetEventcutErrorFlag();};
107  void UpdateErrorFlag(const QwIntegrationPMT *ev_error);
108 
109  void SetEventCutMode(Int_t bcuts){
110  bEVENTCUTMODE=bcuts;
112  }
113 
114  void SetBlindability(Bool_t isblindable){fIsBlindable=isblindable;};
115  void SetNormalizability(Bool_t isnormalizable){fIsNormalizable = isnormalizable;};
116 
117  /// \brief Blind the asymmetry
118  void Blind(const QwBlinder *blinder);
119  /// \brief Blind the difference using the yield
120  void Blind(const QwBlinder *blinder, const QwIntegrationPMT& yield);
121 
122  void PrintValue() const;
123  void PrintInfo() const;
124 
125 /* Double_t GetRawBlockValue(size_t blocknum) */
126 /* {return fTriumf_ADC.GetRawBlockValue(blocknum);}; */
127 
128 
129 
133  void Sum(QwIntegrationPMT &value1, QwIntegrationPMT &value2);
134  void Difference(QwIntegrationPMT &value1, QwIntegrationPMT &value2);
135  void Ratio(QwIntegrationPMT &numer, QwIntegrationPMT &denom);
136  void Scale(Double_t factor);
137  void Normalize(VQwDataElement* denom);
138  void AccumulateRunningSum(const QwIntegrationPMT& value);
141 
142  void SetPedestal(Double_t ped);
143  void SetCalibrationFactor(Double_t calib);
144 
145  void ConstructHistograms(TDirectory *folder, TString &prefix);
146  void FillHistograms();
147 
148  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
149  void ConstructBranch(TTree *tree, TString &prefix);
150  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file);
151  void FillTreeVector(std::vector<Double_t> &values) const;
152 
153  std::vector<QwDBInterface> GetDBEntry();
154  std::vector<QwErrDBInterface> GetErrDBEntry();
155 
156  protected:
157 
158 
159  private:
160 
161  Double_t fPedestal;
162  Double_t fCalibration;
163  Bool_t fGoodEvent;//used to validate sequence number in the IsGoodEvent()
164 
166 
167  Int_t fDeviceErrorCode;//keep the device HW status using a unique code from the QwVQWK_Channel::fDeviceErrorCode
168 
169  Bool_t fIsBlindable; //
171 
172  const static Bool_t bDEBUG=kFALSE;//debugging display purposes
173  Bool_t bEVENTCUTMODE; //global switch to turn event cuts ON/OFF
174 };
175 
176 
177 
178 #endif
void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
std::vector< QwDBInterface > GetDBEntry()
void ClearEventData()
Clear the event data in this element.
Bool_t ApplySingleEventCuts()
void AccumulateRunningSum(const QwIntegrationPMT &value)
virtual ~QwIntegrationPMT()
void RandomizeEventData(int helicity=0, double time=0.0)
void Scale(Double_t factor)
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 SetNormalizability(Bool_t isnormalizable)
void Normalize(VQwDataElement *denom)
QwIntegrationPMT & operator-=(const QwIntegrationPMT &value)
QwIntegrationPMT(TString subsystemname, TString name)
Class for blinding data, adapted from G0 blinder class.
Definition: QwBlinder.h:64
QwIntegrationPMT & operator=(const QwIntegrationPMT &value)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
void FillHistograms()
Fill the histograms for this data element.
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
void IncrementErrorCounters()
void InitializeChannel(TString name, TString datatosave)
void SetEventCutMode(Int_t bcuts)
void Ratio(QwIntegrationPMT &numer, QwIntegrationPMT &denom)
void SetExternalRandomVariable(Double_t random_variable)
The pure virtual base class of all data elements.
virtual UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
QwIntegrationPMT(TString name)
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void PrintValue() const
Print single line of value and error of this data element.
Int_t SetSingleEventCuts(Double_t, Double_t)
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void SetBlindability(Bool_t isblindable)
void SetRandomEventAsymmetry(Double_t asymmetry)
void SetElementName(const TString &name)
Set the name of this element.
void DeaccumulateRunningSum(QwIntegrationPMT &value)
void SetHardwareSum(Double_t hwsum, UInt_t sequencenumber=0)
void Sum(QwIntegrationPMT &value1, QwIntegrationPMT &value2)
void Blind(const QwBlinder *blinder)
Blind the asymmetry.
void SetEventData(Double_t *block, UInt_t sequencenumber)
void FillTreeVector(std::vector< Double_t > &values) const
void EncodeEventData(std::vector< UInt_t > &buffer)
QwVQWK_Channel fTriumf_ADC
static const Bool_t bDEBUG
void UseExternalRandomVariable()
TString fElementName
Name of this data element.
virtual const TString & GetElementName() const
Get the name of this element.
QwIntegrationPMT(const QwIntegrationPMT &source)
void SetPedestal(Double_t ped)
std::vector< QwErrDBInterface > GetErrDBEntry()
void ConstructBranch(TTree *tree, TString &prefix)
void SetElementName(const TString &name)
void LoadChannelParameters(QwParameterFile &paramfile)
void SetRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)
QwIntegrationPMT & operator+=(const QwIntegrationPMT &value)
const QwVQWK_Channel * GetChannel(const TString name) const
void SetDefaultSampleSize(Int_t sample_size)
void SetCalibrationFactor(Double_t calib)
void IncrementErrorCounters()
void Difference(QwIntegrationPMT &value1, QwIntegrationPMT &value2)
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
void PrintInfo() const
Print multiple lines of information about this data element.
void SetEventCutMode(Int_t bcuts)