QwAnalysis
QwLumi.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwLumi.h *
3 * *
4 * Author: *
5 * Time-stamp: *
6 \**********************************************************/
7 
8 #ifndef __QwLUMI__
9 #define __QwLUMI__
10 
11 // System headers
12 #include <vector>
13 
14 // ROOT headers
15 #include "TTree.h"
16 
17 // Qweak headers
18 #include "VQwSubsystemParity.h"
19 
20 #include "QwIntegrationPMT.h"
21 #include "QwCombinedPMT.h"
22 #include "QwTypes.h"
23 #include "QwScaler_Channel.h"
24 
25 
27 
28  public:
29 
32  fSubelement(999999),fmoduletype(""),fdetectorname("")
33  {};
34 
35  int fSubbankIndex;
36  int fWordInSubbank; //first word reported for this channel in the subbank
37  //(eg VQWK channel report 6 words for each event, scalers oly report one word per event)
38  // The first word of the subbank gets fWordInSubbank=0
39 
40  EQwPMTInstrumentType fTypeID; // type of detector
41  int fIndex; // index of this detector in the vector containing all the detector of same type
42  UInt_t fSubelement; // some detectors have many subelements (eg stripline have 4 antenas) some have only one sub element(eg lumis have one channel)
43 
44  TString fmoduletype; // eg: VQWK, SCALER
45  TString fdetectorname;
46  TString fdetectortype; // IntegrationPMT,fLumiCounter .. this string is encoded by fTypeID
47  std::vector<TString> fCombinedChannelNames;
48  std::vector<Double_t> fWeight;
49  void Print() const;
50 
51 };
52 
53 
54 /*****************************************************************
55 * Class:
56 ******************************************************************/
57 class QwLumi : public VQwSubsystemParity, public MQwSubsystemCloneable<QwLumi> {
58  /////
59  friend class QwCombinedPMT;
60 
61  private:
62  /// Private default constructor (not implemented, will throw linker error on use)
63  QwLumi();
64 
65  public:
66  /// Constructor with name
67  QwLumi(const TString& name)
68  : VQwSubsystem(name),VQwSubsystemParity(name),bNormalization(kFALSE)
69  {
70  fTargetCharge.InitializeChannel("q_targ","derived");
71  };
72  /// Copy constructor
73  QwLumi(const QwLumi& source)
74  : VQwSubsystem(source),VQwSubsystemParity(source),
76  fScalerPMT(source.fScalerPMT),
78  { }
79  /// Virtual destructor
80  virtual ~QwLumi() { };
81 
82 
83  /* derived from VQwSubsystem */
84 
85  /// \brief Define options function
86  static void DefineOptions(QwOptions &options);
87 
88 
89  void ProcessOptions(QwOptions &options);//Handle command line options
90  Int_t LoadChannelMap(TString mapfile);
91  Int_t LoadInputParameters(TString pedestalfile);
92  Int_t LoadEventCuts(TString filename);//derived from VQwSubsystemParity
93  Bool_t ApplySingleEventCuts();//derived from VQwSubsystemParity
95  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliures
96  UInt_t GetEventcutErrorFlag();//return the error flag
97  //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
98  void UpdateErrorFlag(const VQwSubsystem *ev_error);
99 
100  void AccumulateRunningSum(VQwSubsystem* value);
101  //remove one entry from the running sums for devices
104 
105  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
106  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
107  void PrintDetectorID() const;
108 
109  void ClearEventData();
110  Bool_t IsGoodEvent();
111 
112  void ProcessEvent();
113  void ExchangeProcessedData();
114  void ProcessEvent_2();
115 
116  Bool_t PublishInternalValues() const;
117  Bool_t PublishByRequest(TString device_name);
118 
119  void DoNormalization(Double_t factor=1.0);
120 
121  void SetRandomEventParameters(Double_t mean, Double_t sigma);
122  void SetRandomEventAsymmetry(Double_t asymmetry);
123  void RandomizeEventData(int helicity = 0, double time = 0.0);
124  void EncodeEventData(std::vector<UInt_t> &buffer);
125 
129  void Sum(VQwSubsystem *value1, VQwSubsystem *value2);
130  void Difference(VQwSubsystem *value1, VQwSubsystem *value2);
131  void Ratio(VQwSubsystem *numer, VQwSubsystem *denom);
132  void Normalize(VQwDataElement* denom);
133  void Scale(Double_t factor);
134 
136  void ConstructHistograms(TDirectory *folder, TString &prefix);
137  void FillHistograms();
138 
139  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
140  void ConstructBranch(TTree *tree, TString &prefix);
141  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file);
142  void FillTreeVector(std::vector<Double_t> &values) const;
143  void FillDB(QwParityDB *db, TString datatype);
144  void FillErrDB(QwParityDB *db, TString datatype);
145 
146  const QwIntegrationPMT* GetChannel(const TString name) const;
147  const QwIntegrationPMT* GetIntegrationPMT(const TString name) const;
148  const QwCombinedPMT* GetCombinedPMT(const TString name) const;
149 
150  Bool_t Compare(VQwSubsystem *source);
151 
152  void PrintValue() const;
153  void PrintInfo() const;
154  void WritePromptSummary(QwPromptSummary *ps, TString type);
155 
156  std::vector<TString> fgDetectorTypeNames;
157 
158 
159 /////
160  protected:
161 
163 
164  Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name);
165  //when the type and the name is passed the detector index from appropriate vector will be returned
166  //for example if TypeID is IntegrationPMT then the index of the detector from fIntegrationPMT vector for given name will be returnd.
167 
168  std::vector <QwIntegrationPMT> fIntegrationPMT;
169  std::vector <QwCombinedPMT> fCombinedPMT;
170  std::vector <QwSIS3801D24_Channel> fScalerPMT;
171 
172  std::vector <QwLumiDetectorID> fLumiDetectorID;
173 
174  protected:
178 
179 /////
180  private:
182 
183  static const Bool_t bDEBUG=kFALSE;
184 
185 };
186 
187 
188 
189 
190 #endif
void Print() const
Definition: QwLumi.cc:1162
QwLumi(const QwLumi &source)
Copy constructor.
Definition: QwLumi.h:73
const QwIntegrationPMT * GetIntegrationPMT(const TString name) const
Definition: QwLumi.cc:852
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwLumi.cc:943
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Definition: QwLumi.cc:1200
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Definition: QwLumi.cc:45
TString fdetectorname
Definition: QwLumi.h:45
An options class.
Definition: QwOptions.h:133
Int_t fQwLumiErrorCount
Definition: QwLumi.h:181
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
Definition: QwLumi.cc:1108
void Normalize(VQwDataElement *denom)
Definition: QwLumi.cc:991
std::vector< Double_t > fWeight
Definition: QwLumi.h:48
Bool_t bIsExchangedDataValid
Definition: QwLumi.h:176
void PrintInfo() const
Print some information about the subsystem.
Definition: QwLumi.cc:1134
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
void FillErrDB(QwParityDB *db, TString datatype)
Definition: QwLumi.cc:1319
TString fdetectortype
Definition: QwLumi.h:46
EQwPMTInstrumentType
Definition: QwTypes.h:124
int fSubbankIndex
Definition: QwLumi.h:33
void PrintValue() const
Print values of all channels.
Definition: QwLumi.cc:1122
UInt_t fSubelement
Definition: QwLumi.h:42
void FillHistograms()
Fill the histograms for this subsystem.
Definition: QwLumi.cc:1044
Virtual base class for the parity subsystems.
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
Definition: QwLumi.cc:1069
void DoNormalization(Double_t factor=1.0)
Definition: QwLumi.cc:1213
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwLumi.cc:953
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
Definition: QwLumi.cc:352
const QwIntegrationPMT * GetChannel(const TString name) const
Definition: QwLumi.cc:845
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: QwLumi.cc:542
std::vector< QwCombinedPMT > fCombinedPMT
Definition: QwLumi.h:169
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Definition: QwLumi.cc:615
Bool_t bNormalization
Definition: QwLumi.h:177
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
Bool_t PublishByRequest(TString device_name)
Try to publish an internal variable matching the submitted name.
Definition: QwLumi.cc:763
void ProcessOptions(QwOptions &options)
Process the command line options.
Definition: QwLumi.cc:34
VQwSubsystem & operator+=(VQwSubsystem *value)
Definition: QwLumi.cc:908
The pure virtual base class of all data elements.
static const Bool_t bDEBUG
Definition: QwLumi.h:183
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Definition: QwLumi.cc:888
void WritePromptSummary(QwPromptSummary *ps, TString type)
Definition: QwLumi.cc:1389
int fWordInSubbank
Definition: QwLumi.h:36
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
Definition: VQwSubsystem.h:88
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Definition: QwLumi.cc:646
QwLumiDetectorID()
Definition: QwLumi.h:30
EQwPMTInstrumentType fTypeID
Definition: QwLumi.h:40
void RandomizeEventData(int helicity=0, double time=0.0)
Definition: QwLumi.cc:497
QwLumi(const TString &name)
Constructor with name.
Definition: QwLumi.h:67
class QwVQWK_Channel QwBeamCharge
Definition: QwTypes.h:315
virtual ~QwLumi()
Virtual destructor.
Definition: QwLumi.h:80
void ClearEventData()
Definition: QwLumi.cc:801
std::vector< TString > fgDetectorTypeNames
Definition: QwLumi.h:156
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwLumi.cc:786
void CalculateRunningAverage()
Calculate the average for all good events.
Definition: QwLumi.cc:1177
std::vector< QwLumiDetectorID > fLumiDetectorID
Definition: QwLumi.h:172
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name)
Definition: QwLumi.cc:818
std::vector< QwIntegrationPMT > fIntegrationPMT
Definition: QwLumi.h:168
void EncodeEventData(std::vector< UInt_t > &buffer)
Definition: QwLumi.cc:505
Bool_t IsGoodEvent()
Definition: QwLumi.cc:792
void ProcessEvent_2()
Process the event data again, including data from other subsystems. Not all derived classes will requ...
Definition: QwLumi.cc:726
void SetRandomEventParameters(Double_t mean, Double_t sigma)
Definition: QwLumi.cc:483
Bool_t Compare(VQwSubsystem *source)
Definition: QwLumi.cc:1003
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Definition: QwLumi.cc:1058
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
Definition: QwLumi.cc:429
void SetRandomEventAsymmetry(Double_t asymmetry)
Definition: QwLumi.cc:490
Definition: QwLumi.h:57
void Scale(Double_t factor)
Definition: QwLumi.cc:980
void ProcessEvent()
Definition: QwLumi.cc:691
Bool_t PublishInternalValues() const
Publish all variables of the subsystem.
Definition: QwLumi.cc:752
void PrintDetectorID() const
Definition: QwLumi.cc:1151
std::vector< QwSIS3801D24_Channel > fScalerPMT
Definition: QwLumi.h:170
QwBeamCharge fTargetCharge
Definition: QwLumi.h:175
void IncrementErrorCounters()
Increment the error counters.
Definition: QwLumi.cc:635
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
Definition: QwLumi.cc:1243
std::vector< TString > fCombinedChannelNames
Definition: QwLumi.h:47
void ExchangeProcessedData()
Definition: QwLumi.cc:707
TString fmoduletype
Definition: QwLumi.h:44
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
Definition: QwLumi.cc:963
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Definition: QwLumi.cc:664
const QwCombinedPMT * GetCombinedPMT(const TString name) const
Definition: QwLumi.cc:865
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
Definition: QwLumi.cc:1187
QwLumi()
Private default constructor (not implemented, will throw linker error on use)
VQwSubsystem & operator-=(VQwSubsystem *value)
Definition: QwLumi.cc:925
EQwPMTInstrumentType GetDetectorTypeID(TString name)
Definition: QwLumi.cc:812