ToFlat.cpp
Go to the documentation of this file.
1 //File: ToFlat.cpp
2 //Brief: Converts Triggers to a flat TTree. Useful when Sarah wants to access CRT output
3 // in python.
4 //Usage: Provide one or more EBuilder output files on
5 // the command line. Files should have been produced by EBuilder.
6 //
7 // fromEBuilder/toROOTFlat <one EBuilder file name> [another EBuilder file name]...
8 //
9 //Author: Andrew Olivier aolivier@ur.rochester.edu
10 
11 //local includes
12 #include "toROOT/ToFlat.h"
13 
14 namespace CRT
15 {
17 
18  void ToFlat::AnalyzeEvent(const std::vector<CRT::Trigger>& triggers)
19  {
20  ResetBranches();
21 
22  size_t trigIt = 0;
23  fNTriggers = triggers.size();
24  for(const auto& trigger: triggers)
25  {
26  fTimestamps[trigIt] = trigger.Timestamp();
27  fModules[trigIt] = trigger.Channel();
28 
29  const auto& hits = trigger.Hits();
30  for(const auto& hit: hits)
31  {
32  fADCs[trigIt][hit.Channel()] = hit.ADC();
33  }
34  ++trigIt;
35  }
36 
37  fTree->Fill();
38  }
39 
41  {
42  for(size_t trigger = 0; trigger < MaxTriggers; ++trigger)
43  {
44  fNTriggers = 0;
45  fTimestamps[trigger] = -1;
46  fModules[trigger] = -1;
47  for(size_t channel = 0; channel < NChannels; ++channel) fADCs[trigger][channel] = 0;
48  }
49  }
50 }
unsigned long long fTimestamps[MaxTriggers]
Definition: ToFlat.h:53
void AnalyzeEvent(const std::vector< CRT::Trigger > &triggers)
Definition: ToFlat.cpp:18
TTree * fTree
Definition: ToFlat.h:56
short fModules[MaxTriggers]
Definition: ToFlat.h:54
static constexpr size_t MaxTriggers
Definition: ToFlat.h:46
short fADCs[MaxTriggers][NChannels]
Definition: ToFlat.h:52
uint8_t channel
Definition: CRTFragment.hh:201
virtual ~ToFlat()
Definition: ToFlat.cpp:16
void ResetBranches()
Definition: ToFlat.cpp:40
Detector simulation of raw signals on wires.
static constexpr size_t NChannels
Definition: ToFlat.h:45
size_t fNTriggers
Definition: ToFlat.h:51