SNAna_module.cc
Go to the documentation of this file.
1 #include <functional> // std::greater
2 
3 //ROOT includes
4 #include "TH1I.h"
5 #include "TH1F.h"
6 #include "TH2F.h"
7 #include "TTree.h"
8 #include "TMath.h"
9 #include "TGeoMatrix.h" // TGeoHMatrix
10 
11 // LArSoft libraries
12 
13 //LArSoft includes
15 
18 
21 
23 #include "lardataobj/RawData/raw.h"
30 
33 
37 
38 //ART includes
45 #include "art_root_io/TFileDirectory.h"
46 #include "art_root_io/TFileService.h"
50 #include "canvas/Persistency/Common/FindMany.h"
51 #include "canvas/Persistency/Common/FindManyP.h"
52 #include "canvas/Persistency/Common/FindOneP.h"
53 
54 #include "fhiclcpp/ParameterSet.h"
56 
58 std::map<PType, std::string> PTypeString{
59  {kUnknown,"Unknown"},
60  {kMarl ,"Marl" },
61  {kAPA ,"APA" },
62  {kCPA ,"CPA" },
63  {kAr39 ,"Ar39" },
64  {kNeut ,"Neut" },
65  {kKryp ,"Kryp" },
66  {kPlon ,"Plon" },
67  {kRdon ,"Rdon" },
68  {kAr42 ,"Ar42" }};
69 
70 
71 class SNAna : public art::EDAnalyzer {
72 
73 public:
74  explicit SNAna(fhicl::ParameterSet const & p);
75 
76  SNAna(SNAna const &) = delete;
77  SNAna(SNAna &&) = delete;
78  SNAna & operator = (SNAna const &) = delete;
79  SNAna & operator = (SNAna &&) = delete;
80 
81  void analyze(art::Event const & evt) override;
82  void reconfigure(fhicl::ParameterSet const & p);
83  void beginJob() override;
84  void endJob() override;
85 
86 private:
87 
88  void ResetVariables();
89  void FillMyMaps ( std::map< int, simb::MCParticle> &MyMap,
90  art::FindManyP<simb::MCParticle> Assn,
91  art::Handle< std::vector<simb::MCTruth> > Hand,
92  std::map<int, int>* indexMap=nullptr);
93  PType WhichParType( int TrID );
94  bool InMyMap ( int TrID, std::map< int, simb::MCParticle> ParMap );
95  void FillTruth(const art::FindManyP<simb::MCParticle> Assn,
96  const art::Handle<std::vector<simb::MCTruth>>& Hand,
97  const PType type) ;
98  void SaveNeighbourADC(int channel,
99  art::Handle< std::vector<raw::RawDigit> >rawDigitsVecHandle,
100  std::set<int> badChannels,
101  recob::Hit const& hits);
102 
103  void SaveIDEs(art::Event const & evt);
105 
109 
114 
116  std::string fMARLLabel ; std::map< int, simb::MCParticle > MarlParts;
117  std::string fAPALabel ; std::map< int, simb::MCParticle > APAParts ;
118  std::string fCPALabel ; std::map< int, simb::MCParticle > CPAParts ;
119  std::string fAr39Label ; std::map< int, simb::MCParticle > Ar39Parts;
120  std::string fNeutLabel ; std::map< int, simb::MCParticle > NeutParts;
121  std::string fKrypLabel ; std::map< int, simb::MCParticle > KrypParts;
122  std::string fPlonLabel ; std::map< int, simb::MCParticle > PlonParts;
123  std::string fRdonLabel ; std::map< int, simb::MCParticle > RdonParts;
124  std::string fAr42Label ; std::map< int, simb::MCParticle > Ar42Parts;
125  std::map<int, const simb::MCParticle*> truthmap;
126  // Which MARLEY interaction (if any) caused this true track ID?
127  std::map<int, int> trkIDToMarleyIndex;
128 
129  // Mapping from track ID to particle type, for use in WhichParType()
130  std::map<int, PType> trkIDToPType;
131 
133  bool fSaveIDEs;
135  bool fSaveTPC;
136  bool fSavePDS;
137 
138  TTree* fSNAnaTree;
139 
140  int Run;
141  int SubRun;
142  int Event;
143 
144  int NTotHit ;
145  int NColHit ;
146  int NIndHit ;
147  int NHitNoBT ;
148 
149  std::vector<int> Hit_View ;
150  std::vector<int> Hit_Size ;
151  std::vector<int> Hit_TPC ;
152  std::vector<int> Hit_Chan ;
153  std::vector<double> Hit_X_start ;
154  std::vector<double> Hit_Y_start ;
155  std::vector<double> Hit_Z_start ;
156  std::vector<double> Hit_X_end ;
157  std::vector<double> Hit_Y_end ;
158  std::vector<double> Hit_Z_end ;
159  std::vector<float> Hit_Time ;
160  std::vector<float> Hit_RMS ;
161  std::vector<float> Hit_SADC ;
162  std::vector<float> Hit_Int ;
163  std::vector<float> Hit_Peak ;
164  std::vector<int> Hit_True_GenType ;
165  std::vector<int> Hit_True_MainTrID ;
166  std::vector<int> Hit_True_TrackID ;
167  std::vector<float> Hit_True_EvEnergy ;
168  std::vector<int> Hit_True_MarleyIndex ;
169  std::vector<float> Hit_True_X ;
170  std::vector<float> Hit_True_Y ;
171  std::vector<float> Hit_True_Z ;
172  std::vector<float> Hit_True_Energy ;
173  std::vector<float> Hit_True_nElec ;
174  std::vector<int> Hit_True_nIDEs ;
175  std::vector<int> Hit_AdjM5SADC ;
176  std::vector<int> Hit_AdjM2SADC ;
177  std::vector<int> Hit_AdjM1SADC ;
178  std::vector<int> Hit_AdjP1SADC ;
179  std::vector<int> Hit_AdjP2SADC ;
180  std::vector<int> Hit_AdjP5SADC ;
181  std::vector<int> Hit_AdjM5Chan ;
182  std::vector<int> Hit_AdjM2Chan ;
183  std::vector<int> Hit_AdjM1Chan ;
184  std::vector<int> Hit_AdjP1Chan ;
185  std::vector<int> Hit_AdjP2Chan ;
186  std::vector<int> Hit_AdjP5Chan ;
187 
188  std::vector<int> PDS_OpHit_OpChannel ;
189  std::vector<double> PDS_OpHit_X ;
190  std::vector<double> PDS_OpHit_Y ;
191  std::vector<double> PDS_OpHit_Z ;
192  std::vector<double> PDS_OpHit_PeakTimeAbs ;
193  std::vector<double> PDS_OpHit_PeakTime ;
194  std::vector<unsigned short> PDS_OpHit_Frame ;
195  std::vector<double> PDS_OpHit_Width ;
196  std::vector<double> PDS_OpHit_Area ;
197  std::vector<double> PDS_OpHit_Amplitude ;
198  std::vector<double> PDS_OpHit_PE ;
199  std::vector<double> PDS_OpHit_FastToTotal ;
200  std::vector<int> PDS_OpHit_True_GenType ;
201  std::vector<int> PDS_OpHit_True_Index ;
202  std::vector<double> PDS_OpHit_True_Energy ;
203  std::vector<int> PDS_OpHit_True_TrackID ;
204  std::vector<int> PDS_OpHit_True_GenTypeAll;
205  std::vector<double> PDS_OpHit_True_EnergyAll ;
206  std::vector<int> PDS_OpHit_True_TrackIDAll;
207  std::vector<int> PDS_OpHit_True_IndexAll ;
208 
209  std::vector<int> True_VertexChan ;
210  std::vector<int> True_Nu_Type ;
211  std::vector<int> True_Nu_Lep_Type ;
212  std::vector<int> True_Mode ;
213  std::vector<int> True_CCNC ;
214  std::vector<int> True_HitNucleon ;
215  std::vector<int> True_Target ;
216  std::vector<int> True_MarlSample ;
217  std::vector<float> True_MarlTime ;
218  std::vector<float> True_MarlWeight ;
219  std::vector<float> True_ENu ;
220  std::vector<float> True_ENu_Lep ;
221  std::vector<float> True_VertX ;
222  std::vector<float> True_VertY ;
223  std::vector<float> True_VertZ ;
224  std::vector<float> True_VertexT ;
225  std::vector<float> True_Px ;
226  std::vector<float> True_Py ;
227  std::vector<float> True_Pz ;
228  std::vector<float> True_Dirx ;
229  std::vector<float> True_Diry ;
230  std::vector<float> True_Dirz ;
231  std::vector<float> True_Time ;
232 
233  std::vector<int> True_Bck_Mode ;
234  std::vector<int> True_Bck_PDG ;
235  std::vector<int> True_Bck_ID ;
236  std::vector<std::string> True_Bck_Process ; // str because why not
237  std::vector<std::string> True_Bck_EndProcess ;
238  std::vector<int> True_Bck_Mother ;
239  std::vector<double> True_Bck_P ;
240  std::vector<double> True_Bck_VertX ;
241  std::vector<double> True_Bck_VertY ;
242  std::vector<double> True_Bck_VertZ ;
243  std::vector<double> True_Bck_Time ;
244  std::vector<double> True_Bck_Energy ;
245  std::vector<double> True_Bck_EndX ;
246  std::vector<double> True_Bck_EndY ;
247  std::vector<double> True_Bck_EndZ ;
248  std::vector<double> True_Bck_EndT ;
249  std::vector<double> True_Bck_EndE ;
250 
251  int NTotIDEs;
252  std::vector<int> IDEChannel ;
253  std::vector<int> IDEStartTime ;
254  std::vector<int> IDEEndTime ;
255  std::vector<float> IDEEnergy ;
256  std::vector<float> IDEElectrons ;
257  std::vector<int> IDEParticle ;
258 
268 
269 
274 
275 };
276 
278  fname("SNAna_module")
279 {
280  this->reconfigure(p);
281 }
282 
283 
285 {
286 
287  fRawDigitLabel = p.get<std::string>("RawDigitLabel" );
288  fHitLabel = p.get<std::string>("HitLabel" );
289  fCalDataModuleLabel = p.get<std::string>("CalDataModuleLabel");
290  fOpHitModuleLabel = p.get<std::string>("OpHitModuleLabel" );
291 
292  fGEANTLabel = p.get<std::string> ("GEANT4Label" );
293  fMARLLabel = p.get<std::string> ("MARLEYLabel" );
294  fAPALabel = p.get<std::string> ("APALabel" );
295  fCPALabel = p.get<std::string> ("CPALabel" );
296  fAr39Label = p.get<std::string> ("Argon39Label" );
297  fNeutLabel = p.get<std::string> ("NeutronLabel" );
298  fKrypLabel = p.get<std::string> ("KryptonLabel" );
299  fPlonLabel = p.get<std::string> ("PoloniumLabel");
300  fRdonLabel = p.get<std::string> ("RadonLabel" );
301  fAr42Label = p.get<std::string> ("Argon42Label" );
302 
303  fSaveNeighbourADCs = p.get<bool> ("SaveNeighbourADCs",0);
304  fSaveTruth = p.get<bool>("SaveTruth",0);
305  fSaveIDEs = p.get<bool>("SaveIDEs",0);
306  fSaveTPC = p.get<bool>("SaveTPC",1);
307  fSavePDS = p.get<bool>("SavePDS",1);
308 
309  mf::LogInfo(fname) << "Reconfigured " << this->processName() << " with "
310  << " SaveNeighbourADCs: " << std::boolalpha << fSaveNeighbourADCs
311  << " SaveTruth: " << std::boolalpha << fSaveTruth
312  << " SaveIDEs: " << std::boolalpha << fSaveIDEs << std::endl;
313 }
314 
315 
317 {
318  trkIDToPType.clear();
319 
320  MarlParts.clear(); APAParts .clear(); CPAParts .clear(); Ar39Parts.clear();
321  NeutParts.clear(); KrypParts.clear(); PlonParts.clear(); RdonParts.clear();
322  Ar42Parts.clear();
323 
324  Run = SubRun = Event = -1;
325 
328  TotGen_Ar42 = 0;
329 
330  NTotHit = 0;
331  NColHit = 0;
332  NIndHit = 0;
333  NHitNoBT = 0;
334 
335  Hit_View .clear();
336  Hit_Size .clear();
337  Hit_TPC .clear();
338  Hit_Chan .clear();
339  Hit_X_start .clear();
340  Hit_Y_start .clear();
341  Hit_Z_start .clear();
342  Hit_X_end .clear();
343  Hit_Y_end .clear();
344  Hit_Z_end .clear();
345  Hit_Time .clear();
346  Hit_RMS .clear();
347  Hit_SADC .clear();
348  Hit_Int .clear();
349  Hit_Peak .clear();
350  Hit_True_GenType .clear();
351  Hit_True_MainTrID .clear();
352  Hit_True_TrackID .clear();
353  Hit_True_EvEnergy .clear();
354  Hit_True_MarleyIndex .clear();
355  Hit_True_X .clear();
356  Hit_True_Y .clear();
357  Hit_True_Z .clear();
358  Hit_True_Energy .clear();
359  Hit_True_nElec .clear();
360  Hit_True_nIDEs .clear();
361 
362  Hit_AdjM5SADC .clear();
363  Hit_AdjM2SADC .clear();
364  Hit_AdjM1SADC .clear();
365  Hit_AdjP1SADC .clear();
366  Hit_AdjP2SADC .clear();
367  Hit_AdjP5SADC .clear();
368  Hit_AdjM5Chan .clear();
369  Hit_AdjM2Chan .clear();
370  Hit_AdjM1Chan .clear();
371  Hit_AdjP1Chan .clear();
372  Hit_AdjP2Chan .clear();
373  Hit_AdjP5Chan .clear();
374 
375  PDS_OpHit_OpChannel .clear();
376  PDS_OpHit_X .clear();
377  PDS_OpHit_Y .clear();
378  PDS_OpHit_Z .clear();
379  PDS_OpHit_PeakTimeAbs .clear();
380  PDS_OpHit_PeakTime .clear();
381  PDS_OpHit_Frame .clear();
382  PDS_OpHit_Width .clear();
383  PDS_OpHit_Area .clear();
384  PDS_OpHit_Amplitude .clear();
385  PDS_OpHit_PE .clear();
386  PDS_OpHit_FastToTotal .clear();
387  PDS_OpHit_True_GenType .clear();
388  PDS_OpHit_True_Index .clear();
389  PDS_OpHit_True_Energy .clear();
390  PDS_OpHit_True_TrackID .clear();
392  PDS_OpHit_True_EnergyAll .clear();
394  PDS_OpHit_True_IndexAll .clear();
395 
396  True_VertexChan .clear();
397  True_Nu_Type .clear();
398  True_Nu_Lep_Type .clear();
399  True_Mode .clear();
400  True_CCNC .clear();
401  True_HitNucleon .clear();
402  True_Target .clear();
403  True_MarlSample .clear();
404  True_MarlTime .clear();
405  True_MarlWeight .clear();
406  True_ENu .clear();
407  True_ENu_Lep .clear();
408  True_VertX .clear();
409  True_VertY .clear();
410  True_VertZ .clear();
411  True_VertexT .clear();
412  True_Px .clear();
413  True_Py .clear();
414  True_Pz .clear();
415  True_Dirx .clear();
416  True_Diry .clear();
417  True_Dirz .clear();
418  True_Time .clear();
419 
420  True_Bck_Mode .clear();
421  True_Bck_PDG .clear();
422  True_Bck_ID .clear();
423  True_Bck_Process .clear();
424  True_Bck_EndProcess .clear();
425  True_Bck_Mother .clear();
426  True_Bck_P .clear();
427  True_Bck_VertX .clear();
428  True_Bck_VertY .clear();
429  True_Bck_VertZ .clear();
430  True_Bck_Time .clear();
431  True_Bck_Energy .clear();
432  True_Bck_EndX .clear();
433  True_Bck_EndY .clear();
434  True_Bck_EndZ .clear();
435  True_Bck_EndT .clear();
436  True_Bck_EndE .clear();
437 
438  // IDEs
439  NTotIDEs=0;
440  IDEChannel .clear();
441  IDEStartTime .clear();
442  IDEEndTime .clear();
443  IDEEnergy .clear();
444  IDEElectrons .clear();
445  IDEParticle .clear();
446 
447 }
448 
449 
451 {
453 
454 
455  fSNAnaTree = tfs->make<TTree>("SNSimTree","SN simulation analysis tree");
456 
457  fSNAnaTree->Branch("Run" , &Run , "Run/I" );
458  fSNAnaTree->Branch("SubRun" , &SubRun , "SubRun/I" );
459  fSNAnaTree->Branch("Event" , &Event , "Event/I" );
460  fSNAnaTree->Branch("NTotHit" , &NTotHit , "NTotHits/I" );
461  fSNAnaTree->Branch("NColHit" , &NColHit , "NColHits/I" );
462  fSNAnaTree->Branch("NIndHit" , &NIndHit , "NIndHits/I" );
463  fSNAnaTree->Branch("NHitNoBT" , &NHitNoBT , "NHitNoBT/I" );
464 
465  if (fSaveTPC) {
466  fSNAnaTree->Branch("Hit_View" , &Hit_View );
467  fSNAnaTree->Branch("Hit_Size" , &Hit_Size );
468  fSNAnaTree->Branch("Hit_TPC" , &Hit_TPC );
469  fSNAnaTree->Branch("Hit_Chan" , &Hit_Chan );
470  fSNAnaTree->Branch("Hit_X_start" , &Hit_X_start );
471  fSNAnaTree->Branch("Hit_Y_start" , &Hit_Y_start );
472  fSNAnaTree->Branch("Hit_Z_start" , &Hit_Z_start );
473  fSNAnaTree->Branch("Hit_X_end" , &Hit_X_end );
474  fSNAnaTree->Branch("Hit_Y_end" , &Hit_Y_end );
475  fSNAnaTree->Branch("Hit_Z_end" , &Hit_Z_end );
476  fSNAnaTree->Branch("Hit_Time" , &Hit_Time );
477  fSNAnaTree->Branch("Hit_RMS" , &Hit_RMS );
478  fSNAnaTree->Branch("Hit_SADC" , &Hit_SADC );
479  fSNAnaTree->Branch("Hit_Int" , &Hit_Int );
480  fSNAnaTree->Branch("Hit_Peak" , &Hit_Peak );
481  fSNAnaTree->Branch("Hit_True_GenType" , &Hit_True_GenType );
482  fSNAnaTree->Branch("Hit_True_MainTrID" , &Hit_True_MainTrID );
483  fSNAnaTree->Branch("Hit_True_TrackID" , &Hit_True_TrackID );
484  fSNAnaTree->Branch("Hit_True_EvEnergy" , &Hit_True_EvEnergy );
485  fSNAnaTree->Branch("Hit_True_MarleyIndex" , &Hit_True_MarleyIndex );
486  fSNAnaTree->Branch("Hit_True_X" , &Hit_True_X );
487  fSNAnaTree->Branch("Hit_True_Y" , &Hit_True_Y );
488  fSNAnaTree->Branch("Hit_True_Z" , &Hit_True_Z );
489  fSNAnaTree->Branch("Hit_True_Energy" , &Hit_True_Energy );
490  fSNAnaTree->Branch("Hit_True_nElec" , &Hit_True_nElec );
491  fSNAnaTree->Branch("Hit_True_nIDEs" , &Hit_True_nIDEs );
492  }
493 
494  if (fSaveNeighbourADCs) {
495  fSNAnaTree->Branch("Hit_AdjM5SADC" , &Hit_AdjM5SADC );
496  fSNAnaTree->Branch("Hit_AdjM2SADC" , &Hit_AdjM2SADC );
497  fSNAnaTree->Branch("Hit_AdjM1SADC" , &Hit_AdjM1SADC );
498  fSNAnaTree->Branch("Hit_AdjP1SADC" , &Hit_AdjP1SADC );
499  fSNAnaTree->Branch("Hit_AdjP2SADC" , &Hit_AdjP2SADC );
500  fSNAnaTree->Branch("Hit_AdjP5SADC" , &Hit_AdjP5SADC );
501  fSNAnaTree->Branch("Hit_AdjM5Chan" , &Hit_AdjM5Chan );
502  fSNAnaTree->Branch("Hit_AdjM2Chan" , &Hit_AdjM2Chan );
503  fSNAnaTree->Branch("Hit_AdjM1Chan" , &Hit_AdjM1Chan );
504  fSNAnaTree->Branch("Hit_AdjP1Chan" , &Hit_AdjP1Chan );
505  fSNAnaTree->Branch("Hit_AdjP2Chan" , &Hit_AdjP2Chan );
506  fSNAnaTree->Branch("Hit_AdjP5Chan" , &Hit_AdjP5Chan );
507  }
508 
509  if (fSavePDS) {
510  fSNAnaTree->Branch("PDS_OpHit_OpChannel" , &PDS_OpHit_OpChannel );
511  fSNAnaTree->Branch("PDS_OpHit_X" , &PDS_OpHit_X );
512  fSNAnaTree->Branch("PDS_OpHit_Y" , &PDS_OpHit_Y );
513  fSNAnaTree->Branch("PDS_OpHit_Z" , &PDS_OpHit_Z );
514  fSNAnaTree->Branch("PDS_OpHit_PeakTimeAbs" , &PDS_OpHit_PeakTimeAbs );
515  fSNAnaTree->Branch("PDS_OpHit_PeakTime" , &PDS_OpHit_PeakTime );
516  fSNAnaTree->Branch("PDS_OpHit_Frame" , &PDS_OpHit_Frame );
517  fSNAnaTree->Branch("PDS_OpHit_Width" , &PDS_OpHit_Width );
518  fSNAnaTree->Branch("PDS_OpHit_Area" , &PDS_OpHit_Area );
519  fSNAnaTree->Branch("PDS_OpHit_Amplitude" , &PDS_OpHit_Amplitude );
520  fSNAnaTree->Branch("PDS_OpHit_PE" , &PDS_OpHit_PE );
521  fSNAnaTree->Branch("PDS_OpHit_FastToTotal" , &PDS_OpHit_FastToTotal );
522  fSNAnaTree->Branch("PDS_OpHit_True_GenType" , &PDS_OpHit_True_GenType );
523  fSNAnaTree->Branch("PDS_OpHit_True_Energy" , &PDS_OpHit_True_Energy );
524  fSNAnaTree->Branch("PDS_OpHit_True_TrackID" , &PDS_OpHit_True_TrackID );
525  fSNAnaTree->Branch("PDS_OpHit_True_GenTypeAll", &PDS_OpHit_True_GenTypeAll);
526  fSNAnaTree->Branch("PDS_OpHit_True_EnergyAll" , &PDS_OpHit_True_EnergyAll );
527  fSNAnaTree->Branch("PDS_OpHit_True_TrackIDAll", &PDS_OpHit_True_TrackIDAll);
528  fSNAnaTree->Branch("PDS_OpHit_True_IndexAll" , &PDS_OpHit_True_IndexAll );
529  }
530 
531  fSNAnaTree->Branch("True_VertexChan" , &True_VertexChan );
532  fSNAnaTree->Branch("True_Nu_Type" , &True_Nu_Type );
533  fSNAnaTree->Branch("True_Nu_Lep_Type" , &True_Nu_Lep_Type );
534  fSNAnaTree->Branch("True_Mode" , &True_Mode );
535  fSNAnaTree->Branch("True_CCNC" , &True_CCNC );
536  fSNAnaTree->Branch("True_HitNucleon" , &True_HitNucleon );
537  fSNAnaTree->Branch("True_Target" , &True_Target );
538  fSNAnaTree->Branch("True_MarlSample" , &True_MarlSample );
539  fSNAnaTree->Branch("True_MarlTime" , &True_MarlTime );
540  fSNAnaTree->Branch("True_MarlWeight" , &True_MarlWeight );
541  fSNAnaTree->Branch("True_ENu" , &True_ENu );
542  fSNAnaTree->Branch("True_ENu_Lep" , &True_ENu_Lep );
543  fSNAnaTree->Branch("True_VertX" , &True_VertX );
544  fSNAnaTree->Branch("True_VertY" , &True_VertY );
545  fSNAnaTree->Branch("True_VertZ" , &True_VertZ );
546  fSNAnaTree->Branch("True_VertexT" , &True_VertexT );
547  fSNAnaTree->Branch("True_Px" , &True_Px );
548  fSNAnaTree->Branch("True_Py" , &True_Py );
549  fSNAnaTree->Branch("True_Pz" , &True_Pz );
550  fSNAnaTree->Branch("True_Dirx" , &True_Dirx );
551  fSNAnaTree->Branch("True_Diry" , &True_Diry );
552  fSNAnaTree->Branch("True_Dirz" , &True_Dirz );
553  fSNAnaTree->Branch("True_Time" , &True_Time );
554 
555 
556  fSNAnaTree->Branch("True_Bck_Mode" , &True_Bck_Mode );
557  fSNAnaTree->Branch("True_Bck_PDG" , &True_Bck_PDG );
558  fSNAnaTree->Branch("True_Bck_ID" , &True_Bck_ID );
559  fSNAnaTree->Branch("True_Bck_Process" , &True_Bck_Process );
560  fSNAnaTree->Branch("True_Bck_EndProcess" , &True_Bck_EndProcess );
561  fSNAnaTree->Branch("True_Bck_Mother" , &True_Bck_Mother );
562  fSNAnaTree->Branch("True_Bck_P" , &True_Bck_P );
563  fSNAnaTree->Branch("True_Bck_VertX" , &True_Bck_VertX );
564  fSNAnaTree->Branch("True_Bck_VertY" , &True_Bck_VertY );
565  fSNAnaTree->Branch("True_Bck_VertZ" , &True_Bck_VertZ );
566  fSNAnaTree->Branch("True_Bck_Time" , &True_Bck_Time );
567  fSNAnaTree->Branch("True_Bck_Energy" , &True_Bck_Energy );
568  fSNAnaTree->Branch("True_Bck_EndX" , &True_Bck_EndX );
569  fSNAnaTree->Branch("True_Bck_EndY" , &True_Bck_EndY );
570  fSNAnaTree->Branch("True_Bck_EndZ" , &True_Bck_EndZ );
571  fSNAnaTree->Branch("True_Bck_EndT" , &True_Bck_EndT );
572  fSNAnaTree->Branch("True_Bck_EndE" , &True_Bck_EndE );
573 
574  // IDEs
575  if(fSaveIDEs) {
576  fSNAnaTree->Branch("NTotIDEs" , &NTotIDEs , "NTotIDEs/I" );
577  fSNAnaTree->Branch("IDEChannel" , &IDEChannel );
578  fSNAnaTree->Branch("IDEStartTime" , &IDEStartTime );
579  fSNAnaTree->Branch("IDEEndTime" , &IDEEndTime );
580  fSNAnaTree->Branch("IDEEnergy" , &IDEEnergy );
581  fSNAnaTree->Branch("IDEElectrons" , &IDEElectrons );
582  fSNAnaTree->Branch("IDEParticle" , &IDEParticle );
583  }
584 
585  fSNAnaTree->Branch("TotGen_Marl", &TotGen_Marl, "TotGen_Marl/I");
586  fSNAnaTree->Branch("TotGen_APA" , &TotGen_APA , "TotGen_APA/I" );
587  fSNAnaTree->Branch("TotGen_CPA" , &TotGen_CPA , "TotGen_CPA/I" );
588  fSNAnaTree->Branch("TotGen_Ar39", &TotGen_Ar39, "TotGen_Ar39/I");
589  fSNAnaTree->Branch("TotGen_Neut", &TotGen_Neut, "TotGen_Neut/I");
590  fSNAnaTree->Branch("TotGen_Kryp", &TotGen_Kryp, "TotGen_Kryp/I");
591  fSNAnaTree->Branch("TotGen_Plon", &TotGen_Plon, "TotGen_Plon/I");
592  fSNAnaTree->Branch("TotGen_Rdon", &TotGen_Rdon, "TotGen_Rdon/I");
593  fSNAnaTree->Branch("TotGen_Ar42", &TotGen_Ar42, "TotGen_Ar42/I");
594 
595 
596 }
597 
598 
600 {
601  ResetVariables();
602 
603  Run = evt.run();
604  SubRun = evt.subRun();
605  Event = evt.event();
606 
607  //GET INFORMATION ABOUT THE DETECTOR'S GEOMETRY.
608  auto const* geo = lar::providerFrom<geo::Geometry>();
609 
610  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
611  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
612 
613  //LIFT OUT THE MARLEY PARTICLES.
614  //auto MarlTrue = evt.getValidHandle<std::vector<simb::MCTruth> >(fMARLLabel);
615  auto MarlTrue = evt.getHandle< std::vector<simb::MCTruth> >(fMARLLabel);
616  if (MarlTrue) {
617  art::FindManyP<simb::MCParticle> MarlAssn(MarlTrue,evt,fGEANTLabel);
618  FillMyMaps( MarlParts, MarlAssn, MarlTrue, &trkIDToMarleyIndex );
619  TotGen_Marl = MarlParts.size();
620  double Px_(0), Py_(0), Pz_(0), Pnorm(1);
621 
622  for(size_t i = 0; i < MarlTrue->size(); i++)
623  {
624  True_Nu_Type .push_back(MarlTrue->at(i).GetNeutrino().Nu().PdgCode());
625  True_Nu_Lep_Type.push_back(MarlTrue->at(i).GetNeutrino().Lepton().PdgCode());
626  True_Mode .push_back(MarlTrue->at(i).GetNeutrino().Mode());
627  True_CCNC .push_back(MarlTrue->at(i).GetNeutrino().CCNC());
628  True_Target .push_back(MarlTrue->at(i).GetNeutrino().Target());
629  True_HitNucleon .push_back(MarlTrue->at(i).GetNeutrino().HitNuc());
630  True_VertX .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Vx());
631  True_VertY .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Vy());
632  True_VertZ .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Vz());
633  True_ENu_Lep .push_back(MarlTrue->at(i).GetNeutrino().Lepton().E());
634  True_ENu .push_back(MarlTrue->at(i).GetNeutrino().Nu().E());
635  True_Px .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Px());
636  True_Py .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Py());
637  True_Pz .push_back(MarlTrue->at(i).GetNeutrino().Lepton().Pz());
638  Pnorm = std::sqrt(Px_*Px_+Py_*Py_+Pz_*Pz_);
639  double Px = Px_/Pnorm;
640  double Py = Py_/Pnorm;
641  double Pz = Pz_/Pnorm;
642  True_Dirx.push_back(Px);
643  True_Diry.push_back(Py);
644  True_Dirz.push_back(Pz);
645  True_Time.push_back(MarlTrue->at(i).GetNeutrino().Lepton().T());
646 
647  try {
648  art::FindManyP<sim::SupernovaTruth> SNTruth(MarlTrue, evt, fMARLLabel);
649  for (size_t j = 0; j < SNTruth.at(i).size(); j++) {
650  const sim::SupernovaTruth ThisTr = (*SNTruth.at(i).at(j));
651  True_MarlTime .push_back(ThisTr.SupernovaTime);
652  True_MarlWeight.push_back(ThisTr.Weight);
653  True_MarlSample.push_back(ThisTr.SamplingMode);
654  }
655  } catch (...) {
656  mf::LogDebug(fname) << "Didnt find SN truth (few things wont available):\n"
657  << " - MarlTime\n"
658  << " - MarlWeight\n"
659  << " - MarlSample\n";
660  }
661  }
662 
663  for(size_t i=0; i<True_VertX.size(); ++i) {
664  bool caught = false;
665  double Vertex[3] = {True_VertX[i],
666  True_VertY[i],
667  True_VertZ[i]};
669  geo::PlaneID Plane(geo->FindTPCAtPosition(Vertex),geo::kZ);
670  try
671  {
672  WireID = geo->NearestWireID(Vertex, Plane);
673  }
674  catch(...)
675  {
676  caught = true;
677  }
678  if(caught==true)
679  {
680  True_VertexChan.push_back(-1);
681  }
682  else
683  {
684  True_VertexChan.push_back(geo->PlaneWireToChannel(WireID));
685  }
686 
687  //CM/MICROSECOND.
688  double drift_velocity = detProp.DriftVelocity(detProp.Efield(),detProp.Temperature());
689  //CM/TICK
690  drift_velocity = drift_velocity*0.5;
691  True_VertexT.push_back(True_VertX.back()/drift_velocity);
692  }
693  if (fSaveTruth)
694  FillTruth(MarlAssn, MarlTrue, kMarl);
695  }
696 
697  auto APATrue = evt.getHandle< std::vector<simb::MCTruth> >(fAPALabel);
698  if (APATrue) {
699  art::FindManyP<simb::MCParticle> APAAssn(APATrue,evt,fGEANTLabel);
700  FillMyMaps( APAParts, APAAssn, APATrue );
701  TotGen_APA = APAParts.size();
702  if(fSaveTruth) FillTruth(APAAssn , APATrue , kAPA );
703 
704  }
705 
706  auto CPATrue = evt.getHandle< std::vector<simb::MCTruth> >(fCPALabel);
707  if (CPATrue) {
708  art::FindManyP<simb::MCParticle> CPAAssn(CPATrue,evt,fGEANTLabel);
709  FillMyMaps( CPAParts, CPAAssn, CPATrue );
710  TotGen_CPA = CPAParts.size();
711  if(fSaveTruth) FillTruth(CPAAssn , CPATrue , kCPA );
712  }
713 
714  auto Ar39True = evt.getHandle< std::vector<simb::MCTruth> >(fAr39Label);
715  if (Ar39True) {
716  art::FindManyP<simb::MCParticle> Ar39Assn(Ar39True,evt,fGEANTLabel);
717  FillMyMaps( Ar39Parts, Ar39Assn, Ar39True );
718  TotGen_Ar39 = Ar39Parts.size();
719  if(fSaveTruth) FillTruth(Ar39Assn, Ar39True, kAr39);
720  }
721 
722  auto NeutTrue = evt.getHandle< std::vector<simb::MCTruth> >(fNeutLabel);
723  if (NeutTrue) {
724  art::FindManyP<simb::MCParticle> NeutAssn(NeutTrue,evt,fGEANTLabel);
725  FillMyMaps( NeutParts, NeutAssn, NeutTrue );
726  TotGen_Neut = NeutParts.size();
727  if(fSaveTruth) FillTruth(NeutAssn, NeutTrue, kNeut);
728  }
729 
730  auto KrypTrue = evt.getHandle< std::vector<simb::MCTruth> >(fKrypLabel);
731  if (KrypTrue) {
732  art::FindManyP<simb::MCParticle> KrypAssn(KrypTrue,evt,fGEANTLabel);
733  FillMyMaps( KrypParts, KrypAssn, KrypTrue );
734  TotGen_Kryp = KrypParts.size();
735  if(fSaveTruth) FillTruth(KrypAssn, KrypTrue, kKryp);
736  }
737 
738  auto PlonTrue = evt.getHandle< std::vector<simb::MCTruth> >(fPlonLabel);
739  if (PlonTrue) {
740  art::FindManyP<simb::MCParticle> PlonAssn(PlonTrue,evt,fGEANTLabel);
741  FillMyMaps( PlonParts, PlonAssn, PlonTrue );
742  TotGen_Plon = PlonParts.size();
743  if(fSaveTruth) FillTruth(PlonAssn, PlonTrue, kPlon);
744  }
745 
746  auto RdonTrue = evt.getHandle< std::vector<simb::MCTruth> >(fRdonLabel);
747  if (RdonTrue) {
748  art::FindManyP<simb::MCParticle> RdonAssn(RdonTrue,evt,fGEANTLabel);
749  FillMyMaps( RdonParts, RdonAssn, RdonTrue );
750  TotGen_Rdon = RdonParts.size();
751  if(fSaveTruth) FillTruth(RdonAssn, RdonTrue, kRdon);
752  }
753 
754  auto Ar42True = evt.getHandle< std::vector<simb::MCTruth> >(fAr42Label);
755  if (Ar42True) {
756  art::FindManyP<simb::MCParticle> Ar42Assn(Ar42True,evt,fGEANTLabel);
757  FillMyMaps( Ar42Parts, Ar42Assn, Ar42True );
758  TotGen_Ar42 = Ar42Parts.size();
759  if(fSaveTruth) FillTruth(Ar42Assn, Ar42True, kAr42);
760  }
761 
762  std::vector<simb::MCParticle> allTruthParts;
763  for(auto& it: APAParts)
764  allTruthParts.push_back(it.second);
765  for(auto& it: CPAParts)
766  allTruthParts.push_back(it.second);
767  for(auto& it: Ar39Parts)
768  allTruthParts.push_back(it.second);
769  for(auto& it: NeutParts)
770  allTruthParts.push_back(it.second);
771  for(auto& it: KrypParts)
772  allTruthParts.push_back(it.second);
773  for(auto& it: PlonParts)
774  allTruthParts.push_back(it.second);
775  for(auto& it: RdonParts)
776  allTruthParts.push_back(it.second);
777  for(auto& it: Ar42Parts)
778  allTruthParts.push_back(it.second);
779 
780  std::map<PType, std::map< int, simb::MCParticle >&> PTypeToMap{
781  {kMarl, MarlParts},
782  {kAPA, APAParts },
783  {kCPA, CPAParts },
784  {kAr39, Ar39Parts},
785  {kAr42, Ar42Parts},
786  {kNeut, NeutParts},
787  {kKryp, KrypParts},
788  {kPlon, PlonParts},
789  {kRdon, RdonParts}
790  };
791 
792  std::map<PType,std::set<int>> PTypeToTrackID;
793 
794  for(auto const& it : PTypeToMap){
795  const PType p=it.first;
796  auto const& m=it.second;
797  for(auto const& it2 : m){
798  trkIDToPType.insert(std::make_pair(it2.first, p));
799  PTypeToTrackID[p].insert(it2.first);
800  }
801  }
802 
803  mf::LogInfo(fname) << "THE EVENTS NUMBER IS: " << Event << std::endl;
804 
805  if (fSaveTPC) {
806  auto reco_hits = evt.getHandle< std::vector<recob::Hit> >(fHitLabel);
807  auto rawDigitsVecHandle = evt.getHandle< std::vector<raw::RawDigit> >(fRawDigitLabel);
808 
809  if ( reco_hits && rawDigitsVecHandle ) {
810  std::vector< recob::Hit > ColHits_Marl;
811  std::vector< recob::Hit > ColHits_CPA ;
812  std::vector< recob::Hit > ColHits_APA ;
813  std::vector< recob::Hit > ColHits_Ar39;
814  std::vector< recob::Hit > ColHits_Neut;
815  std::vector< recob::Hit > ColHits_Kryp;
816  std::vector< recob::Hit > ColHits_Plon;
817  std::vector< recob::Hit > ColHits_Rdon;
818  std::vector< recob::Hit > ColHits_Oth ;
819  std::vector< recob::Hit > ColHits_Ar42;
820 
821  NTotHit = reco_hits->size();
822  int colHitCount(0);
823  int LoopHits = NTotHit;
824 
825  for(int hit = 0; hit < LoopHits; ++hit) {
826  recob::Hit const& ThisHit = reco_hits->at(hit);
827  if(ThisHit.View() == geo::kU || ThisHit.View() == geo::kV) {
828  ++NIndHit;
829  } else {
830  ++NColHit;
831  }
832  }
833 
834 
835  // Fill a set of the channels that we don't want to consider in the
836  // adjacent-channel loop below. Do it here once so we don't have to
837  // re-do it for every single hit
838  std::set<int> badChannels;
839  for(size_t i=0; i<rawDigitsVecHandle->size(); ++i) {
840  int rawWireChannel=(*rawDigitsVecHandle)[i].Channel();
841  std::vector<geo::WireID> adjacentwire = geo->ChannelToWire(rawWireChannel);
842 
843  if (adjacentwire.size() < 1 || adjacentwire[0].Plane == geo::kU ||
844  adjacentwire[0].Plane == geo::kV){
845  badChannels.insert(rawWireChannel);
846  }
847  }
848  // std::cout << "Inserted " << badChannels.size() << " out of " << rawDigitsVecHandle->size() << " channels into set" << std::endl;
849 
850  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
851  for(int hit = 0; hit < LoopHits; ++hit) {
852  recob::Hit const& ThisHit = reco_hits->at(hit);
853 
854  if (ThisHit.View() == 2) {
855  std::vector<sim::TrackIDE> ThisHitIDE;
856  //GETTING HOLD OF THE SIM::IDEs.
857 
858  std::vector<const sim::IDE*> ThisSimIDE;
859  try {
860  // HitToTrackIDEs opens a specific window around the hit. I want a
861  // wider one, because the filtering can delay the hit. So this bit
862  // is a copy of HitToTrackIDEs from the backtracker, with some
863  // modification
864  const double start = ThisHit.PeakTime()-20;
865  const double end = ThisHit.PeakTime()+ThisHit.RMS()+20;
866  ThisHitIDE = bt_serv->ChannelToTrackIDEs(clockData, ThisHit.Channel(), start, end);
867 
868  // ThisHitIDE = bt_serv->HitToTrackIDEs(clockData, ThisHit );
869  } catch(...){
870  // std::cout << "FIRST CATCH" << std::endl;
871  firstCatch++;
872  try {
873  ThisSimIDE = bt_serv->HitToSimIDEs_Ps(clockData, ThisHit);
874  } catch(...) {
875  // std::cout << "SECOND CATCH" << std::endl;
876  secondCatch++;
877  // continue;
878  }
879  // continue;
880  }
881 
882  // Get the simIDEs.
883  try {
884  ThisSimIDE = bt_serv->HitToSimIDEs_Ps(clockData, ThisHit);
885  } catch(...) {
886  // std::cout << "THIRD CATCH" << std::endl;
887  thirdCatch++;
888  // continue;
889  }
890 
891  Hit_View.push_back(ThisHit.View());
892  Hit_Size.push_back(ThisHit.EndTick() - ThisHit.StartTick());
893  Hit_TPC .push_back(ThisHit.WireID().TPC);
894  int channel = ThisHit.Channel();
895  Hit_Chan.push_back(channel);
896 
898  SaveNeighbourADC(channel,rawDigitsVecHandle, badChannels, ThisHit);
899 
900  double wire_start[3] = {0,0,0};
901  double wire_end[3] = {0,0,0};
902  auto& wgeo = geo->WireIDToWireGeo(ThisHit.WireID());
903  wgeo.GetStart(wire_start);
904  wgeo.GetEnd(wire_end);
905  Hit_X_start.push_back(wire_start[0]);
906  Hit_Y_start.push_back(wire_start[1]);
907  Hit_Z_start.push_back(wire_start[2]);
908  Hit_X_end .push_back(wire_end[0]);
909  Hit_Y_end .push_back(wire_end[1]);
910  Hit_Z_end .push_back(wire_end[2]);
911  Hit_Time .push_back(ThisHit.PeakTime());
912  Hit_RMS .push_back(ThisHit.RMS());
913  Hit_SADC .push_back(ThisHit.SummedADC());
914  Hit_Int .push_back(ThisHit.Integral());
915  Hit_Peak .push_back(ThisHit.PeakAmplitude());
916  Hit_True_nIDEs.push_back(ThisHitIDE.size());
917 
918  if(ThisHitIDE.size()==0)
919  NHitNoBT++;
920 
921  //WHICH PARTICLE CONTRIBUTED MOST TO THE HIT.
922  double TopEFrac = -DBL_MAX;
923 
924  Hit_True_EvEnergy.push_back(0);
925  Hit_True_MainTrID.push_back(-1);
926  for (size_t ideL=0; ideL < ThisHitIDE.size(); ++ideL) {
927  Hit_True_TrackID.push_back(ThisHitIDE[ideL].trackID);
928  for (size_t ipart=0; ipart<allTruthParts.size(); ++ipart) {
929 
930  if (allTruthParts[ipart].TrackId() == ThisHitIDE[ideL].trackID) {
931  Hit_True_EvEnergy.at(colHitCount) += allTruthParts[ipart].E();
932  }
933  }
934  if (ThisHitIDE[ideL].energyFrac > TopEFrac) {
935  TopEFrac = ThisHitIDE[ideL].energyFrac;
936  Hit_True_MainTrID.at(colHitCount) = ThisHitIDE[ideL].trackID;
937 
938  }
939  }
940 
941  PType ThisPType = WhichParType(Hit_True_MainTrID.at(colHitCount));
942  Hit_True_GenType.push_back(ThisPType);
943 
944  int thisMarleyIndex=-1;
945  int MainTrID=Hit_True_MainTrID.at(colHitCount);
946  if(ThisPType==kMarl && MainTrID!=0){
947  auto const it=trkIDToMarleyIndex.find(MainTrID);
948  if(it==trkIDToMarleyIndex.end()){
949  mf::LogDebug(fname) << "Track ID " << MainTrID << " is not in Marley index map" << std::endl;
950  }
951  else{
952  thisMarleyIndex=it->second;
953  }
954  }
955  Hit_True_MarleyIndex.push_back(thisMarleyIndex);
956 
957  if(Hit_True_MainTrID[colHitCount] == -1)
958  {
959  Hit_True_X .push_back(-1);
960  Hit_True_Y .push_back(-1);
961  Hit_True_Z .push_back(-1);
962  Hit_True_Energy.push_back(-1);
963  Hit_True_nElec .push_back(-1);
964  }
965  else
966  {
967  for(unsigned int i = 0; i < ThisSimIDE.size(); i++)
968  {
969  if(ThisSimIDE.at(i)->trackID==Hit_True_MainTrID[colHitCount])
970  {
971  Hit_True_X .push_back(ThisSimIDE.at(i)->x );
972  Hit_True_Y .push_back(ThisSimIDE.at(i)->y );
973  Hit_True_Z .push_back(ThisSimIDE.at(i)->z );
974  Hit_True_Energy.push_back(ThisSimIDE.at(i)->energy );
975  Hit_True_nElec .push_back(ThisSimIDE.at(i)->numElectrons);
976  break;
977  }
978  }
979  }
980 
981  if (ThisPType == 0) { ColHits_Oth .push_back( ThisHit ); }
982  else if (ThisPType == 1) { ColHits_Marl.push_back( ThisHit ); }
983  else if (ThisPType == 2) { ColHits_APA .push_back( ThisHit ); }
984  else if (ThisPType == 3) { ColHits_CPA .push_back( ThisHit ); }
985  else if (ThisPType == 4) { ColHits_Ar39.push_back( ThisHit ); }
986  else if (ThisPType == 5) { ColHits_Neut.push_back( ThisHit ); }
987  else if (ThisPType == 6) { ColHits_Kryp.push_back( ThisHit ); }
988  else if (ThisPType == 7) { ColHits_Plon.push_back( ThisHit ); }
989  else if (ThisPType == 8) { ColHits_Rdon.push_back( ThisHit ); }
990  else if (ThisPType == 9) { ColHits_Ar42.push_back( ThisHit ); }
991 
992  colHitCount++;
993  }
994  }
995  mf::LogInfo(fname) << "Total of:\n"
996  << " - Other: " << ColHits_Oth.size() << " col plane hits\n"
997  << " - Marl : " << TotGen_Marl << " true parts\t| " << ColHits_Marl.size() << " col plane hits\n"
998  << " - APA : " << TotGen_APA << " true parts\t| " << ColHits_APA .size() << " col plane hits\n"
999  << " - CPA : " << TotGen_CPA << " true parts\t| " << ColHits_CPA .size() << " col plane hits\n"
1000  << " - Ar39 : " << TotGen_Ar39 << " true parts\t| " << ColHits_Ar39.size() << " col plane hits\n"
1001  << " - Neut : " << TotGen_Neut << " true parts\t| " << ColHits_Neut.size() << " col plane hits\n"
1002  << " - Kryp : " << TotGen_Kryp << " true parts\t| " << ColHits_Kryp.size() << " col plane hits\n"
1003  << " - Plon : " << TotGen_Plon << " true parts\t| " << ColHits_Plon.size() << " col plane hits\n"
1004  << " - Rdon : " << TotGen_Rdon << " true parts\t| " << ColHits_Rdon.size() << " col plane hits\n"
1005  << " - Ar42 : " << TotGen_Ar42 << " true parts\t| " << ColHits_Ar42.size() << " col plane hits\n";
1006  } else {
1007  mf::LogError(fname) << "Requested to save wire hits, but cannot load any wire hits";
1008  throw art::Exception(art::errors::NotFound) << "Requested to save wire hits, but cannot load any wire hits\n";
1009  }
1010  }
1011 
1012  if (fSavePDS) {
1013 
1014  std::vector<art::Ptr<recob::OpHit> > ophitlist;
1015  std::map<PType, std::vector<art::Ptr<recob::OpHit> > > map_of_ophit;
1016 
1017  auto OpHitHandle = evt.getHandle< std::vector< recob::OpHit > >(fOpHitModuleLabel);
1018  if (OpHitHandle) {
1019  art::fill_ptr_vector(ophitlist, OpHitHandle);
1020 
1021  mf::LogDebug(fname) << "There are " << ophitlist.size() << " optical hits in the event." << std::endl;
1022 
1023  for(size_t i = 0; i < ophitlist.size(); ++i)
1024  {
1025  std::vector<sim::TrackSDP> vec_tracksdp = pbt_serv->OpHitToTrackSDPs(ophitlist.at(i));
1026  PType gen = kUnknown;
1027 
1028  std::sort(vec_tracksdp.begin(), vec_tracksdp.end(),
1029  [](const sim::TrackSDP& a, const sim::TrackSDP& b) -> bool { return a.energyFrac > b.energyFrac; });
1030 
1031  for (size_t iSDP=0; iSDP<vec_tracksdp.size(); ++iSDP) {
1032  PDS_OpHit_True_TrackIDAll.push_back(vec_tracksdp[iSDP].trackID);
1033  PDS_OpHit_True_GenTypeAll.push_back(WhichParType(vec_tracksdp[iSDP].trackID));
1034  PDS_OpHit_True_EnergyAll .push_back(vec_tracksdp[iSDP].energy);
1035  PDS_OpHit_True_IndexAll .push_back((int)i);
1036  }
1037 
1038  if (vec_tracksdp.size()>0){
1039  int MainTrID = vec_tracksdp[0].trackID;
1040  PDS_OpHit_True_TrackID.push_back(vec_tracksdp[0].trackID);
1041  gen = WhichParType(vec_tracksdp[0].trackID);
1042  PDS_OpHit_True_GenType.push_back(gen);
1043  int thisMarleyIndex;
1044  if(gen==kMarl && MainTrID!=0){
1045  auto const it=trkIDToMarleyIndex.find(MainTrID);
1046  if(it==trkIDToMarleyIndex.end()){
1047  mf::LogDebug(fname) << "Track ID " << MainTrID << " is not in Marley index map" << std::endl;
1048  }
1049  else{
1050  thisMarleyIndex=it->second;
1051  }
1052  }
1053  PDS_OpHit_True_Index .push_back(thisMarleyIndex);
1054  PDS_OpHit_True_Energy .push_back(vec_tracksdp[0].energy);
1055  } else {
1056  PDS_OpHit_True_TrackID.push_back(-1);
1057  PDS_OpHit_True_GenType.push_back(kUnknown);
1058  PDS_OpHit_True_Energy .push_back(-1);
1059  }
1060 
1061  map_of_ophit[gen].push_back(ophitlist.at(i));
1062 
1063  double xyz_optdet[3]={0,0,0};
1064  double xyz_world [3]={0,0,0};
1065 
1066  geo->OpDetGeoFromOpChannel(ophitlist[i]->OpChannel()).LocalToWorld(xyz_optdet,xyz_world);
1067  PDS_OpHit_OpChannel .push_back(ophitlist[i]->OpChannel());
1068  PDS_OpHit_X .push_back(xyz_world[0]);
1069  PDS_OpHit_Y .push_back(xyz_world[1]);
1070  PDS_OpHit_Z .push_back(xyz_world[2]);
1071  PDS_OpHit_PeakTimeAbs .push_back(ophitlist[i]->PeakTimeAbs());
1072  PDS_OpHit_PeakTime .push_back(ophitlist[i]->PeakTime());
1073  PDS_OpHit_Frame .push_back(ophitlist[i]->Frame());
1074  PDS_OpHit_Width .push_back(ophitlist[i]->Width());
1075  PDS_OpHit_Area .push_back(ophitlist[i]->Area());
1076  PDS_OpHit_Amplitude .push_back(ophitlist[i]->Amplitude());
1077  PDS_OpHit_PE .push_back(ophitlist[i]->PE());
1078  PDS_OpHit_FastToTotal .push_back(ophitlist[i]->FastToTotal());
1079  }
1080  mf::LogInfo(fname) << "Total of :\n"
1081  << " - Other: " << map_of_ophit[kUnknown].size() << " opt hits\n"
1082  << " - Marl : " << TotGen_Marl << " true parts\t| " << map_of_ophit[kMarl].size() << " opt hits\n"
1083  << " - APA : " << TotGen_APA << " true parts\t| " << map_of_ophit[kAPA] .size() << " opt hits\n"
1084  << " - CPA : " << TotGen_CPA << " true parts\t| " << map_of_ophit[kCPA] .size() << " opt hits\n"
1085  << " - Ar39 : " << TotGen_Ar39 << " true parts\t| " << map_of_ophit[kAr39].size() << " opt hits\n"
1086  << " - Neut : " << TotGen_Neut << " true parts\t| " << map_of_ophit[kNeut].size() << " opt hits\n"
1087  << " - Kryp : " << TotGen_Kryp << " true parts\t| " << map_of_ophit[kKryp].size() << " opt hits\n"
1088  << " - Plon : " << TotGen_Plon << " true parts\t| " << map_of_ophit[kPlon].size() << " opt hits\n"
1089  << " - Rdon : " << TotGen_Rdon << " true parts\t| " << map_of_ophit[kRdon].size() << " opt hits\n"
1090  << " - Ar42 : " << TotGen_Ar42 << " true parts\t| " << map_of_ophit[kAr42].size() << " opt hits\n";
1091  }
1092  else {
1093  mf::LogError(fname) << "Requested to save optical hits, but cannot load any ophits";
1094  throw art::Exception(art::errors::NotFound) << "Requested to save optical hits, but cannot load any optical hits\n";
1095  }
1096  }
1097 
1098  if(fSaveIDEs) SaveIDEs(evt);
1099 
1100 
1101  fSNAnaTree->Fill();
1102 }
1103 
1104 void SNAna::FillTruth(const art::FindManyP<simb::MCParticle> Assn,
1105  const art::Handle<std::vector<simb::MCTruth>>& Hand,
1106  const PType type) {
1107 
1108  for(size_t i1=0; i1<Hand->size(); ++i1) {
1109  for ( size_t i2=0; i2 < Assn.at(i1).size(); ++i2 ) {
1110  const simb::MCParticle ThisPar = (*Assn.at(i1).at(i2));
1111  True_Bck_Mode .push_back(type);
1112  True_Bck_PDG .push_back(ThisPar.PdgCode ());
1113  True_Bck_ID .push_back(ThisPar.TrackId ());
1114  True_Bck_Mother .push_back(ThisPar.Mother ());
1115  True_Bck_P .push_back(ThisPar.P ());
1116  True_Bck_VertX .push_back(ThisPar.Vx ());
1117  True_Bck_VertY .push_back(ThisPar.Vy ());
1118  True_Bck_VertZ .push_back(ThisPar.Vz ());
1119  True_Bck_Time .push_back(ThisPar.T ());
1120  True_Bck_Energy .push_back(ThisPar.E ());
1121  True_Bck_EndX .push_back(ThisPar.EndX ());
1122  True_Bck_EndY .push_back(ThisPar.EndY ());
1123  True_Bck_EndZ .push_back(ThisPar.EndZ ());
1124  True_Bck_EndT .push_back(ThisPar.EndT ());
1125  True_Bck_EndE .push_back(ThisPar.EndE ());
1126  True_Bck_EndProcess.push_back(ThisPar.EndProcess());
1127  True_Bck_Process .push_back(ThisPar.Process ());
1128  }
1129  }
1130 }
1131 
1132 void SNAna::FillMyMaps(std::map< int, simb::MCParticle> &MyMap,
1133  art::FindManyP<simb::MCParticle> Assn,
1134  art::Handle< std::vector<simb::MCTruth> > Hand,
1135  std::map<int, int>* indexMap) {
1136  for ( size_t L1=0; L1 < Hand->size(); ++L1 ) {
1137  for ( size_t L2=0; L2 < Assn.at(L1).size(); ++L2 ) {
1138  const simb::MCParticle ThisPar = (*Assn.at(L1).at(L2));
1139  MyMap[ThisPar.TrackId()] = ThisPar;
1140  if(indexMap) indexMap->insert({ThisPar.TrackId(), L1});
1141  }
1142  }
1143  return;
1144 }
1145 
1146 
1148 {
1149  PType ThisPType = kUnknown;
1150  auto const& it=trkIDToPType.find(TrID);
1151  if(it!=trkIDToPType.end()){
1152  ThisPType=it->second;
1153  }
1154  return ThisPType;
1155 
1156 }
1157 
1158 
1159 bool SNAna::InMyMap( int TrID, std::map< int, simb::MCParticle> ParMap )
1160 {
1162  ParIt = ParMap.find( TrID );
1163  if ( ParIt != ParMap.end() ) {
1164  return true;
1165  } else
1166  return false;
1167 }
1168 
1169 //......................................................
1171 {
1172  auto allParticles = evt.getValidHandle<std::vector<simb::MCParticle> >(fGEANTLabel);
1173  art::FindMany<simb::MCTruth> assn(allParticles,evt,fGEANTLabel);
1174  std::map<int, const simb::MCTruth*> idToTruth;
1175  for(size_t i=0; i<allParticles->size(); ++i){
1176  const simb::MCParticle& particle=allParticles->at(i);
1177  const std::vector<const simb::MCTruth*> truths=assn.at(i);
1178  if(truths.size()==1){
1179  idToTruth[particle.TrackId()]=truths[0];
1180  }
1181  else{
1182  mf::LogDebug("DAQSimAna") << "Particle " << particle.TrackId() << " has " << truths.size() << " truths";
1183  idToTruth[particle.TrackId()]=nullptr;
1184  }
1185  }
1186 
1187  // Get the SimChannels so we can see where the actual energy depositions were
1188  auto& simchs=*evt.getValidHandle<std::vector<sim::SimChannel>>("largeant");
1189 
1190  for(auto&& simch: simchs){
1191  // We only care about collection channels
1192  if(geo->SignalType(simch.Channel())!=geo::kCollection) continue;
1193 
1194  // The IDEs record energy depositions at every tick, but
1195  // mostly we have several depositions at contiguous times. So
1196  // we're going to save just one output IDE for each contiguous
1197  // block of hits on a channel. Each item in vector is a list
1198  // of (TDC, IDE*) for contiguous-in-time IDEs
1199  std::vector<std::vector<std::pair<int, const sim::IDE*> > > contigIDEs;
1200  int prevTDC=0;
1201  for (const auto& TDCinfo: simch.TDCIDEMap()) {
1202  // Do we need to start a new group of IDEs? Yes if this is
1203  // the first IDE in this channel. Yes if this IDE is not
1204  // contiguous with the previous one
1205  if(contigIDEs.empty() || TDCinfo.first-prevTDC>5){
1206  contigIDEs.push_back(std::vector<std::pair<int, const sim::IDE*> >());
1207  }
1208  std::vector<std::pair<int, const sim::IDE*> >& currentIDEs=contigIDEs.back();
1209 
1210  // Add all the current tick's IDEs to the list
1211  for (const sim::IDE& ide: TDCinfo.second) {
1212  currentIDEs.push_back(std::make_pair(TDCinfo.first, &ide));
1213  }
1214  prevTDC=TDCinfo.first;
1215  }
1216 
1217  for(auto const& contigs : contigIDEs){
1218  float energy=0;
1219  float electrons=0;
1220  int startTime=99999;
1221  int endTime=0;
1222  std::map<PType, float> ptypeToEnergy;
1223  for(auto const& timeide : contigs){
1224  const int tdc=timeide.first;
1225  startTime=std::min(tdc, startTime);
1226  endTime=std::max(tdc, endTime);
1227  const sim::IDE& ide=*timeide.second;
1228  const float thisEnergy=ide.energy;
1229  const PType thisPType=WhichParType(std::abs(ide.trackID));
1230  energy+=thisEnergy;
1231  electrons+=ide.numElectrons;
1232  ptypeToEnergy[thisPType]+=thisEnergy;
1233  }
1234  float bestEnergy=0;
1235  PType bestPType=kUnknown;
1236  for(auto const& it : ptypeToEnergy){
1237  if(it.second>bestEnergy){
1238  bestEnergy=it.second;
1239  bestPType=it.first;
1240  }
1241  }
1242  // Ignore anything past the end of the readout window
1243  if(startTime<4492){
1244  IDEChannel.push_back(simch.Channel());
1245  IDEStartTime.push_back(startTime);
1246  IDEEndTime.push_back(endTime);
1247  IDEEnergy.push_back(energy);
1248  IDEElectrons.push_back(electrons);
1249  IDEParticle.push_back(bestPType);
1250  }
1251  } // loop over our compressed IDEs
1252  } // loop over SimChannels
1253 }
1254 
1255 
1257  art::Handle< std::vector<raw::RawDigit> >rawDigitsVecHandle,
1258  std::set<int>badChannels,
1259  recob::Hit const& ThisHit) {
1260 
1261  Hit_AdjM5SADC.push_back(0);
1262  Hit_AdjM2SADC.push_back(0);
1263  Hit_AdjM1SADC.push_back(0);
1264  Hit_AdjP1SADC.push_back(0);
1265  Hit_AdjP2SADC.push_back(0);
1266  Hit_AdjP5SADC.push_back(0);
1267  Hit_AdjM5Chan.push_back(0);
1268  Hit_AdjM2Chan.push_back(0);
1269  Hit_AdjM1Chan.push_back(0);
1270  Hit_AdjP1Chan.push_back(0);
1271  Hit_AdjP2Chan.push_back(0);
1272  Hit_AdjP5Chan.push_back(0);
1273  int colHitCount = Hit_AdjM1Chan.size()-1;
1274 
1275  // A vector for us to uncompress the rawdigits into. Create it
1276  // outside the loop here so that we only have to allocate it once
1277  raw::RawDigit::ADCvector_t ADCs((*rawDigitsVecHandle)[0].Samples());
1278 
1279  std::vector<geo::WireID> wids = geo->ChannelToWire(channel);
1280  for(size_t i=0; i<rawDigitsVecHandle->size(); ++i)
1281  {
1282  int rawWireChannel=(*rawDigitsVecHandle)[i].Channel();
1283  const int chanDiff=rawWireChannel-channel;
1284  if(abs(chanDiff)!=1 && abs(chanDiff)!=2 && abs(chanDiff)!=5) continue;
1285 
1286  if(badChannels.find(rawWireChannel)!=badChannels.end()) continue;
1287 
1288  switch(chanDiff)
1289  {
1290  case -5:
1291  Hit_AdjM5SADC[colHitCount] = 0;
1292  Hit_AdjM5Chan[colHitCount] = rawWireChannel;
1293  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1294  (*rawDigitsVecHandle)[i].Compression());
1295  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1296  Hit_AdjM5SADC[colHitCount]+=ADCs[i];
1297  break;
1298  case -2:
1299  Hit_AdjM2SADC[colHitCount] = 0;
1300  Hit_AdjM2Chan[colHitCount] = rawWireChannel;
1301  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1302  (*rawDigitsVecHandle)[i].Compression());
1303  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1304  Hit_AdjM2SADC[colHitCount]+=ADCs[i];
1305  break;
1306  case -1:
1307  Hit_AdjM1SADC[colHitCount] = 0;
1308  Hit_AdjM1Chan[colHitCount] = rawWireChannel;
1309  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1310  (*rawDigitsVecHandle)[i].Compression());
1311  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1312  Hit_AdjM1SADC[colHitCount]+=ADCs[i];
1313  break;
1314  case 1:
1315  Hit_AdjP1SADC[colHitCount] = 0;
1316  Hit_AdjP1Chan[colHitCount] = rawWireChannel;
1317  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1318  (*rawDigitsVecHandle)[i].Compression());
1319  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1320  Hit_AdjP1SADC[colHitCount]+=ADCs[i];
1321  break;
1322  case 2:
1323  Hit_AdjP2SADC[colHitCount] = 0;
1324  Hit_AdjP2Chan[colHitCount] = rawWireChannel;
1325  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1326  (*rawDigitsVecHandle)[i].Compression());
1327  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1328  Hit_AdjP2SADC[colHitCount]+=ADCs[i];
1329  break;
1330  case 5:
1331  Hit_AdjP5SADC[colHitCount] = 0;
1332  Hit_AdjP5Chan[colHitCount] = rawWireChannel;
1333  raw::Uncompress((*rawDigitsVecHandle)[i].ADCs(), ADCs,
1334  (*rawDigitsVecHandle)[i].Compression());
1335  for(int i=ThisHit.StartTick(); i<=ThisHit.EndTick();++i)
1336  Hit_AdjP5SADC[colHitCount]+=ADCs[i];
1337  break;
1338  default:
1339  break;
1340  }
1341  }
1342 }
1343 
1344 
1346 {
1347  mf::LogDebug(fname) << firstCatch << " " << secondCatch << " " << thirdCatch << std::endl;
1348 }
1349 
bool fSaveNeighbourADCs
double E(const int i=0) const
Definition: MCParticle.h:233
TrackID_t trackID
Geant4 supplied track ID.
Definition: SimChannel.h:112
std::string const & processName() const
Definition: Observer.cc:68
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
intermediate_table::iterator iterator
std::vector< int > True_Bck_ID
std::vector< int > Hit_AdjP1Chan
Index OpChannel(Index detNum, Index channel)
std::vector< double > PDS_OpHit_X
SNAna(fhicl::ParameterSet const &p)
void analyze(art::Event const &evt) override
std::vector< int > PDS_OpHit_True_TrackID
int secondCatch
std::vector< int > Hit_AdjP5Chan
std::vector< float > True_VertY
int PdgCode() const
Definition: MCParticle.h:212
std::vector< float > Hit_Peak
std::string fCalDataModuleLabel
EventNumber_t event() const
Definition: DataViewImpl.cc:85
std::vector< float > True_Dirz
std::vector< double > True_Bck_VertY
std::vector< float > Hit_True_Energy
int TotGen_Neut
int TotGen_Plon
double EndE() const
Definition: MCParticle.h:244
std::vector< int > Hit_AdjM5SADC
double EndZ() const
Definition: MCParticle.h:228
std::vector< float > True_MarlTime
std::vector< float > Hit_True_Z
std::vector< unsigned short > PDS_OpHit_Frame
int TotGen_Marl
void endJob() override
std::vector< int > Hit_Size
bool fSaveTPC
std::string fOpHitModuleLabel
std::vector< double > True_Bck_EndE
std::vector< int > True_CCNC
art::ServiceHandle< geo::Geometry > geo
void SaveNeighbourADC(int channel, art::Handle< std::vector< raw::RawDigit > >rawDigitsVecHandle, std::set< int > badChannels, recob::Hit const &hits)
std::string fname
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::vector< double > PDS_OpHit_PE
std::string string
Definition: nybbler.cc:12
std::vector< float > True_Time
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Planes which measure V.
Definition: geo_types.h:130
std::vector< double > PDS_OpHit_True_Energy
TTree * fSNAnaTree
geo::WireID WireID() const
Definition: Hit.h:233
std::vector< int > PDS_OpHit_True_IndexAll
float RMS() const
RMS of the hit shape, in tick units.
Definition: Hit.h:220
int Mother() const
Definition: MCParticle.h:213
std::vector< int > Hit_AdjM2SADC
int thirdCatch
std::vector< double > Hit_X_end
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::map< int, int > trkIDToMarleyIndex
std::string fHitLabel
struct vector vector
std::vector< float > True_Py
std::vector< double > True_Bck_P
std::vector< double > True_Bck_EndY
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition: RawDigit.h:73
int firstCatch
std::vector< double > True_Bck_VertZ
std::vector< double > Hit_Y_start
std::vector< float > Hit_SADC
bool fSavePDS
PType WhichParType(int TrID)
Planes which measure Z direction.
Definition: geo_types.h:132
std::vector< int > True_Bck_Mode
std::string fAPALabel
std::vector< int > Hit_True_nIDEs
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:224
geo::View_t View() const
View for the plane of the hit.
Definition: Hit.h:232
double Width(Resonance_t res)
resonance width (GeV)
uint8_t channel
Definition: CRTFragment.hh:201
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< int > Hit_View
std::vector< int > Hit_AdjP2SADC
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
std::vector< int > True_MarlSample
std::string Process() const
Definition: MCParticle.h:215
std::vector< float > Hit_Time
double EndY() const
Definition: MCParticle.h:227
std::map< int, simb::MCParticle > RdonParts
std::vector< int > True_VertexChan
std::vector< int > True_HitNucleon
std::vector< double > True_Bck_Energy
void beginJob() override
std::vector< double > PDS_OpHit_FastToTotal
SupernovaSamplingMode_t SamplingMode
Method used to sample the supernova neutrino&#39;s energy and arrival time.
std::vector< int > Hit_AdjP5SADC
art framework interface to geometry description
int TrackId() const
Definition: MCParticle.h:210
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:221
std::vector< int > PDS_OpHit_OpChannel
void FillTruth(const art::FindManyP< simb::MCParticle > Assn, const art::Handle< std::vector< simb::MCTruth >> &Hand, const PType type)
std::vector< double > Hit_Z_start
int TotGen_Ar42
std::map< int, const simb::MCParticle * > truthmap
std::vector< float > True_ENu
double Weight
Statistical weight for this neutrino vertex.
std::string fRawDigitLabel
std::vector< float > True_Pz
std::string fRdonLabel
T abs(T value)
Planes which measure U.
Definition: geo_types.h:129
std::vector< float > Hit_RMS
std::string fMARLLabel
int NColHit
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
bool fSaveIDEs
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::string EndProcess() const
Definition: MCParticle.h:216
Local-to-world transformations with LArSoft geometry vectors.
std::vector< float > Hit_True_X
Ionization at a point of the TPC sensitive volume.
Definition: SimChannel.h:84
std::vector< int > Hit_True_GenType
std::vector< int > PDS_OpHit_True_Index
const double a
int Event
std::vector< int > PDS_OpHit_True_TrackIDAll
std::map< int, simb::MCParticle > MarlParts
double P(const int i=0) const
Definition: MCParticle.h:234
T get(std::string const &key) const
Definition: ParameterSet.h:271
float energy
energy deposited by ionization by this track ID and time [MeV]
Definition: SimChannel.h:114
float energyFrac
fraction of OpHit energy from the particle with this trackID
std::vector< int > True_Target
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &opHit_P)
double T(const int i=0) const
Definition: MCParticle.h:224
bool InMyMap(int TrID, std::map< int, simb::MCParticle > ParMap)
std::map< int, simb::MCParticle > Ar39Parts
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
int TotGen_CPA
p
Definition: test.py:223
std::vector< double > PDS_OpHit_Y
std::vector< double > PDS_OpHit_Z
std::vector< double > PDS_OpHit_True_EnergyAll
std::vector< float > Hit_Int
std::vector< int > Hit_True_MarleyIndex
std::string fAr42Label
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
std::string fKrypLabel
gen
Definition: demo.py:24
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
std::vector< double > True_Bck_VertX
int NIndHit
SNAna & operator=(SNAna const &)=delete
RunNumber_t run() const
Definition: DataViewImpl.cc:71
static int max(int a, int b)
double EndT() const
Definition: MCParticle.h:229
void FillMyMaps(std::map< int, simb::MCParticle > &MyMap, art::FindManyP< simb::MCParticle > Assn, art::Handle< std::vector< simb::MCTruth > > Hand, std::map< int, int > *indexMap=nullptr)
std::vector< double > Hit_Z_end
std::vector< float > Hit_True_Y
raw::TDCtick_t StartTick() const
Initial tdc tick for hit.
Definition: Hit.h:216
std::string fGEANTLabel
std::vector< int > True_Nu_Lep_Type
void SaveIDEs(art::Event const &evt)
int TotGen_Rdon
std::vector< double > True_Bck_EndX
std::vector< int > Hit_AdjM2Chan
art::ServiceHandle< cheat::PhotonBackTrackerService > pbt_serv
std::vector< int > IDEChannel
int NTotIDEs
Detector simulation of raw signals on wires.
std::vector< int > Hit_AdjM1Chan
std::vector< int > IDEStartTime
std::vector< int > True_Bck_Mother
std::vector< float > True_VertX
std::vector< int > Hit_AdjM1SADC
std::vector< int > Hit_TPC
std::string fCPALabel
Encapsulate the geometry of a wire.
std::vector< float > True_VertexT
std::vector< double > PDS_OpHit_Amplitude
raw::TDCtick_t EndTick() const
Final tdc tick for hit.
Definition: Hit.h:217
std::vector< int > Hit_True_MainTrID
std::vector< int > Hit_AdjP1SADC
Ionization photons from a Geant4 track.
std::vector< int > True_Nu_Type
std::vector< double > PDS_OpHit_Area
void ResetVariables()
std::vector< int > IDEEndTime
std::vector< float > Hit_True_EvEnergy
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< double > PDS_OpHit_PeakTimeAbs
std::vector< int > Hit_True_TrackID
double Vx(const int i=0) const
Definition: MCParticle.h:221
std::map< int, simb::MCParticle > NeutParts
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
std::vector< float > True_VertZ
Declaration of signal hit object.
int TotGen_APA
std::vector< int > Hit_AdjM5Chan
std::map< int, PType > trkIDToPType
std::vector< int > PDS_OpHit_True_GenType
std::vector< float > IDEElectrons
std::string fPlonLabel
double SupernovaTime
Arrival time of the supernova neutrino (seconds)
std::vector< float > IDEEnergy
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
std::map< int, simb::MCParticle > PlonParts
std::vector< std::string > True_Bck_Process
std::vector< int > Hit_Chan
std::vector< double > PDS_OpHit_Width
std::map< int, simb::MCParticle > APAParts
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Stores extra MC truth information that is recorded when generating events using a time-dependent supe...
int NTotHit
std::vector< float > True_Dirx
std::vector< int > True_Mode
std::string fAr39Label
std::map< int, simb::MCParticle > CPAParts
std::vector< double > PDS_OpHit_PeakTime
std::map< int, simb::MCParticle > KrypParts
std::map< int, simb::MCParticle > Ar42Parts
double Vz(const int i=0) const
Definition: MCParticle.h:223
static bool * b
Definition: config.cpp:1043
std::vector< double > Hit_Y_end
std::vector< float > True_Px
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
Definition: Hit.h:223
std::vector< int > PDS_OpHit_True_GenTypeAll
std::vector< float > True_ENu_Lep
Definitions of geometry vector data types.
Declaration of basic channel signal object.
int TotGen_Kryp
std::vector< double > True_Bck_EndT
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::vector< const sim::IDE * > HitToSimIDEs_Ps(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
void reconfigure(fhicl::ParameterSet const &p)
std::vector< int > True_Bck_PDG
std::vector< std::string > True_Bck_EndProcess
Tools and modules for checking out the basics of the Monte Carlo.
TCEvent evt
Definition: DataStructs.cxx:7
int TotGen_Ar39
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
std::vector< double > True_Bck_Time
std::vector< float > Hit_True_nElec
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
double EndX() const
Definition: MCParticle.h:226
int NHitNoBT
std::map< PType, std::string > PTypeString
Definition: SNAna_module.cc:58
recob::tracking::Plane Plane
Definition: TrackState.h:17
std::vector< int > Hit_AdjP2Chan
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::string fNeutLabel
std::vector< double > Hit_X_start
std::vector< float > True_Diry
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:230
int SubRun
double Vy(const int i=0) const
Definition: MCParticle.h:222
std::vector< float > True_MarlWeight
std::vector< double > True_Bck_EndZ
std::vector< sim::TrackIDE > ChannelToTrackIDEs(detinfo::DetectorClocksData const &clockData, raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
float numElectrons
number of electrons at the readout for this track ID and time
Definition: SimChannel.h:113
QTextStream & endl(QTextStream &s)
Signal from collection planes.
Definition: geo_types.h:146
bool fSaveTruth
std::vector< int > IDEParticle
art::ServiceHandle< cheat::BackTrackerService > bt_serv