BeamlineAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: BeamlineAna
3 // Plugin Type: analyzer (art v2_13_00)
4 // File: BeamlineAna_module.cc
5 //
6 // Generated at Wed Feb 5 14:37:00 2020 by Teresa Lackey using cetskelgen
7 // from cetlib version v3_06_01.
8 // Create TTree with hit information for each beamline device
9 ////////////////////////////////////////////////////////////////////////
10 
11 // C/C++ includes
12 #include <string>
13 
14 // Framework includes
23 #include "fhiclcpp/ParameterSet.h"
25 
26 // NOvASoft includes
28 #include "BeamlineRecoBase/ToF.h"
29 #include "RawData/RawBeamline.h"
31 
32 // ROOT includes
33 #include "TH1F.h"
34 #include "TTree.h"
35 
36 
37 class BeamlineAna;
38 
39 
40 class BeamlineAna : public art::EDAnalyzer {
41 public:
42  explicit BeamlineAna(fhicl::ParameterSet const & pset);
43  ~BeamlineAna();
44  void reconfigure(fhicl::ParameterSet const & pset);
45  void beginJob();
46  void analyze(art::Event const & e) override;
47 
48 private:
49 
55 
57 
58  double spillTime;
60 
62 
69 
75 
77 
78  TTree *tree;
79 
80 };
81 
82 //.......................................................................
83 
85  : EDAnalyzer(pset)
86 {
87  reconfigure(pset);
88 }
89 
90 //.......................................................................
91 
93 {
94 }
95 
96 //.......................................................................
97 
99 {
100  fSpillDataLabel = pset.get<std::string>("SpillDataLabel");
101  fRawDataLabel = pset.get<std::string>("RawDataLabel");
102  fToFCFDLabel = pset.get<std::string>("ToFCFDLabel");
103  fRawWCDataLabel = pset.get<std::string>("RawWCDataLabel");
104  fRecoCkovLabel = pset.get<std::string>("RecoCkovLabel");
105 }
106 
107 //.......................................................................
108 
110 {
112  tree = tfs->make<TTree>("beamana","");
113 
114  tree->Branch("run",&run,"run/I");
115  tree->Branch("subrun",&subrun,"subrun/I");
116  tree->Branch("event",&event,"event/I");
117 
118  tree->Branch("spillTime",&spillTime,"spillTime/D");
119  tree->Branch("mcnrg",&mcnrg,"mcnrg/D");
120  tree->Branch("mc6ic",&mc6ic,"mc6ic/D");
121  tree->Branch("mc6cv",&mc6cv,"mc6cv/D");
122  tree->Branch("mc7sc1",&mc7sc1,"mc7sc1/D");
123  tree->Branch("novtsc01",&novtsc01,"novtsc01/D");
124  tree->Branch("novtsc07",&novtsc07,"novtsc07/D");
125  tree->Branch("mc7an1",&mc7an1,"mc7an1/D");
126 
127  tree->Branch("tofUSnhit",&tofUSnhit,"tofUSnhit/I");
128  tree->Branch("tofUSchan0PeakADC",&tofUSchan0PeakADC,"tofUSchan0PeakADC/I");
129  tree->Branch("tofUSchan1PeakADC",&tofUSchan1PeakADC,"tofUSchan1PeakADC/I");
130  tree->Branch("tofUSchan2PeakADC",&tofUSchan2PeakADC,"tofUSchan2PeakADC/I");
131  tree->Branch("tofUSchan3PeakADC",&tofUSchan3PeakADC,"tofUSchan3PeakADC/I");
132  tree->Branch("tofUSchan0StrtTime",&tofUSchan0StrtTime,"tofUSchan0StrtTime/I");
133  tree->Branch("tofUSchan1StrtTime",&tofUSchan1StrtTime,"tofUSchan1StrtTime/I");
134  tree->Branch("tofUSchan2StrtTime",&tofUSchan2StrtTime,"tofUSchan2StrtTime/I");
135  tree->Branch("tofUSchan3StrtTime",&tofUSchan3StrtTime,"tofUSchan3StrtTime/I");
136 
137  tree->Branch("wc1xnhit",&wc1xnhit,"wc1xnhit/I");
138  tree->Branch("wc1ynhit",&wc1ynhit,"wc1ynhit/I");
139  tree->Branch("wc1xChannel",&wc1xChannel);
140  tree->Branch("wc1xTime",&wc1xTime);
141  tree->Branch("wc1yChannel",&wc1yChannel);
142  tree->Branch("wc1yTime",&wc1yTime);
143 
144  tree->Branch("wc2xnhit",&wc2xnhit,"wc2xnhit/I");
145  tree->Branch("wc2ynhit",&wc2ynhit,"wc2ynhit/I");
146  tree->Branch("wc2xChannel",&wc2xChannel);
147  tree->Branch("wc2xTime",&wc2xTime);
148  tree->Branch("wc2yChannel",&wc2yChannel);
149  tree->Branch("wc2yTime",&wc2yTime);
150 
151  tree->Branch("wc3xnhit",&wc3xnhit,"wc3xnhit/I");
152  tree->Branch("wc3ynhit",&wc3ynhit,"wc3ynhit/I");
153  tree->Branch("wc3xChannel",&wc3xChannel);
154  tree->Branch("wc3xTime",&wc3xTime);
155  tree->Branch("wc3yChannel",&wc3yChannel);
156  tree->Branch("wc3yTime",&wc3yTime);
157 
158  tree->Branch("wc4xnhit",&wc4xnhit,"wc4xnhit/I");
159  tree->Branch("wc4ynhit",&wc4ynhit,"wc4ynhit/I");
160  tree->Branch("wc4xChannel",&wc4xChannel);
161  tree->Branch("wc4xTime",&wc4xTime);
162  tree->Branch("wc4yChannel",&wc4yChannel);
163  tree->Branch("wc4yTime",&wc4yTime);
164 
165  tree->Branch("ckovStrtTime",&ckovStrtTime,"ckovStrtTime/I");
166  tree->Branch("ckovPeakADC",&ckovPeakADC,"ckovPeakADC/I");
167  tree->Branch("tofDSnhit",&tofDSnhit,"tofDSnhit/I");
168  tree->Branch("tofDSchan0PeakADC",&tofDSchan0PeakADC,"tofDSchan0PeakADC/I");
169  tree->Branch("tofDSchan1PeakADC",&tofDSchan1PeakADC,"tofDSchan1PeakADC/I");
170  tree->Branch("tofDSchan2PeakADC",&tofDSchan2PeakADC,"tofDSchan2PeakADC/I");
171  tree->Branch("tofDSchan3PeakADC",&tofDSchan3PeakADC,"tofDSchan3PeakADC/I");
172  tree->Branch("tofDSchan0StrtTime",&tofDSchan0StrtTime,"tofDSchan0StrtTime/I");
173  tree->Branch("tofDSchan1StrtTime",&tofDSchan1StrtTime,"tofDSchan1StrtTime/I");
174  tree->Branch("tofDSchan2StrtTime",&tofDSchan2StrtTime,"tofDSchan2StrtTime/I");
175  tree->Branch("tofDSchan3StrtTime",&tofDSchan3StrtTime,"tofDSchan3StrtTime/I");
176 
177  tree->Branch("tofSiPMnhit",&tofSiPMnhit,"tofSiPMnhit/I");
178  tree->Branch("tofSiPMchan0PeakADC",&tofSiPMchan0PeakADC,"tofSiPMchan0PeakADC/I");
179  tree->Branch("tofSiPMchan1PeakADC",&tofSiPMchan1PeakADC,"tofSiPMchan1PeakADC/I");
180  tree->Branch("tofSiPMchan2PeakADC",&tofSiPMchan2PeakADC,"tofSiPMchan2PeakADC/I");
181  tree->Branch("tofSiPMchan3PeakADC",&tofSiPMchan3PeakADC,"tofSiPMchan3PeakADC/I");
182  tree->Branch("tofSiPMchan0StrtTime",&tofSiPMchan0StrtTime,"tofSiPMchan0StrtTime/I");
183  tree->Branch("tofSiPMchan1StrtTime",&tofSiPMchan1StrtTime,"tofSiPMchan1StrtTime/I");
184  tree->Branch("tofSiPMchan2StrtTime",&tofSiPMchan2StrtTime,"tofSiPMchan2StrtTime/I");
185  tree->Branch("tofSiPMchan3StrtTime",&tofSiPMchan3StrtTime,"tofSiPMchan3StrtTime/I");
186 
187 }
188 
189 //.......................................................................
190 
192 {
193 
194  // Get "header" info (not all in header, but general info about event)
195  run = evt.run();
196  subrun = evt.subRun();
197  event = evt.event();
198 
199  // initialize variables that don't always get filled
200  spillTime=-5;
201  mcnrg=-5;
202  mc6ic=-5;
203  mc6cv=-5;
204  mc7sc1=-5;
205  novtsc01=-5;
206  novtsc07=-5;
207  mc7an1=-5;
208 
209  tofUSnhit=0;
210  tofDSnhit=0;
211  tofSiPMnhit=0;
212 
225 
238 
239  wc1xnhit=0;
240  wc1ynhit=0;
241  wc2xnhit=0;
242  wc2ynhit=0;
243  wc3xnhit=0;
244  wc3ynhit=0;
245  wc4xnhit=0;
246  wc4ynhit=0;
247 
248  wc1xChannel.clear();
249  wc1xTime.clear();
250  wc1yChannel.clear();
251  wc1yTime.clear();
252  wc2xChannel.clear();
253  wc2xTime.clear();
254  wc2yChannel.clear();
255  wc2yTime.clear();
256  wc3xChannel.clear();
257  wc3xTime.clear();
258  wc3yChannel.clear();
259  wc3yTime.clear();
260  wc4xChannel.clear();
261  wc4xTime.clear();
262  wc4yChannel.clear();
263  wc4yTime.clear();
264 
265  ckovStrtTime=-5;
266  ckovPeakADC=-5;
267 
268  // Get beam info from counters
270  evt.getByLabel(fSpillDataLabel,mcspill);
271  spillTime = mcspill->spilltimesec + mcspill->spilltimensec*1e-9;
272  mcnrg = mcspill->mcenrg;
273  mc6ic = mcspill->mc6int;
274  mc6cv = mcspill->mc6col;
275  mc7sc1 = mcspill->mc7int;
276  novtsc01 = mcspill->targetsc;
277  novtsc07 = mcspill->daqtrigger;
278  mc7an1 = mcspill->mc7magnet;
279 
280  // Get TOF raw info
281  // art::Handle<std::vector<rawdata::RawBeamlineDigit>> tofDigitHandle;
282  // std::vector<art::Ptr<rawdata::RawBeamlineDigit>> tofDigits;
283  // if (evt.getByLabel(fRawDataLabel, tofDigitHandle))
284  // art::fill_ptr_vector(tofDigits, tofDigitHandle);
285 
286 
287  // Get TOF cfd info
289  std::vector<art::Ptr<brb::BeamlineDigit>> tofCFDDigits;
290  if (evt.getByLabel(fToFCFDLabel, tofCFDDigitHandle))
291  art::fill_ptr_vector(tofCFDDigits, tofCFDDigitHandle);
292 
293  for (std::vector<art::Ptr<brb::BeamlineDigit>>::const_iterator tofDigitIt = tofCFDDigits.begin(); tofDigitIt != tofCFDDigits.end(); ++tofDigitIt){
294  // US = 0
295  // DS = 1
296  // DSiPM = 2
297  switch ( (*tofDigitIt)->ChannelID().Detector ){
298  case 0:
299  tofUSnhit++;
300  switch( (*tofDigitIt)->ChannelID().Channel ){
301  case 0:
302  tofUSchan0StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
303  tofUSchan0PeakADC = (*tofDigitIt)->PeakADC();
304  break;
305  case 1:
306  tofUSchan1StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
307  tofUSchan1PeakADC = (*tofDigitIt)->PeakADC();
308  break;
309  case 2:
310  tofUSchan2StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
311  tofUSchan2PeakADC = (*tofDigitIt)->PeakADC();
312  break;
313  case 3:
314  tofUSchan3StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
315  tofUSchan3PeakADC = (*tofDigitIt)->PeakADC();
316  break;
317  default:
318  std::cout<<"Unexpected channel: "<< (*tofDigitIt)->ChannelID().Channel<<std::endl;
319  break;
320  }// end switch channel
321  break;
322  case 1:
323  tofDSnhit++;
324  switch( (*tofDigitIt)->ChannelID().Channel ){
325  case 0:
326  tofDSchan0StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
327  tofDSchan0PeakADC = (*tofDigitIt)->PeakADC();
328  break;
329  case 1:
330  tofDSchan1StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
331  tofDSchan1PeakADC = (*tofDigitIt)->PeakADC();
332  break;
333  case 2:
334  tofDSchan2StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
335  tofDSchan2PeakADC = (*tofDigitIt)->PeakADC();
336  break;
337  case 3:
338  tofDSchan3StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
339  tofDSchan3PeakADC = (*tofDigitIt)->PeakADC();
340  break;
341  default:
342  std::cout<<"Unexpected channel: "<< (*tofDigitIt)->ChannelID().Channel<<std::endl;
343  break;
344  }// end switch channel
345  break;
346  case 2:
347  tofSiPMnhit++;
348  switch( (*tofDigitIt)->ChannelID().Channel ){
349  case 0:
350  tofSiPMchan0StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
351  tofSiPMchan0PeakADC = (*tofDigitIt)->PeakADC();
352  break;
353  case 1:
354  tofSiPMchan1StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
355  tofSiPMchan1PeakADC = (*tofDigitIt)->PeakADC();
356  break;
357  case 2:
358  tofSiPMchan2StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
359  tofSiPMchan2PeakADC = (*tofDigitIt)->PeakADC();
360  break;
361  case 3:
362  tofSiPMchan3StrtTime = (*tofDigitIt)->StartTimeInNanoSec();
363  tofSiPMchan3PeakADC = (*tofDigitIt)->PeakADC();
364  break;
365  default:
366  std::cout<<"Unexpected channel: "<< (*tofDigitIt)->ChannelID().Channel<<std::endl;
367  break;
368  }// end switch channel
369  break;
370  default:
371  std::cout<<"Unexpected detector: "<< (*tofDigitIt)->ChannelID().Detector<<std::endl;
372  break;
373  }// end switch detector
374  } // end loop over tof digits
375 
376 
377  // Get WC raw info
379  std::vector<art::Ptr<rawdata::RawBeamlineWC>> wcObj;
380  if (evt.getByLabel(fRawWCDataLabel, wcHandle))
381  art::fill_ptr_vector(wcObj, wcHandle);
382 
383  // loop over WCs
384  for (unsigned int WCdigitIdx = 0; WCdigitIdx < wcHandle->size(); ++WCdigitIdx){
385  rawdata::RawBeamlineWC WCdigit = wcHandle->at(WCdigitIdx);
386  std::vector<rawdata::RawBeamlineWC::WCPulse> xPulses = WCdigit.XPulses();
387  std::vector<rawdata::RawBeamlineWC::WCPulse> yPulses = WCdigit.YPulses();
388 
389  std::vector<int> xPulseChannel;
390  std::vector<int> xPulseTime;
391  std::vector<int> yPulseChannel;
392  std::vector<int> yPulseTime;
393  int wcXnhit=0;
394  int wcYnhit=0;
395 
396  for (unsigned int xIdx = 0; xIdx < xPulses.size(); ++xIdx){
397  xPulseChannel.push_back(xPulses[xIdx].Channel);
398  xPulseTime.push_back(xPulses[xIdx].Time);
399  wcXnhit++;
400  }
401  for (unsigned int yIdx = 0; yIdx < yPulses.size(); ++yIdx){
402  yPulseChannel.push_back(yPulses[yIdx].Channel);
403  yPulseTime.push_back(yPulses[yIdx].Time);
404  wcYnhit++;
405  }
406 
407  switch ( WCdigit.DetectorID().Detector ){
408  case 0:
409  wc1xnhit = wcXnhit;
410  wc1ynhit = wcYnhit;
411  wc1xChannel = xPulseChannel;
412  wc1xTime = xPulseTime;
413  wc1yChannel = yPulseChannel;
414  wc1yTime = yPulseTime;
415  break;
416  case 1:
417  wc2xnhit = wcXnhit;
418  wc2ynhit = wcYnhit;
419  wc2xChannel = xPulseChannel;
420  wc2xTime = xPulseTime;
421  wc2yChannel = yPulseChannel;
422  wc2yTime = yPulseTime;
423  break;
424  case 2:
425  wc3xnhit = wcXnhit;
426  wc3ynhit = wcYnhit;
427  wc3xChannel = xPulseChannel;
428  wc3xTime = xPulseTime;
429  wc3yChannel = yPulseChannel;
430  wc3yTime = yPulseTime;
431  break;
432  case 3:
433  wc4xnhit = wcXnhit;
434  wc4ynhit = wcYnhit;
435  wc4xChannel = xPulseChannel;
436  wc4xTime = xPulseTime;
437  wc4yChannel = yPulseChannel;
438  wc4yTime = yPulseTime;
439  break;
440  default:
441  std::cout<<"Unexpected detector: "<< WCdigit.DetectorID().Detector<<std::endl;
442  break;
443  }// end switch wc detector
444 
445  } // end loop over WC digits
446 
447 
448  // get Ckov reco
450  std::vector<art::Ptr<brb::BeamlineDigit>> cherenkovs;
451  if (evt.getByLabel(fRecoCkovLabel, cherenkovHandle))
452  art::fill_ptr_vector(cherenkovs, cherenkovHandle);
453 
454  for (auto ckov : cherenkovs) {
455  ckovStrtTime = ckov->StartTimeInNanoSec();
456  ckovPeakADC = ckov->PeakADC();
457  }
458 
459  // now fill everything
460  tree->Fill();
461 }
462 
std::vector< WCPulse > YPulses() const
std::vector< int > wc2xTime
std::vector< int > wc2yChannel
SubRunNumber_t subRun() const
Definition: Event.h:72
std::string fRawWCDataLabel
std::vector< int > wc1xChannel
std::vector< int > wc1xTime
std::string fToFCFDLabel
std::string fRawDataLabel
std::vector< int > wc1yTime
std::vector< WCPulse > XPulses() const
std::vector< int > wc3xTime
DEFINE_ART_MODULE(TestTMapFile)
unsigned long int spilltimesec
Definition: MCenterData.h:20
double mc6int
MC6 intensity [ppp].
Definition: MCenterData.h:25
std::vector< int > wc4yChannel
unsigned long int spilltimensec
Definition: MCenterData.h:21
std::vector< int > wc4xTime
std::string fSpillDataLabel
Encapsulation of reconstructed digitizer &#39;hits&#39;. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
std::vector< int > wc2yTime
std::vector< int > wc3yTime
void analyze(art::Event const &e) override
T get(std::string const &key) const
Definition: ParameterSet.h:231
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
double mc6col
MC6 vertical collimator opening [mm].
Definition: MCenterData.h:26
std::vector< int > wc2xChannel
int evt
std::vector< int > wc4yTime
std::vector< int > wc1yChannel
EventNumber_t event() const
Definition: Event.h:67
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::vector< int > wc4xChannel
std::string fRecoCkovLabel
Definition: run.py:1
OStream cout
Definition: OStream.cxx:6
double mcenrg
MCenter energy [GeV].
Definition: MCenterData.h:24
T * make(ARGS...args) const
BeamlineAna(fhicl::ParameterSet const &pset)
double daqtrigger
Beamline DAQ triggers [counts].
Definition: MCenterData.h:30
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double mc7magnet
Tertiary beamline magnet current [Amps].
Definition: MCenterData.h:29
void reconfigure(fhicl::ParameterSet const &pset)
std::vector< int > wc3yChannel
Raw data definitions for beamline data used in NOvA test beam experiment.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
double targetsc
MC7 target counter [counts].
Definition: MCenterData.h:28
Float_t e
Definition: plot.C:35
RunNumber_t run() const
Definition: Event.h:77
std::vector< int > wc3xChannel
Definition: fwd.h:28
beamlinegeo::DetectorID DetectorID() const
double mc7int
MC7 intensity [counts] - scintillator counter.
Definition: MCenterData.h:27
enum BeamMode string