QwAnalysis
QwMollerDetector.h
Go to the documentation of this file.
1 /**
2  * \class QwMollerDetector QwMollerDetector.h
3  *
4  * \brief Implementation of the analysis of Moller data (copied from QwComptonElectronDetector.h)
5  *
6  * \author Andrew Kubera
7  * \date 2010-06-07
8  * \ingroup QwMoller
9  *
10  */
11 
12 
13 #ifndef __QwMollerDetector__
14 #define __QwMollerDetector__
15 
16 // System headers
17 #include <vector>
18 
19 // Boost multi array
20 #include <boost/multi_array.hpp>
21 
22 // ROOT headers
23 #include "TTree.h"
24 #include "TFile.h"
25 
26 // Qweak headers
27 #include "VQwSubsystemParity.h"
28 #include "QwVQWK_Channel.h"
29 #include "QwScaler_Channel.h"
30 
32 {
33  public:
36 
37  int fIndex; // index of this detector in the vector containing all the detector of same type
39 
40  int fWordInSubbank; //first word reported for this channel in the subbank
41  //(eg VQWK channel report 6 words for each event, scalers oly report one word per event)
42  // The first word of the subbank gets fWordInSubbank=0
43 
45 
46  TString fModuleType;
47  UInt_t fModuleNumber;
48  TString fChannelName;
49  TString fDetectorType;
50 
51  void Print(){
52  QwMessage << "***************************************" << std::endl;
53  QwMessage << " QwMoller channel: " << fChannelName << std::endl;
54  QwMessage << " Detector Type: " << fDetectorType << std::endl;
55  QwMessage << " Channel #: " << fChannelNumber << std::endl;
56  QwMessage << " Word In Sub: " << fWordInSubbank << std::endl;
57  QwMessage << " Index: " << fIndex << std::endl;
58  };
59 
60 };
61 
63  public VQwSubsystemParity,
64  public MQwSubsystemCloneable<QwMollerDetector> {
65 
66  private:
67  /// Private default constructor (not implemented, will throw linker error on use)
69 
70  public:
71 
72  /// Constructor with name
73  QwMollerDetector(const TString& name)
74  : VQwSubsystem(name), VQwSubsystemParity(name)
75  { };
76  /// Copy constructor
78  : VQwSubsystem(source),VQwSubsystemParity(source),
80  { }
81  /// Virtual destructor
82  virtual ~QwMollerDetector() { };
83 
84  /* derived from VQwSubsystem */
85  void ProcessOptions(QwOptions &options); //Handle command line options
86  Int_t LoadChannelMap(TString mapfile);
87  Int_t LoadInputParameters(TString pedestalfile);
88  Int_t LoadEventCuts(TString & filename);
89  Bool_t SingleEventCuts();
90  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
91  Int_t ProcessConfigurationBuffer(UInt_t ev_type, const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
92  Int_t ProcessEvBuffer(UInt_t roc_id, UInt_t bank_id, UInt_t *buffer, UInt_t num_words);
93  Int_t ProcessEvBuffer(UInt_t ev_type, UInt_t roc_id, UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
94  void ClearEventData();
95  void ProcessEvent();
96 
98  void ConstructHistograms(TDirectory *folder, TString &prefix);
99  void FillHistograms();
100 
104  void Sum(VQwSubsystem *value1, VQwSubsystem *value2);
105  void Difference(VQwSubsystem *value1, VQwSubsystem *value2);
106  void Ratio(VQwSubsystem *value1, VQwSubsystem *value2);
107  void Scale(Double_t);
108  void AccumulateRunningSum(VQwSubsystem* value);
109  //remove one entry from the running sums for devices
111  };
113  Int_t LoadEventCuts(TString filename);
114  Bool_t ApplySingleEventCuts();
116  void PrintErrorCounters() const;
117  UInt_t GetEventcutErrorFlag();
118 
119  //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
120  void UpdateErrorFlag(const VQwSubsystem *ev_error){
121  };
122 
124  void ConstructBranchAndVector(TTree*, TString&, std::vector<double, std::allocator<double> >&);
125  void ConstructBranch(TTree *tree, TString& prefix) { };
126  void ConstructBranch(TTree *tree, TString& prefix, QwParameterFile& trim_file) { };
127  void FillTreeVector(std::vector<Double_t> &values) const;
128 
129  Bool_t Compare(VQwSubsystem *source);
130  void print();
131  void PrintValue() const;
132  float* GetRawChannelArray();
133 
134  Int_t GetChannelIndex(TString channelName, UInt_t module_number);
135  float GetDataForChannelInModule(Int_t module_number, Int_t channel_index){
136  return fSTR7200_Channel[module_number][channel_index].GetValue();
137  }
138 
139  float GetDataForChannelInModule(Int_t module_number, TString channel_name){
140  return GetDataForChannelInModule(module_number, GetChannelIndex(channel_name,module_number));
141  }
142 
143  protected:
144  //Array of ChannelIDs which contain the map file
145  std::vector<QwMollerChannelID> fMollerChannelID;
146 
147  //the running total scaler structure
148  std::vector< std::vector<QwSTR7200_Channel> > fSTR7200_Channel;
149  std::vector< std::vector<QwSTR7200_Channel> > fPrevious_STR7200_Channel;
150 
151  private:
153  static const Bool_t bDEBUG = kFALSE;
154  UInt_t fNumberOfEvents; //! Number of triggered events
155 
156 };
157 
158 #endif // __QwMollerDetector__
#define QwMessage
Predefined log drain for regular messages.
Definition: QwLog.h:50
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Bool_t Compare(VQwSubsystem *source)
void ProcessOptions(QwOptions &options)
Process the command line options.
VQwSubsystem & operator-=(VQwSubsystem *value)
float GetDataForChannelInModule(Int_t module_number, Int_t channel_index)
VQwSubsystem & operator+=(VQwSubsystem *value)
void Ratio(VQwSubsystem *value1, VQwSubsystem *value2)
An options class.
Definition: QwOptions.h:133
Int_t LoadChannelMap(TString mapfile)
float * GetRawChannelArray()
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
QwMollerDetector(const QwMollerDetector &source)
Copy constructor.
Virtual base class for the parity subsystems.
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
void AccumulateRunningSum(VQwSubsystem *value)
Update the running sums for devices.
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
static const Bool_t bDEBUG
float GetDataForChannelInModule(Int_t module_number, TString channel_name)
void FillHistograms()
Fill the histograms for this subsystem.
void IncrementErrorCounters()
Increment the error counters.
QwMollerDetector(const TString &name)
Constructor with name.
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Int_t LoadEventCuts(TString &filename)
Int_t GetChannelIndex(TString channelName, UInt_t module_number)
VQwSubsystem & operator=(VQwSubsystem *value)
Assignment Note: Must be called at the beginning of all subsystems routine call to operator=(VQwSubsy...
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
std::vector< std::vector< QwSTR7200_Channel > > fSTR7200_Channel
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
Bool_t SingleEventCuts()
virtual ~QwMollerDetector()
Virtual destructor.
Implementation of the analysis of Moller data (copied from QwComptonElectronDetector.h)
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
void Scale(Double_t)
QwMollerDetector()
Private default constructor (not implemented, will throw linker error on use)
std::vector< QwMollerChannelID > fMollerChannelID
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
std::vector< std::vector< QwSTR7200_Channel > > fPrevious_STR7200_Channel
void ConstructBranchAndVector(TTree *, TString &, std::vector< double, std::allocator< double > > &)
void UpdateErrorFlag(const VQwSubsystem *ev_error)
update the error flag in the subsystem level from the top level routines related to stability checks...
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
void CalculateRunningAverage()
Calculate the average for all good events.
void PrintValue() const
Print values of all channels.
Int_t ProcessEvBuffer(UInt_t roc_id, 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 ConstructBranch(TTree *tree, TString &prefix, QwParameterFile &trim_file)
Construct the branch and tree vector based on the trim file.
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.