QwAnalysis
QwLinearDiodeArray.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwLinearDiodeArray.h *
3 * *
4 * Author: B.Waidyawansa *
5 * Time-stamp: 09-14-2010 *
6 \**********************************************************/
7 
8 #ifndef __QwLinearDiodeArray__
9 #define __QwLinearDiodeArray__
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 QwLinearDiodeArray : public VQwBPM {
33 
34  public:
35  static UInt_t GetSubElementIndex(TString subname);
36 
38  };
39  QwLinearDiodeArray(TString name):VQwBPM(name){
40  };
41  QwLinearDiodeArray(TString subsystemname, TString name):VQwBPM(name){
42  SetSubsystemName(subsystemname);
43  InitializeChannel(subsystemname, name);
44  };
46  : VQwBPM(source),
48  {
49  for (size_t i = 0; i < 2; i++) {
50  fRelPos[i] = source.fRelPos[i];
51  fAbsPos[i] = source.fAbsPos[i];
52  }
53  for (size_t i = 0; i < 8; i++) {
54  fPhotodiode[i] = source.fPhotodiode[i];
55  }
56  }
57  virtual ~QwLinearDiodeArray() { };
58 
59  void InitializeChannel(TString name);
60  // new routine added to update necessary information for tree trimming
61  void InitializeChannel(TString subsystem, TString name);
62  void ClearEventData();
63 
65  for(size_t i=0;i<kMaxElements;i++)
66  fPhotodiode[i].LoadChannelParameters(paramfile);
67  }
68 
69  Int_t ProcessEvBuffer(UInt_t* buffer,
70  UInt_t word_position_in_buffer,UInt_t indexnumber);
71  void ProcessEvent();
72  void PrintValue() const;
73  void PrintInfo() const;
74 
76  if (axis<0 || axis>2){
77  TString loc="QwLinearDiodeArray::GetPosition for "
78  +this->GetElementName()+" failed for axis value "+Form("%d",axis);
79  throw std::out_of_range(loc.Data());
80  }
81  return &fAbsPos[axis];
82  }
84 
85  TString GetSubElementName(Int_t subindex);
86  UInt_t SetSubElementName(TString subname);
87  void GetAbsolutePosition();
88 
89  Bool_t ApplyHWChecks();//Check for harware errors in the devices
90  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
91  //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
92  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
93  //void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t min, Double_t max, Double_t stability);
94  void SetEventCutMode(Int_t bcuts);
96  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
97  UInt_t GetEventcutErrorFlag();
98  UInt_t UpdateErrorFlag();
99  void UpdateErrorFlag(const VQwBPM *ev_error);
100 
101  void SetDefaultSampleSize(Int_t sample_size);
102  void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY);
103  void RandomizeEventData(int helicity = 0, double time = 0.0);
104  void SetEventData(Double_t* block, UInt_t sequencenumber);
105  void EncodeEventData(std::vector<UInt_t> &buffer);
106  void SetSubElementPedestal(Int_t j, Double_t value);
107  void SetSubElementCalibrationFactor(Int_t j, Double_t value);
108 
109  void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom);
110  void Scale(Double_t factor);
111 
112 
113  VQwBPM& operator= (const VQwBPM &value);
114  VQwBPM& operator+= (const VQwBPM &value);
115  VQwBPM& operator-= (const VQwBPM &value);
116 
117  virtual QwLinearDiodeArray& operator= (const QwLinearDiodeArray &value);
118  virtual QwLinearDiodeArray& operator+= (const QwLinearDiodeArray &value);
119  virtual QwLinearDiodeArray& operator-= (const QwLinearDiodeArray &value);
120 
121  void AccumulateRunningSum(const QwLinearDiodeArray& value);
122  void AccumulateRunningSum(const VQwBPM& value);
124  void DeaccumulateRunningSum(VQwBPM& value);
126 
127  void ConstructHistograms(TDirectory *folder, TString &prefix);
128  void FillHistograms();
129 
130  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
131  void ConstructBranch(TTree *tree, TString &prefix);
132  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
133  void FillTreeVector(std::vector<Double_t> &values) const;
134 
135 
136 
137  std::vector<QwDBInterface> GetDBEntry();
138  std::vector<QwErrDBInterface> GetErrDBEntry();
139 
140  void MakeLinearArrayList();
141 
142  protected:
143  VQwHardwareChannel* GetSubelementByName(TString ch_name);
144 
145  /////
146  private:
147  static const size_t kMaxElements;
148  static const TString subelement[8];
149 
150  /* Position calibration factor, transform ADC counts in mm */
151  static const Double_t kQwLinearDiodeArrayPadSize;
152 
153 
154 
155  protected:
156  // std::vector<QwVQWK_Channel> fPhotodiode;
159 
160  // These are the "real" data elements, to which the base class
161  // fAbsPos_base and fEffectiveCharge_base are pointers.
164 
165  std::vector<QwVQWK_Channel> fLinearArrayElementList;
166 
167 };
168 
169 
170 #endif
static const size_t kMaxElements
void EncodeEventData(std::vector< UInt_t > &buffer)
std::vector< QwVQWK_Channel > fLinearArrayElementList
static UInt_t GetSubElementIndex(TString subname)
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
UInt_t SetSubElementName(TString subname)
void SetSubElementPedestal(Int_t j, Double_t value)
QwLinearDiodeArray(TString name)
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const
void PrintInfo() const
Print multiple lines of information about this data element.
TString GetSubElementName(Int_t subindex)
std::vector< QwDBInterface > GetDBEntry()
VQwBPM & operator+=(const VQwBPM &value)
VQwHardwareChannel * GetSubelementByName(TString ch_name)
void ClearEventData()
Clear the event data in this element.
VQwBPM & operator=(const VQwBPM &value)
void FillTreeVector(std::vector< Double_t > &values) const
void AccumulateRunningSum(const QwLinearDiodeArray &value)
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void InitializeChannel(TString name)
void SetSubElementCalibrationFactor(Int_t j, Double_t value)
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
void ConstructBranch(TTree *tree, TString &prefix)
void SetEventData(Double_t *block, UInt_t sequencenumber)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber)
Process the CODA event buffer for this element.
static const TString axis[3]
Definition: VQwBPM.h:260
QwVQWK_Channel fPhotodiode[8]
EBeamPositionMonitorAxis
Definition: VQwBPM.h:54
void Scale(Double_t factor)
void LoadChannelParameters(QwParameterFile &paramfile)
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
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.
VQwBPM & operator-=(const VQwBPM &value)
Definition: VQwBPM.h:34
virtual const TString & GetElementName() const
Get the name of this element.
void Ratio(QwLinearDiodeArray &numer, QwLinearDiodeArray &denom)
void FillHistograms()
Fill the histograms for this data element.
const VQwHardwareChannel * GetEffectiveCharge() const
void DeaccumulateRunningSum(QwLinearDiodeArray &value)
QwVQWK_Channel fRelPos[2]
void PrintValue() const
Print single line of value and error of this data element.
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
void RandomizeEventData(int helicity=0, double time=0.0)
QwVQWK_Channel fEffectiveCharge
std::vector< QwErrDBInterface > GetErrDBEntry()
QwLinearDiodeArray(const QwLinearDiodeArray &source)
QwLinearDiodeArray(TString subsystemname, TString name)
static const TString subelement[8]
static const Double_t kQwLinearDiodeArrayPadSize
QwVQWK_Channel fAbsPos[2]
void SetDefaultSampleSize(Int_t sample_size)