All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CellTree_module.cc
Go to the documentation of this file.
1 // Read data from MC raw files and convert it into ROOT tree
2 // Chao Zhang (chao@bnl.gov) 5/13/2014
3 // Added optical info --- Brooke Russell (brussell@yale.edu) 1/31/2017
4 
5 // LArSoft includes
11 #include "nusimdata/SimulationBase/MCParticle.h"
12 #include "nusimdata/SimulationBase/MCTruth.h"
13 #include "nusimdata/SimulationBase/MCNeutrino.h"
14 #include "lardataobj/RawData/raw.h"
20 
21 // Framework includes
22 #include "art/Framework/Core/EDAnalyzer.h"
23 #include "art/Framework/Principal/Event.h"
24 #include "art/Framework/Principal/Handle.h"
25 #include "art/Framework/Services/Registry/ServiceHandle.h"
26 #include "art/Framework/Core/ModuleMacros.h"
27 #include "canvas/Persistency/Common/FindOneP.h"
28 #include "messagefacility/MessageLogger/MessageLogger.h"
29 #include "fhiclcpp/ParameterSet.h"
30 
31 // ROOT includes.
32 #include "TFile.h"
33 #include "TTree.h"
34 #include "TDirectory.h"
35 #include "TString.h"
36 #include "TClonesArray.h"
37 #include "TH1F.h"
38 #include "TLorentzVector.h"
39 #include "TDatabasePDG.h"
40 #include "TObjArray.h"
41 #include "TSystem.h"
42 #include "TTimeStamp.h"
43 
44 // C++ Includes
45 #include <map>
46 #include <fstream>
47 #include <cstdio>
48 
49 #define MAX_TRACKS 30000
50 
51 using namespace std;
52 
53 namespace wc {
54 
55 class CellTree : public art::EDAnalyzer {
56 public:
57 
58  explicit CellTree(fhicl::ParameterSet const& pset);
59 
60 private:
61 
62  void endJob();
63  void beginRun(const art::Run& run);
64  void analyze(const art::Event& evt);
65 
66  void initOutput();
67  void printEvent();
68  void print_vector(ostream& out, vector<double>& v, TString desc, bool end=false);
69 
70  void processRaw(const art::Event& evt);
71  void processCalib(const art::Event& evt);
72  void processOpHit(const art::Event& evt);
73  void processOpFlash(const art::Event& evt);
74  void processSpacePoint( const art::Event& event, TString option, ostream& out=cout);
75  void processSpacePointTruthDepo( const art::Event& event, TString option, ostream& out=cout);
76  void processSimChannel(const art::Event& evt);
77  void processMC(const art::Event& evt);
78  void processMCTracks();
79  void processTrigger(const art::Event& evt);
80 
81  void reset();
82  void InitProcessMap();
83 
84  bool IsPrimary(int i) { return mc_mother[i] == 0 ; }
85  bool KeepMC(int i);
86  double KE(float* momentum); // KE
87  TString PDGName(int pdg);
88  bool DumpMCJSON(int id, ostream& out);
89  void DumpMCJSON(ostream& out=cout);
90 
91 
92  // the parameters we'll read from the .fcl
93  std::string fRawDigitLabel;
94  std::string fCalibLabel;
95  std::string fOpHitLabel;
96  std::string fOpFlashLabel;
97  std::string fTriggerLabel;
99  std::vector<std::string> fSpacePointLabels;
100  std::string fSimChannelLabel;
101  std::string fOutFileName;
102  std::string mcOption;
107  bool fSaveRaw;
111  bool fSaveMC;
113  bool fSaveJSON;
114  art::ServiceHandle<geo::Geometry const> fGeometry; // pointer to Geometry service
115 
116  // art::ServiceHandle<geo::Geometry const> fGeom;
117  // // auto const* larp = lar::providerFrom<detinfo::LArPropertiesService>();
118 
119  TFile *fOutFile;
120  TTree *fEventTree;
121  std::map<std::string, int> processMap;
122  std::map<int, int> savedMCTrackIdMap; // key: id; value: pdg;
123 
124  int entryNo;
125 
126  // Event Tree Leafs
127  int fEvent;
128  int fRun;
129  int fSubRun;
130  double fEventTime;
131 
132  unsigned int fTriggernumber; //trigger counter
133  double fTriggertime; //trigger time w.r.t. electronics clock T0
134  double fBeamgatetime; //beamgate time w.r.t. electronics clock T0
135  unsigned int fTriggerbits; //trigger bits
136 
138  // int fCalib_channelId[MAX_CHANNEL]; // hit channel id; size == fCalib_Nhit
139  // // FIXEME:: cannot save e.g std::vector<std::vector<float> > in ttree
140  std::vector<int> fCalib_channelId;
141  // std::vector<std::vector<float> > fCalib_wf;
142  TClonesArray *fCalib_wf;
143  // std::vector<std::vector<int> > fCalib_wfTDC;
144 
145  int oh_nHits;
146  vector<int> oh_channel;
147  vector<double> oh_bgtime;
148  vector<double> oh_trigtime;
149  vector<double> oh_pe;
150 
152  vector<float> of_t;
153  vector<float> of_peTotal;
154  vector<int> of_multiplicity;
155  TClonesArray *fPEperOpDet;
156 
158  std::vector<int> fRaw_channelId;
159  TClonesArray *fRaw_wf;
160 
162  vector<int> fSIMIDE_channelIdY;
163  vector<int> fSIMIDE_trackId;
164  vector<unsigned short> fSIMIDE_tdc;
165  vector<float> fSIMIDE_x;
166  vector<float> fSIMIDE_y;
167  vector<float> fSIMIDE_z;
168  vector<float> fSIMIDE_numElectrons;
169 
170  int mc_Ntrack; // number of tracks in MC
171  int mc_id[MAX_TRACKS]; // track id; size == mc_Ntrack
172  int mc_pdg[MAX_TRACKS]; // track particle pdg; size == mc_Ntrack
173  int mc_process[MAX_TRACKS]; // track generation process code; size == mc_Ntrack
174  int mc_mother[MAX_TRACKS]; // mother id of this track; size == mc_Ntrack
175  float mc_startXYZT[MAX_TRACKS][4]; // start position of this track; size == mc_Ntrack
176  float mc_endXYZT[MAX_TRACKS][4]; // end position of this track; size == mc_Ntrack
177  float mc_startMomentum[MAX_TRACKS][4]; // start momentum of this track; size == mc_Ntrack
178  float mc_endMomentum[MAX_TRACKS][4]; // end momentum of this track; size == mc_Ntrack
179  std::vector<std::vector<int> > mc_daughters; // daughters id of this track; vector
180  TObjArray *fMC_trackPosition;
181 
182  int mc_isnu; // is neutrino interaction
183  int mc_nGeniePrimaries; // number of Genie primaries
184  int mc_nu_pdg; // pdg code of neutrino
185  int mc_nu_ccnc; // cc or nc
186  int mc_nu_mode; // mode: http://nusoft.fnal.gov/larsoft/doxsvn/html/MCNeutrino_8h_source.html
187  int mc_nu_intType; // interaction type
188  int mc_nu_target; // target interaction
189  int mc_hitnuc; // hit nucleon
190  int mc_hitquark; // hit quark
191  double mc_nu_Q2; // Q^2
192  double mc_nu_W; // W
193  double mc_nu_X; // X
194  double mc_nu_Y; // Y
195  double mc_nu_Pt; // Pt
196  double mc_nu_Theta; // angle relative to lepton
197  float mc_nu_pos[4]; // interaction position of nu
198  float mc_nu_mom[4]; // interaction momentum of nu
199 
200  // ----- derived ---
201  std::map<int, int> trackIndex;
202  std::vector<std::vector<int> > trackParents;
203  std::vector<std::vector<int> > trackChildren;
204  std::vector<std::vector<int> > trackSiblings;
205  TDatabasePDG *dbPDG;
206 
207 }; // class CellTree
208 
209 
210 //-----------------------------------------------------------------------
211 CellTree::CellTree(fhicl::ParameterSet const& p)
212  : EDAnalyzer(p)
213 {
214  dbPDG = new TDatabasePDG();
215  entryNo = 0;
216 
217  fRawDigitLabel = p.get<std::string>("RawDigitLabel");
218  fCalibLabel = p.get<std::string>("CalibLabel");
219  fOpHitLabel = p.get<std::string>("OpHitLabel");
220  fOpFlashLabel = p.get<std::string>("OpFlashLabel");
221  fTriggerLabel = p.get<std::string>("TriggerLabel");
222  fSimEnergyDepositLabel = p.get<std::string>("SimEnergyDepositLabel");
223  fSpacePointLabels= p.get<std::vector<std::string> >("SpacePointLabels");
224  fSimChannelLabel = p.get<std::string>("SimChannelLabel");
225  fOutFileName = p.get<std::string>("outFile");
226  mcOption = p.get<std::string>("mcOption");
227  fSaveMCTrackPoints = p.get<bool>("saveMCTrackPoints");
228  fSaveRaw = p.get<bool>("saveRaw");
229  fSaveCalib = p.get<bool>("saveCalib");
230  fSaveOpHit = p.get<bool>("saveOpHit");
231  fSaveOpFlash = p.get<bool>("saveOpFlash");
232  fSaveMC = p.get<bool>("saveMC");
233  fSaveSimChannel = p.get<bool>("saveSimChannel");
234  fSaveTrigger = p.get<bool>("saveTrigger");
235  fSaveJSON = p.get<bool>("saveJSON");
236  opMultPEThresh = p.get<float>("opMultPEThresh");
237  nRawSamples = p.get<int>("nRawSamples");
238 
239  InitProcessMap();
240  initOutput();
241 }
242 
243 //-----------------------------------------------------------------------
245 {
246  TDirectory* tmpDir = gDirectory;
247 
248  fOutFile = new TFile(fOutFileName.c_str(), "recreate");
249 
250  // 3.1: add mc_trackPosition
251  TNamed version("version", "4.0");
252  version.Write();
253 
254  // init Event TTree
255  TDirectory* subDir = fOutFile->mkdir("Event");
256  subDir->cd();
257  fEventTree = new TTree("Sim", "Event Tree from Simulation");
258  fEventTree->Branch("eventNo", &fEvent);
259  fEventTree->Branch("runNo", &fRun);
260  fEventTree->Branch("subRunNo", &fSubRun);
261  fEventTree->Branch("eventTime", &fEventTime); // timestamp
262 
263  fEventTree->Branch("triggerNo", &fTriggernumber); // timestamp
264  fEventTree->Branch("triggerTime", &fTriggertime); // timestamp
265  fEventTree->Branch("beamgateTime", &fBeamgatetime); // timestamp
266  fEventTree->Branch("triggerBits", &fTriggerbits); // timestamp
267 
268  fEventTree->Branch("raw_nChannel", &fRaw_nChannel); // number of hit channels above threshold
269  fEventTree->Branch("raw_channelId" , &fRaw_channelId); // hit channel id; size == raw_nChannel
270  fRaw_wf = new TClonesArray("TH1F");
271  fEventTree->Branch("raw_wf", &fRaw_wf, 256000, 0); // raw waveform adc of each channel
272 
273 
274  fEventTree->Branch("calib_nChannel", &fCalib_nChannel); // number of hit channels above threshold
275  fEventTree->Branch("calib_channelId" , &fCalib_channelId); // hit channel id; size == calib_Nhit
276  fCalib_wf = new TClonesArray("TH1F");
277  fEventTree->Branch("calib_wf", &fCalib_wf, 256000, 0); // calib waveform adc of each channel
278  // fCalib_wf->BypassStreamer();
279  // fEventTree->Branch("calib_wfTDC", &fCalib_wfTDC); // calib waveform tdc of each channel
280 
281  fEventTree->Branch("oh_nHits", &oh_nHits); // number of op hits
282  fEventTree->Branch("oh_channel", &oh_channel); //opchannel id; size == no ophits
283  fEventTree->Branch("oh_bgtime", &oh_bgtime); // optical pulse peak time w.r.t. start of beam gate
284  fEventTree->Branch("oh_trigtime", &oh_trigtime); // optical pulse peak time w.r.t. trigger
285  fEventTree->Branch("oh_pe", &oh_pe); // pulse PE
286 
287  fEventTree->Branch("of_nFlash", &of_nFlash);
288  fEventTree->Branch("of_t", &of_t); // time in us w.r.t. the trigger for each flash
289  fEventTree->Branch("of_peTotal", &of_peTotal); // total PE (sum of all PMTs) for each flash
290  fEventTree->Branch("of_multiplicity", &of_multiplicity); // total number of PMTs above threshold for each flash
291  fPEperOpDet = new TClonesArray("TH1F");
292  fEventTree->Branch("pe_opdet", &fPEperOpDet, 256000, 0);
293 
294  fEventTree->Branch("simide_size", &fSIMIDE_size); // size of stored sim:IDE
295  fEventTree->Branch("simide_channelIdY", &fSIMIDE_channelIdY);
296  fEventTree->Branch("simide_trackId", &fSIMIDE_trackId);
297  fEventTree->Branch("simide_tdc", &fSIMIDE_tdc);
298  fEventTree->Branch("simide_x", &fSIMIDE_x);
299  fEventTree->Branch("simide_y", &fSIMIDE_y);
300  fEventTree->Branch("simide_z", &fSIMIDE_z);
301  fEventTree->Branch("simide_numElectrons", &fSIMIDE_numElectrons);
302 
303  fEventTree->Branch("mc_Ntrack", &mc_Ntrack); // number of tracks in MC
304  fEventTree->Branch("mc_id", &mc_id, "mc_id[mc_Ntrack]/I"); // track id; size == mc_Ntrack
305  fEventTree->Branch("mc_pdg", &mc_pdg, "mc_pdg[mc_Ntrack]/I"); // track particle pdg; size == mc_Ntrack
306  fEventTree->Branch("mc_process", &mc_process, "mc_process[mc_Ntrack]/I"); // track generation process code; size == mc_Ntrack
307  fEventTree->Branch("mc_mother", &mc_mother, "mc_mother[mc_Ntrack]/I"); // mother id of this track; size == mc_Ntrack
308  fEventTree->Branch("mc_daughters", &mc_daughters); // daughters id of this track; vector
309  fEventTree->Branch("mc_startXYZT", &mc_startXYZT, "mc_startXYZT[mc_Ntrack][4]/F"); // start position of this track; size == mc_Ntrack
310  fEventTree->Branch("mc_endXYZT", &mc_endXYZT, "mc_endXYZT[mc_Ntrack][4]/F"); // start position of this track; size == mc_Ntrack
311  fEventTree->Branch("mc_startMomentum", &mc_startMomentum, "mc_startMomentum[mc_Ntrack][4]/F"); // start momentum of this track; size == mc_Ntrack
312  fEventTree->Branch("mc_endMomentum", &mc_endMomentum, "mc_endMomentum[mc_Ntrack][4]/F"); // start momentum of this track; size == mc_Ntrack
313  fMC_trackPosition = new TObjArray();
314  fMC_trackPosition->SetOwner(kTRUE);
315  fEventTree->Branch("mc_trackPosition", &fMC_trackPosition);
316 
317  fEventTree->Branch("mc_isnu", &mc_isnu);
318  fEventTree->Branch("mc_nGeniePrimaries", &mc_nGeniePrimaries);
319  fEventTree->Branch("mc_nu_pdg", &mc_nu_pdg);
320  fEventTree->Branch("mc_nu_ccnc", &mc_nu_ccnc);
321  fEventTree->Branch("mc_nu_mode", &mc_nu_mode);
322  fEventTree->Branch("mc_nu_intType", &mc_nu_intType);
323  fEventTree->Branch("mc_nu_target", &mc_nu_target);
324  fEventTree->Branch("mc_hitnuc", &mc_hitnuc);
325  fEventTree->Branch("mc_hitquark", &mc_hitquark);
326  fEventTree->Branch("mc_nu_Q2", &mc_nu_Q2);
327  fEventTree->Branch("mc_nu_W", &mc_nu_W);
328  fEventTree->Branch("mc_nu_X", &mc_nu_X);
329  fEventTree->Branch("mc_nu_Y", &mc_nu_Y);
330  fEventTree->Branch("mc_nu_Pt", &mc_nu_Pt);
331  fEventTree->Branch("mc_nu_Theta", &mc_nu_Theta);
332  fEventTree->Branch("mc_nu_pos", &mc_nu_pos, "mc_nu_pos[4]/F");
333  fEventTree->Branch("mc_nu_mom", &mc_nu_mom, "mc_nu_mom[4]/F");
334 
335  gDirectory = tmpDir;
336  if (fSaveJSON) {
337  system("rm -rf bee");
338  gSystem->MakeDirectory("bee");
339  // gSystem->ChangeDirectory("bee");
340  gSystem->MakeDirectory("bee/data");
341  }
342 
343 }
344 
345 //-----------------------------------------------------------------------
347 {
348  // Write fEventTree to file
349  TDirectory* tmpDir = gDirectory;
350  fOutFile->cd("/Event");
351 
352  fEventTree->Write();
353 
354  gDirectory = tmpDir;
355 
356  fOutFile->Close();
357 
358  if (fSaveJSON) {
359  gSystem->ChangeDirectory("bee");
360  system("zip -r bee_upload data");
361  gSystem->ChangeDirectory("..");
362  }
363 }
364 
365 //-----------------------------------------------------------------------
366 void CellTree::beginRun(const art::Run& /*run*/)
367 {
368  mf::LogInfo("CellTree") << "begin run";
369 }
370 
371 //-----------------------------------------------------------------------
372 void CellTree::analyze( const art::Event& event )
373 {
374  reset();
375  fEvent = event.id().event();
376  fRun = event.run();
377  fSubRun = event.subRun();
378  art::Timestamp ts = event.time();
379  TTimeStamp tts(ts.timeHigh(), ts.timeLow());
380  fEventTime = tts.AsDouble();
381 
382  if (fSaveRaw) processRaw(event);
383  if (fSaveCalib) processCalib(event);
384  if (fSaveOpHit) processOpHit(event);
385  if (fSaveOpFlash) processOpFlash(event);
387  if (fSaveMC) processMC(event);
388  if (fSaveTrigger) processTrigger(event);
389 
390  if (fSaveJSON) {
391  gSystem->MakeDirectory(TString::Format("bee/data/%i", entryNo).Data());
392  int nSp = fSpacePointLabels.size();
393  for (int i=0; i<nSp; i++) {
394  TString jsonfile;
395  jsonfile.Form("bee/data/%i/%i-%s.json", entryNo, entryNo, fSpacePointLabels[i].c_str());
396  std::ofstream out(jsonfile.Data());
397  if (fSpacePointLabels[i] == "truthDepo") {
399  }
400  else {
401  processSpacePoint(event, fSpacePointLabels[i], out);
402  }
403  out.close();
404  }
405 
406  if(fSaveMC) {
407  processMCTracks();
408  TString jsonfile;
409  jsonfile.Form("bee/data/%i/%i-mc.json", entryNo, entryNo);
410  std::ofstream out(jsonfile.Data());
411  DumpMCJSON(out);
412  out.close();
413  }
414  }
415 
416  // printEvent();
417  fEventTree->Fill();
418 
419  entryNo++;
420 }
421 
422 //-----------------------------------------------------------------------
424 {
425 
426  fRaw_channelId.clear();
427  // fRaw_wf->Clear();
428  fRaw_wf->Delete();
429 
430  fCalib_channelId.clear();
431  fCalib_wf->Clear();
432 
433  oh_channel.clear();
434  oh_bgtime.clear();
435  oh_trigtime.clear();
436  oh_pe.clear();
437 
438  of_t.clear();
439  of_peTotal.clear();
440  of_multiplicity.clear();
441  fPEperOpDet->Delete();
442 
443  fSIMIDE_channelIdY.clear();
444  fSIMIDE_trackId.clear();
445  fSIMIDE_tdc.clear();
446  fSIMIDE_x.clear();
447  fSIMIDE_y.clear();
448  fSIMIDE_z.clear();
449  fSIMIDE_numElectrons.clear();
450 
451  mc_Ntrack = 0;
452  for (int i=0; i<MAX_TRACKS; i++) {
453  mc_id[i] = 0;
454  mc_pdg[i] = 0;
455  mc_mother[i] = 0;
456  for (int j=0; j<4; j++) {
457  mc_startXYZT[i][j] = 0;
458  mc_endXYZT[i][j] = 0;
459  mc_startMomentum[i][j] = 0;
460  mc_endMomentum[i][j] = 0;
461  }
462  }
463  mc_daughters.clear();
464  savedMCTrackIdMap.clear();
465  fMC_trackPosition->Clear();
466 
467  mc_isnu = 0;
468  mc_nGeniePrimaries = -1;
469  mc_nu_pdg = -1;
470  mc_nu_ccnc = -1;
471  mc_nu_mode = -1;
472  mc_nu_intType = -1;
473  mc_nu_target = -1;
474  mc_hitnuc = -1;
475  mc_hitquark = -1;
476  mc_nu_Q2 = -1;
477  mc_nu_W = -1;
478  mc_nu_X = -1;
479  mc_nu_Y = -1;
480  mc_nu_Pt = -1;
481  mc_nu_Theta = -1;
482  for (int i=0; i<4; i++) {
483  mc_nu_pos[i] = 0;
484  mc_nu_mom[i] = 0;
485  }
486 
487  trackIndex.clear();
488  trackParents.clear();
489  trackChildren.clear();
490  trackSiblings.clear();
491 }
492 
493 //-----------------------------------------------------------------------
494 void CellTree::processRaw( const art::Event& event )
495 {
496  art::Handle< std::vector<raw::RawDigit> > rawdigit;
497  if (! event.getByLabel(fRawDigitLabel, rawdigit)) {
498  cout << "WARNING: no label " << fRawDigitLabel << endl;
499  return;
500  }
501  std::vector< art::Ptr<raw::RawDigit> > wires;
502  art::fill_ptr_vector(wires, rawdigit);
503 
504  fRaw_nChannel = wires.size();
505 
506  int i=0;
507  for (auto const& wire: wires) {
508  int chanId = wire->Channel();
509  fRaw_channelId.push_back(chanId);
510 
511  int nSamples = wire->Samples();
512  std::vector<short> uncompressed(nSamples);
513  raw::Uncompress(wire->ADCs(), uncompressed, wire->Compression());
514 
515  TH1F *h = new((*fRaw_wf)[i]) TH1F("", "", nRawSamples, 0, nRawSamples);
516  for (int j=1; j<=nSamples; j++) {
517  h->SetBinContent(j, uncompressed[j-1]);
518  }
519  i++;
520  if (i==1) {
521  cout << nSamples << " samples expanding to " << nRawSamples << endl;
522  }
523  }
524 
525 }
526 
527 //-----------------------------------------------------------------------
528 void CellTree::processCalib( const art::Event& event )
529 {
530 
531  art::Handle< std::vector<recob::Wire> > wires_handle;
532  if (! event.getByLabel(fCalibLabel, wires_handle)) {
533  cout << "WARNING: no label " << fCalibLabel << endl;
534  return;
535  }
536  std::vector< art::Ptr<recob::Wire> > wires;
537  art::fill_ptr_vector(wires, wires_handle);
538 
539  // wires size should == Nchannels == 1992; (no hit channel has a flat 0-waveform)
540  // cout << "\n wires size: " << wires.size() << endl;
541  fCalib_nChannel = wires.size();
542 
543  int i=0;
544  for (auto const& wire: wires) {
545  std::vector<float> calibwf = wire->Signal();
546  int chanId = wire->Channel();
547  fCalib_channelId.push_back(chanId);
548  TH1F *h = new((*fCalib_wf)[i]) TH1F("", "", nRawSamples, 0, nRawSamples);
549  for (int j=1; j<=nRawSamples; j++) {
550  h->SetBinContent(j, calibwf[j]);
551  }
552  // fCalib_wf.push_back(calibwf);
553  // cout << chanId << ", " << nSamples << endl;
554  i++;
555  }
556 
557 }
558 
559  //----------------------------------------------------------------------
560 void CellTree::processOpHit( const art::Event& event)
561 {
562  art::Handle<std::vector<recob::OpHit> > ophit_handle;
563  if(! event.getByLabel(fOpHitLabel, ophit_handle)){
564  cout << "WARNING: no label " << fOpHitLabel << endl;
565  return;
566  }
567  std::vector<art::Ptr<recob::OpHit> > ophits;
568  art::fill_ptr_vector(ophits, ophit_handle);
569  oh_nHits = (int)ophits.size();
570 
571  for(auto const& oh : ophits){
572  oh_channel.push_back(oh->OpChannel());
573  oh_bgtime.push_back(oh->PeakTime());
574  oh_trigtime.push_back(oh->PeakTimeAbs());
575  oh_pe.push_back(oh->PE());
576  }
577 
578 }
579 
580  //----------------------------------------------------------------------
581  void CellTree::processOpFlash( const art::Event& event)
582  {
583  art::Handle<std::vector<recob::OpFlash> > flash_handle;
584  if(! event.getByLabel(fOpFlashLabel, flash_handle)){
585  cout << "WARNING: no label " << fOpFlashLabel << endl;
586  return;
587  }
588  std::vector<art::Ptr<recob::OpFlash> > flashes;
589  art::fill_ptr_vector(flashes, flash_handle);
590  of_nFlash = (int)flashes.size();
591 
592  int a=0;
593  int nOpDet = fGeometry->NOpDets();
594 
595  for(auto const& flash: flashes){
596  of_t.push_back(flash->Time());
597  of_peTotal.push_back(flash->TotalPE());
598  TH1F *h = new ((*fPEperOpDet)[a]) TH1F("","",nOpDet,0,nOpDet);
599 
600  int mult = 0;
601  for(int i=0; i<nOpDet; ++i){
602  if(flash->PE(i) >= opMultPEThresh){
603  mult++;
604  }
605  h->SetBinContent(i, flash->PE(i));
606  }
607  of_multiplicity.push_back(mult);
608  a++;
609  }
610  }
611 
612 //-----------------------------------------------------------------------
613 void CellTree::processSimChannel( const art::Event& event )
614 {
615  art::Handle< std::vector<sim::SimChannel> > simChannelHandle;
616  // event.getByLabel("largeant", simChannelHandle);
617  if (! event.getByLabel(fSimChannelLabel, simChannelHandle)) {
618  cout << "WARNING: no label " << fSimChannelLabel << endl;
619  return;
620  }
621 
622  // cout << "total simChannel: " << (*simChannelHandle).size() << endl;
623  fSIMIDE_size = 0;
624  for ( auto const& channel : (*simChannelHandle) ) {
625  auto channelNumber = channel.Channel();
626  // cout << channelNumber << endl;
627  // if (! (fGeometry->SignalType( channelNumber ) == geo::kCollection) ) {
628  // continue;
629  // }
630  auto const& timeSlices = channel.TDCIDEMap();
631  for ( auto const& timeSlice : timeSlices ) {
632  auto const& energyDeposits = timeSlice.second;
633  for ( auto const& energyDeposit : energyDeposits ) {
634  fSIMIDE_size++;
635  fSIMIDE_channelIdY.push_back(channelNumber);
636  fSIMIDE_tdc.push_back(timeSlice.first);
637  fSIMIDE_trackId.push_back(energyDeposit.trackID);
638  fSIMIDE_x.push_back(energyDeposit.x);
639  fSIMIDE_y.push_back(energyDeposit.y);
640  fSIMIDE_z.push_back(energyDeposit.z);
641  fSIMIDE_numElectrons.push_back(energyDeposit.numElectrons);
642  // cout << channelNumber << ": " << energyDeposit.trackID << ": " << timeSlice.first << ": "
643  // << energyDeposit.x << ", " << energyDeposit.y << ", " << energyDeposit.z << ", "
644  // << energyDeposit.numElectrons << endl;
645  }
646  }
647 
648  }
649  cout << "total IDEs: " << fSIMIDE_size << endl;
650 
651 
652 }
653 
654 //-----------------------------------------------------------------------
655 void CellTree::processMC( const art::Event& event )
656 {
657  art::Handle< std::vector<simb::MCParticle> > particleHandle;
658  if (! event.getByLabel("largeant", particleHandle)) return;
659  std::vector< art::Ptr<simb::MCParticle> > particles;
660  art::fill_ptr_vector(particles, particleHandle);
661 
662  art::Handle< std::vector<sim::SimChannel> > simChannelHandle;
663  event.getByLabel("largeant", simChannelHandle);
664 
665  // art::ServiceHandle<cheat::BackTracker const> bt;
666  art::FindOneP<simb::MCTruth> fo(particleHandle, event, "largeant");
667 
668  int i=0; // track index in saved MCParticles;
669  int i_all=0; // track index in all MCParticles;
670  for (auto const& particle: particles ) {
671  art::Ptr<simb::MCTruth> mctruth = fo.at(i_all);
672  i_all++;
673 
674  if (mcOption == "nuOnly") {
675  if ( !(mctruth->Origin() == 1 && particle->Mother() == 0) ) {
676  continue;
677  }
678  }
679 
680  // if (mctruth->Origin() == 1 || mc_mother[i] == 0) {
681  // cout << "process: " << particle->Process()
682  // << ", id: " << mc_id[i]
683  // << ", pdg: " << mc_pdg[i]
684  // << ", mother: " << mc_mother[i]
685  // << ", nDaughter: " << (particle->NumberDaughters())
686  // << ", truth: " << mctruth->Origin()
687  // << endl;
688  // }
689  // const art::Ptr<simb::MCTruth> mctruth = bt_serv->TrackIDToMCTruth(mc_id[i]);
690 
691  mc_process[i] = processMap[particle->Process()];
692  if (mc_process[i] == 0) cout << "unknown process: " << particle->Process() << endl;
693  mc_id[i] = particle->TrackId();
694  mc_pdg[i] = particle->PdgCode();
695  mc_mother[i] = particle->Mother();
696  savedMCTrackIdMap[mc_id[i]] = mc_pdg[i];
697 
698  int Ndaughters = particle->NumberDaughters();
699  vector<int> daughters;
700  for (int i=0; i<Ndaughters; i++) {
701  daughters.push_back(particle->Daughter(i));
702  }
703  mc_daughters.push_back(daughters);
704  size_t numberTrajectoryPoints = particle->NumberTrajectoryPoints();
705  int last = numberTrajectoryPoints - 1;
706  const TLorentzVector& positionStart = particle->Position(0);
707  const TLorentzVector& positionEnd = particle->Position(last);
708  const TLorentzVector& momentumStart = particle->Momentum(0);
709  const TLorentzVector& momentumEnd = particle->Momentum(last);
710  positionStart.GetXYZT(mc_startXYZT[i]);
711  positionEnd.GetXYZT(mc_endXYZT[i]);
712  momentumStart.GetXYZT(mc_startMomentum[i]);
713  momentumEnd.GetXYZT(mc_endMomentum[i]);
714 
715  if (fSaveMCTrackPoints) {
716  TClonesArray *Lposition = new TClonesArray("TLorentzVector", numberTrajectoryPoints);
717  // Read the position and momentum along this particle track
718  for(unsigned int j=0; j<numberTrajectoryPoints; j++) {
719  new ((*Lposition)[j]) TLorentzVector(particle->Position(j));
720  }
721  fMC_trackPosition->Add(Lposition);
722  }
723 
724  i++;
725  if (i==MAX_TRACKS) {
726  cout << "WARNING:: # tracks exceeded MAX_TRACKS " << MAX_TRACKS << endl;
727  break;
728  }
729  } // particle loop done
730  mc_Ntrack = i;
731  // cout << "MC_Ntracks:" << mc_Ntrack << endl;
732 
733  // Generator Info
734  art::Handle< std::vector<simb::MCTruth> > mctruthListHandle;
735  event.getByLabel("generator",mctruthListHandle);
736  std::vector<art::Ptr<simb::MCTruth> > mclist;
737  art::fill_ptr_vector(mclist, mctruthListHandle);
738  art::Ptr<simb::MCTruth> mctruth;
739 
740  if (mclist.size()>0) {
741  mctruth = mclist.at(0);
742  if (mctruth->NeutrinoSet()) {
743  simb::MCNeutrino nu = mctruth->GetNeutrino();
744  mc_isnu = 1;
745  mc_nGeniePrimaries = mctruth->NParticles();
746  mc_nu_pdg = nu.Nu().PdgCode();
747  mc_nu_ccnc = nu.CCNC();
748  mc_nu_mode = nu.Mode();
749  mc_nu_intType = nu.InteractionType();
750  mc_nu_target = nu.Target();
751  mc_hitnuc = nu.HitNuc();
752  mc_hitquark = nu.HitQuark();
753  mc_nu_Q2 = nu.QSqr();
754  mc_nu_W = nu.W();
755  mc_nu_X = nu.X();
756  mc_nu_Y = nu.Y();
757  mc_nu_Pt = nu.Pt();
758  mc_nu_Theta = nu.Theta();
759 
760  const TLorentzVector& position = nu.Nu().Position(0);
761  const TLorentzVector& momentum = nu.Nu().Momentum(0);
762  position.GetXYZT(mc_nu_pos);
763  momentum.GetXYZT(mc_nu_mom);
764  // cout << "nu: " << mc_nu_pdg << ", nPrim: " << mc_nGeniePrimaries
765  // << ", ccnc: " << mc_nu_ccnc << endl;
766  // for (int i=0; i<mc_nGeniePrimaries; i++) {
767  // simb::MCParticle particle = mctruth->GetParticle(i);
768  // cout << "id: " << particle.TrackId()
769  // << ", pdg: " << particle.PdgCode()
770  // << endl;
771  // }
772  }
773  }
774 
775 }
776 
777 
778 //-----------------------------------------------------------------------
779 void CellTree::processSpacePoint( const art::Event& event, TString option, ostream& out)
780 {
781 
782  art::Handle< std::vector<recob::SpacePoint> > sp_handle;
783  art::Handle< std::vector<recob::PointCharge> > pc_handle;
784  bool sp_exists = event.getByLabel(option.Data(), sp_handle);
785  bool pc_exists = event.getByLabel(option.Data(), pc_handle);
786  if (! sp_exists) {
787  cout << "WARNING: no label " << option << endl;
788  return;
789  }
790  std::vector< art::Ptr<recob::SpacePoint> > sps;
791  std::vector< art::Ptr<recob::PointCharge> > pcs;
792  art::fill_ptr_vector(sps, sp_handle);
793  if (pc_exists) {
794  art::fill_ptr_vector(pcs, pc_handle);
795  if (sps.size() != pcs.size()) {
796  cout << "WARNING: SpacePoint and PointCharge length mismatch" << endl;
797  return;
798  }
799  }
800  double x=0, y=0, z=0, q=0, nq=1;
801  vector<double> vx, vy, vz, vq, vnq;
802 
803  for (uint i=0; i < sps.size(); i++ ) {
804  // cout << sp->XYZ()[0] << ", " << sp->XYZ()[1] << ", " << sp->XYZ()[2] << endl;
805  x = sps[i]->XYZ()[0];
806  y = sps[i]->XYZ()[1];
807  z = sps[i]->XYZ()[2];
808  if (pc_exists && pcs[i]->hasCharge()) {
809  q = pcs[i]->charge();
810  } else {
811  q = 0;
812  }
813  vx.push_back(x);
814  vy.push_back(y);
815  vz.push_back(z);
816  vq.push_back(q);
817  vnq.push_back(nq);
818  }
819 
820  out << fixed << setprecision(1);
821  out << "{" << endl;
822 
823  out << '"' << "runNo" << '"' << ":" << '"' << fRun << '"' << "," << endl;
824  out << '"' << "subRunNo" << '"' << ":" << '"' << fSubRun << '"' << "," << endl;
825  out << '"' << "eventNo" << '"' << ":" << '"' << fEvent << '"' << "," << endl;
826 
827  TString geomName(fGeometry->DetectorName().c_str());
828  if (geomName.Contains("35t")) { geomName = "dune35t"; }
829  else if (geomName.Contains("protodune")) { geomName = "protodune"; }
830  else if (geomName.Contains("workspace")) { geomName = "dune10kt_workspace"; }
831  else if (geomName.Contains("icarus")) { geomName = "icarus"; }
832  else { geomName = "uboone"; } // use uboone as default
833  out << '"' << "geom" << '"' << ":" << '"' << geomName << '"' << "," << endl;
834 
835 
836  print_vector(out, vx, "x");
837  print_vector(out, vy, "y");
838  print_vector(out, vz, "z");
839 
840  out << fixed << setprecision(0);
841  print_vector(out, vq, "q");
842  print_vector(out, vnq, "nq");
843 
844  out << '"' << "type" << '"' << ":" << '"' << option << '"' << endl;
845  out << "}" << endl;
846 }
847 
848 //-----------------------------------------------------------------------
849 void CellTree::processSpacePointTruthDepo( const art::Event& event, TString option, ostream& out)
850 {
851 
852  art::Handle< std::vector<sim::SimEnergyDeposit> > sed_handle;
853  if (!event.getByLabel(fSimEnergyDepositLabel, sed_handle)) {
854  cout << "WARNING: no label " << fSimEnergyDepositLabel << " for SimEnergyDeposit" << endl;
855  return;
856  }
857  std::vector< art::Ptr<sim::SimEnergyDeposit> > sed;
858  art::fill_ptr_vector(sed, sed_handle);
859  int size = sed.size();
860  double x=0, y=0, z=0, q=0, nq=1;
861  vector<double> vx, vy, vz, vq, vnq;
862 
863  for (int i=0; i < size; i++ ) {
864  // cout << sp->XYZ()[0] << ", " << sp->XYZ()[1] << ", " << sp->XYZ()[2] << endl;
865  x = sed[i]->MidPointX();
866  y = sed[i]->MidPointY();
867  z = sed[i]->MidPointZ();
868  q = sed[i]->NumElectrons();
869  if (q<0) q = sed[i]->Energy()*25000; // approx. #electrons
870  // cout << q << ", " << sed[i]->Energy()*25000 << endl;
871  if (q<1000) continue; // skip small dots to reduce size
872  vx.push_back(x);
873  vy.push_back(y);
874  vz.push_back(z);
875  vq.push_back(q);
876  vnq.push_back(nq);
877  }
878 
879  out << fixed << setprecision(1);
880  out << "{" << endl;
881 
882  out << '"' << "runNo" << '"' << ":" << '"' << fRun << '"' << "," << endl;
883  out << '"' << "subRunNo" << '"' << ":" << '"' << fSubRun << '"' << "," << endl;
884  out << '"' << "eventNo" << '"' << ":" << '"' << fEvent << '"' << "," << endl;
885 
886  TString geomName(fGeometry->DetectorName().c_str());
887  if (geomName.Contains("35t")) { geomName = "dune35t"; }
888  else if (geomName.Contains("protodune")) { geomName = "protodune"; }
889  else if (geomName.Contains("workspace")) { geomName = "dune10kt_workspace"; }
890  else if (geomName.Contains("icarus")) { geomName = "icarus"; }
891  else { geomName = "uboone"; } // use uboone as default
892  out << '"' << "geom" << '"' << ":" << '"' << geomName << '"' << "," << endl;
893 
894  print_vector(out, vx, "x");
895  print_vector(out, vy, "y");
896  print_vector(out, vz, "z");
897 
898  out << fixed << setprecision(0);
899  print_vector(out, vq, "q");
900  print_vector(out, vnq, "nq");
901 
902  out << '"' << "type" << '"' << ":" << '"' << option << '"' << endl;
903  out << "}" << endl;
904 }
905 
906 //-----------------------------------------------------------------------
907 void CellTree::print_vector(ostream& out, vector<double>& v, TString desc, bool end)
908 {
909  int N = v.size();
910 
911  out << '"' << desc << '"' << ":[";
912  for (int i=0; i<N; i++) {
913  out << v[i];
914  if (i!=N-1) {
915  out << ",";
916  }
917  }
918  out << "]";
919  if (!end) out << ",";
920  out << endl;
921 }
922 
923 //-----------------------------------------------------------------------
925 {
926  // map track id to track index in the array
927  for (int i=0; i<mc_Ntrack; i++) {
928  trackIndex[mc_id[i]] = i;
929  }
930 
931  // in trackParents, trackChildren, trackSiblings vectors, store track index (not track id)
932  for (int i=0; i<mc_Ntrack; i++) {
933  // currently, parent size == 1;
934  // for primary particle, parent id = 0;
935  vector<int> parents;
936  if ( !IsPrimary(i) ) {
937  parents.push_back(trackIndex[mc_mother[i]]);
938  }
939  trackParents.push_back(parents); // primary track will have 0 parents
940 
941  vector<int> children;
942  int nChildren = mc_daughters.at(i).size();
943  for (int j=0; j<nChildren; j++) {
944  children.push_back(trackIndex[mc_daughters.at(i).at(j)]);
945  }
946  trackChildren.push_back(children);
947 
948  }
949 
950  // siblings
951  for (int i=0; i<mc_Ntrack; i++) {
952  vector<int> siblings;
953  if ( IsPrimary(i) ) {
954  for (int j=0; j<mc_Ntrack; j++) {
955  if( IsPrimary(j) ) {
956  siblings.push_back(j);
957  }
958  }
959  }
960  else {
961  // siblings are simply children of the mother
962  int mother = trackIndex[mc_mother[i]];
963  int nSiblings = trackChildren.at(mother).size();
964  for (int j=0; j<nSiblings; j++) {
965  siblings.push_back(trackChildren.at(mother).at(j));
966  }
967  }
968  trackSiblings.push_back(siblings);
969  }
970 
971 }
972 
973 //-----------------------------------------------------------------------
974 void CellTree::processTrigger(const art::Event& event)
975 {
976  art::Handle< std::vector<raw::Trigger>> triggerListHandle;
977  std::vector<art::Ptr<raw::Trigger>> triggerlist;
978  if (event.getByLabel(fTriggerLabel, triggerListHandle)) {
979  art::fill_ptr_vector(triggerlist, triggerListHandle);
980  }
981  else {
982  cout << "WARNING: no trigger label " << fTriggerLabel << endl;
983  }
984  if (triggerlist.size()){
985  fTriggernumber = triggerlist[0]->TriggerNumber();
986  fTriggertime = triggerlist[0]->TriggerTime();
987  fBeamgatetime = triggerlist[0]->BeamGateTime();
988  fTriggerbits = triggerlist[0]->TriggerBits();
989  }
990  else {
991  fTriggernumber = 0;
992  fTriggertime = 0;
993  fBeamgatetime = 0;
994  fTriggerbits = 0;
995  }
996 }
997 
998 //-----------------------------------------------------------------------
999 bool CellTree::DumpMCJSON(int id, ostream& out)
1000 {
1001  int i = trackIndex[id];
1002  if (!KeepMC(i)) return false;
1003 
1004  int e = KE(mc_startMomentum[i])*1000;
1005 
1006  int nDaughter = mc_daughters.at(i).size();
1007  vector<int> saved_daughters;
1008  for (int j=0; j<nDaughter; j++) {
1009  int daughter_id = mc_daughters.at(i).at(j);
1010  // int e_daughter = KE(mc_startMomentum[ trackIndex[daughter_id] ])*1000;
1011  // if (e_daughter >= thresh_KE) {
1012  if ( KeepMC(trackIndex[daughter_id]) ) {
1013  saved_daughters.push_back(daughter_id);
1014  }
1015  }
1016 
1017  vector<double> vx, vy, vz;
1018  if (fSaveMCTrackPoints) {
1019  // fMC_trackPosition->Print();
1020  TClonesArray *traj = (TClonesArray*)(*fMC_trackPosition)[i];
1021  int nPoints = traj->GetEntries();
1022  // cout << "traj points: " << nPoints << endl;
1023  for(int j=0; j<nPoints; j++) {
1024  TLorentzVector* pos = (TLorentzVector*)(*traj)[j];
1025  vx.push_back(pos->X());
1026  vy.push_back(pos->Y());
1027  vz.push_back(pos->Z());
1028  }
1029  }
1030 
1031  out << fixed << setprecision(1);
1032  out << "{";
1033 
1034  out << "\"id\":" << id << ",";
1035  out << "\"text\":" << "\"" << PDGName(mc_pdg[i]) << " " << e << " MeV\",";
1036  out << "\"data\":{";
1037  print_vector(out, vx, "traj_x");
1038  print_vector(out, vy, "traj_y");
1039  print_vector(out, vz, "traj_z");
1040  out << "\"start\":[" << mc_startXYZT[i][0] << ", " << mc_startXYZT[i][1] << ", " << mc_startXYZT[i][2] << "],";
1041  out << "\"end\":[" << mc_endXYZT[i][0] << ", " << mc_endXYZT[i][1] << ", " << mc_endXYZT[i][2] << "]";
1042  out << "},";
1043  out << "\"children\":[";
1044  int nSavedDaughter = saved_daughters.size();
1045  if (nSavedDaughter == 0) {
1046  out << "],";
1047  out << "\"icon\":" << "\"jstree-file\"";
1048  out << "}";
1049  return true;
1050  }
1051  else {
1052  for (int j=0; j<nSavedDaughter; j++) {
1053  DumpMCJSON(saved_daughters.at(j), out);
1054  if (j!=nSavedDaughter-1) {
1055  out << ",";
1056  }
1057  }
1058  out << "]";
1059  out << "}";
1060  return true;
1061  }
1062 }
1063 
1064 //-----------------------------------------------------------------------
1065 void CellTree::DumpMCJSON(ostream& out)
1066 {
1067  out << "[";
1068  vector<int> primaries;
1069  for (int i=0; i<mc_Ntrack; i++) {
1070  if (IsPrimary(i)) {
1071  // int e = KE(mc_startMomentum[i])*1000;
1072  // if (e<thresh_KE) continue;
1073  if (KeepMC(i)) {
1074  primaries.push_back(i);
1075  }
1076  }
1077  }
1078  int size = primaries.size();
1079  // cout << size << endl;
1080  for (int i=0; i<size; i++) {
1081  if (DumpMCJSON(mc_id[primaries[i]], out) && i!=size-1) {
1082  out << ", ";
1083  }
1084  }
1085 
1086  out << "]";
1087 }
1088 
1089 //-----------------------------------------------------------------------
1090 double CellTree::KE(float* momentum)
1091 {
1092  TLorentzVector particle(momentum);
1093  return particle.E()-particle.M();
1094 }
1095 
1096 //-----------------------------------------------------------------------
1097 bool CellTree::KeepMC(int i)
1098 {
1099  double e = KE(mc_startMomentum[i])*1000;
1100  double thresh_KE_em = 5.; // MeV
1101  double thresh_KE_np = 50; // MeV
1102  // cout << "pdg: " << mc_pdg[i] << ", KE: " << e << " MeV, process: " << mc_process[i] << endl;
1103  if (mc_process[i] == 8 // muIoni
1104  || mc_process[i] == 6 // eBrem
1105  || mc_process[i] == 5 // eIoni
1106  ) {
1107  return false; // skip those ionization and radiation electrons as there are too many to show.
1108  }
1109 
1110  if (mc_pdg[i]==22 || mc_pdg[i]==11 || mc_pdg[i]==-11) {
1111  if (e>=thresh_KE_em) return true;
1112  else return false;
1113  }
1114  else if (mc_pdg[i]==2112 || mc_pdg[i]==2212 || mc_pdg[i]>1e9) {
1115  if (e>=thresh_KE_np) return true;
1116  else return false;
1117  }
1118  return true;
1119 }
1120 
1121 //-----------------------------------------------------------------------
1123 {
1124  TParticlePDG *p = dbPDG->GetParticle(pdg);
1125  if (p == 0) {
1126  if (pdg>1e9) {
1127  int z = (pdg - 1e9) / 10000;
1128  int a = (pdg - 1e9 - z*1e4) / 10;
1129  TString name;
1130  if (z == 18) name = "Ar";
1131 
1132  else if (z == 17) name = "Cl";
1133  else if (z == 19) name = "Ca";
1134  else if (z == 16) name = "S";
1135  else if (z == 15) name = "P";
1136  else if (z == 14) name = "Si";
1137  else if (z == 1) name = "H";
1138  else if (z == 2) name = "He";
1139 
1140  else return Form("%i", pdg);
1141  return Form("%s-%i", name.Data(), a);
1142  }
1143  return Form("%i", pdg);
1144  }
1145  else {
1146  return p->GetName();
1147  }
1148 }
1149 
1150 //-----------------------------------------------------------------------
1152 {
1153  cout << " Run/SubRun/Event: " << fRun << "/" << fSubRun << "/" << fEvent << endl;
1154  cout << " Ntracks:" << mc_Ntrack << endl;
1155 
1156  for (int i=0; i<mc_Ntrack; i++) {
1157  cout << "\n id: " << mc_id[i];
1158  cout << "\n pdg: " << mc_pdg[i];
1159  cout << "\n mother: " << mc_mother[i];
1160  cout << "\n Ndaughters: " << mc_daughters.at(i).size();
1161  cout << "\n start XYZT: (" << mc_startXYZT[i][0] << ", " << mc_startXYZT[i][1] << ", " << mc_startXYZT[i][2] << ", " << mc_startXYZT[i][3] << ")";
1162  cout << "\n end XYZT: (" << mc_endXYZT[i][0] << ", " << mc_endXYZT[i][1] << ", " << mc_endXYZT[i][2] << ", " << mc_endXYZT[i][3] << ")";
1163  cout << "\n start momentum: (" << mc_startMomentum[i][0] << ", " << mc_startMomentum[i][1] << ", " << mc_startMomentum[i][2] << ", " << mc_startMomentum[i][3] << ")";
1164  cout << "\n end momentum: (" << mc_endMomentum[i][0] << ", " << mc_endMomentum[i][1] << ", " << mc_endMomentum[i][2] << ", " << mc_endMomentum[i][3] << ")";
1165 
1166  cout << endl;
1167  }
1168 }
1169 
1170 //-----------------------------------------------------------------------
1172 {
1173  processMap["unknown"] = 0;
1174  processMap["primary"] = 1;
1175  processMap["compt"] = 2;
1176  processMap["phot"] = 3;
1177  processMap["annihil"] = 4;
1178  processMap["eIoni"] = 5;
1179  processMap["eBrem"] = 6;
1180  processMap["conv"] = 7;
1181  processMap["muIoni"] = 8;
1182  processMap["muMinusCaptureAtRest"] = 9;
1183  processMap["neutronInelastic"] = 10;
1184  processMap["nCapture"] = 11;
1185  processMap["hadElastic"] = 12;
1186  processMap["Decay"] = 13;
1187  processMap["CoulombScat"] = 14;
1188  processMap["muPairProd"] = 15;
1189  processMap["muBrems"] = 16;
1190  processMap["muPairProd"] = 17;
1191  processMap["PhotonInelastic"] = 18;
1192  processMap["hIoni"] = 19;
1193  processMap["protonInelastic"] = 20;
1194  processMap["pi+Inelastic"] = 21;
1195  processMap["CHIPSNuclearCaptureAtRest"] = 22;
1196  processMap["pi-Inelastic"] = 23;
1197 }
1198 
1199 //-----------------------------------------------------------------------
1200 DEFINE_ART_MODULE(CellTree)
1201 } // namespace microboone
float mc_startMomentum[MAX_TRACKS][4]
std::vector< std::vector< int > > trackChildren
process_name opflash particleana ie ie ie z
process_name opflashCryo1 flashfilter analyze
vector< double > oh_pe
vector< int > fSIMIDE_channelIdY
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
std::map< int, int > trackIndex
var pdg
Definition: selectors.fcl:14
vector< int > fSIMIDE_trackId
process_name opflash particleana ie x
std::string fSimChannelLabel
float mc_endXYZT[MAX_TRACKS][4]
void processMCTracks()
void processRaw(const art::Event &evt)
int mc_id[MAX_TRACKS]
TString PDGName(int pdg)
pdgs p
Definition: selectors.fcl:22
void processSpacePointTruthDepo(const art::Event &event, TString option, ostream &out=cout)
int mc_pdg[MAX_TRACKS]
std::vector< std::vector< int > > trackSiblings
vector< int > of_multiplicity
Definition of basic raw digits.
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
Information about charge reconstructed in the active volume.
vector< float > fSIMIDE_y
void processSimChannel(const art::Event &evt)
art::ServiceHandle< geo::Geometry const > fGeometry
std::string fOutFileName
std::string fRawDigitLabel
vector< float > fSIMIDE_x
bool DumpMCJSON(int id, ostream &out)
int mc_mother[MAX_TRACKS]
process_name gaushit a
vector< unsigned short > fSIMIDE_tdc
while getopts h
std::map< int, int > savedMCTrackIdMap
float mc_endMomentum[MAX_TRACKS][4]
vector< int > oh_channel
std::string fOpHitLabel
std::string fOpFlashLabel
int mc_process[MAX_TRACKS]
void analyze(const art::Event &evt)
void print_vector(ostream &out, vector< double > &v, TString desc, bool end=false)
process_name opflash particleana ie ie y
vector< double > oh_bgtime
bool KeepMC(int i)
TDatabasePDG * dbPDG
void processOpFlash(const art::Event &evt)
vector< double > oh_trigtime
TClonesArray * fCalib_wf
Collect all the RawData header files together.
TObjArray * fMC_trackPosition
std::vector< int > fRaw_channelId
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
vector< float > fSIMIDE_z
unsigned int fTriggerbits
std::string fSimEnergyDepositLabel
#define MAX_TRACKS
void processOpHit(const art::Event &evt)
std::vector< std::vector< int > > mc_daughters
TClonesArray * fRaw_wf
void beginRun(const art::Run &run)
unsigned int fTriggernumber
double KE(float *momentum)
std::string mcOption
std::vector< int > fCalib_channelId
void processCalib(const art::Event &evt)
std::string fCalibLabel
float mc_nu_mom[4]
contains information for a single step in the detector simulation
void processMC(const art::Event &evt)
process_name largeant stream1 can override from command line with o or output physics producers generator N
std::vector< std::string > fSpacePointLabels
object containing MC truth information necessary for making RawDigits and doing back tracking ...
TClonesArray * fPEperOpDet
do i e
vector< float > fSIMIDE_numElectrons
std::string fTriggerLabel
std::map< std::string, int > processMap
Declaration of basic channel signal object.
float mc_startXYZT[MAX_TRACKS][4]
then echo fcl name
echo Invalid option
Definition: TrainMVA.sh:17
TCEvent evt
Definition: DataStructs.cxx:8
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
void processSpacePoint(const art::Event &event, TString option, ostream &out=cout)
bool IsPrimary(int i)
vector< float > of_peTotal
BEGIN_PROLOG SN nu
float mc_nu_pos[4]
art framework interface to geometry description
BEGIN_PROLOG could also be cout
void processTrigger(const art::Event &evt)
vector< float > of_t
std::vector< std::vector< int > > trackParents