DDTPrescaleOffline_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: Mono
3 // Module Type: analyzer
4 // File: DDTPrescale_module.cc
5 //
6 // Generated at Thu Mar 14 13:30:55 2019 by Mohamed Elashri using artmod
7 // from cetpkgsupport v1_14_01.
8 ////////////////////////////////////////////////////////////////////////
9 
10 // Framework includes
17 #include "fhiclcpp/ParameterSet.h"
20 
21 // NOvASoft includes
22 #include "RawData/RawDigit.h"
23 #include "RawData/FlatDAQData.h"
24 #include "RawData/RawTrigger.h"
25 
26 // ROOT includes
27 #include <TTree.h>
28 
29 // DDT includes
30 #include "DAQDataFormats/TriggerDefines.h"
31 #include "DAQDataFormats/RawEvent.h"
32 #include "DAQDataFormats/RawTrigger.h"
33 #include "DAQDataFormats/RawTriggerMask.h"
34 #include "DAQDataFormats/RawDataBlock.h"
37 
38 // Standard C++ libraries
39 #include "iostream"
40 
41 
42 
43 
44 
45 
46 namespace Mono {
47  class Mono;
48 }
49 
50 class Mono::Mono : public art::EDAnalyzer {
51 public:
52  explicit Mono(fhicl::ParameterSet const & p);
53  // The destructor generated by the compiler is fine for classes
54  // without bare pointers or other resource use.
55 
56  // Plugins should not be copied or assigned.
57  Mono(Mono const &) = delete;
58  Mono(Mono &&) = delete;
59  Mono & operator = (Mono const &) = delete;
60  Mono & operator = (Mono &&) = delete;
61 
62  // Required functions.
63  void analyze(art::Event const & e) override;
64  void endSubRun(art::SubRun const & s) override;
65  void beginJob() override;
66  void endJob() override;
67 
68 private:
69  unsigned int fRun; ///< Run number
70  unsigned int fTrigLength; /// trigger length
71  unsigned int fSubRun; ///< Subrun number
72  unsigned int fEvent; ///< Event number
73  unsigned int fTrigger; ///< Trigger type
74  unsigned int n_events; /// number of events
75  uint32_t fprescale; ///< prescale number
76  unsigned int prescale_sum; /// sum of prescales
77  float prescale_mean; /// average prescale
78  std::string fRawDataLabel; ///< ART module label for Raw Data
79 
80  // Declare member data here.
81  // This ART Service allows us to interact with TFiles on disk.
83  TTree* Job;
84 
85 };
86 
87 
89  :
90  EDAnalyzer(p), // ,
91  fRun(0),
92  fTrigLength(0),
93  fSubRun(0),
94  fEvent(0),
95  fTrigger(0),
96  n_events(0),
97  fprescale(0),
98  prescale_sum(0),
99  prescale_mean(0),
100  fRawDataLabel(p.get<std::string>("RawDataLabel"))
101 {}
102 
104 {
105 
106 // use art:event method to get run,subrun and event numbers
107  fRun = e.run();
108  fSubRun = e.subRun();
109  fEvent = e.event();
110 
111  // use rawdata::RawTrigger method to get trigger ID
113  e.getByLabel(fRawDataLabel, trigv);
114  const rawdata::RawTrigger& trig = (*trigv)[0];
115  fTrigger = trig.fTriggerMask_TriggerType;
116 
117  // use rawdata::RawTrigger method to get prescale number
119  e.getByLabel(fRawDataLabel, rawtrigger);
120  const rawdata::RawTrigger& pre = (*rawtrigger)[0];
121  fprescale = pre.fTriggerMask_Prescale;
122 
123  // use rawdata::RawTrigger method to get prescale number
125  e.getByLabel(fRawDataLabel, rawtrigger2);
126  const rawdata::RawTrigger& pree = (*rawtrigger2)[0];
127  fTrigLength = pree.fTriggerRange_TriggerLength;;
128 
129 
130 // sum of prescale and get number of events.
131 prescale_sum += fprescale;
132 n_events += 1;
133 // averaging the prescale over events and get prescale average per SubRun
134 prescale_mean = prescale_sum / n_events;
135 
136 
137  // Now to print our values
138 // std::cout << "run = " << fRun << std::endl;
139 // std::cout << "SubRun = " << fSubRun << std::endl;
140 std::cout << "Event = " << fEvent << std::endl;
141 std::cout << "Trigger length = " << fTrigLength << std::endl;
142 std::cout << "TriggerID = " << fTrigger << std::endl;
143 // std::cout << "Prescale = " << fprescale << std::endl;
144 
145 }
146 
147 
149 
150 {
151 
152 // We want to get these numbers per SubRun so we print them in endSubRun level.
153  //std::cout << "run = " << fRun << std::endl;
154 //std::cout << "SubRun = " << fSubRun << std::endl;
155 std::cout << "TriggerID = " << fTrigger << std::endl;
156 // std::cout << "prescale total = " << prescale_sum << std::endl;
157 // std::cout << "n_events = " << n_events << std::endl;
158 std::cout << "average prescale = " << prescale_mean << std::endl;
159 Job->Fill();
160 
161 
162 }
164 {
165 
166  Job = tfs->make<TTree>("Trigger", "Trigger");
167 
168 
169  Job->Branch("Run", &fRun);
170  Job->Branch("SubRun", &fSubRun);
171  Job->Branch("Event", &fEvent);
172  Job->Branch("TriggerID", &fTrigger);
173  Job->Branch("Prescale", &fprescale);
174  Job->Branch("number of events", &n_events);
175  Job->Branch("Trigger length", &fTrigLength);
176 
177 
178 }
179 
181  {
182  // Implementation of optional member function here.
183 }
184 
185 
Mono & operator=(Mono const &)=delete
void beginJob() override
SubRunNumber_t subRun() const
Definition: Event.h:72
uint32_t fTriggerMask_Prescale
Definition: RawTrigger.h:44
unsigned int fRun
Run number.
unsigned int fTrigger
Trigger type.
const char * p
Definition: xmltok.h:285
unsigned int fTrigLength
DEFINE_ART_MODULE(TestTMapFile)
uint8_t fTriggerMask_TriggerType
Definition: RawTrigger.h:43
float prescale_mean
sum of prescales
const XML_Char * s
Definition: expat.h:262
void endSubRun(art::SubRun const &s) override
unsigned int prescale_sum
unsigned int fEvent
Event number.
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void analyze(art::Event const &e) override
OStream cout
Definition: OStream.cxx:6
unsigned int fSubRun
trigger length
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Mono(fhicl::ParameterSet const &p)
void endJob() override
uint32_t fTriggerRange_TriggerLength
Definition: RawTrigger.h:40
art::ServiceHandle< art::TFileService > tfs
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
int n_events
Definition: test_Tier.py:22
std::string fRawDataLabel
average prescale
uint32_t fprescale
number of events
enum BeamMode string