SimAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SimAna
3 // Module Type: analyzer
4 // File: SimAna_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 SimAna;
30 }
31 
33 public:
34  explicit SimAna(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  SimAna(SimAna const &) = delete;
40  SimAna(SimAna &&) = delete;
41  SimAna & operator = (SimAna const &) = delete;
42  SimAna & operator = (SimAna &&) = 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 *fTree;
53  std::vector<long> fPdg;
54  std::vector<double> fP;
55  std::vector<double> fX,fY,fZ,fT;
56 
57 // struct { long adc; int nx, ny; } fCluster;
58 
59 };
60 
61 
63  :
64  EDAnalyzer(p) // ,
65  // More initializers here.
66 {
67 
68 }
69 
72  fTree = tfs->make<TTree>("particles", "Particles tree");
73  fTree->Branch("pdg",&fPdg);
74  fTree->Branch("p",&fP);
75  fTree->Branch("x",&fX);
76  fTree->Branch("y",&fY);
77  fTree->Branch("z",&fZ);
78  fTree->Branch("t",&fT);
79 }
80 
82 {
83 
84  auto truth=e.getValidHandle<std::vector<simb::MCTruth> >("generator");
85 // auto hits=e.getValidHandle<std::vector<novaddt::DAQHit> >("");
86 // fCluster=CalcCluster(*hits);
87  //
88  for(const auto& mc: *truth){
89  fPdg.clear();
90  fP.clear();
91  fX.clear();
92  fY.clear();
93  fZ.clear();
94  fT.clear();
95  for(int i=0; i<mc.NParticles();++i){
96  auto p=mc.GetParticle(i);
97  fPdg.push_back(p.PdgCode());
98  fP.push_back(p.P(0));
99  fX.push_back(p.Vx());
100  fY.push_back(p.Vy());
101  fZ.push_back(p.Vz());
102  fT.push_back(p.T());
103  }
104  fTree->Fill();
105  }
106 
107 }
108 
void analyze(art::Event const &e) override
back track the reconstruction to the simulation
std::vector< double > fX
const char * p
Definition: xmltok.h:285
std::vector< double > fY
DEFINE_ART_MODULE(TestTMapFile)
SimAna(fhicl::ParameterSet const &p)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void beginJob() override
T * make(ARGS...args) const
std::vector< double > fP
SimAna & operator=(SimAna const &)=delete
std::vector< double > fT
An ART module for generating supernova events via GENIE.
std::vector< double > fZ
std::vector< long > fPdg
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Float_t e
Definition: plot.C:35