QwAnalysis
QwBPMCavity.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwBPMStripline.h *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #ifndef __QwVQWK_CAVITY__
9 #define __QwVQWK_CAVITY__
10 
11 // System headers
12 #include <vector>
13 
14 // ROOT headres
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 QwBPMCavity : public VQwBPM {
33  template <typename TT> friend class QwCombinedBPM;
34  friend class QwEnergyCalculator;
35 
36  public:
37  static UInt_t GetSubElementIndex(TString subname);
38 
39  public:
40  QwBPMCavity() { };
41  QwBPMCavity(TString name):VQwBPM(name){
42  InitializeChannel(name);
43  bRotated=kTRUE;
44  };
45  QwBPMCavity(TString subsystemname, TString name)
46  : VQwBPM(name) {
47  SetSubsystemName(subsystemname);
48  InitializeChannel(subsystemname, name);
49  bRotated=kTRUE;
50  };
51  QwBPMCavity(const QwBPMCavity& source)
52  : VQwBPM(source),
53  fWire(source.fWire),fRelPos(source.fRelPos),fAbsPos(source.fAbsPos),
55  { }
56  virtual ~QwBPMCavity() { };
57 
58  void InitializeChannel(TString name);
59  // new routine added to update necessary information for tree trimming
60  void InitializeChannel(TString subsystem, TString name);
61  void ClearEventData();
62 
64  for(Short_t i=0;i<2;i++)
65  fWire[i].LoadChannelParameters(paramfile);
66  }
67 
68  Int_t ProcessEvBuffer(UInt_t* buffer,
69  UInt_t word_position_in_buffer,UInt_t indexnumber);
70  void ProcessEvent();
71  void PrintValue() const;
72  void PrintInfo() const;
73 
75  if (axis<0 || axis>2){
76  TString loc="QwBPMCavity::GetPosition for "
77  +this->GetElementName()+" failed for axis value "+Form("%d",axis);
78  throw std::out_of_range(loc.Data());
79  }
80  return &fAbsPos[axis];
81  }
83 
84  TString GetSubElementName(Int_t subindex);
85  void GetAbsolutePosition();
86 
87  Bool_t ApplyHWChecks();//Check for harware errors in the devices
88  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
89  //void SetSingleEventCuts(TString ch_name, Double_t minX, Double_t maxX);
90  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
91  //void SetSingleEventCuts(TString ch_name, UInt_t errorflag,Double_t min, Double_t max, Double_t stability);
92  void SetEventCutMode(Int_t bcuts);
94  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
95  UInt_t GetEventcutErrorFlag();
96  UInt_t UpdateErrorFlag();
97  void UpdateErrorFlag(const VQwBPM *ev_error);
98 
99  void SetDefaultSampleSize(Int_t sample_size);
100  void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY);
101  void RandomizeEventData(int helicity = 0, double time = 0.0);
102  void SetEventData(Double_t* block, UInt_t sequencenumber);
103  void EncodeEventData(std::vector<UInt_t> &buffer);
104  void SetSubElementPedestal(Int_t j, Double_t value);
105  void SetSubElementCalibrationFactor(Int_t j, Double_t value);
106 
107  void Ratio(QwBPMCavity &numer, QwBPMCavity &denom);
108  void Scale(Double_t factor);
109 
110  VQwBPM& operator= (const VQwBPM &value);
111  VQwBPM& operator+= (const VQwBPM &value);
112  VQwBPM& operator-= (const VQwBPM &value);
113 
114  virtual QwBPMCavity& operator= (const QwBPMCavity &value);
115  virtual QwBPMCavity& operator+= (const QwBPMCavity &value);
116  virtual QwBPMCavity& operator-= (const QwBPMCavity &value);
117 
118  void AccumulateRunningSum(const VQwBPM &value);
119  void AccumulateRunningSum(const QwBPMCavity &value);
120  void DeaccumulateRunningSum(VQwBPM &value);
121  void DeaccumulateRunningSum(QwBPMCavity &value);
123 
124  void ConstructHistograms(TDirectory *folder, TString &prefix);
125  void FillHistograms();
126 
127  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
128  void FillTreeVector(std::vector<Double_t> &values) const;
129  void ConstructBranch(TTree *tree, TString &prefix);
130  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
131 
132 
133  std::vector<QwDBInterface> GetDBEntry();
134  std::vector<QwErrDBInterface> GetErrDBEntry();
135 
136  protected:
137  VQwHardwareChannel* GetSubelementByName(TString ch_name);
138 
139  /////
140  private:
141  /* Position calibration factor, transform ADC counts in mm */
142  static const Double_t kQwCavityCalibration;
143  /* Rotation factor for the BPM which antenna are at 45 deg */
144  static const Double_t kRotationCorrection;
145  static const TString subelement[3];
146 
147 
148 
149  protected:
150  Bool_t bRotated;
153 
154  // These are the "real" data elements, to which the base class
155  // fAbsPos_base and fEffectiveCharge_base are pointers.
158 
159 
160  private:
161  // Functions to be removed
162  void MakeBPMCavityList();
163  std::vector<QwVQWK_Channel> fBPMElementList;
164 
165 };
166 
167 
168 #endif
static const TString subelement[3]
Definition: QwBPMCavity.h:145
QwBPMCavity(const QwBPMCavity &source)
Definition: QwBPMCavity.h:51
VQwBPM & operator=(const VQwBPM &value)
Definition: QwBPMCavity.cc:438
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
Definition: QwBPMCavity.cc:131
QwBPMCavity(TString name)
Definition: QwBPMCavity.h:41
void ConstructBranch(TTree *tree, TString &prefix)
Definition: QwBPMCavity.cc:642
void ClearEventData()
Clear the event data in this element.
Definition: QwBPMCavity.cc:74
QwVQWK_Channel fAbsPos[2]
Definition: QwBPMCavity.h:156
void GetAbsolutePosition()
Definition: QwBPMCavity.cc:425
void RandomizeEventData(int helicity=0, double time=0.0)
Definition: QwBPMCavity.cc:820
void SetSubElementCalibrationFactor(Int_t j, Double_t value)
Definition: QwBPMCavity.cc:858
const VQwHardwareChannel * GetPosition(EBeamPositionMonitorAxis axis) const
Definition: QwBPMCavity.h:74
VQwBPM & operator+=(const VQwBPM &value)
Definition: QwBPMCavity.cc:478
static UInt_t GetSubElementIndex(TString subname)
Definition: QwBPMCavity.cc:412
void SetRandomEventParameters(Double_t meanX, Double_t sigmaX, Double_t meanY, Double_t sigmaY)
Definition: QwBPMCavity.cc:786
void AccumulateRunningSum(const VQwBPM &value)
Definition: QwBPMCavity.cc:546
std::vector< QwDBInterface > GetDBEntry()
Definition: QwBPMCavity.cc:756
void MakeBPMCavityList()
Definition: QwBPMCavity.cc:743
void EncodeEventData(std::vector< UInt_t > &buffer)
Definition: QwBPMCavity.cc:839
TString GetSubElementName(Int_t subindex)
Definition: QwBPMCavity.cc:400
Bool_t bRotated
Definition: QwBPMCavity.h:150
void CalculateRunningAverage()
Definition: QwBPMCavity.cc:536
void SetEventData(Double_t *block, UInt_t sequencenumber)
Definition: QwBPMCavity.cc:828
VQwBPM & operator-=(const VQwBPM &value)
Definition: QwBPMCavity.cc:502
void InitializeChannel(TString name)
Definition: QwBPMCavity.cc:24
static const Double_t kQwCavityCalibration
Definition: QwBPMCavity.h:142
const VQwHardwareChannel * GetEffectiveCharge() const
Definition: QwBPMCavity.h:82
void PrintInfo() const
Print multiple lines of information about this data element.
Definition: QwBPMCavity.cc:388
void ProcessEvent()
Definition: QwBPMCavity.cc:325
void LoadChannelParameters(QwParameterFile &paramfile)
Definition: QwBPMCavity.h:63
static const Double_t kRotationCorrection
Definition: QwBPMCavity.h:144
VQwHardwareChannel * GetSubelementByName(TString ch_name)
Definition: QwBPMCavity.cc:216
void SetSubsystemName(TString sysname)
Set the name of the inheriting subsystem name.
void SetSubElementPedestal(Int_t j, Double_t value)
Definition: QwBPMCavity.cc:852
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
Definition: QwBPMCavity.cc:119
void DeaccumulateRunningSum(VQwBPM &value)
Definition: QwBPMCavity.cc:561
QwBPMCavity(TString subsystemname, TString name)
Definition: QwBPMCavity.h:45
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Definition: QwBPMCavity.cc:618
QwVQWK_Channel fEffectiveCharge
Definition: QwBPMCavity.h:157
void Scale(Double_t factor)
Definition: QwBPMCavity.cc:523
static const TString axis[3]
Definition: VQwBPM.h:260
QwVQWK_Channel fRelPos[2]
Definition: QwBPMCavity.h:152
EBeamPositionMonitorAxis
Definition: VQwBPM.h:54
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber)
Process the CODA event buffer for this element.
Definition: QwBPMCavity.cc:358
void FillHistograms()
Fill the histograms for this data element.
Definition: QwBPMCavity.cc:600
void PrintValue() const
Print single line of value and error of this data element.
Definition: QwBPMCavity.cc:378
void IncrementErrorCounters()
Definition: QwBPMCavity.cc:107
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
Definition: QwBPMCavity.cc:145
Definition: VQwBPM.h:34
void FillTreeVector(std::vector< Double_t > &values) const
Definition: QwBPMCavity.cc:713
virtual const TString & GetElementName() const
Get the name of this element.
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Definition: QwBPMCavity.cc:578
void Ratio(QwBPMCavity &numer, QwBPMCavity &denom)
Definition: QwBPMCavity.cc:511
void SetDefaultSampleSize(Int_t sample_size)
Definition: QwBPMCavity.cc:845
std::vector< QwVQWK_Channel > fBPMElementList
Definition: QwBPMCavity.h:163
std::vector< QwErrDBInterface > GetErrDBEntry()
Definition: QwBPMCavity.cc:769
Bool_t ApplySingleEventCuts()
Definition: QwBPMCavity.cc:165
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: QwBPMCavity.cc:730
virtual ~QwBPMCavity()
Definition: QwBPMCavity.h:56
QwVQWK_Channel fWire[2]
Definition: QwBPMCavity.h:151
Bool_t ApplyHWChecks()
Definition: QwBPMCavity.cc:89