QwAnalysis
QwBeamLine.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwBeamLine.h *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #ifndef __QwBEAMLINE__
9 #define __QwBEAMLINE__
10 
11 // System headers
12 #include <vector>
13 
14 // ROOT headers
15 #include "TTree.h"
16 #include "TString.h"
17 
18 // Qweak headers
19 #include "VQwSubsystemParity.h"
20 #include "QwTypes.h"
21 #include "QwBPMStripline.h"
22 #include "VQwBCM.h"
23 #include "QwBCM.h"
24 #include "QwBPMCavity.h"
25 #include "QwCombinedBCM.h"
26 #include "QwCombinedBPM.h"
27 #include "QwEnergyCalculator.h"
28 #include "QwHaloMonitor.h"
29 #include "QwQPD.h"
30 #include "QwLinearDiodeArray.h"
31 #include "VQwClock.h"
32 #include "QwBeamDetectorID.h"
33 
34 
35 /*****************************************************************
36 * Class:
37 ******************************************************************/
38 class QwBeamLine : public VQwSubsystemParity, public MQwSubsystemCloneable<QwBeamLine> {
39 
40  private:
41  /// Private default constructor (not implemented, will throw linker error on use)
42  QwBeamLine();
43 
44  public:
45  /// Constructor with name
46  QwBeamLine(const TString& name)
47  : VQwSubsystem(name),VQwSubsystemParity(name)
48  { };
49  /// Copy constructor
50  QwBeamLine(const QwBeamLine& source)
51  : VQwSubsystem(source),VQwSubsystemParity(source),
52  fQPD(source.fQPD),
53  fLinearArray(source.fLinearArray),
54  fCavity(source.fCavity),
55  fHaloMonitor(source.fHaloMonitor),
56  fECalculator(source.fECalculator),
58  { this->CopyTemplatedDataElements(&source); }
59  /// Virtual destructor
60  virtual ~QwBeamLine() { };
61 
62  void CopyTemplatedDataElements(const VQwSubsystem *source);
63 
64  /* derived from VQwSubsystem */
65 
66  void ProcessOptions(QwOptions &options);//Handle command line options
67  Int_t LoadChannelMap(TString mapfile);
68  Int_t LoadInputParameters(TString pedestalfile);
69  Int_t LoadEventCuts(TString filename);//derived from VQwSubsystemParity
70  Int_t LoadGeometryDefinition(TString mapfile);
71  void AssignGeometry(QwParameterFile* mapstr, VQwBPM * bpm);
72 
73  Bool_t ApplySingleEventCuts();//derived from VQwSubsystemParity
75  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliures
76  UInt_t GetEventcutErrorFlag();//return the error flag
77 
78  UInt_t UpdateErrorFlag();//Update and return the error flags
79 
80  //update the error flag in the subsystem level from the top level routines related to stability checks. This will uniquely update the errorflag at each channel based on the error flag in the corresponding channel in the ev_error subsystem
81  void UpdateErrorFlag(const VQwSubsystem *ev_error);
82 
83  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
84  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
85  void PrintDetectorID() const;
86 
87  void ClearEventData();
88  void ProcessEvent();
89 
90  Bool_t PublishInternalValues() const;
91  Bool_t PublishByRequest(TString device_name);
92 
93 
94  public:
95  void RandomizeEventData(int helicity = 0, double time = 0.0);
96  void EncodeEventData(std::vector<UInt_t> &buffer);
97 
101  void Sum(VQwSubsystem *value1, VQwSubsystem *value2);
102  void Difference(VQwSubsystem *value1, VQwSubsystem *value2);
103  void Ratio(VQwSubsystem *numer, VQwSubsystem *denom);
104 
105  void Scale(Double_t factor);
106 
107  void AccumulateRunningSum(VQwSubsystem* value);
108  //remove one entry from the running sums for devices
110 
111 
113 
115  void ConstructHistograms(TDirectory *folder, TString &prefix);
116  void FillHistograms();
117 
119  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
120  void ConstructBranch(TTree *tree, TString &prefix);
121  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file );
122  void FillTreeVector(std::vector<Double_t> &values) const;
123  void FillDB(QwParityDB *db, TString datatype);
124  void FillErrDB(QwParityDB *db, TString datatype);
125 
126  Bool_t Compare(VQwSubsystem *source);
127 
128  void PrintValue() const;
129  void PrintInfo() const;
130  void WritePromptSummary(QwPromptSummary *ps, TString type);
131 
133  VQwDataElement* GetElement(EQwBeamInstrumentType TypeID, TString name);
134  VQwDataElement* GetElement(EQwBeamInstrumentType TypeID, Int_t index);
135  const VQwDataElement* GetElement(EQwBeamInstrumentType TypeID, Int_t index) const;
136 
137  const VQwHardwareChannel* GetChannel(EQwBeamInstrumentType TypeID, Int_t index, TString device_prop) const;
138 
139  VQwBPM* GetBPMStripline(const TString name);
140  VQwBCM* GetBCM(const TString name);
141  VQwClock* GetClock(const TString name);
142  QwBPMCavity* GetBPMCavity(const TString name);
143  VQwBCM* GetCombinedBCM(const TString name);
144  VQwBPM* GetCombinedBPM(const TString name);
145  QwEnergyCalculator* GetEnergyCalculator(const TString name);
146  QwHaloMonitor* GetScalerChannel(const TString name);
147  const QwBPMCavity* GetBPMCavity(const TString name) const;
148  const VQwBPM* GetBPMStripline(const TString name) const;
149  const VQwBCM* GetBCM(const TString name) const;
150  const VQwClock* GetClock(const TString name) const;
151  const VQwBCM* GetCombinedBCM(const TString name) const;
152  const VQwBPM* GetCombinedBPM(const TString name) const;
153  const QwEnergyCalculator* GetEnergyCalculator(const TString name) const;
154  const QwHaloMonitor* GetScalerChannel(const TString name) const;
155 
156 
157 /////
158 protected:
159 
160  /// \brief Adds a new element to a vector of data elements, and returns
161  /// the index of that element within the array.
162  template <typename TT>
163  Int_t AddToElementList(std::vector<TT> &elementlist, QwBeamDetectorID &detector_id);
164 
165  Int_t GetDetectorIndex(EQwBeamInstrumentType TypeID, TString name) const;
166  //when the type and the name is passed the detector index from appropriate vector will be returned
167  //for example if TypeID is bcm then the index of the detector from fBCM vector for given name will be returnd.
168 
169  std::vector <VQwBPM_ptr> fStripline;
170  std::vector <VQwBPM_ptr> fBPMCombo;
171 
172  std::vector <VQwBCM_ptr> fBCM;
173  std::vector <VQwBCM_ptr> fBCMCombo;
174 
175  std::vector <VQwClock_ptr> fClock;
176 
177  std::vector <QwQPD> fQPD;
178  std::vector <QwLinearDiodeArray> fLinearArray;
179  std::vector <QwBPMCavity> fCavity;
180  std::vector <QwHaloMonitor> fHaloMonitor;
181 
182 
183  std::vector <QwEnergyCalculator> fECalculator;
184  std::vector <QwBeamDetectorID> fBeamDetectorID;
185 
186 /////
187 private:
188  // std::vector<TString> DetectorTypes;// for example could be BCM, LUMI,BPMSTRIPLINE, etc..
190 
191 
192  static const Bool_t bDEBUG=kFALSE;
193 
194 };
195 
196 #endif
void AssignGeometry(QwParameterFile *mapstr, VQwBPM *bpm)
Definition: QwBeamLine.cc:776
std::vector< VQwBPM_ptr > fBPMCombo
Definition: QwBeamLine.h:170
void PrintDetectorID() const
Definition: QwBeamLine.cc:2552
void Scale(Double_t factor)
Definition: QwBeamLine.cc:2115
Int_t fQwBeamLineErrorCount
Definition: QwBeamLine.h:189
QwBPMCavity * GetBPMCavity(const TString name)
Definition: QwBeamLine.cc:1762
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Definition: QwBeamLine.cc:1332
Definition: VQwBCM.h:32
Bool_t PublishInternalValues() const
Publish all variables of the subsystem.
Definition: QwBeamLine.cc:1487
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamLine.cc:2062
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Definition: QwBeamLine.cc:1172
static const Bool_t bDEBUG
Definition: QwBeamLine.h:192
An options class.
Definition: QwOptions.h:133
QwBeamLine(const QwBeamLine &source)
Copy constructor.
Definition: QwBeamLine.h:50
std::vector< QwBPMCavity > fCavity
Definition: QwBeamLine.h:179
QwEnergyCalculator * GetEnergyCalculator(const TString name)
Definition: QwBeamLine.cc:1845
UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
Definition: QwBeamLine.cc:1367
std::vector< QwEnergyCalculator > fECalculator
Definition: QwBeamLine.h:183
void PrintValue() const
Print values of all channels.
Definition: QwBeamLine.cc:2146
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Definition: QwBeamLine.cc:94
void CalculateRunningAverage()
Calculate the average for all good events.
Definition: QwBeamLine.cc:2131
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
Definition: QwBeamLine.cc:2073
VQwBCM * GetCombinedBCM(const TString name)
Definition: QwBeamLine.cc:1811
Virtual base class for the parity subsystems.
QwBeamLine(const TString &name)
Constructor with name.
Definition: QwBeamLine.h:46
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
Definition: QwBeamLine.cc:821
const VQwHardwareChannel * GetChannel(EQwBeamInstrumentType TypeID, Int_t index, TString device_prop) const
Definition: QwBeamLine.cc:1703
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
std::vector< VQwClock_ptr > fClock
Definition: QwBeamLine.h:175
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwBeamLine.cc:1480
VQwClock * GetClock(const TString name)
Definition: QwBeamLine.cc:1794
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Definition: QwBeamLine.cc:1249
Int_t AddToElementList(std::vector< TT > &elementlist, QwBeamDetectorID &detector_id)
Adds a new element to a vector of data elements, and returns the index of that element within the arr...
Definition: QwBeamLine.cc:82
std::vector< VQwBCM_ptr > fBCM
Definition: QwBeamLine.h:172
std::vector< VQwBPM_ptr > fStripline
Definition: QwBeamLine.h:169
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
Definition: QwBeamLine.cc:2602
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Definition: QwBeamLine.cc:1919
void ProcessEvent()
Definition: QwBeamLine.cc:1440
The pure virtual base class of all data elements.
Int_t GetDetectorIndex(EQwBeamInstrumentType TypeID, TString name) const
Definition: QwBeamLine.cc:1620
VQwBCM * GetBCM(const TString name)
Definition: QwBeamLine.cc:1776
void EncodeEventData(std::vector< UInt_t > &buffer)
Definition: QwBeamLine.cc:1006
virtual ~QwBeamLine()
Virtual destructor.
Definition: QwBeamLine.h:60
std::vector< QwHaloMonitor > fHaloMonitor
Definition: QwBeamLine.h:180
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Definition: QwBeamLine.cc:2350
void PrintInfo() const
Print some information about the subsystem.
Definition: QwBeamLine.cc:2529
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
Definition: QwBeamLine.cc:2173
void FillErrDB(QwParityDB *db, TString datatype)
Definition: QwBeamLine.cc:2830
QwHaloMonitor * GetScalerChannel(const TString name)
Definition: QwBeamLine.cc:1865
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
Definition: QwBeamLine.cc:2502
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
Definition: QwBeamLine.cc:425
Bool_t PublishByRequest(TString device_name)
Try to publish an internal variable matching the submitted name.
Definition: QwBeamLine.cc:1538
void WritePromptSummary(QwPromptSummary *ps, TString type)
Definition: QwBeamLine.cc:2995
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
void IncrementErrorCounters()
Increment the error counters.
Definition: QwBeamLine.cc:1297
QwBeamLine()
Private default constructor (not implemented, will throw linker error on use)
std::vector< VQwBCM_ptr > fBCMCombo
Definition: QwBeamLine.h:173
Bool_t Compare(VQwSubsystem *source)
Definition: QwBeamLine.cc:2233
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
std::vector< QwBeamDetectorID > fBeamDetectorID
Definition: QwBeamLine.h:184
std::vector< QwLinearDiodeArray > fLinearArray
Definition: QwBeamLine.h:178
Definition: VQwBPM.h:34
Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
Definition: QwBeamLine.cc:1048
VQwDataElement * GetElement(QwBeamDetectorID det_id)
Definition: QwBeamLine.cc:1643
void ClearEventData()
Definition: QwBeamLine.cc:1593
void RandomizeEventData(int helicity=0, double time=0.0)
Definition: QwBeamLine.cc:986
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
Definition: QwBeamLine.cc:2378
VQwSubsystem & operator-=(VQwSubsystem *value)
Definition: QwBeamLine.cc:2007
EQwBeamInstrumentType
Definition: QwTypes.h:132
void FillHistograms()
Fill the histograms for this subsystem.
Definition: QwBeamLine.cc:2322
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Definition: QwBeamLine.cc:2203
void ProcessOptions(QwOptions &options)
Process the command line options.
Definition: QwBeamLine.cc:30
void CopyTemplatedDataElements(const VQwSubsystem *source)
Definition: QwBeamLine.cc:2566
VQwSubsystem & operator+=(VQwSubsystem *value)
Definition: QwBeamLine.cc:1964
std::vector< QwQPD > fQPD
Definition: QwBeamLine.h:177
VQwBPM * GetBPMStripline(const TString name)
Definition: QwBeamLine.cc:1748
VQwBPM * GetCombinedBPM(const TString name)
Definition: QwBeamLine.cc:1828
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamLine.cc:2051
Int_t LoadGeometryDefinition(TString mapfile)
Optional geometry definition.
Definition: QwBeamLine.cc:597