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

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