ToFlat.h
Go to the documentation of this file.
1 //File: flat.h
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 #ifndef CRT_TOFLAT_H
12 #define CRT_TOFLAT_H
13 
14 //ROOT includes
15 #include "TTree.h"
16 
17 //crt-core includes
18 #include "persistency/CRTTrigger.h"
19 
20 //c++ includes
21 #include <iostream>
22 
23 namespace CRT
24 {
25  class ToFlat
26  {
27  public:
28 
29  template <class TFS> //TFS is an object with an interface like ART's TFileService
30  ToFlat(TFS& fileService)
31  {
32  fTree = fileService->template make<TTree>("EBuilder", "CRT::Triggers");
33 
34  fTree->Branch("NTriggers", &fNTriggers, "NTriggers/l");
35  fTree->Branch("Modules", &fModules, "Modules[NTriggers]/s");
36  fTree->Branch("ADCs", &fADCs, "ADCs[NTriggers][64]/s"); //Second index is explicitly channel number
37  fTree->Branch("Timestamps", &fTimestamps, "Timestamps[NTriggers]/l");
38  }
39 
40  virtual ~ToFlat();
41 
42  void AnalyzeEvent(const std::vector<CRT::Trigger>& triggers);
43 
44  protected:
45  static constexpr size_t NChannels = 64; //There are 64 strips = channels in each CRT module
46  static constexpr size_t MaxTriggers = 32*2; //I don't expect many duplicate modules in an event. Just in case, leave space for
47  //up to 2 of each module in a single event.
48 
49  //TTree Branches
50  //TODO: Writing variable-sized arrays now, so these could probably be vectors
51  size_t fNTriggers;
53  unsigned long long fTimestamps[MaxTriggers];
55 
56  TTree* fTree; //TTree to which ROOT output will be written
57 
58  private:
59  void ResetBranches();
60  };
61 }
62 
63 #endif //CRT_TOFLAT_H
unsigned long long fTimestamps[MaxTriggers]
Definition: ToFlat.h:53
ToFlat(TFS &fileService)
Definition: ToFlat.h:30
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
virtual ~ToFlat()
Definition: ToFlat.cpp:16
void ResetBranches()
Definition: ToFlat.cpp:40
static constexpr size_t NChannels
Definition: ToFlat.h:45
size_t fNTriggers
Definition: ToFlat.h:51