QwAnalysis
QwEnergyCalculator.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwEnergyCalculator.h *
3 * *
4 * Author: B.Waidyawansa *
5 * Time-stamp: 05-24-2010 *
6 \**********************************************************/
7 
8 #ifndef __QwVQWK_ENERGYCALCULATOR__
9 #define __QwVQWK_ENERGYCALCULATOR__
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 "QwBPMStripline.h"
20 #include "QwCombinedBPM.h"
21 #include "VQwBPM.h"
22 #include "VQwHardwareChannel.h"
23 
24 // Forward declarations
25 class QwDBInterface;
26 
28  /******************************************************************
29  * Class:QwEnergyCalculator
30  * Perfroms the beam energy calculation using the beam angle
31  * amnd position at the target and the beam postition at the
32  * highest dispersive region on the beamline.
33  *
34  ******************************************************************/
35 
36 
37  public:
38  // Default constructor
40  QwEnergyCalculator(TString name){
41  InitializeChannel(name,"derived");
42  };
43  QwEnergyCalculator(TString subsystem, TString name){
44  InitializeChannel(subsystem, name,"derived");
45  };
48  { }
49  virtual ~QwEnergyCalculator() { };
50 
51  void InitializeChannel(TString name,TString datatosave);
52  // new routine added to update necessary information for tree trimming
53  void InitializeChannel(TString subsystem, TString name, TString datatosave);
54 
56 
57  void ClearEventData();
58  Int_t ProcessEvBuffer(UInt_t* buffer,
59  UInt_t word_position_in_buffer,UInt_t indexnumber);
60  void ProcessEvent();
61  void PrintValue() const;
62  void PrintInfo() const;
63  void SetRootSaveStatus(TString &prefix);
64 
65  Bool_t ApplyHWChecks();//Check for harware errors in the devices
66  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
67  Int_t SetSingleEventCuts(Double_t mean, Double_t sigma);//two limts and sample size
68  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
69  void SetSingleEventCuts(UInt_t errorflag,Double_t min, Double_t max, Double_t stability);
70  void SetEventCutMode(Int_t bcuts){
71  bEVENTCUTMODE=bcuts;
73  }
75  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
76  UInt_t GetEventcutErrorFlag(){//return the error flag
78  }
79  UInt_t UpdateErrorFlag();
80 
81  void UpdateErrorFlag(const QwEnergyCalculator *ev_error);
82 
83 
84  void Set(const VQwBPM* device,TString type, TString property ,Double_t tmatrix_ratio);
85  void Ratio(QwEnergyCalculator &numer,QwEnergyCalculator &denom);
86  void Scale(Double_t factor);
87 
88  virtual QwEnergyCalculator& operator= (const QwEnergyCalculator &value);
89  virtual QwEnergyCalculator& operator+= (const QwEnergyCalculator &value);
90  virtual QwEnergyCalculator& operator-= (const QwEnergyCalculator &value);
91 
92  void AccumulateRunningSum(const QwEnergyCalculator& value);
95 
96  void ConstructHistograms(TDirectory *folder, TString &prefix);
97  void FillHistograms();
98 
99  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
100  void ConstructBranch(TTree *tree, TString &prefix);
101  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file);
102  void FillTreeVector(std::vector<Double_t> &values) const;
103 
105  return &fEnergyChange;
106  };
107 
109  return const_cast<QwEnergyCalculator*>(this)->GetEnergy();
110  };
111 
112  std::vector<QwDBInterface> GetDBEntry();
113  std::vector<QwErrDBInterface> GetErrDBEntry();
114 
115  protected:
117 
118 
119  private:
120  std::vector <const VQwBPM*> fDevice;
121  std::vector <Double_t> fTMatrixRatio;
122  std::vector <TString> fProperty;
123  std::vector <TString> fType;
124  Int_t fDeviceErrorCode;//keep the device HW status using a unique code from the QwVQWK_Channel::fDeviceErrorCode
125  Bool_t bEVENTCUTMODE;//If this set to kFALSE then Event cuts do not depend on HW ckecks. This is set externally through the qweak_beamline_eventcuts.map
126  Bool_t bFullSave; // used to restrict the amount of data histogramed
127 
128 
129 
130 };
131 
132 #endif
void AccumulateRunningSum(const QwEnergyCalculator &value)
void ConstructBranch(TTree *tree, TString &prefix)
void SetRootSaveStatus(TString &prefix)
std::vector< TString > fType
QwEnergyCalculator(const QwEnergyCalculator &source)
VQwHardwareChannel * GetEnergy()
void LoadChannelParameters(QwParameterFile &paramfile)
QwEnergyCalculator(TString name)
void InitializeChannel(TString name, TString datatosave)
void Ratio(QwEnergyCalculator &numer, QwEnergyCalculator &denom)
std::vector< const VQwBPM * > fDevice
void Set(const VQwBPM *device, TString type, TString property, Double_t tmatrix_ratio)
void FillHistograms()
Fill the histograms for this data element.
void SetEventCutMode(Int_t bcuts)
std::vector< TString > fProperty
std::vector< QwErrDBInterface > GetErrDBEntry()
void PrintErrorCounters() const
report number of events failed due to HW and event cut failure
void DeaccumulateRunningSum(QwEnergyCalculator &value)
The pure virtual base class of all data elements.
virtual UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
std::vector< Double_t > fTMatrixRatio
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
virtual QwEnergyCalculator & operator+=(const QwEnergyCalculator &value)
QwEnergyCalculator(TString subsystem, TString name)
void PrintInfo() const
Print multiple lines of information about this data element.
void Scale(Double_t factor)
static const double min
Definition: QwUnits.h:76
virtual QwEnergyCalculator & operator=(const QwEnergyCalculator &value)
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
const VQwHardwareChannel * GetEnergy() const
Definition: VQwBPM.h:34
void SetEventCutMode(Int_t bcuts)
void FillTreeVector(std::vector< Double_t > &values) const
void ClearEventData()
Clear the event data in this element.
void PrintValue() const
Print single line of value and error of this data element.
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
Int_t SetSingleEventCuts(Double_t mean, Double_t sigma)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t indexnumber)
Process the CODA event buffer for this element.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
virtual QwEnergyCalculator & operator-=(const QwEnergyCalculator &value)
std::vector< QwDBInterface > GetDBEntry()
QwVQWK_Channel fEnergyChange