QwAnalysis
QwQPD.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwQPD.h *
3 * *
4 * Author: B.Waidyawansa *
5 * Time-stamp: 09-14-2010 *
6 \**********************************************************/
7 
8 #ifndef __QwQPD__
9 #define __QwQPD__
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 "VQwBPM.h"
20 #include "QwParameterFile.h"
21 
22 // Forward declarations
23 class QwDBInterface;
24 class QwErrDBInterface;
25 
26 /*****************************************************************
27 * Class:
28 ******************************************************************/
29 ///
30 /// \ingroup QwAnalysis_BL
31 
32 class QwQPD : public VQwBPM {
33 
34  public:
35  static UInt_t GetSubElementIndex(TString subname);
36 
37  QwQPD() {
38  };
39  QwQPD(TString name):VQwBPM(name){
40  InitializeChannel(name);
41  };
42  QwQPD(TString subsystemname, TString name):VQwBPM(name){
43  SetSubsystemName(subsystemname);
44  InitializeChannel(subsystemname, name);
45  fQwQPDCalibration[0] = 1.0;
46  fQwQPDCalibration[1] = 1.0;
47  };
48  QwQPD(const QwQPD& source)
49  : VQwBPM(source),
50  fPhotodiode(source.fPhotodiode),
51  fRelPos(source.fRelPos),
52  fAbsPos(source.fAbsPos),
54  { }
55  virtual ~QwQPD() { };
56 
57  void InitializeChannel(TString name);
58  // new routine added to update necessary information for tree trimming
59  void InitializeChannel(TString subsystem, TString name);
60 
62  for(Short_t i=0;i<4;i++)
63  fPhotodiode[i].LoadChannelParameters(paramfile);
64  }
65 
66  void GetCalibrationFactors(Double_t AlphaX, Double_t AlphaY);
67 
68  void ClearEventData();
69  Int_t ProcessEvBuffer(UInt_t* buffer,
70  UInt_t word_position_in_buffer,UInt_t indexnumber);
71  void ProcessEvent();
72 
74  if (axis<0 || axis>2){
75  TString loc="QwQPD::GetPosition for "
76  +this->GetElementName()+" failed for axis value "+Form("%d",axis);
77  throw std::out_of_range(loc.Data());
78  }
79  return &fAbsPos[axis];
80  }
82 
83  TString GetSubElementName(Int_t subindex);
85 
86  Bool_t ApplyHWChecks();//Check for harware errors in the devices
87  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
88  //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
89  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
90  //void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t min, Double_t max, Double_t stability);
91  void SetEventCutMode(Int_t bcuts);
93  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
94  UInt_t GetEventcutErrorFlag();
95  UInt_t UpdateErrorFlag();
96  void UpdateErrorFlag(const VQwBPM *ev_error);
97 
98  void SetDefaultSampleSize(Int_t sample_size);
99  void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY);
100  void RandomizeEventData(int helicity = 0, double time = 0.0);
101  void SetEventData(Double_t* block, UInt_t sequencenumber);
102  void EncodeEventData(std::vector<UInt_t> &buffer);
103  void SetSubElementPedestal(Int_t j, Double_t value);
104  void SetSubElementCalibrationFactor(Int_t j, Double_t value);
105 
106  void Ratio(QwQPD &numer, QwQPD &denom);
107  void Scale(Double_t factor);
108 
109  VQwBPM& operator= (const VQwBPM &value);
110  VQwBPM& operator+= (const VQwBPM &value);
111  VQwBPM& operator-= (const VQwBPM &value);
112 
113  virtual QwQPD& operator= (const QwQPD &value);
114  virtual QwQPD& operator+= (const QwQPD &value);
115  virtual QwQPD& operator-= (const QwQPD &value);
116 
117  void AccumulateRunningSum(const QwQPD& value);
118  void AccumulateRunningSum(const VQwBPM& value);
119  void DeaccumulateRunningSum(VQwBPM &value);
120  void DeaccumulateRunningSum(QwQPD& value);
122 
123  void ConstructHistograms(TDirectory *folder, TString &prefix);
124  void FillHistograms();
125 
126  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
127  void ConstructBranch(TTree *tree, TString &prefix);
128  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
129  void FillTreeVector(std::vector<Double_t> &values) const;
130 
131 
132 
133  std::vector<QwDBInterface> GetDBEntry();
134  std::vector<QwErrDBInterface> GetErrDBEntry();
135  void MakeQPDList();
136 
137 
138  protected:
139  VQwHardwareChannel* GetSubelementByName(TString ch_name);
140 
141 
142  /////
143  private:
144 
145 
146  static const TString subelement[4];
147  /* Position calibration factor, transform ADC counts in mm */
148  Double_t fQwQPDCalibration[2];
149 
150 
151  protected:
154 
155  // These are the "real" data elements, to which the base class
156  // fAbsPos_base and fEffectiveCharge_base are pointers.
159 
160  std::vector<QwVQWK_Channel> fQPDElementList;
161 
162 };
163 
164 
165 #endif
void MakeQPDList()
Definition: QwQPD.cc:800
Bool_t ApplySingleEventCuts()
Definition: QwQPD.cc:183
void CalculateRunningAverage()
Definition: QwQPD.cc:578
void SetSubElementCalibrationFactor(Int_t j, Double_t value)
Definition: QwQPD.cc:912
void LoadChannelParameters(QwParameterFile &paramfile)
Definition: QwQPD.h:61
QwQPD(TString name)
Definition: QwQPD.h:39
void SetEventData(Double_t *block, UInt_t sequencenumber)
Definition: QwQPD.cc:882
virtual ~QwQPD()
Definition: QwQPD.h:55
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
Definition: QwQPD.cc:846
void FillTreeVector(std::vector< Double_t > &values) const
Definition: QwQPD.cc:765
QwQPD(const QwQPD &source)
Definition: QwQPD.h:48
void ClearEventData()
Clear the event data in this element.
Definition: QwQPD.cc:89
void InitializeChannel(TString name)
Definition: QwQPD.cc:20
void SetDefaultSampleSize(Int_t sample_size)
Definition: QwQPD.cc:899
void IncrementErrorCounters()
Definition: QwQPD.cc:123
QwQPD(TString subsystemname, TString name)
Definition: QwQPD.h:42
VQwBPM & operator-=(const VQwBPM &value)
Definition: QwQPD.cc:531
void AccumulateRunningSum(const QwQPD &value)
Definition: QwQPD.cc:595
std::vector< QwErrDBInterface > GetErrDBEntry()
Definition: QwQPD.cc:827
Double_t fQwQPDCalibration[2]
Definition: QwQPD.h:148
void SetEventCutMode(Int_t bcuts)
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
Definition: QwQPD.cc:787
VQwBPM & operator=(const VQwBPM &value)
Definition: QwQPD.cc:490
void ProcessEvent()
Definition: QwQPD.cc:354
QwVQWK_Channel fPhotodiode[4]
Definition: QwQPD.h:152
Bool_t ApplyHWChecks()
Definition: QwQPD.cc:106
void FillHistograms()
Fill the histograms for this data element.
Definition: QwQPD.cc:655
std::vector< QwVQWK_Channel > fQPDElementList
Definition: QwQPD.h:160
void RandomizeEventData(int helicity=0, double time=0.0)
Definition: QwQPD.cc:874
VQwHardwareChannel * GetSubelementByName(TString ch_name)
Definition: QwQPD.cc:214
void Scale(Double_t factor)
Definition: QwQPD.cc:565
void DeaccumulateRunningSum(VQwBPM &value)
Definition: QwQPD.cc:609
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void ConstructBranch(TTree *tree, TString &prefix)
Definition: QwQPD.cc:700
QwVQWK_Channel fAbsPos[2]
Definition: QwQPD.h:157
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Definition: QwQPD.cc:631
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber)
Process the CODA event buffer for this element.
Definition: QwQPD.cc:450
static const TString axis[3]
Definition: VQwBPM.h:260
QwVQWK_Channel fRelPos[2]
Definition: QwQPD.h:153
EBeamPositionMonitorAxis
Definition: VQwBPM.h:54
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Definition: QwQPD.cc:674
TString GetSubElementName(Int_t subindex)
Definition: QwQPD.cc:465
VQwBPM & operator+=(const VQwBPM &value)
Definition: QwQPD.cc:510
std::vector< QwDBInterface > GetDBEntry()
Definition: QwQPD.cc:813
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
Definition: QwQPD.cc:163
void Ratio(QwQPD &numer, QwQPD &denom)
Definition: QwQPD.cc:553
static UInt_t GetSubElementIndex(TString subname)
Definition: QwQPD.cc:477
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
Definition: QwQPD.cc:135
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const
Definition: QwQPD.h:73
const VQwHardwareChannel * GetEffectiveCharge() const
Definition: QwQPD.h:81
Definition: VQwBPM.h:34
virtual const TString & GetElementName() const
Get the name of this element.
void EncodeEventData(std::vector< UInt_t > &buffer)
Definition: QwQPD.cc:893
void GetCalibrationFactors(Double_t AlphaX, Double_t AlphaY)
Definition: QwQPD.cc:68
static const TString subelement[4]
Definition: QwQPD.h:146
QwVQWK_Channel fEffectiveCharge
Definition: QwQPD.h:158
void GetAbsolutePosition()
Definition: QwQPD.h:84
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
Definition: QwQPD.cc:147
QwQPD()
Definition: QwQPD.h:37
void SetSubElementPedestal(Int_t j, Double_t value)
Definition: QwQPD.cc:906
Definition: QwQPD.h:32