SnovaAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SnovaAna
3 // Module Type: analyzer
4 // File: SnovaAna_module.cc
5 //
6 // Generated at Mon Jan 9 16:10:25 2017 by Andrey Sheshukov using artmod
7 // from cetpkgsupport v1_10_02.
8 ////////////////////////////////////////////////////////////////////////
9 #include "TTree.h"
10 #include "TH1D.h"
11 #include "Simulation/FLSHit.h"
12 #include "Simulation/FLSHitList.h"
13 #include "RawData/RawDigit.h"
14 #include "RecoBase/CellHit.h"
22 #include "art/Utilities/InputTag.h"
23 #include "fhiclcpp/ParameterSet.h"
25 #include "MCCheater/BackTracker.h"
26 
27 
28 namespace supernova {
29  class SnovaAna;
30 }
31 
33 public:
34  explicit SnovaAna(fhicl::ParameterSet const & p);
35  // The destructor generated by the compiler is fine for classes
36  // without bare pointers or other resource use.
37 
38  // Plugins should not be copied or assigned.
39  SnovaAna(SnovaAna const &) = delete;
40  SnovaAna(SnovaAna &&) = delete;
41  SnovaAna & operator = (SnovaAna const &) = delete;
42  SnovaAna & operator = (SnovaAna &&) = delete;
43 
44  // Required functions.
45  void analyze(art::Event const & e) override;
46  void beginJob() override;
47 
48 
49 private:
50 
51  // Declare member data here.
52  TTree *fTreeP, *fTreeD;
53  struct { long pdg; double p,x,y,z,t; } fPart;
54  struct { long adc; double t; } fDigit;
55 
57 };
58 
59 
61  :
62  EDAnalyzer(p) // ,
63  // More initializers here.
64 {
65 
66 }
67 
70  double tmax=1;
71  hDigsTime = tfs->make<TH1D>("h_digs","RawDigit time distribution;Time,s",100,0,tmax);
72  hHitsTime = tfs->make<TH1D>("h_hits","FLSHits time distribution;Time,s", 100,0,tmax);
73  hVtxTime = tfs->make<TH1D>("h_vtx", "Vtx timing distribution; Time,s", 100,0,tmax);
74  fTreeP = tfs->make<TTree>("parts", "Particles tree");
75  fTreeP->Branch("part",&fPart,"pdg/L:p/D:x:y:z:t");
76  fTreeD = tfs->make<TTree>("digits", "Digits tree");
77  fTreeD->Branch("digit",&fDigit,"adc/l:t/D");
78 }
79 
81 {
82  // Implementation of required member function here.
84 
85  auto digs=e.getValidHandle<std::vector<rawdata::RawDigit> >("daq");
86  auto hits=e.getValidHandle<std::vector<sim::FLSHitList> >("geantgen");
87  auto truth=e.getValidHandle<std::vector<simb::MCTruth> >("generator");
88 
89 /* std::cout<<"hits size="<<hits->size()<<std::endl;
90  std::cout<<"truth size="<<hits->size()<<std::endl;
91  std::cout<<"time:"<<e.time().value()<<std::endl;
92  */
93  auto et=(e.id().event()-1)*5e-3;//e.time().timeLow()/1e9;
94 
95  for(const auto& mc: *truth){
96  if(mc.NParticles()==0)continue;
97  auto t=mc.GetParticle(0).T(0)/1e9;
98  for(int i=0;i<mc.NParticles();++i){
99  auto p=mc.GetParticle(i);
100  fPart={(long)p.PdgCode(),p.P(0),p.Vx(),p.Vy(),p.Vz(),p.T()*1e-9+et};
101  fTreeP->Fill();
102  }
103  std::cout<<"t_mc="<<et+t<<std::endl;
104  hVtxTime->Fill(et+t);
105  }
106 
107  for(const auto& hlist: *hits)
108  for(const auto& hit: hlist.fHits){
109  auto t=hit.GetEntryT()/1e9;
110  // std::cout<<"t_hit="<<t<<std::endl;
111  hHitsTime->Fill(t);
112  }
113  for(const auto& dig: *digs){
114  auto t=dig.TDC()/64e6;
115  fDigit={dig.ADC(),t};
116  fTreeD->Fill();
117  hDigsTime->Fill(t);
118  }
119 }
120 
back track the reconstruction to the simulation
SnovaAna(fhicl::ParameterSet const &p)
struct supernova::SnovaAna::@42 fDigit
const char * p
Definition: xmltok.h:285
DEFINE_ART_MODULE(TestTMapFile)
void hits()
Definition: readHits.C:15
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
OStream cout
Definition: OStream.cxx:6
SnovaAna & operator=(SnovaAna const &)=delete
EventNumber_t event() const
Definition: EventID.h:116
T * make(ARGS...args) const
struct supernova::SnovaAna::@41 fPart
Definition: structs.h:12
An ART module for generating supernova events via GENIE.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35
void analyze(art::Event const &e) override
void beginJob() override
EventID id() const
Definition: Event.h:56