All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
ICARUSParticleAna Class Reference
Inheritance diagram for ICARUSParticleAna:

Public Member Functions

 ICARUSParticleAna (fhicl::ParameterSet const &p)
 
 ICARUSParticleAna (ICARUSParticleAna const &)=delete
 
 ICARUSParticleAna (ICARUSParticleAna &&)=delete
 
ICARUSParticleAnaoperator= (ICARUSParticleAna const &)=delete
 
ICARUSParticleAnaoperator= (ICARUSParticleAna &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

TFile * _f
 
std::string _output_fname
 
std::string _particle_label
 
std::string _trajectory_label
 
TTree * _particletree
 
int _run
 
int _event
 
int _pdg_code
 
double _x
 
double _y
 
double _z
 
double _time
 
double _energy
 
double _momentum
 
int _track_id
 
std::vector< double > _x_v
 
std::vector< double > _y_v
 
std::vector< double > _z_v
 
std::vector< double > _time_v
 
std::vector< double > _energy_v
 

Detailed Description

Definition at line 30 of file ICARUSParticleAna_module.cc.

Constructor & Destructor Documentation

ICARUSParticleAna::ICARUSParticleAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 67 of file ICARUSParticleAna_module.cc.

68  : EDAnalyzer{p} // ,
69  // More initializers here.
70 {
71  // Call appropriate consumes<>() for any products to be retrieved by this module.
72  _output_fname = p.get<std::string>("OutputFileName");
73  _particle_label = p.get<std::string>("ParticleProducer");
74  _trajectory_label = p.get<std::string>("TrajectoryProducer");
75 }
pdgs p
Definition: selectors.fcl:22
ICARUSParticleAna::ICARUSParticleAna ( ICARUSParticleAna const &  )
delete
ICARUSParticleAna::ICARUSParticleAna ( ICARUSParticleAna &&  )
delete

Member Function Documentation

void ICARUSParticleAna::analyze ( art::Event const &  e)
override

Definition at line 106 of file ICARUSParticleAna_module.cc.

107 {
108  // Implementation of required member function here.
109  _event = e.id().event();
110  _run = e.id().run();
111 
112  art::Handle<std::vector< simb::MCTruth > > mctruth_h;
113  e.getByLabel(_particle_label, mctruth_h);
114  /*for (size_t idx = 0; idx < mctruth_h->size(); ++idx) {
115  auto const& mctruth = (*mctruth_h)[idx];
116  for (int part_idx = 0; part_idx < mctruth.NParticles(); ++part_idx) {
117  const auto& particle = mctruth.GetParticle(part_idx);
118  _pdg_code = particle.PdgCode();
119  _x = particle.Vx();
120  _y = particle.Vy();
121  _z = particle.Vz();
122  _time = particle.T();
123  _energy = particle.E();
124  _momentum = particle.P();
125  _track_id = particle.TrackId();
126 
127  const auto& trajectory = particle.Trajectory();
128  _x_v.resize(trajectory.size(), 0.);
129  _y_v.resize(trajectory.size(), 0.);
130  _z_v.resize(trajectory.size(), 0.);
131  for (size_t pt_idx = 0; pt_idx < trajectory.size(); ++pt_idx) {
132  _x_v[pt_idx] = trajectory.X(pt_idx);
133  _y_v[pt_idx] = trajectory.Y(pt_idx);
134  _z_v[pt_idx] = trajectory.Z(pt_idx);
135  _time_v[pt_idx] = trajectory.T(pt_idx);
136  _energy_v[pt_idx] = trajectory.E(pt_idx);
137  }
138  for (auto const & pair : trajectory) {
139  TLorentzVector const& pos = pair.first;
140  _x_v.push_back(pos.X());
141  _y_v.push_back(pos.Y());
142  _z_v.push_back(pos.Z());
143  _time_v.push_back(pos.T());
144  _energy_v.push_back(pos.E());
145  std::cout << pos << std::endl;
146  }
147  _particletree->Fill();
148  }
149  }*/
150 
151  art::Handle<std::vector< simb::MCParticle > > mcparticle_h;
152  e.getByLabel(_trajectory_label, mcparticle_h);
153  for (size_t idx = 0; idx < mcparticle_h->size(); ++idx) {
154  auto const& particle = (*mcparticle_h)[idx];
155  //for (auto const& particle : mcparticle_v) {
156  _pdg_code = particle.PdgCode();
157  _x = particle.Vx();
158  _y = particle.Vy();
159  _z = particle.Vz();
160  _time = particle.T();
161  _energy = particle.E();
162  _momentum = particle.P();
163  _track_id = particle.TrackId();
164 
165  const auto& trajectory = particle.Trajectory();
166  _x_v.resize(trajectory.size(), 0.);
167  _y_v.resize(trajectory.size(), 0.);
168  _z_v.resize(trajectory.size(), 0.);
169  _time_v.resize(trajectory.size(), 0.);
170  _energy_v.resize(trajectory.size(), 0.);
171  for (size_t pt_idx = 0; pt_idx < trajectory.size(); ++pt_idx) {
172  _x_v[pt_idx] = trajectory.X(pt_idx);
173  _y_v[pt_idx] = trajectory.Y(pt_idx);
174  _z_v[pt_idx] = trajectory.Z(pt_idx);
175  _time_v[pt_idx] = trajectory.T(pt_idx);
176  _energy_v[pt_idx] = trajectory.E(pt_idx);
177  }
178  _particletree->Fill();
179  //}
180  }
181 
182  // Also record sim::SimEnergyDeposit from largeant?
183  //art::Handle<std::vector< sim::SimEnergyDeposit > > simenergy_h;
184  //e.getByLabel(_simenergy_label, simenergy_h);
185  // Plus Kazu's algorithm to sparsify?
186 }
std::vector< double > _time_v
std::vector< double > _z_v
std::vector< double > _energy_v
std::vector< double > _x_v
do i e
std::vector< double > _y_v
void ICARUSParticleAna::beginJob ( )
override

Definition at line 77 of file ICARUSParticleAna_module.cc.

78 {
79  _f = TFile::Open(_output_fname.c_str(), "RECREATE");
80  std::string name = _particle_label + "_particletree";
81  _particletree = new TTree(name.c_str(), name.c_str());
82  _particletree->Branch("run", &_run, "run/I");
83  _particletree->Branch("event", &_event, "event/I");
84  _particletree->Branch("pdg_code", &_pdg_code, "pdg_code/I");
85  _particletree->Branch("x", &_x, "x/D");
86  _particletree->Branch("y", &_y, "y/D");
87  _particletree->Branch("z", &_z, "z/D");
88  _particletree->Branch("time", &_time, "time/D");
89  _particletree->Branch("energy", &_energy, "energy/D");
90  _particletree->Branch("momentum", &_momentum, "momentum/D");
91  _particletree->Branch("track_id", &_track_id, "track_id/I");
92  _particletree->Branch("x_v", &_x_v);
93  _particletree->Branch("y_v", &_y_v);
94  _particletree->Branch("z_v", &_z_v);
95  _particletree->Branch("time_v", &_time_v);
96  _particletree->Branch("energy_v", &_energy_v);
97 }
std::vector< double > _time_v
std::vector< double > _z_v
std::vector< double > _energy_v
std::vector< double > _x_v
then echo fcl name
std::vector< double > _y_v
void ICARUSParticleAna::endJob ( )
override

Definition at line 99 of file ICARUSParticleAna_module.cc.

100 {
101  _f->cd();
102  _particletree->Write();
103  if (_f) _f->Close();
104 }
ICARUSParticleAna& ICARUSParticleAna::operator= ( ICARUSParticleAna const &  )
delete
ICARUSParticleAna& ICARUSParticleAna::operator= ( ICARUSParticleAna &&  )
delete

Member Data Documentation

double ICARUSParticleAna::_energy
private

Definition at line 60 of file ICARUSParticleAna_module.cc.

std::vector<double> ICARUSParticleAna::_energy_v
private

Definition at line 63 of file ICARUSParticleAna_module.cc.

int ICARUSParticleAna::_event
private

Definition at line 56 of file ICARUSParticleAna_module.cc.

TFile* ICARUSParticleAna::_f
private

Definition at line 50 of file ICARUSParticleAna_module.cc.

double ICARUSParticleAna::_momentum
private

Definition at line 61 of file ICARUSParticleAna_module.cc.

std::string ICARUSParticleAna::_output_fname
private

Definition at line 51 of file ICARUSParticleAna_module.cc.

std::string ICARUSParticleAna::_particle_label
private

Definition at line 52 of file ICARUSParticleAna_module.cc.

TTree* ICARUSParticleAna::_particletree
private

Definition at line 55 of file ICARUSParticleAna_module.cc.

int ICARUSParticleAna::_pdg_code
private

Definition at line 57 of file ICARUSParticleAna_module.cc.

int ICARUSParticleAna::_run
private

Definition at line 56 of file ICARUSParticleAna_module.cc.

double ICARUSParticleAna::_time
private

Definition at line 59 of file ICARUSParticleAna_module.cc.

std::vector<double> ICARUSParticleAna::_time_v
private

Definition at line 63 of file ICARUSParticleAna_module.cc.

int ICARUSParticleAna::_track_id
private

Definition at line 62 of file ICARUSParticleAna_module.cc.

std::string ICARUSParticleAna::_trajectory_label
private

Definition at line 53 of file ICARUSParticleAna_module.cc.

double ICARUSParticleAna::_x
private

Definition at line 58 of file ICARUSParticleAna_module.cc.

std::vector<double> ICARUSParticleAna::_x_v
private

Definition at line 63 of file ICARUSParticleAna_module.cc.

double ICARUSParticleAna::_y
private

Definition at line 58 of file ICARUSParticleAna_module.cc.

std::vector<double> ICARUSParticleAna::_y_v
private

Definition at line 63 of file ICARUSParticleAna_module.cc.

double ICARUSParticleAna::_z
private

Definition at line 58 of file ICARUSParticleAna_module.cc.

std::vector<double> ICARUSParticleAna::_z_v
private

Definition at line 63 of file ICARUSParticleAna_module.cc.


The documentation for this class was generated from the following file: