QwAnalysis
QwBeamMod.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwBeamMod.h *
3 * *
4 * Author: Joshua Hoskins *
5 * Time-stamp: 052510 *
6 ***********************************************************
7 * *
8 * Time-Stamp: 101910 *
9 * *
10 * Added support of QwWord *
11 * *
12 \**********************************************************/
13 
14 #ifndef __QwBEAMMOD__
15 #define __QwBEAMMOD__
16 
17 // System headers
18 #include <vector>
19 
20 // ROOT headers
21 #include "TTree.h"
22 
23 // Qweak headers
24 #include "VQwSubsystemParity.h"
25 #include "QwVQWK_Channel.h"
26 #include "QwWord.h"
27 
28 
29 //enum EBeamInstrumentType{kBPMStripline = 0,
30 // kBCM,
31 // kCombinedBCM,
32 // kCombinedBPM};
33 
34 // this emun vector needs to be coherent with the DetectorTypes declaration in the QwBeamLine constructor
35 
36 class QwModChannelID;
37 
38 /*****************************************************************
39 * Class:
40 ******************************************************************/
41 class QwBeamMod: public VQwSubsystemParity, public MQwSubsystemCloneable<QwBeamMod> {
42 
43  private:
44  ///
45  QwBeamMod();
46 
47  public:
48  /// Constructor with name
49  QwBeamMod(const TString& name)
50  : VQwSubsystem(name),VQwSubsystemParity(name)
51  {
52  // these declaration need to be coherent with the enum vector EBeamInstrumentType
53  fgModTypeNames.push_back(""); // Need to define these wrt to our detector types.
54  fgModTypeNames.push_back("");
55  fgModTypeNames.push_back("");
56  fgModTypeNames.push_back("");
57  for(size_t i=0;i<fgModTypeNames.size();i++)
58  fgModTypeNames[i].ToLower();
60  fFFB_Flag=kTRUE;
61  fRampChannelIndex = -1;
62  fPatternWordIndex = -1;
63  };
64  /// Copy constructor
65  QwBeamMod(const QwBeamMod& source)
66  : VQwSubsystem(source),VQwSubsystemParity(source),
67  fModChannel(source.fModChannel),fWord(source.fWord),
70  { }
71  /// Virtual destructor
72  virtual ~QwBeamMod() {};
73 
74  std::vector<TString> fgModTypeNames;
75  /* derived from VQwSubsystem */
76 
77  //Handle command line options
78  void ProcessOptions(QwOptions &options);
80  //remove one entry from the running sums for devices
82  };
83 
84  Int_t LoadChannelMap(TString mapfile);
85  Int_t LoadEventCuts(TString filename);//derived from VQwSubsystemParity
86  Int_t LoadGeometry(TString mapfile);
87  Int_t LoadInputParameters(TString pedestalfile);
88 
89 
90  Bool_t ApplySingleEventCuts();//derived from VQwSubsystemParity
92  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliures
93  UInt_t GetEventcutErrorFlag();//return the error flag
94 
95  //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
96  void UpdateErrorFlag(const VQwSubsystem *ev_error);
97 
98  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
99  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
100 // void PrintDetectorID();
101 
102  void ClearEventData();
103 
104  void ProcessEvent();
105  void ExchangeProcessedData();
106  void ProcessEvent_2();
107 
111 
112 
113  void Sum(VQwSubsystem *value1, VQwSubsystem *value2);
114 
115  void Difference(VQwSubsystem *value1, VQwSubsystem *value2);
116  void Ratio(VQwSubsystem *numer, VQwSubsystem *denom);
117 
118  void Scale(Double_t factor);
119 
121  void PrintModChannelID();
122 
124  void ConstructHistograms(TDirectory *folder, TString &prefix);
125  void FillHistograms();
126 
128  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
129  void ConstructBranch(TTree *tree, TString& prefix) { };
130  void ConstructBranch(TTree *tree, TString& prefix, QwParameterFile& trim_file) { };
131  void FillTreeVector(std::vector<Double_t> &values) const;
132 
133  void FillDB_MPS(QwParityDB *db, TString datatype);
134  void FillDB(QwParityDB *db, TString datatype);
135  void FillErrDB(QwParityDB *db, TString datatype);
136  void WritePromptSummary(QwPromptSummary *ps, TString type);
137 
138  Bool_t Compare(VQwSubsystem *source);
139 
140  void Print();
141 
142  void AtEndOfEventLoop();
143  void AnalyzeOpticsPlots();
144  void ResizeOpticsDataContainers(Int_t);
145  void ClearVectors();
146 
147  Double_t GetAmplitudeSign(Double_t, Double_t, Double_t, Double_t);
148 
149  protected:
150  Int_t GetDetectorTypeID(TString name);
151  Int_t GetDetectorIndex(Int_t TypeID, TString name); // when the type and the name is passed the detector index from appropriate vector will be returned
152  Int_t fTreeArrayIndex; // for example if TypeID is bcm then the index of the detector from fBCM vector for given name will be returnd.
153 
154 
155  std::vector <QwVQWK_Channel> fModChannel;
156  std::vector <QwModChannelID> fModChannelID;
157  std::vector <QwWord> fWord;
158  std::vector < std::pair<Int_t, Int_t> > fWordsPerSubbank;
159 
160 
161 
162  private:
163 
164  UInt_t fFFB_Index;
165  UInt_t fFFB_holdoff;
168  Bool_t fFFB_Flag;
169  static const Bool_t bDEBUG=kFALSE;
170 
171  static const Int_t fNumberPatterns = 5;
172 
173  // List of monitor channels
174 
175  std::vector<TString> fMonitorNames;
176  std::vector<QwVQWK_Channel> fMonitors;
177  std::vector<Double_t> fBPMPosition;
178 
179  std::vector <std::vector <Double_t> > fAmplitude;
180  std::vector <std::vector <Double_t> > fOffset;
181  std::vector <std::vector <Double_t> > fPhase;
182 
183  std::vector <std::vector <Double_t> > fAmplitudeError;
184  std::vector <std::vector <Double_t> > fOffsetError;
185  std::vector <std::vector <Double_t> > fPhaseError;
186 
187  std::vector <std::vector <Double_t> > fChisquare;
188  std::vector <std::vector <Int_t> > fNFitPoints;
189 
192 
193 };
194 
195 
196 
198 {
199  public:
200 
201  QwModChannelID(Int_t subbankid, Int_t wordssofar,TString name,
202  TString modtype ,QwBeamMod * obj);
203 
204 
205 /* QwModChannelID():fSubbankIndex(-1),fWordInSubbank(-1),fTypeID(-1),fIndex(-1), */
206 /* fSubelement(999999),fmoduletype(""),fmodulename("") */
207 /* {}; */
208 
209  Int_t fSubbankIndex; //Generated from ROCID(readout CPU) & BankID(corespondes to internal headers to ID differnt types of data..ex. F1TDC)
211  //first word reported for this channel in the subbank
212  //(eg VQWK channel report 6 words for each event, scalers oly report one word per event)
213 
214  // The first word of the subbank gets fWordInSubbank=0
215 
216  TString fmoduletype; // eg: VQWK, SCALER
217  TString fmodulename;
218  // TString fdetectortype;
219 
221  Int_t fTypeID; // type of detector eg: lumi or stripline, etc..
222  Int_t fIndex; // index of this detector in the vector containing all the detector of same type
223 
224  void Print();
225 
226 };
227 
228 
229 
230 #endif
std::vector< std::pair< Int_t, Int_t > > fWordsPerSubbank
Definition: QwBeamMod.h:158
void Print()
Definition: QwBeamMod.cc:954
std::vector< std::vector< Double_t > > fAmplitude
Definition: QwBeamMod.h:179
void ProcessEvent()
Definition: QwBeamMod.cc:485
Int_t GetDetectorIndex(Int_t TypeID, TString name)
Definition: QwBeamMod.cc:541
void ProcessEvent_2()
Process the event data again, including data from other subsystems. Not all derived classes will requ...
Definition: QwBeamMod.cc:508
Int_t fRampChannelIndex
Definition: QwBeamMod.h:190
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Definition: QwBeamMod.cc:414
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
Definition: QwBeamMod.cc:636
UInt_t fFFB_ErrorFlag
Definition: QwBeamMod.h:167
UInt_t fFFB_holdoff_Counter
Definition: QwBeamMod.h:166
UInt_t fFFB_holdoff
Definition: QwBeamMod.h:165
std::vector< TString > fMonitorNames
Definition: QwBeamMod.h:175
static const Int_t fNumberPatterns
Definition: QwBeamMod.h:171
void FillErrDB(QwParityDB *db, TString datatype)
Definition: QwBeamMod.cc:1058
void FillHistograms()
Fill the histograms for this subsystem.
Definition: QwBeamMod.cc:724
An options class.
Definition: QwOptions.h:133
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamMod.cc:627
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwBeamMod.cc:514
Int_t LoadGeometry(TString mapfile)
Int_t kUnknownDeviceType
Definition: QwBeamMod.h:220
virtual ~QwBeamMod()
Virtual destructor.
Definition: QwBeamMod.h:72
Bool_t fFFB_Flag
Definition: QwBeamMod.h:168
std::vector< std::vector< Double_t > > fPhaseError
Definition: QwBeamMod.h:185
VQwSubsystem & operator-=(VQwSubsystem *value)
Definition: QwBeamMod.cc:600
UInt_t fFFB_Index
Definition: QwBeamMod.h:164
void ClearVectors()
Definition: QwBeamMod.cc:791
Virtual base class for the parity subsystems.
void ResizeOpticsDataContainers(Int_t)
Definition: QwBeamMod.cc:804
void FillDB_MPS(QwParityDB *db, TString datatype)
Fill the database with MPS-based variables Note that most subsystems don&#39;t need to do this...
Definition: QwBeamMod.cc:995
static const Bool_t bDEBUG
Definition: QwBeamMod.h:169
VQwSubsystem & operator+=(VQwSubsystem *value)
Definition: QwBeamMod.cc:584
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
Definition: QwBeamMod.cc:1053
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
std::vector< QwModChannelID > fModChannelID
Definition: QwBeamMod.h:156
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwBeamMod.cc:618
std::vector< std::vector< Int_t > > fNFitPoints
Definition: QwBeamMod.h:188
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Definition: QwBeamMod.cc:472
void AccumulateRunningSum(VQwSubsystem *)
Update the running sums for devices.
Definition: QwBeamMod.cc:662
TString fmoduletype
Definition: QwBeamMod.h:216
QwBeamMod(const QwBeamMod &source)
Copy constructor.
Definition: QwBeamMod.h:65
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
Definition: QwBeamMod.cc:36
std::vector< QwWord > fWord
Definition: QwBeamMod.h:157
Int_t GetDetectorTypeID(TString name)
Definition: QwBeamMod.cc:531
void Scale(Double_t factor)
Definition: QwBeamMod.cc:654
std::vector< QwVQWK_Channel > fModChannel
Definition: QwBeamMod.h:155
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Definition: QwBeamMod.h:81
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
Definition: QwBeamMod.cc:305
std::vector< std::vector< Double_t > > fChisquare
Definition: QwBeamMod.h:187
std::vector< QwVQWK_Channel > fMonitors
Definition: QwBeamMod.h:176
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
Definition: QwBeamMod.cc:244
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: QwBeamMod.cc:350
void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile &trim_file)
Construct the branch and tree vector based on the trim file.
Definition: QwBeamMod.h:130
void PrintModChannelID()
Definition: QwBeamMod.cc:967
void IncrementErrorCounters()
Increment the error counters.
Definition: QwBeamMod.cc:446
Int_t fPatternWordIndex
Definition: QwBeamMod.h:191
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
void AtEndOfEventLoop()
Perform actions at the end of the event loop.
Definition: QwBeamMod.cc:784
Int_t fTreeArrayIndex
Definition: QwBeamMod.h:152
void WritePromptSummary(QwPromptSummary *ps, TString type)
Definition: QwBeamMod.cc:1064
Int_t fSubbankIndex
Definition: QwBeamMod.h:209
void ProcessOptions(QwOptions &options)
Process the command line options.
Definition: QwBeamMod.cc:32
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Definition: QwBeamMod.cc:924
std::vector< std::vector< Double_t > > fOffset
Definition: QwBeamMod.h:180
QwBeamMod(const TString &name)
Constructor with name.
Definition: QwBeamMod.h:49
std::vector< std::vector< Double_t > > fPhase
Definition: QwBeamMod.h:181
void ClearEventData()
Definition: QwBeamMod.cc:521
Double_t GetAmplitudeSign(Double_t, Double_t, Double_t, Double_t)
Definition: QwBeamMod.cc:900
std::vector< Double_t > fBPMPosition
Definition: QwBeamMod.h:177
std::vector< std::vector< Double_t > > fAmplitudeError
Definition: QwBeamMod.h:183
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
Definition: QwBeamMod.h:129
void AnalyzeOpticsPlots()
Definition: QwBeamMod.cc:827
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
Definition: QwBeamMod.cc:942
std::vector< TString > fgModTypeNames
Definition: QwBeamMod.h:72
void ExchangeProcessedData()
Request processed data from other subsystems for internal use in the second event processing stage...
Definition: QwBeamMod.cc:494
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Definition: QwBeamMod.cc:567
Bool_t Compare(VQwSubsystem *source)
Definition: QwBeamMod.cc:664
void CalculateRunningAverage()
Calculate the average for all good events.
Definition: QwBeamMod.cc:660
std::vector< std::vector< Double_t > > fOffsetError
Definition: QwBeamMod.h:184
QwModChannelID(Int_t subbankid, Int_t wordssofar, TString name, TString modtype, QwBeamMod *obj)
Definition: QwBeamMod.cc:221
Int_t fWordInSubbank
Definition: QwBeamMod.h:210
TString fmodulename
Definition: QwBeamMod.h:217
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Definition: QwBeamMod.cc:453