QwAnalysis
VQwBCM.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: VQwBCM.h *
3 * *
4 * Author: (??) & J.C Cornejo *
5 * Time-stamp: <2011-05-26> *
6 \**********************************************************/
7 
8 #ifndef __VQWBCM__
9 #define __VQWBCM__
10 
11 // System headers
12 #include <vector>
13 #include <boost/shared_ptr.hpp>
14 
15 // ROOT headers
16 #include <TTree.h>
17 
18 #include "QwParameterFile.h"
19 #include "VQwDataElement.h"
20 #include "VQwHardwareChannel.h"
21 
22 // Forward declarations
23 class QwDBInterface;
24 class QwErrDBInterface;
25 
26 template<typename T> class QwCombinedBCM;
27 template<typename T> class QwBCM;
28 
29 /**
30  * \ingroup QwAnalysis_BeamLine
31  */
32 class VQwBCM : public VQwDataElement {
33  /***************************************************************
34  * Class: VQwBCM
35  * Pure Virtual base class for the BCMs in the beamline.
36  * Through use of the Create factory function, one can
37  * get a concrete instance of a templated QwBCM.
38  *
39  ***************************************************************/
40 protected:
41  VQwBCM(VQwDataElement& beamcurrent): fBeamCurrent_ref(beamcurrent) { };
42  VQwBCM(VQwDataElement& beamcurrent, TString name): fBeamCurrent_ref(beamcurrent) { };
43 
44 public:
45  virtual ~VQwBCM() { };
46 
47  // VQwDataElement virtual functions
48  virtual Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t word_position_in_buffer, UInt_t subelement=0) = 0;
49  virtual void ConstructHistograms(TDirectory *folder, TString &prefix) = 0;
50  virtual void FillHistograms() = 0;
51  /*! \brief Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel */
52  virtual void SetSingleEventCuts(UInt_t errorflag,Double_t min, Double_t max, Double_t stability) = 0;
53  virtual void Ratio( const VQwBCM &numer, const VQwBCM &denom)
54  { std::cerr << "Ratio not defined! (VQwBCM)" << std::endl; }
55  virtual void ClearEventData() = 0;
56 
57  // Virtual functions delegated to sub classes
58  virtual void InitializeChannel(TString name, TString datatosave) = 0;
59  // new routine added to update necessary information for tree trimming
60  virtual void InitializeChannel(TString subsystem, TString name, TString datatosave) = 0;
61 
62  virtual void LoadChannelParameters(QwParameterFile &paramfile) = 0;
63  virtual Bool_t NeedsExternalClock() = 0;
64  virtual void SetExternalClockPtr( const VQwHardwareChannel* clock) = 0;
65  virtual void SetExternalClockName( const std::string name) = 0;
66  virtual Double_t GetNormClockValue() = 0;
67 
68  virtual void SetDefaultSampleSize(Int_t sample_size) = 0;
69  virtual void SetEventCutMode(Int_t bcuts) = 0;
70  virtual UInt_t UpdateErrorFlag(){return this->GetEventcutErrorFlag();};
71  virtual void UpdateErrorFlag(const VQwBCM *ev_error) = 0;
72  virtual void SetPedestal(Double_t ped) = 0;
73  virtual void SetCalibrationFactor(Double_t calib) = 0;
74  virtual void RandomizeEventData(int helicity, double time) = 0;
75  virtual void EncodeEventData(std::vector<UInt_t> &buffer) = 0;
76  virtual Bool_t ApplySingleEventCuts() = 0;//Check for good events by stting limits on the devices readings
77  virtual void IncrementErrorCounters() = 0;
78  virtual void ProcessEvent() = 0;
79  virtual void Scale(Double_t factor) = 0;
80  virtual void CalculateRunningAverage() = 0;
81  virtual void AccumulateRunningSum(const VQwBCM& value) = 0;
82  virtual void DeaccumulateRunningSum(VQwBCM& value) = 0;
83  virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values) = 0;
84  virtual void ConstructBranch(TTree *tree, TString &prefix) = 0;
85  virtual void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist) = 0;
86  virtual void FillTreeVector(std::vector<Double_t> &values) const = 0;
87 
88  virtual std::vector<QwDBInterface> GetDBEntry() = 0;
89  virtual std::vector<QwErrDBInterface> GetErrDBEntry() = 0;
90 
91  virtual Double_t GetValue() = 0;
92  virtual Double_t GetValueError() = 0;
93  virtual Double_t GetValueWidth() = 0;
94 
95  virtual const VQwHardwareChannel* GetCharge() const = 0;
96 
97  virtual void SetRandomEventParameters(Double_t mean, Double_t sigma) = 0;
98  virtual void SetRandomEventAsymmetry(Double_t asymmetry) = 0 ;
99  virtual void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency) =0;
100 
101  // Operators
102  virtual VQwBCM& operator= (const VQwBCM &value) =0;
103  virtual VQwBCM& operator+= (const VQwBCM &value) =0;
104  virtual VQwBCM& operator-= (const VQwBCM &value) =0;
105 
106  // This one is for QwCombinedBCM (could be done differently)
107  virtual void SetBCMForCombo(VQwBCM* bcm, Double_t weight, Double_t sumqw ) = 0;
108 
109 
110  // Factory function to produce appropriate BCM
111  static VQwBCM* Create(TString subsystemname, TString type, TString name, TString clock = "");
112  static VQwBCM* Create(const VQwBCM& source); // Create a generic BCM (define properties later)
113  static VQwBCM* CreateCombo(TString subsystemname, TString type, TString name);
114  static VQwBCM* CreateCombo(const VQwBCM& source); // Create a generic BCM (define properties later)
115 
116 
117 protected:
119 
120 };
121 
122 typedef boost::shared_ptr<VQwBCM> VQwBCM_ptr;
123 
124 #endif // __VQWBCM__
virtual void SetRandomEventAsymmetry(Double_t asymmetry)=0
boost::shared_ptr< VQwBCM > VQwBCM_ptr
Definition: VQwBCM.h:122
virtual ~VQwBCM()
Definition: VQwBCM.h:45
virtual void Scale(Double_t factor)=0
static VQwBCM * Create(TString subsystemname, TString type, TString name, TString clock="")
A fast way of creating a BCM of specified type.
Definition: VQwBCM.cc:27
virtual UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
Definition: VQwBCM.h:70
Definition: VQwBCM.h:32
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
virtual Double_t GetNormClockValue()=0
VQwDataElement & fBeamCurrent_ref
Definition: VQwBCM.h:118
virtual Bool_t NeedsExternalClock()=0
virtual void CalculateRunningAverage()=0
virtual void FillTreeVector(std::vector< Double_t > &values) const =0
virtual void DeaccumulateRunningSum(VQwBCM &value)=0
virtual void AccumulateRunningSum(const VQwBCM &value)=0
virtual void SetDefaultSampleSize(Int_t sample_size)=0
virtual void FillHistograms()=0
Fill the histograms for this data element.
virtual void ConstructBranch(TTree *tree, TString &prefix)=0
virtual std::vector< QwErrDBInterface > GetErrDBEntry()=0
virtual void SetBCMForCombo(VQwBCM *bcm, Double_t weight, Double_t sumqw)=0
virtual void Ratio(const VQwBCM &numer, const VQwBCM &denom)
Definition: VQwBCM.h:53
virtual void SetSingleEventCuts(UInt_t errorflag, Double_t min, Double_t max, Double_t stability)=0
Inherited from VQwDataElement to set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel.
Definition of the pure virtual base class of all data elements.
virtual void SetEventCutMode(Int_t bcuts)=0
virtual void EncodeEventData(std::vector< UInt_t > &buffer)=0
The pure virtual base class of all data elements.
virtual UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
virtual void RandomizeEventData(int helicity, double time)=0
virtual void SetExternalClockName(const std::string name)=0
virtual Bool_t ApplySingleEventCuts()=0
virtual Double_t GetValueError()=0
virtual std::vector< QwDBInterface > GetDBEntry()=0
virtual VQwBCM & operator=(const VQwBCM &value)=0
virtual Double_t GetValue()=0
VQwBCM(VQwDataElement &beamcurrent)
Definition: VQwBCM.h:41
virtual VQwBCM & operator+=(const VQwBCM &value)=0
virtual void InitializeChannel(TString name, TString datatosave)=0
virtual void ConstructHistograms(TDirectory *folder, TString &prefix)=0
Construct the histograms for this data element.
virtual void SetRandomEventParameters(Double_t mean, Double_t sigma)=0
static const double min
Definition: QwUnits.h:76
virtual Double_t GetValueWidth()=0
virtual void AddRandomEventDriftParameters(Double_t amplitude, Double_t phase, Double_t frequency)=0
virtual VQwBCM & operator-=(const VQwBCM &value)=0
VQwBCM(VQwDataElement &beamcurrent, TString name)
Definition: VQwBCM.h:42
virtual void SetCalibrationFactor(Double_t calib)=0
Definition: QwBCM.h:34
virtual const VQwHardwareChannel * GetCharge() const =0
virtual Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t word_position_in_buffer, UInt_t subelement=0)=0
Process the CODA event buffer for this element.
virtual void ClearEventData()=0
Clear the event data in this element.
virtual void ProcessEvent()=0
virtual void IncrementErrorCounters()=0
virtual void SetExternalClockPtr(const VQwHardwareChannel *clock)=0
virtual void SetPedestal(Double_t ped)=0
static VQwBCM * CreateCombo(TString subsystemname, TString type, TString name)
A fast way of creating a combo BCM of specified type.
Definition: VQwBCM.cc:70
virtual void LoadChannelParameters(QwParameterFile &paramfile)=0