QwAnalysis
QwMainCerenkovDetector.h
Go to the documentation of this file.
1 /**********************************************************\
2 * File: QwMainCerenkovDetector.h *
3 * *
4 * Author: P. M. King *
5 * Time-stamp: <2007-05-08 15:40> *
6 \**********************************************************/
7 
8 ///
9 /// \ingroup QwAnalysis_ADC
10 
11 #ifndef __QWMAINCERENKOVDETECTOR__
12 #define __QWMAINCERENKOVDETECTOR__
13 
14 // System headers
15 #include <vector>
16 
17 // Qweak headers
18 #include "VQwSubsystemParity.h"
19 #include "QwIntegrationPMT.h"
20 #include "QwCombinedPMT.h"
21 
22 
23 // Forward declarations
24 class QwBlinder;
26 
27 
29  public VQwSubsystemParity,
30  public MQwSubsystemCloneable<QwMainCerenkovDetector>
31 {
32  friend class QwCombinedPMT;
33  /******************************************************************
34  * Class: QwMainCerenkovDetector
35  *
36  *
37  ******************************************************************/
38  private:
39  /// Private default constructor (not implemented, will throw linker error on use)
41 
42  public:
43  /// Constructor with name
44  QwMainCerenkovDetector(const TString& name)
45  : VQwSubsystem(name),VQwSubsystemParity(name),bNormalization(kFALSE)
46  {
47  fTargetCharge.InitializeChannel("q_targ","derived");
48  fTargetX.InitializeChannel("x_targ","derived");
49  fTargetY.InitializeChannel("y_targ","derived");
50  fTargetXprime.InitializeChannel("xp_targ","derived");
51  fTargetYprime.InitializeChannel("yp_targ","derived");
52  fTargetEnergy.InitializeChannel("e_targ","derived");
53  };
54  /// Copy constructor
56  : VQwSubsystem(source),VQwSubsystemParity(source),
59  { }
60  /// Virtual destructor
61  virtual ~QwMainCerenkovDetector() { };
62 
63  /* Member functions derived from VQwSubsystemParity. */
64 
65  /// \brief Define options function
66  static void DefineOptions(QwOptions &options);
67 
68 
69  void ProcessOptions(QwOptions &options);//Handle command line options
70  Int_t LoadChannelMap(TString mapfile);
71  Int_t LoadInputParameters(TString pedestalfile);
72  Int_t LoadEventCuts(TString filename);
73  Bool_t ApplySingleEventCuts();//Check for good events by stting limits on the devices readings
75  void PrintErrorCounters() const;// report number of events failed due to HW and event cut faliure
76  UInt_t GetEventcutErrorFlag();//return the error flag
77 
78  //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
79  void UpdateErrorFlag(const VQwSubsystem *ev_error);
80 
81 
82  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
83  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
84 
85  void ClearEventData();
86  Bool_t IsGoodEvent();
87 
88  void ProcessEvent();
89  void ExchangeProcessedData();
90  void ProcessEvent_2();
91 
92 
93  Bool_t PublishInternalValues() const;
94 
95  void SetRandomEventParameters(Double_t mean, Double_t sigma);
96  void SetRandomEventAsymmetry(Double_t asymmetry);
97  void RandomizeEventData(int helicity = 0, Double_t time = 0.0);
98  void EncodeEventData(std::vector<UInt_t> &buffer);
99 
100  void ConstructHistograms(TDirectory *folder){
101  TString tmpstr("");
102  ConstructHistograms(folder,tmpstr);
103  };
104 
106  void ConstructHistograms(TDirectory *folder, TString &prefix);
107  void FillHistograms();
108 
110  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
111  void ConstructBranch(TTree *tree, TString &prefix);
112  void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile& trim_file );
113 
114  void FillTreeVector(std::vector<Double_t> &values) const;
115  void FillDB(QwParityDB *db, TString datatype);
116  void FillErrDB(QwParityDB *db, TString datatype);
117 
118  const QwIntegrationPMT* GetChannel(const TString name) const;
119 
120  Bool_t Compare(VQwSubsystem* source);
121 
122 
123  /// \brief Blind the asymmetry
124  void Blind(const QwBlinder *blinder);
125  /// \brief Blind the difference using the yield
126  void Blind(const QwBlinder *blinder, const VQwSubsystemParity* subsys);
127 
128 
132 
133 
134  void Sum(VQwSubsystem* value1, VQwSubsystem* value2);
135  void Difference(VQwSubsystem* value1, VQwSubsystem* value2);
136  void Ratio(VQwSubsystem* numer, VQwSubsystem* denom);
137  void Scale(Double_t factor);
138  void Normalize(VQwDataElement* denom);
139 
140  void AccumulateRunningSum(VQwSubsystem* value);
141  //remove one entry from the running sums for devices
144 
145  const QwIntegrationPMT* GetIntegrationPMT(const TString name) const;
146  const QwCombinedPMT* GetCombinedPMT(const TString name) const;
147 
148  void DoNormalization(Double_t factor=1.0);
149 
150  Bool_t ApplyHWChecks(){//Check for harware errors in the devices
151  Bool_t status = kTRUE;
152  for (size_t i=0; i<fIntegrationPMT.size(); i++){
153  status &= fIntegrationPMT.at(i).ApplyHWChecks();
154  }
155  return status;
156  };
157 
158  void PrintValue() const;
159  void WritePromptSummary(QwPromptSummary *ps, TString type);
160  void PrintInfo() const;
161  void PrintDetectorID() const;
162 
163 
164  protected:
165  Bool_t fDEBUG;
166 
168 
169  // when the type and the name is passed the detector index from appropriate vector
170  // will be returned. For example if TypeID is IntegrationPMT then the index of
171  // the detector from fIntegrationPMT vector for given name will be returnd.
172  Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name);
173 
174  std::vector <QwIntegrationPMT> fIntegrationPMT;
175  std::vector <QwCombinedPMT> fCombinedPMT;
176  std::vector <QwMainCerenkovDetectorID> fMainDetID;
177 
178  protected:
185 
187 
189 
190  private:
191 
192  static const Bool_t bDEBUG=kFALSE;
194 
195 };
196 
197 
199 {
200  public:
204  {};
205 
206  int fSubbankIndex;
207  int fWordInSubbank; //first word reported for this channel in the subbank
208  //(eg VQWK channel report 6 words for each event, scalers oly report one word per event)
209  // The first word of the subbank gets fWordInSubbank=0
210 
211  EQwPMTInstrumentType fTypeID; // type of detector
212  int fIndex; // index of this detector in the vector containing all the detector of same type
213  UInt_t fSubelement; // some detectors have many subelements (eg stripline have 4 antenas)
214  // some have only one sub element(eg lumis have one channel)
215 
216  TString fmoduletype; // eg: VQWK, SCALER
217  TString fdetectorname;
218  TString fdetectortype; // stripline, IntegrationPMT, ... this string is encoded by fTypeID
219 
220  std::vector<TString> fCombinedChannelNames;
221  std::vector<Double_t> fWeight;
222 
223  void Print() const;
224 
225 };
226 
227 
228 #endif
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
QwMainCerenkovDetector(const QwMainCerenkovDetector &source)
Copy constructor.
void Normalize(VQwDataElement *denom)
class QwVQWK_Channel QwBeamPosition
Definition: QwTypes.h:316
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
void FillHistograms()
Fill the histograms for this subsystem.
void WritePromptSummary(QwPromptSummary *ps, TString type)
std::vector< Double_t > fWeight
void SetRandomEventAsymmetry(Double_t asymmetry)
An options class.
Definition: QwOptions.h:133
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
const QwIntegrationPMT * GetChannel(const TString name) const
void IncrementErrorCounters()
Increment the error counters.
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Class for blinding data, adapted from G0 blinder class.
Definition: QwBlinder.h:64
virtual UInt_t UpdateErrorFlag()
Uses the error flags of contained data elements to update Returns the error flag to the top level rou...
virtual ~QwMainCerenkovDetector()
Virtual destructor.
EQwPMTInstrumentType
Definition: QwTypes.h:124
const QwIntegrationPMT * GetIntegrationPMT(const TString name) const
std::vector< QwIntegrationPMT > fIntegrationPMT
Virtual base class for the parity subsystems.
void Blind(const QwBlinder *blinder)
Blind the asymmetry.
void ProcessOptions(QwOptions &options)
EQwPMTInstrumentType GetDetectorTypeID(TString name)
static const UInt_t kInvalidSubelementIndex
Definition: QwTypes.h:191
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
std::vector< QwMainCerenkovDetectorID > fMainDetID
void SetRandomEventParameters(Double_t mean, Double_t sigma)
void FillDB(QwParityDB *db, TString datatype)
Fill the database.
std::vector< QwCombinedPMT > fCombinedPMT
Bool_t PublishInternalValues() const
void PrintValue() const
Print values of all channels.
void ConstructHistograms(TDirectory *folder)
Construct the histograms for this subsystem in a folder.
The pure virtual base class of all data elements.
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
Definition: VQwSubsystem.h:88
void FillErrDB(QwParityDB *db, TString datatype)
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
void DoNormalization(Double_t factor=1.0)
VQwSubsystem & operator-=(VQwSubsystem *value)
class QwVQWK_Channel QwBeamCharge
Definition: QwTypes.h:315
void PrintInfo() const
Print some information about the subsystem.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
class QwVQWK_Channel QwBeamAngle
Definition: QwTypes.h:317
QwMainCerenkovDetector(const TString &name)
Constructor with name.
void CalculateRunningAverage()
Calculate the average for all good events.
Bool_t Compare(VQwSubsystem *source)
void ProcessEvent_2()
Process the event data again, including data from other subsystems. Not all derived classes will requ...
const QwCombinedPMT * GetCombinedPMT(const TString name) const
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
std::vector< TString > fCombinedChannelNames
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
VQwSubsystem & operator+=(VQwSubsystem *value)
Int_t GetDetectorIndex(EQwPMTInstrumentType TypeID, TString name)
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
void Ratio(VQwSubsystem *numer, VQwSubsystem *denom)
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...
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
void EncodeEventData(std::vector< UInt_t > &buffer)
QwMainCerenkovDetector()
Private default constructor (not implemented, will throw linker error on use)
class QwVQWK_Channel QwBeamEnergy
Definition: QwTypes.h:318
void RandomizeEventData(int helicity=0, Double_t time=0.0)
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)