QwAnalysis
QwHaloMonitor.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwHaloMonitor.h *
3 * *
4 * Author:B. Waidyawansa *
5 * Time-stamp:24-june-2010 *
6 \**********************************************************/
7 
8 #ifndef __QwHALO_MONITOR__
9 #define __QwHALO_MONITOR__
10 
11 // System headers
12 #include <vector>
13 
14 // ROOT headers
15 #include <TTree.h>
16 
17 // Qweak headers
18 #include "QwParameterFile.h"
19 #include "QwScaler_Channel.h"
20 #include "VQwHardwareChannel.h"
21 
22 // Forward declarations
23 class QwDBInterface;
24 
25 /*****************************************************************
26 * Class: QwHaloMonitor handles the halo counters. This use
27  QwSIS3801_Channel scaler channels.
28 ******************************************************************/
29 ///
30 /// \ingroup QwAnalysis_BL
32 /////
33 
34  public:
36  QwHaloMonitor(TString name){
37  InitializeChannel(name);
38  };
39  QwHaloMonitor(TString subsystemname, TString name){
40  InitializeChannel(subsystemname, name);
41  };
43  : VQwDataElement(source),
45  { }
46  virtual ~QwHaloMonitor() { };
47 
48  void InitializeChannel(TString name);
49  // new routine added to update necessary information for tree trimming
50  void InitializeChannel(TString subsystem, TString name);
51  void ClearEventData();
52 
54  fHalo_Counter.LoadChannelParameters(paramfile);
55  }
56  std::string GetExternalClockName() { return fHalo_Counter.GetExternalClockName(); };
57  Bool_t NeedsExternalClock() { return fHalo_Counter.NeedsExternalClock(); };
58  void SetExternalClockPtr( const VQwHardwareChannel* clock) {fHalo_Counter.SetExternalClockPtr(clock);};
59  void SetExternalClockName( const std::string name) { fHalo_Counter.SetExternalClockName(name);};
60  Double_t GetNormClockValue() { return fHalo_Counter.GetNormClockValue();}
61 
62 
63 
64  void PrintErrorCounters();//This will display the error summary for each device
65  void UpdateHWErrorCount();//Update error counter for HW faliure
66 
67  Int_t ProcessEvBuffer(UInt_t* buffer, UInt_t num_words_left,UInt_t index=0);
68  void ProcessEvent();
69 
70  QwHaloMonitor& operator= (const QwHaloMonitor &value);
73  void Sum(QwHaloMonitor &value1, QwHaloMonitor &value2);
74  void Difference(QwHaloMonitor &value1, QwHaloMonitor &value2);
75  void Ratio(QwHaloMonitor &numer, QwHaloMonitor &denom);
76  void Offset(Double_t Offset);
77  void Scale(Double_t Offset);
78 
79  void SetPedestal(Double_t ped) { fHalo_Counter.SetPedestal(ped); };
80  void SetCalibrationFactor(Double_t factor) { fHalo_Counter.SetCalibrationFactor(factor); };
81  void AccumulateRunningSum(const QwHaloMonitor& value);
84 
85  Bool_t ApplySingleEventCuts();//check values read from modules are at desired level
86  void IncrementErrorCounters(){fHalo_Counter.IncrementErrorCounters();};
87  UInt_t GetEventcutErrorFlag(){return fHalo_Counter.GetEventcutErrorFlag();};
88 
89  UInt_t UpdateErrorFlag() {return GetEventcutErrorFlag();};
90  void UpdateErrorFlag(const QwHaloMonitor *ev_error){
91  fHalo_Counter.UpdateErrorFlag(ev_error->fHalo_Counter);
92  };
93 
94  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
95  Bool_t ApplyHWChecks();
96  void SetSingleEventCuts(UInt_t errorflag,Double_t min, Double_t max, Double_t stability){
97  fHalo_Counter.SetSingleEventCuts(errorflag,min,max,stability);
98  };
99  void SetEventCutMode(Int_t bcuts){
100  fHalo_Counter.SetEventCutMode(bcuts);
101  }
102 
103 
104  void ConstructHistograms(TDirectory *folder, TString &prefix);
105  void FillHistograms();
106 
107  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
108  void ConstructBranch(TTree *tree, TString &prefix);
109  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& modulelist);
110  void FillTreeVector(std::vector<Double_t> &values) const;
111 
113  return &fHalo_Counter;
114  };
115 
117  return const_cast<QwHaloMonitor*>(this)->GetScaler();
118  };
119 
120  Double_t GetValue() {
121  return fHalo_Counter.GetValue();
122  }
123 
124  void PrintValue() const;
125  void PrintInfo() const;
126 
127  std::vector<QwDBInterface> GetDBEntry();
128  std::vector<QwErrDBInterface> GetErrDBEntry();
129 
130  protected:
131 
132  private:
133  static const Bool_t kDEBUG;
134 
136 
137  Int_t fDeviceErrorCode;//keep the device HW status using a unique code from the QwVQWK_Channel::fDeviceErrorCode
138  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
139 
140 };
141 
142 
143 #endif
void FillTreeVector(std::vector< Double_t > &values) const
void InitializeChannel(TString name)
std::string GetExternalClockName()
Definition: QwHaloMonitor.h:56
void AccumulateRunningSum(const QwHaloMonitor &value)
QwHaloMonitor & operator+=(const QwHaloMonitor &value)
Int_t fDeviceErrorCode
VQwHardwareChannel * GetScaler()
void CalculateRunningAverage()
QwHaloMonitor(TString name)
Definition: QwHaloMonitor.h:36
std::vector< QwDBInterface > GetDBEntry()
void ConstructBranch(TTree *tree, TString &prefix)
Bool_t ApplyHWChecks()
Double_t GetValue()
void SetSingleEventCuts(UInt_t errorflag, Double_t min, Double_t max, Double_t stability)
set the upper and lower limits (fULimit and fLLimit), stability % and the error flag on this channel ...
Definition: QwHaloMonitor.h:96
void SetExternalClockName(const std::string name)
Definition: QwHaloMonitor.h:59
void SetExternalClockPtr(const VQwHardwareChannel *clock)
Definition: QwHaloMonitor.h:58
QwHaloMonitor(const QwHaloMonitor &source)
Definition: QwHaloMonitor.h:42
void DeaccumulateRunningSum(QwHaloMonitor &value)
void ConstructHistograms(TDirectory *folder, TString &prefix)
Construct the histograms for this data element.
Double_t GetNormClockValue()
Definition: QwHaloMonitor.h:60
void IncrementErrorCounters()
Definition: QwHaloMonitor.h:86
void PrintValue() const
Print single line of value and error of this data element.
The pure virtual base class of all data elements.
void Ratio(QwHaloMonitor &numer, QwHaloMonitor &denom)
void SetPedestal(Double_t ped)
Definition: QwHaloMonitor.h:79
QwHaloMonitor(TString subsystemname, TString name)
Definition: QwHaloMonitor.h:39
void ClearEventData()
Clear the event data in this element.
void UpdateErrorFlag(const QwHaloMonitor *ev_error)
Definition: QwHaloMonitor.h:90
void ProcessEvent()
Bool_t NeedsExternalClock()
Definition: QwHaloMonitor.h:57
static const Bool_t kDEBUG
void UpdateHWErrorCount()
static const double min
Definition: QwUnits.h:76
QwHaloMonitor & operator=(const QwHaloMonitor &value)
class QwScaler_Channel< 0x00ffffff, 0 > QwSIS3801D24_Channel
UInt_t GetEventcutErrorFlag()
return the error flag on this channel/device
Definition: QwHaloMonitor.h:87
void SetCalibrationFactor(Double_t factor)
Definition: QwHaloMonitor.h:80
void Offset(Double_t Offset)
void PrintErrorCounters()
Bool_t ApplySingleEventCuts()
Bool_t bEVENTCUTMODE
void LoadChannelParameters(QwParameterFile &paramfile)
Definition: QwHaloMonitor.h:53
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
void PrintInfo() const
Print multiple lines of information about this data element.
void SetEventCutMode(Int_t bcuts)
Definition: QwHaloMonitor.h:99
void Scale(Double_t Offset)
virtual ~QwHaloMonitor()
Definition: QwHaloMonitor.h:46
void Difference(QwHaloMonitor &value1, QwHaloMonitor &value2)
void Sum(QwHaloMonitor &value1, QwHaloMonitor &value2)
Int_t ProcessEvBuffer(UInt_t *buffer, UInt_t num_words_left, UInt_t index=0)
Process the CODA event buffer for this element.
UInt_t UpdateErrorFlag()
Update the error flag based on the error flags of internally contained objects Return paramter is the...
Definition: QwHaloMonitor.h:89
QwHaloMonitor & operator-=(const QwHaloMonitor &value)
QwSIS3801D24_Channel fHalo_Counter
void FillHistograms()
Fill the histograms for this data element.
const VQwHardwareChannel * GetScaler() const
std::vector< QwErrDBInterface > GetErrDBEntry()