QwAnalysis
QwScaler.h
Go to the documentation of this file.
1 
2 #ifndef __QWSCALER__
3 #define __QWSCALER__
4 
5 // System headers
6 #include <vector>
7 
8 // Boost headers
9 #include <boost/shared_ptr.hpp>
10 
11 // Qweak headers
12 #include "VQwSubsystemParity.h"
13 #include "QwScaler_Channel.h"
14 
15 
16 class QwScaler: public VQwSubsystemParity, public MQwSubsystemCloneable<QwScaler>
17 {
18  private:
19  /// Private default constructor (not implemented, will throw linker error on use)
20  QwScaler();
21 
22  public:
23 
24  /// Constructor with name
25  QwScaler(const TString& name);
26  /// Copy constructor
27  QwScaler(const QwScaler& source)
28  : VQwSubsystem(source),VQwSubsystemParity(source)
29  {
30  fScaler.resize(source.fScaler.size());
31  for (size_t i = 0; i < fScaler.size(); i++) {
32  VQwScaler_Channel* scaler_tmp = 0;
33  if ((scaler_tmp = dynamic_cast<QwSIS3801D24_Channel*>(source.fScaler.at(i)))) {
34  QwSIS3801D24_Channel* scaler = dynamic_cast<QwSIS3801D24_Channel*>(source.fScaler.at(i));
35  fScaler.at(i) = new QwSIS3801D24_Channel(*scaler);
36  } else if ((scaler_tmp = dynamic_cast<QwSIS3801D32_Channel*>(source.fScaler.at(i)))) {
37  QwSIS3801D32_Channel* scaler = dynamic_cast<QwSIS3801D32_Channel*>(source.fScaler.at(i));
38  fScaler.at(i) = new QwSIS3801D32_Channel(*scaler);
39  }
40  }
41  }
42  /// Destructor
43  virtual ~QwScaler();
44 
45  // Handle command line options
46  static void DefineOptions(QwOptions &options);
47  void ProcessOptions(QwOptions &options);
48 
49  Int_t LoadChannelMap(TString mapfile);
50  Int_t LoadInputParameters(TString pedestalfile);
51 
52  void ClearEventData();
53 
54  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
55  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words);
56  void ProcessEvent();
57 
59  void ConstructHistograms(TDirectory *folder, TString &prefix);
60  void FillHistograms();
61 
63  void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector<Double_t> &values);
64  void ConstructBranch(TTree *tree, TString& prefix) { };
65  void ConstructBranch(TTree *tree, TString& prefix, QwParameterFile& trim_file) { };
66  void FillTreeVector(std::vector<Double_t> &values) const;
67 
68  Bool_t Compare(VQwSubsystem *source);
69 
73  void Sum(VQwSubsystem *value1, VQwSubsystem *value2);
74  void Difference(VQwSubsystem *value1, VQwSubsystem *value2);
75  void Ratio(VQwSubsystem *value1, VQwSubsystem *value2);
76  void Scale(Double_t factor);
77 
79  //remove one entry from the running sums for devices
81  };
83 
84  Int_t LoadEventCuts(TString filename);
85  Bool_t SingleEventCuts();
86  Bool_t ApplySingleEventCuts();
88 
89  void PrintErrorCounters() const;
90  UInt_t GetEventcutErrorFlag();
91  //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
92  void UpdateErrorFlag(const VQwSubsystem *ev_error){
93  };
94 
95  void PrintValue() const;
96  void PrintInfo() const;
97 
98  Double_t* GetRawChannelArray();
99 
100  Double_t GetDataForChannelInModule(Int_t modnum, Int_t channum) {
101  Int_t index = fModuleChannel_Map[std::pair<Int_t,Int_t>(modnum,channum)];
102  return fScaler.at(index)->GetValue();
103  }
104 
105  Int_t GetChannelIndex(TString channelName, UInt_t module_number);
106 
107  private:
108 
109  // Number of good events
111 
112  // Mapping from subbank to scaler channels
113  typedef std::map< Int_t, std::vector< std::vector<Int_t> > > Subbank_to_Scaler_Map_t;
115 
116  // Mapping from module and channel number to scaler channel
117  typedef std::map< std::pair<Int_t,Int_t>, Int_t > Module_Channel_to_Scaler_Map_t;
119 
120  // Mapping from name to scaler channel
121  typedef std::map< TString, Int_t> Name_to_Scaler_Map_t;
123 
124  // Vector of scaler channels
125  std::vector< VQwScaler_Channel* > fScaler; // Raw channels
126  std::vector< UInt_t > fBufferOffset; // Offset in scaler buffer
127  std::vector< std::pair< VQwScaler_Channel*, double > > fNorm;
128 };
129 
130 #endif
Bool_t Compare(VQwSubsystem *source)
Definition: QwScaler.cc:527
Int_t LoadChannelMap(TString mapfile)
Definition: QwScaler.cc:55
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
Definition: QwScaler.cc:361
void PrintInfo() const
Definition: QwScaler.cc:549
void ProcessEvent()
Definition: QwScaler.cc:324
An options class.
Definition: QwOptions.h:133
void DeaccumulateRunningSum(VQwSubsystem *value)
remove one entry from the running sums for devices
Definition: QwScaler.h:80
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwScaler.cc:278
void PrintErrorCounters() const
Report the number of events failed due to HW and event cut failures.
Definition: QwScaler.cc:507
void ClearEventData()
Definition: QwScaler.cc:260
std::vector< std::pair< VQwScaler_Channel *, double > > fNorm
Definition: QwScaler.h:127
VQwSubsystem & operator=(VQwSubsystem *value)
Definition: QwScaler.cc:373
Virtual base class for the parity subsystems.
Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
Definition: QwScaler.cc:291
Bool_t ApplySingleEventCuts()
Apply the single event cuts.
Definition: QwScaler.cc:498
Module_Channel_to_Scaler_Map_t fModuleChannel_Map
Definition: QwScaler.h:118
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
void FillHistograms()
Fill the histograms for this subsystem.
Definition: QwScaler.cc:347
void UpdateErrorFlag(const VQwSubsystem *ev_error)
update the error flag in the subsystem level from the top level routines related to stability checks...
Definition: QwScaler.h:92
QwScaler(const QwScaler &source)
Copy constructor.
Definition: QwScaler.h:27
Name_to_Scaler_Map_t fName_Map
Definition: QwScaler.h:122
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
Definition: VQwSubsystem.h:88
void IncrementErrorCounters()
Increment the error counters.
Definition: QwScaler.cc:503
std::map< Int_t, std::vector< std::vector< Int_t > > > Subbank_to_Scaler_Map_t
Definition: QwScaler.h:113
VQwSubsystem & operator+=(VQwSubsystem *value)
Definition: QwScaler.cc:390
void PrintValue() const
Definition: QwScaler.cc:564
virtual ~QwScaler()
Destructor.
Definition: QwScaler.cc:40
void CalculateRunningAverage()
Definition: QwScaler.cc:484
Int_t GetChannelIndex(TString channelName, UInt_t module_number)
Definition: QwScaler.cc:516
UInt_t GetEventcutErrorFlag()
Return the error flag to the top level routines related to stability checks and ErrorFlag updates...
Definition: QwScaler.cc:511
Subbank_to_Scaler_Map_t fSubbank_Map
Definition: QwScaler.h:114
The pure virtual base class of all subsystems.
Definition: VQwSubsystem.h:59
Double_t GetDataForChannelInModule(Int_t modnum, Int_t channum)
Definition: QwScaler.h:100
class QwScaler_Channel< 0xffffffff, 0 > QwSIS3801D32_Channel
void Difference(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwScaler.cc:435
std::vector< UInt_t > fBufferOffset
Definition: QwScaler.h:126
class QwScaler_Channel< 0x00ffffff, 0 > QwSIS3801D24_Channel
void ConstructBranch(TTree *tree, TString &prefix)
Construct the branch and tree vector.
Definition: QwScaler.h:64
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
std::map< TString, Int_t > Name_to_Scaler_Map_t
Definition: QwScaler.h:121
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
Definition: QwScaler.cc:354
Int_t fGoodEventCount
Definition: QwScaler.h:110
VQwSubsystem & operator-=(VQwSubsystem *value)
Definition: QwScaler.cc:406
void Scale(Double_t factor)
Definition: QwScaler.cc:463
std::map< std::pair< Int_t, Int_t >, Int_t > Module_Channel_to_Scaler_Map_t
Definition: QwScaler.h:117
void ConstructBranch(TTree *tree, TString &prefix, QwParameterFile &trim_file)
Construct the branch and tree vector based on the trim file.
Definition: QwScaler.h:65
void ProcessOptions(QwOptions &options)
Process the command line options.
Definition: QwScaler.cc:20
void Ratio(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwScaler.cc:448
Bool_t SingleEventCuts()
std::vector< VQwScaler_Channel * > fScaler
Definition: QwScaler.h:125
QwScaler()
Private default constructor (not implemented, will throw linker error on use)
Int_t LoadInputParameters(TString pedestalfile)
Mandatory parameter file definition.
Definition: QwScaler.cc:225
void Sum(VQwSubsystem *value1, VQwSubsystem *value2)
Definition: QwScaler.cc:422
Int_t LoadEventCuts(TString filename)
Load the event cuts file.
Definition: QwScaler.cc:493
void AccumulateRunningSum(VQwSubsystem *value)
Definition: QwScaler.cc:473
Double_t * GetRawChannelArray()