/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/stable/src/io/include/RAT/OutNtupleProc.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/stable/src/io/include/RAT/OutNtupleProc.hh Source File
Ratpac-two
OutNtupleProc.hh
1 #ifndef __RATOutNtupleProc___
2 #define __RATOutNtupleProc___
3 
4 #include <TTimeStamp.h>
5 #include <TTree.h>
6 #include <sys/types.h>
7 
8 #include <RAT/DS/Classifier.hh>
9 #include <RAT/DS/FitResult.hh>
10 #include <RAT/DS/Run.hh>
11 #include <RAT/Processor.hh>
12 #include <RAT/TransitTimeCalculator.hh>
13 #include <functional>
14 
15 #include "Math/Types.h"
16 
17 class TFile;
18 class TTree;
19 
20 namespace RAT {
21 
22 class OutNtupleProc : public Processor {
23  public:
24  static int run_num;
25  OutNtupleProc();
26  void BeginOfRun(DS::Run *run) override;
27 
28  enum mc_pe_type { noise = 0, cherenkov = 1, scintillation = 2, reemission = 3, unknown = 4 };
29 
30  // file - string, name of file to open for output, file will be erased
31  // updatefile - string, name of file to append to
32  // (do not use both file and update file)
33  // virtual void SetS(std::string param, std::string value);
34 
35  // autosave - integer, update root file every N kilobytes
36  // savetree 0 - Do not save the event tree. Must set *before* file or
37  // updatefile.
38  // virtual void SetI(std::string param, int value);
39 
40  virtual Processor::Result DSEvent(DS::Root *ds);
41 
42  virtual bool OpenFile(std::string theFilename);
43 
44  virtual void SetI(std::string param, int value);
45  virtual void SetS(std::string param, std::string value);
46  // Utility function
47  static ULong64_t TTimeStamp_to_UnixTime(TTimeStamp ts) {
48  const ULong64_t stonano = 1000000000;
49  return static_cast<ULong64_t>(ts.GetSec()) * stonano + static_cast<ULong64_t>(ts.GetNanoSec());
50  }
51  virtual void EndOfRun(DS::Run *run) override;
52 
53  // Extensible functions
54  virtual void AssignAdditionalAddresses(){};
55  virtual void AssignAdditionalMetaAddresses(){};
56  virtual void FillEvent(DS::Root *, DS::EV *){};
57  virtual void FillNoTriggerEvent(DS::Root *){};
58  virtual void FillMeta(){};
59 
60  // Exposed members for external tools
61  DS::Run *runBranch;
62  // Fill Functions
63  struct NtupleOptions {
64  bool tracking;
65  bool mcparticles;
66  bool pmthits;
67  bool digitizerwaveforms;
68  bool digitizerhits;
69  bool digitizerfits;
70  bool untriggered;
71  bool mchits;
72  bool nthits;
73  bool calib;
74  bool transittime;
75  };
76  NtupleOptions options;
77 
78  std::vector<std::string> waveform_fitters;
79  std::map<std::string, std::vector<std::string>> waveform_fitter_FOMs;
80  std::vector<std::string> event_fitters;
81  std::map<std::string, std::vector<std::string>> event_fitter_FOMs;
82  std::vector<std::string> event_classifiers;
83  std::map<std::string, std::vector<std::string>> event_classifier_FOMs;
84 
85  std::unique_ptr<RAT::TransitTimeCalculator> fTransitTimeCalculator;
86 
87  protected:
88  std::string defaultFilename;
89  TFile *outputFile;
90  TTree *outputTree;
91  TTree *metaTree;
92  TTree *waveformTree;
93  // Meta Branches
94  Int_t runId;
95  ULong64_t runType;
96  ULong64_t runTime;
97  int dsentries;
98  std::string macro;
99  std::vector<int> pmtType;
100  std::vector<int> pmtId;
101  std::vector<int> pmtChannel;
102  std::vector<bool> pmtIsOnline;
103  std::vector<double> pmtCableOffset;
104  std::vector<double> pmtChargeScale;
105  std::vector<double> pmtPulseWidthScale;
106  std::vector<double> pmtX;
107  std::vector<double> pmtY;
108  std::vector<double> pmtZ;
109  std::vector<double> pmtU;
110  std::vector<double> pmtV;
111  std::vector<double> pmtW;
112  std::vector<int> ntId;
113  std::vector<double> ntX;
114  std::vector<double> ntY;
115  std::vector<double> ntZ;
116  std::vector<double> ntU;
117  std::vector<double> ntV;
118  std::vector<double> ntW;
119  u_int32_t digitizerWindowSize;
120  Double_t digitizerSampleRate;
121  Double_t digitizerDynamicRange;
122  Double_t digitizerVoltageResolution;
123  // Calibration source information
124  // get from 1st event, and then mark done.
125  bool done_writing_calib;
126  Int_t calibId;
127  Int_t calibMode;
128  Double_t calibIntensity;
129  Double_t calibWavelength;
130  std::string calibName;
131  ULong64_t calibTime;
132  Double_t calibX, calibY, calibZ, calibU, calibV, calibW;
133  // Digitizer waveforms
134  int waveform_pmtid;
135  std::vector<Double_t> inWindowPulseTimes;
136  std::vector<Double_t> inWindowPulseCharges;
137  std::vector<UShort_t> waveform;
138  // Data Branches
139  Int_t mcpdg;
140  double mcx, mcy, mcz;
141  double mcu, mcv, mcw;
142  double mcke;
143  double mct;
144  std::vector<double> mcTransitTimes;
145  int evid;
146  int subev;
147  int nhits;
148  double totalcharge;
149  double triggerTime;
150  ULong64_t timestamp;
151  ULong64_t trigger_word;
152  ULong64_t event_cleaning_word;
153  double timeSinceLastTrigger_us;
154  // MC Summary Information
155  double scintEdep;
156  double scintEdepQuenched;
157  double scintPhotons;
158  double remPhotons;
159  double cherPhotons;
160  // MCPMT
161  int mcnhits;
162  int mcpecount;
163  std::vector<int> mcpmtid;
164  std::vector<int> mcpmtnpe;
165  std::vector<double> mcpmtcharge;
166  // MCNestedTube
167  int mcnNTs;
168  int mcnNThits;
169  std::vector<int> mcNTid;
170  std::vector<double> mcNThittime;
171  std::vector<double> mcNThitx;
172  std::vector<double> mcNThity;
173  std::vector<double> mcNThitz;
174  // MCPE
175  std::vector<int> mcpepmtid;
176  std::vector<double> mcpehittime;
177  std::vector<double> mcpefrontendtime;
178  std::vector<int> mcpeprocess;
179  std::vector<double> mcpewavelength;
180  std::vector<double> mcpex;
181  std::vector<double> mcpey;
182  std::vector<double> mcpez;
183  std::vector<double> mcpecharge;
184  // MCParticles
185  int mcpcount;
186  int mcid;
187  std::vector<Int_t> pdgcodes;
188  std::vector<double> mcKEnergies;
189  std::vector<double> mcPosx;
190  std::vector<double> mcPosy;
191  std::vector<double> mcPosz;
192  std::vector<double> mcDirx;
193  std::vector<double> mcDiry;
194  std::vector<double> mcDirz;
195  std::vector<double> mcTime;
196  // Reconstruted variables
197  std::map<std::string, double> fitvalues;
198  std::map<std::string, bool> fitvalids;
199  std::map<std::string, std::map<std::string, double>> fiteventFOMs;
200  std::map<std::string, std::map<std::string, double>> classifyeventFOMs;
201  // Store PMT Hit Positions
202  std::vector<int> hitPMTID;
203  std::vector<double> hitPMTTime;
204  std::vector<double> hitPMTCharge;
205  // Store PMT information from digitized waveform
206  int digitNhits;
207  std::vector<double> digitPeak;
208  std::vector<double> digitTime;
209  std::vector<double> digitCharge;
210  std::vector<double> digitTimeOverThreshold;
211  std::vector<double> digitVoltageOverThreshold;
212  std::vector<double> digitLocalTriggerTime;
213  std::vector<int> digitReconNPEs;
214  std::vector<int> digitNCrossings;
215  std::vector<int> digitPMTID;
216  // Hit cleaning information
217  int digitHitCleanedNhits;
218  std::vector<uint64_t> digitHitCleaningMask;
219  // Information from fit to the waveforms
220  std::map<std::string, std::vector<int>> wfmFitPmtID;
221  std::map<std::string, std::vector<double>> wfmFitTime;
222  std::map<std::string, std::vector<double>> wfmFitCharge;
223  std::map<std::string, std::map<std::string, std::vector<double>>> wfmFitFOM;
224  // Tracking
225  std::map<std::string, int> processCodeMap;
226  std::vector<int> processCodeIndex;
227  std::vector<std::string> processName;
228  std::map<std::string, int> volumeCodeMap;
229  std::vector<int> volumeCodeIndex;
230  std::vector<std::string> volumeName;
231 
232  // Tracking
233  std::vector<int> trackPDG;
234  std::vector<std::vector<double>> trackPosX;
235  std::vector<std::vector<double>> trackPosY;
236  std::vector<std::vector<double>> trackPosZ;
237  std::vector<std::vector<double>> trackMomX;
238  std::vector<std::vector<double>> trackMomY;
239  std::vector<std::vector<double>> trackMomZ;
240  std::vector<std::vector<double>> trackKE;
241  std::vector<std::vector<double>> trackTime;
242  std::vector<std::vector<int>> trackProcess;
243  std::vector<std::vector<int>> trackVolume;
244 };
245 
246 } // namespace RAT
247 
248 #endif
Definition: EV.hh:33
Definition: Root.hh:37
Definition: Run.hh:22
Definition: OutNtupleProc.hh:22
virtual void SetI(std::string param, int value)
Definition: OutNtupleProc.cc:882
virtual Processor::Result DSEvent(DS::Root *ds)
Definition: OutNtupleProc.cc:352
virtual void SetS(std::string param, std::string value)
Definition: OutNtupleProc.cc:876
Definition: Processor.hh:36
Result
Definition: Processor.hh:59
Definition: CCCrossSecMessenger.hh:29
Definition: OutNtupleProc.hh:63