All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBAnaICARUS_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: OBAnaICARUS
3 // Plugin Type: analyzer (art v3_05_01)
4 // File: OBAnaICARUS_module.cc
5 //
6 // Generated at Mon Nov 30 14:16:07 2020 by Biswaranjan Behera using cetskelgen
7 // from cetlib version v3_10_00.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDAnalyzer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
19 
20 #include "art_root_io/TFileService.h"
21 
22 #include <memory>
23 #include <map>
24 
25 #include "TTree.h"
26 
27 #include "nusimdata/SimulationBase/MCParticle.h"
30 #include "nusimdata/SimulationBase/MCTruth.h"
31 #include "nusimdata/SimulationBase/GTruth.h"
33 
34 #include "larcorealg/CoreUtils/ParticleFilters.h" // util::PositionInVolumeFilter
36 #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom()
37 
38 #include <boost/uuid/uuid.hpp> // uuid class
39 #include <boost/uuid/uuid_generators.hpp> // generators
40 #include <boost/uuid/uuid_io.hpp> // streaming operators etc.
41 
42 
43 namespace obana {
44  class OBAnaICARUS;
45 }
46 
47 
48 class obana::OBAnaICARUS : public art::EDAnalyzer {
49 public:
50  explicit OBAnaICARUS(fhicl::ParameterSet const& p);
51  // The compiler-generated destructor is fine for non-base
52  // classes without bare pointers or other resource use.
53 
54  // Plugins should not be copied or assigned.
55  OBAnaICARUS(OBAnaICARUS const&) = delete;
56  OBAnaICARUS(OBAnaICARUS&&) = delete;
57  OBAnaICARUS& operator=(OBAnaICARUS const&) = delete;
58  OBAnaICARUS& operator=(OBAnaICARUS&&) = delete;
59 
60  // Required functions.
61  void analyze(art::Event const& e) override;
62  void beginSubRun(art::SubRun const& sr) override;
63 
64  using Point_t = std::array<double, 3>;
65 
66 private:
67 
68  // Declare member data here.
69  /// Clear vectors
70  void clear_vectors();
71 
72  /// Finds the ancestors that was created in the Ovrburden, if any
73  int FindMotherInOverburden(simb::MCParticle);
74 
75  /// Check if the point is in the detector
76  bool InDetector(const double& x, const double& y, const double& z) const;
77 
78  /// Check if an MCP passes through the detector, sets step to the step index when particle is in detector
79  bool InDetector(const art::Ptr<simb::MCParticle>, int & step);
80 
81  /// Saves the pi0 info to a separate tree, give the pi0 track id
82  void SavePi0ShowerInfo(int pi0_track_id);
83 
84  /// Saves the muon info to a separate tree, give the muon track id
85  void SaveMuonShowerInfo(int muon_track_id);
86 
87 
88  /// Configures and returns a particle filter
89  std::unique_ptr<util::PositionInVolumeFilter> CreateParticleVolumeFilter
90  (std::set<std::string> const& vol_names) const;
91 
92  std::map<unsigned int, simb::MCParticle> _trackid_to_mcparticle;
93 
94  std::unique_ptr<util::PositionInVolumeFilter> _part_filter;
95 
96 
97  std::string _mctruth_producer = "generator"; // For storing POT information
98  std::string _mcparticle_producer = "largeant";
99  std::string _mctrack_producer = "mcreco";
100  std::string _mcshower_producer = "mcreco";
101 
102  bool _save_pi0_tree = true;
103  bool _save_muon_tree = true;
104  bool _simulating_dirt = false;
105 
106  std::vector<unsigned int> _pi0_ids;
107  std::vector<unsigned int> _muon_ids;
108 
109 
110  std::vector<std::string> _overburden_volumes = {"volShieldingLid", "volShieldingTop", "volMezzanineLid"};
111 
112  double xminc0 = -358.49;
113  double xmaxc0 = -61.94;
114  double xminc1 = 61.94;
115  double xmaxc1 = 358.49;
116  double ymin = -181.86;
117  double ymax = 134.96;
118  double zmin = -894.951;
119  double zmax = 894.951;
120 
121  double _x_max; //!< x-max of volume box used to determine whether to save track information
122  double _x_min; //!< x-min of volume box used to determine whether to save track information
123  double _y_max; //!< y-max of volume box used to determine whether to save track information
124  double _y_min; //!< y-min of volume box used to determine whether to save track information
125  double _z_max; //!< z-max of volume box used to determine whether to save track information
126  double _z_min; //!< z-min of volume box used to determine whether to save track information
127 
128  boost::uuids::uuid _uuid; ///< A unique ID to identify different events in files with same event number
129  std::string _uuid_str; ///< Same as uuid, but converted to string
130 
131  TTree* _tree;
132 
134 
135  float _nu_e;
136  int _nu_pdg;
137  int _nu_ccnc;
138  int _nu_mode;
140  float _nu_vtx_x;
141  float _nu_vtx_y;
142  float _nu_vtx_z;
143  float _nu_px;
144  float _nu_py;
145  float _nu_pz;
146  int _nu_pip_mult; ///< Pi0 multiplicity
147  int _nu_pi0_mult; ///< Pi plus multiplicity
148  int _nu_p_mult; ///< Proton multiplicity
149  std::vector<int> _pars_pdg; ///< All other particles produced - pdg code
150  std::vector<float> _pars_e; ///< All other particles produced - energy
151 
152 
153  std::vector<float> _mcp_px;
154  std::vector<float> _mcp_py;
155  std::vector<float> _mcp_pz;
156  std::vector<float> _mcp_e;
157  std::vector<float> _mcp_vx;
158  std::vector<float> _mcp_vy;
159  std::vector<float> _mcp_vz;
160  std::vector<float> _mcp_endx;
161  std::vector<float> _mcp_endy;
162  std::vector<float> _mcp_endz;
163  std::vector<float> _mcp_pdg;
164  std::vector<float> _mcp_mother;
165  std::vector<float> _mcp_status_code;
166  std::vector<std::string> _mcp_process;
167  std::vector<std::string> _mcp_end_process;
168  std::vector<bool> _mcp_intpc;
169  std::vector<float> _mcp_intpc_e;
170  std::vector<float> _mcp_trackid;
171  std::vector<float> _mcp_intpc_nu_e;
172  //std::string _neut_par_uuid;
173  std::vector<int> _neut_daughters_pdg; ///< All the neutron daughters
174  std::vector<float> _neut_daughters_e; ///< All the neutron daughters energy
175  std::vector<float> _neut_daughters_px; ///< All the neutron daughters momentrum in x direction
176  std::vector<float> _neut_daughters_py; ///< All the neutron daughters momentrum in y direction
177  std::vector<float> _neut_daughters_pz; ///< All the neutron daughters momentrum in z direction
178  std::vector<std::string> _neut_daughters_startprocess; ///< All the neutron daughters start process
179  std::vector<std::string> _neut_daughters_endprocess; ////< All the neutron daughters end process
180  std::vector<float> _neut_daughters_start_x; ///< All the neutron daughters start x
181  std::vector<float> _neut_daughters_start_y; ///< All the neutron daughters start y
182  std::vector<float> _neut_daughters_start_z; ///< All the neutron daughters start z
183  std::vector<float> _neut_daughters_end_x; ///< All the neutron daughters end x
184  std::vector<float> _neut_daughters_end_y; ///< All the neutron daughters end y
185  std::vector<float> _neut_daughters_end_z; ///< All the neutron daughters end z
186  std::vector<float> _neut_daughters_trackid; ///< All the neutron daughters trackid
187 
188 
189  std::vector<int> _neut_grand_daughters_pdg; ///< All the neutron daughters
190  std::vector<float> _neut_grand_daughters_e; ///< All the neutrons grand daughters energy
191  std::vector<float> _neut_grand_daughters_px; ///< All the neutrons grand daughters momentrum in x direction
192  std::vector<float> _neut_grand_daughters_py; ///< All the neutrons grand daughters momentrum in y direction
193  std::vector<float> _neut_grand_daughters_pz; ///< All the neutrons grand daughters momentrum in z direction
194  std::vector<std::string> _neut_grand_daughters_startprocess; ///< All the neutrons grand daughters start process
195  std::vector<std::string> _neut_grand_daughters_endprocess; ////< All the neutrons grand daughters end process
196  std::vector<float> _neut_grand_daughters_start_x; ///< All the neutrons grand daughters start x
197  std::vector<float> _neut_grand_daughters_start_y; ///< All the neutrons grand daughters start y
198  std::vector<float> _neut_grand_daughters_start_z; ///< All the neutrons grand daughters start z
199  std::vector<float> _neut_grand_daughters_end_x; ///< All the neutrons grand daughters end x
200  std::vector<float> _neut_grand_daughters_end_y; ///< All the neutrons grand daughters end y
201  std::vector<float> _neut_grand_daughters_end_z; ///< All the neutrons grand daughters end z
202  std::vector<float> _neut_grand_daughters_trackid; ///< All the neutrons grand daughters trackid
203 
204 
205  std::vector<float> _mcs_pdg;
206  std::vector<std::string> _mcs_process;
207  std::vector<float> _mcs_start_x;
208  std::vector<float> _mcs_start_y;
209  std::vector<float> _mcs_start_z;
210  std::vector<float> _mcs_end_x;
211  std::vector<float> _mcs_end_y;
212  std::vector<float> _mcs_end_z;
213  std::vector<float> _mcs_start_px;
214  std::vector<float> _mcs_start_py;
215  std::vector<float> _mcs_start_pz;
216  std::vector<float> _mcs_start_e;
217  std::vector<double> _mcs_charge_col;
218  std::vector<double> _mcs_charge_ind2;
219  std::vector<double> _mcs_charge_ind1;
220  std::vector<float> _mcs_mother_pdg;
221  std::vector<float> _mcs_mother_trackid;
222  std::vector<float> _mcs_mother_start_x;
223  std::vector<float> _mcs_mother_start_y;
224  std::vector<float> _mcs_mother_start_z;
225  std::vector<float> _mcs_mother_start_e;
226  std::vector<float> _mcs_mother_end_x;
227  std::vector<float> _mcs_mother_end_y;
228  std::vector<float> _mcs_mother_end_z;
229  std::vector<float> _mcs_mother_end_e;
230  std::vector<std::string> _mcs_mother_process;
231  std::vector<float> _mcs_ancestor_pdg;
232  std::vector<std::string> _mcs_ancestor_process;
233  std::vector<float> _mcs_ancestor_start_e;
234  std::vector<float> _mcs_ancestor_end_e;
235  std::vector<float> _mcs_mother_in_ob_trackid;
236  int _n_mcs_lt1; ///< Number of MC showers with energy less than 10 MeV
237  int _n_mcs_lt1_from_ob; ///< Number of MC showers with energy less than 10 MeV and coming from OB
238 
239  std::vector<float> _mct_pdg;
240  std::vector<std::string> _mct_process;
241  std::vector<float> _mct_start_x;
242  std::vector<float> _mct_start_y;
243  std::vector<float> _mct_start_z;
244  std::vector<float> _mct_end_x;
245  std::vector<float> _mct_end_y;
246  std::vector<float> _mct_end_z;
247  std::vector<float> _mct_start_px;
248  std::vector<float> _mct_start_py;
249  std::vector<float> _mct_start_pz;
250  std::vector<float> _mct_start_e;
251  std::vector<float> _mct_mother_pdg;
252  std::vector<std::string> _mct_mother_process;
253  std::vector<float> _mct_ancestor_pdg;
254  std::vector<std::string> _mct_ancestor_process;
255  std::vector<float> _mct_mother_in_ob_trackid;
256  int _n_mct_lt1; ///< Number of MC tracks with energy less than 10 MeV
257  int _n_mct_lt1_from_ob; ///< Number of MC tracks with energy less than 10 MeV and coming from OB
258 
259  TTree* _pi0_tree; ///< A pi0 TTree, one entry per pi0
260 
261  float _pi0_par_e; ///< The pi0 energy
262  float _pi0_par_start_x; ///< The pi0 start x
263  float _pi0_par_start_y; ///< The pi0 start y
264  float _pi0_par_start_z; ///< The pi0 start z
265  float _pi0_par_end_x; ///< The pi0 end x
266  float _pi0_par_end_y; ///< The pi0 end y
267  float _pi0_par_end_z; ///< The pi0 end z
268  int _pi0_par_mother_pdg; ///< The pi0 mother pdg
269  float _pi0_par_mother_e; ///< The pi0 mother energy
270  float _pi0_par_mother_end_e; ///< The pi0 mother energy at end
271  int _pi0_par_ancestor_trackid; ///< The pi0 primary particle ancestor track id (allows easy pi0 clustering by cosmic interaction)
272  std::string _pi0_par_ancestor_uuid; ///< The pi0 unique ID for the event
273 
274  std::vector<int> _pi0_daughters_pdg; ///< All the pi0 daughters (usually two photons) (pdg)
275  std::vector<float> _pi0_daughters_e; ///< All the pi0 daughters (usually two photons) (energy)
276  std::vector<std::string> _pi0_daughters_startprocess; ///< All the pi0 daughters (usually two photons) (energy) (start process)
277  std::vector<std::string> _pi0_daughters_endprocess; ////< All the pi0 daughters (usually two photons) (energy) (end process)
278  std::vector<float> _pi0_daughters_start_x; ///< All the pi0 daughters (usually two photons) (start x)
279  std::vector<float> _pi0_daughters_start_y; ///< All the pi0 daughters (usually two photons) (start y)
280  std::vector<float> _pi0_daughters_start_z; ///< All the pi0 daughters (usually two photons) (start z)
281  std::vector<float> _pi0_daughters_end_x; ///< All the pi0 daughters (usually two photons) (end x)
282  std::vector<float> _pi0_daughters_end_y; ///< All the pi0 daughters (usually two photons) (end y)
283  std::vector<float> _pi0_daughters_end_z; ///< All the pi0 daughters (usually two photons) (end z)
284 
285  std::vector<int> _pi0_event_particles_pdg; ///< All the particles produced together with the pi0
286  std::vector<float> _pi0_event_particles_e; ///< All the particles produced together with the pi0
287 
288  std::vector<int> _pi0_genealogy_pdg; ///< The full pi0 genealogy, from its mother all the way to the ancestor (pdg)
289  std::vector<std::string> _pi0_genealogy_startprocess; ///< The full pi0 genealogy, from its mother all the way to the ancestor (start process)
290  std::vector<std::string> _pi0_genealogy_endprocess; ///< The full pi0 genealogy, from its mother all the way to the ancestor (end process)
291  std::vector<int> _pi0_genealogy_mother; ///< The full pi0 genealogy, from its mother all the way to the ancestor (mother track id)
292  std::vector<float> _pi0_genealogy_e; ///< The full pi0 genealogy, from its mother all the way to the ancestor (energy)
293  std::vector<float> _pi0_genealogy_start_x; ///< The full pi0 genealogy, from its mother all the way to the ancestor (start x)
294  std::vector<float> _pi0_genealogy_start_y; ///< The full pi0 genealogy, from its mother all the way to the ancestor (start y)
295  std::vector<float> _pi0_genealogy_start_z; ///< The full pi0 genealogy, from its mother all the way to the ancestor (start z)
296  std::vector<float> _pi0_genealogy_end_x; ///< The full pi0 genealogy, from its mother all the way to the ancestor (end x)
297  std::vector<float> _pi0_genealogy_end_y; ///< The full pi0 genealogy, from its mother all the way to the ancestor (end y)
298  std::vector<float> _pi0_genealogy_end_z; ///< The full pi0 genealogy, from its mother all the way to the ancestor (end z)
299  std::vector<float> _pi0_genealogy_trackid; ///< The full pi0 genealogy, from its mother all the way to the ancestor (trackid)
300 
301  TTree* _muon_tree; ///< A muon TTree, one entry per muon
302 
303  float _muon_par_e; ///< The muon energy
304  float _muon_par_start_x; ///< The muon start x
305  float _muon_par_start_y; ///< The muon start y
306  float _muon_par_start_z; ///< The muon start z
307  float _muon_par_end_x; ///< The muon end x
308  float _muon_par_end_y; ///< The muon end y
309  float _muon_par_end_z; ///< The muon end z
310  int _muon_par_mother_pdg; ///< The muon mother pdg
311  float _muon_par_mother_e; ///< The muon mother energy
312  float _muon_par_mother_end_e; ///< The muon mother energy at end
313  int _muon_par_ancestor_trackid; ///< The muon primary particle ancestor track id (allows easy muon clustering by cosmic interaction)
314  std::string _muon_par_ancestor_uuid; ///< The muon unique ID for the event
315 
316  std::vector<int> _muon_daughters_pdg; ///< All the muon daughters (usually two photons) (pdg)
317  std::vector<float> _muon_daughters_e; ///< All the muon daughters (usually two photons) (energy)
318  std::vector<std::string> _muon_daughters_startprocess; ///< All the muon daughters (usually two photons) (energy) (start process)
319  std::vector<std::string> _muon_daughters_endprocess; ////< All the muon daughters (usually two photons) (energy) (end process)
320  std::vector<float> _muon_daughters_start_x; ///< All the muon daughters (usually two photons) (start x)
321  std::vector<float> _muon_daughters_start_y; ///< All the muon daughters (usually two photons) (start y)
322  std::vector<float> _muon_daughters_start_z; ///< All the muon daughters (usually two photons) (start z)
323  std::vector<float> _muon_daughters_end_x; ///< All the muon daughters (usually two photons) (end x)
324  std::vector<float> _muon_daughters_end_y; ///< All the muon daughters (usually two photons) (end y)
325  std::vector<float> _muon_daughters_end_z; ///< All the muon daughters (usually two photons) (end z)
326 
327  std::vector<int> _muon_event_particles_pdg; ///< All the particles produced together with the muon
328  std::vector<float> _muon_event_particles_e; ///< All the particles produced together with the muon
329 
330  std::vector<int> _muon_genealogy_pdg; ///< The full muon genealogy, from its mother all the way to the ancestor (pdg)
331  std::vector<std::string> _muon_genealogy_startprocess; ///< The full muon genealogy, from its mother all the way to the ancestor (start process)
332  std::vector<std::string> _muon_genealogy_endprocess; ///< The full muon genealogy, from its mother all the way to the ancestor (end process)
333  std::vector<int> _muon_genealogy_mother; ///< The full muon genealogy, from its mother all the way to the ancestor (mother track id)
334  std::vector<float> _muon_genealogy_e; ///< The full muon genealogy, from its mother all the way to the ancestor (energy)
335  std::vector<float> _muon_genealogy_start_x; ///< The full muon genealogy, from its mother all the way to the ancestor (start x)
336  std::vector<float> _muon_genealogy_start_y; ///< The full muon genealogy, from its mother all the way to the ancestor (start y)
337  std::vector<float> _muon_genealogy_start_z; ///< The full muon genealogy, from its mother all the way to the ancestor (start z)
338  std::vector<float> _muon_genealogy_end_x; ///< The full muon genealogy, from its mother all the way to the ancestor (end x)
339  std::vector<float> _muon_genealogy_end_y; ///< The full muon genealogy, from its mother all the way to the ancestor (end y)
340  std::vector<float> _muon_genealogy_end_z; ///< The full muon genealogy, from its mother all the way to the ancestor (end z)
341  std::vector<float> _muon_genealogy_trackid; ///< The full muon genealogy, from its mother all the way to the ancestor (trackid)
342 
343 
344 
345  TTree* _sr_tree; ///< TTree filled per subrun
346  int _sr_run; ///< Subrun Run number
347  int _sr_subrun; ///< Subrun Subrun number
348  double _sr_begintime; ///< Subrun start time
349  double _sr_endtime; ///< Subrun end time
350  double _sr_pot; ///< Subrun POT
351 };
352 
353 
354 obana::OBAnaICARUS::OBAnaICARUS(fhicl::ParameterSet const& p)
355  : EDAnalyzer{p} // ,
356  // More initializers here.
357 {
358  // Call appropriate consumes<>() for any products to be retrieved by this module.
359  _save_pi0_tree = p.get<bool>("SavePi0Tree", true);
360  _simulating_dirt = p.get<bool>("SimulatingDirt", false);
361 
362  art::ServiceHandle<art::TFileService> fs;
363  _tree = fs->make<TTree>("OBTree","");
364 
365  _tree->Branch("run", &_run, "run/I");
366  _tree->Branch("subrun", &_subrun, "subrun/I");
367  _tree->Branch("event", &_event, "event/I");
368 
369 
370  _tree->Branch("nu_e", &_nu_e, "nu_e/F");
371  _tree->Branch("nu_pdg", &_nu_pdg, "nu_pdg/I");
372  _tree->Branch("nu_ccnc", &_nu_ccnc, "nu_ccnc/I");
373  _tree->Branch("nu_mode", &_nu_mode, "nu_mode/I");
374  _tree->Branch("nu_int_type", &_nu_int_type, "nu_int_type/I");
375  _tree->Branch("nu_vtx_x", &_nu_vtx_x, "nu_vtx_x/F");
376  _tree->Branch("nu_vtx_y", &_nu_vtx_y, "nu_vtx_y/F");
377  _tree->Branch("nu_vtx_z", &_nu_vtx_z, "nu_vtx_z/F");
378  _tree->Branch("nu_px", &_nu_px, "nu_px/F");
379  _tree->Branch("nu_py", &_nu_py, "nu_px/F");
380  _tree->Branch("nu_pz", &_nu_pz, "nu_px/F");
381  _tree->Branch("nu_pip_mult", &_nu_pip_mult, "nu_pip_mult/I");
382  _tree->Branch("nu_pi0_mult", &_nu_pi0_mult, "nu_pi0_mult/I");
383  _tree->Branch("nu_p_mult", &_nu_p_mult, "nu_p_mult/I");
384  _tree->Branch("pars_pdg", "std::vector<int>", &_pars_pdg);
385  _tree->Branch("pars_e", "std::vector<float>", &_pars_e);
386 
387 
388  _tree->Branch("mcp_px", "std::vector<float>", &_mcp_px);
389  _tree->Branch("mcp_py", "std::vector<float>", &_mcp_py);
390  _tree->Branch("mcp_pz", "std::vector<float>", &_mcp_pz);
391  _tree->Branch("mcp_e", "std::vector<float>", &_mcp_e);
392  _tree->Branch("mcp_vx", "std::vector<float>", &_mcp_vx);
393  _tree->Branch("mcp_vy", "std::vector<float>", &_mcp_vy);
394  _tree->Branch("mcp_vz", "std::vector<float>", &_mcp_vz);
395  _tree->Branch("mcp_endx", "std::vector<float>", &_mcp_endx);
396  _tree->Branch("mcp_endy", "std::vector<float>", &_mcp_endy);
397  _tree->Branch("mcp_endz", "std::vector<float>", &_mcp_endz);
398  _tree->Branch("mcp_pdg", "std::vector<float>", &_mcp_pdg);
399  _tree->Branch("mcp_mother", "std::vector<float>", &_mcp_mother);
400  _tree->Branch("mcp_status_code", "std::vector<float>", &_mcp_status_code);
401  _tree->Branch("mcp_process", "std::vector<std::string>", &_mcp_process);
402  _tree->Branch("mcp_end_process", "std::vector<std::string>", &_mcp_end_process);
403  _tree->Branch("mcp_intpc", "std::vector<bool>", &_mcp_intpc);
404  _tree->Branch("mcp_intpc_e", "std::vector<float>", &_mcp_intpc_e);
405  _tree->Branch("mcp_trackid", "std::vector<float>", &_mcp_trackid);
406  _tree->Branch("mcp_intpc_nu_e", "std::vector<float>", &_mcp_intpc_nu_e);
407 
408  //_tree->Branch("neut_par_uuid", "std::string", &_neut_par_uuid);
409  _tree->Branch("neut_daughters_pdg", "std::vector<int>", &_neut_daughters_pdg);
410  _tree->Branch("neut_daughters_px", "std::vector<float>", &_neut_daughters_px);
411  _tree->Branch("neut_daughters_py", "std::vector<float>", &_neut_daughters_py);
412  _tree->Branch("neut_daughters_pz", "std::vector<float>", &_neut_daughters_pz);
413  _tree->Branch("neut_daughters_e", "std::vector<float>", &_neut_daughters_e);
414  _tree->Branch("neut_daughters_startprocess", "std::vector<std::string>", &_neut_daughters_startprocess);
415  _tree->Branch("neut_daughters_endprocess", "std::vector<std::string>", &_neut_daughters_endprocess);
416  _tree->Branch("neut_daughters_start_x", "std::vector<float>", &_neut_daughters_start_x);
417  _tree->Branch("neut_daughters_start_y", "std::vector<float>", &_neut_daughters_start_y);
418  _tree->Branch("neut_daughters_start_z", "std::vector<float>", &_neut_daughters_start_z);
419  _tree->Branch("neut_daughters_end_x", "std::vector<float>", &_neut_daughters_end_x);
420  _tree->Branch("neut_daughters_end_y", "std::vector<float>", &_neut_daughters_end_y);
421  _tree->Branch("neut_daughters_end_z", "std::vector<float>", &_neut_daughters_end_z);
422  _tree->Branch("neut_daughters_trackid", "std::vector<float>", &_neut_daughters_trackid);
423 
424 
425  _tree->Branch("neut_grand_daughters_pdg", "std::vector<int>", &_neut_grand_daughters_pdg);
426  _tree->Branch("neut_grand_daughters_px", "std::vector<float>", &_neut_grand_daughters_px);
427  _tree->Branch("neut_grand_daughters_py", "std::vector<float>", &_neut_grand_daughters_py);
428  _tree->Branch("neut_grand_daughters_pz", "std::vector<float>", &_neut_grand_daughters_pz);
429  _tree->Branch("neut_grand_daughters_e", "std::vector<float>", &_neut_grand_daughters_e);
430  _tree->Branch("neut_grand_daughters_startprocess", "std::vector<std::string>", &_neut_grand_daughters_startprocess);
431  _tree->Branch("neut_grand_daughters_endprocess", "std::vector<std::string>", &_neut_grand_daughters_endprocess);
432  _tree->Branch("neut_grand_daughters_start_x", "std::vector<float>", &_neut_grand_daughters_start_x);
433  _tree->Branch("neut_grand_daughters_start_y", "std::vector<float>", &_neut_grand_daughters_start_y);
434  _tree->Branch("neut_grand_daughters_start_z", "std::vector<float>", &_neut_grand_daughters_start_z);
435  _tree->Branch("neut_grand_daughters_end_x", "std::vector<float>", &_neut_grand_daughters_end_x);
436  _tree->Branch("neut_grand_daughters_end_y", "std::vector<float>", &_neut_grand_daughters_end_y);
437  _tree->Branch("neut_grand_daughters_end_z", "std::vector<float>", &_neut_grand_daughters_end_z);
438  _tree->Branch("neut_grand_daughters_trackid", "std::vector<float>", &_neut_grand_daughters_trackid);
439 
440  _tree->Branch("mct_pdg", "std::vector<float>", &_mct_pdg);
441  _tree->Branch("mct_process", "std::vector<std::string>", &_mct_process);
442  _tree->Branch("mct_start_x", "std::vector<float>", &_mct_start_x);
443  _tree->Branch("mct_start_y", "std::vector<float>", &_mct_start_y);
444  _tree->Branch("mct_start_z", "std::vector<float>", &_mct_start_z);
445  _tree->Branch("mct_end_x", "std::vector<float>", &_mct_end_x);
446  _tree->Branch("mct_end_y", "std::vector<float>", &_mct_end_y);
447  _tree->Branch("mct_end_z", "std::vector<float>", &_mct_end_z);
448  _tree->Branch("mct_start_px", "std::vector<float>", &_mct_start_px);
449  _tree->Branch("mct_start_py", "std::vector<float>", &_mct_start_py);
450  _tree->Branch("mct_start_pz", "std::vector<float>", &_mct_start_pz);
451  _tree->Branch("mct_start_e", "std::vector<float>", &_mct_start_e);
452  _tree->Branch("mct_mother_pdg", "std::vector<float>", &_mct_mother_pdg);
453  _tree->Branch("mct_ancestor_pdg", "std::vector<float>", &_mct_ancestor_pdg);
454  _tree->Branch("mct_mother_process", "std::vector<std::string>>", &_mct_mother_process);
455  _tree->Branch("mct_ancestor_process", "std::vector<std::string>>", &_mct_ancestor_process);
456  _tree->Branch("mct_mother_in_ob_trackid", "std::vector<float>", &_mct_mother_in_ob_trackid);
457  _tree->Branch("mct_n_lt1", &_n_mct_lt1, "mct_n_lt1/I");
458  _tree->Branch("mct_n_lt1_from_ob", &_n_mct_lt1_from_ob, "mct_n_lt1_from_ob/I");
459 
460  _tree->Branch("mcs_pdg", "std::vector<float>", &_mcs_pdg);
461  _tree->Branch("mcs_process", "std::vector<std::string>", &_mcs_process);
462  _tree->Branch("mcs_start_x", "std::vector<float>", &_mcs_start_x);
463  _tree->Branch("mcs_start_y", "std::vector<float>", &_mcs_start_y);
464  _tree->Branch("mcs_start_z", "std::vector<float>", &_mcs_start_z);
465  _tree->Branch("mcs_end_x", "std::vector<float>", &_mcs_end_x);
466  _tree->Branch("mcs_end_y", "std::vector<float>", &_mcs_end_y);
467  _tree->Branch("mcs_end_z", "std::vector<float>", &_mcs_end_z);
468  _tree->Branch("mcs_start_px", "std::vector<float>", &_mcs_start_px);
469  _tree->Branch("mcs_start_py", "std::vector<float>", &_mcs_start_py);
470  _tree->Branch("mcs_start_pz", "std::vector<float>", &_mcs_start_pz);
471  _tree->Branch("mcs_start_e", "std::vector<float>", &_mcs_start_e);
472  _tree->Branch("mcs_charge_col", "std::vector<double>", &_mcs_charge_col);
473  _tree->Branch("mcs_charge_ind2", "std::vector<double>", &_mcs_charge_ind2);
474  _tree->Branch("mcs_charge_ind1", "std::vector<double>", &_mcs_charge_ind1);
475  _tree->Branch("mcs_mother_pdg", "std::vector<float>", &_mcs_mother_pdg);
476  _tree->Branch("mcs_mother_trackid", "std::vector<float>", &_mcs_mother_trackid);
477  _tree->Branch("mcs_mother_start_x", "std::vector<float>", &_mcs_mother_start_x);
478  _tree->Branch("mcs_mother_start_y", "std::vector<float>", &_mcs_mother_start_y);
479  _tree->Branch("mcs_mother_start_z", "std::vector<float>", &_mcs_mother_start_z);
480  _tree->Branch("mcs_mother_start_e", "std::vector<float>", &_mcs_mother_start_e);
481  _tree->Branch("mcs_mother_end_x", "std::vector<float>", &_mcs_mother_end_x);
482  _tree->Branch("mcs_mother_end_y", "std::vector<float>", &_mcs_mother_end_y);
483  _tree->Branch("mcs_mother_end_z", "std::vector<float>", &_mcs_mother_end_z);
484  _tree->Branch("mcs_mother_end_e", "std::vector<float>", &_mcs_mother_end_e);
485  _tree->Branch("mcs_ancestor_pdg", "std::vector<float>", &_mcs_ancestor_pdg);
486  _tree->Branch("mcs_mother_process", "std::vector<std::string>>", &_mcs_mother_process);
487  _tree->Branch("mcs_ancestor_process", "std::vector<std::string>>", &_mcs_ancestor_process);
488  _tree->Branch("mcs_ancestor_start_e", "std::vector<float>", &_mcs_ancestor_start_e);
489  _tree->Branch("mcs_ancestor_end_e", "std::vector<float>", &_mcs_ancestor_end_e);
490  _tree->Branch("mcs_mother_in_ob_trackid", "std::vector<float>", &_mcs_mother_in_ob_trackid);
491  _tree->Branch("mcs_n_lt1", &_n_mcs_lt1, "mcs_n_lt1/I");
492  _tree->Branch("mcs_n_lt1_from_ob", &_n_mcs_lt1_from_ob, "mcs_n_lt1_from_ob/I");
493 
494 
495  if (_save_pi0_tree) {
496  _pi0_tree = fs->make<TTree>("Pi0Tree","");
497 
498  _pi0_tree->Branch("run", &_run, "run/I");
499  _pi0_tree->Branch("subrun", &_subrun, "subrun/I");
500  _pi0_tree->Branch("event", &_event, "event/I");
501 
502  _pi0_tree->Branch("pi0_par_e", &_pi0_par_e, "pi0_par_e/F");
503  _pi0_tree->Branch("pi0_par_start_x", &_pi0_par_start_x, "pi0_par_start_x/F");
504  _pi0_tree->Branch("pi0_par_start_y", &_pi0_par_start_y, "pi0_par_start_y/F");
505  _pi0_tree->Branch("pi0_par_start_z", &_pi0_par_start_z, "pi0_par_start_z/F");
506  _pi0_tree->Branch("pi0_par_end_x", &_pi0_par_end_x, "pi0_par_end_x/F");
507  _pi0_tree->Branch("pi0_par_end_y", &_pi0_par_end_y, "pi0_par_end_y/F");
508  _pi0_tree->Branch("pi0_par_end_z", &_pi0_par_end_z, "pi0_par_end_z/F");
509  _pi0_tree->Branch("pi0_par_mother_pdg", &_pi0_par_mother_pdg, "pi0_par_mother_pdg/I");
510  _pi0_tree->Branch("pi0_par_mother_e", &_pi0_par_mother_e, "pi0_par_mother_e/F");
511  _pi0_tree->Branch("pi0_par_mother_end_e", &_pi0_par_mother_end_e, "pi0_par_mother_end_e/F");
512  _pi0_tree->Branch("pi0_par_ancestor_trackid", &_pi0_par_ancestor_trackid, "pi0_par_ancestor_trackid/I");
513  _pi0_tree->Branch("pi0_par_ancestor_uuid", "std::string", &_pi0_par_ancestor_uuid);
514 
515  _pi0_tree->Branch("pi0_event_particles_pdg", "std::vector<int>", &_pi0_event_particles_pdg);
516  _pi0_tree->Branch("pi0_event_particles_e", "std::vector<float>", &_pi0_event_particles_e);
517 
518  _pi0_tree->Branch("pi0_daughters_pdg", "std::vector<int>", &_pi0_daughters_pdg);
519  _pi0_tree->Branch("pi0_daughters_e", "std::vector<float>", &_pi0_daughters_e);
520  _pi0_tree->Branch("pi0_daughters_startprocess", "std::vector<std::string>", &_pi0_daughters_startprocess);
521  _pi0_tree->Branch("pi0_daughters_endprocess", "std::vector<std::string>", &_pi0_daughters_endprocess);
522  _pi0_tree->Branch("pi0_daughters_start_x", "std::vector<float>", &_pi0_daughters_start_x);
523  _pi0_tree->Branch("pi0_daughters_start_y", "std::vector<float>", &_pi0_daughters_start_y);
524  _pi0_tree->Branch("pi0_daughters_start_z", "std::vector<float>", &_pi0_daughters_start_z);
525  _pi0_tree->Branch("pi0_daughters_end_x", "std::vector<float>", &_pi0_daughters_end_x);
526  _pi0_tree->Branch("pi0_daughters_end_y", "std::vector<float>", &_pi0_daughters_end_y);
527  _pi0_tree->Branch("pi0_daughters_end_z", "std::vector<float>", &_pi0_daughters_end_z);
528 
529  _pi0_tree->Branch("pi0_genealogy_pdg", "std::vector<int>", &_pi0_genealogy_pdg);
530  _pi0_tree->Branch("pi0_genealogy_startprocess", "std::vector<std::string>", &_pi0_genealogy_startprocess);
531  _pi0_tree->Branch("pi0_genealogy_endprocess", "std::vector<std::string>", &_pi0_genealogy_endprocess);
532  _pi0_tree->Branch("pi0_genealogy_mother", "std::vector<int>", &_pi0_genealogy_mother);
533  _pi0_tree->Branch("pi0_genealogy_e", "std::vector<float>", &_pi0_genealogy_e);
534  _pi0_tree->Branch("pi0_genealogy_start_x", "std::vector<float>", &_pi0_genealogy_start_x);
535  _pi0_tree->Branch("pi0_genealogy_start_y", "std::vector<float>", &_pi0_genealogy_start_y);
536  _pi0_tree->Branch("pi0_genealogy_start_z", "std::vector<float>", &_pi0_genealogy_start_z);
537  _pi0_tree->Branch("pi0_genealogy_end_x", "std::vector<float>", &_pi0_genealogy_end_x);
538  _pi0_tree->Branch("pi0_genealogy_end_y", "std::vector<float>", &_pi0_genealogy_end_y);
539  _pi0_tree->Branch("pi0_genealogy_end_z", "std::vector<float>", &_pi0_genealogy_end_z);
540  _pi0_tree->Branch("pi0_genealogy_trackid", "std::vector<float>", &_pi0_genealogy_trackid);
541 
542 
543  // Add the neutrino information also to this tree so we can better study pi0s
544  // when looking at beam neutrinos
545  _pi0_tree->Branch("nu_e", &_nu_e, "nu_e/F");
546  _pi0_tree->Branch("nu_pdg", &_nu_pdg, "nu_pdg/I");
547  _pi0_tree->Branch("nu_ccnc", &_nu_ccnc, "nu_ccnc/I");
548  _pi0_tree->Branch("nu_mode", &_nu_mode, "nu_mode/I");
549  _pi0_tree->Branch("nu_vtx_x", &_nu_vtx_x, "nu_vtx_x/F");
550  _pi0_tree->Branch("nu_vtx_y", &_nu_vtx_y, "nu_vtx_y/F");
551  _pi0_tree->Branch("nu_vtx_z", &_nu_vtx_z, "nu_vtx_z/F");
552  _pi0_tree->Branch("nu_pip_mult", &_nu_pip_mult, "nu_pip_mult/I");
553  _pi0_tree->Branch("nu_pi0_mult", &_nu_pi0_mult, "nu_pi0_mult/I");
554  _pi0_tree->Branch("nu_p_mult", &_nu_p_mult, "nu_p_mult/I");
555  _pi0_tree->Branch("pars_pdg", "std::vector<int>", &_pars_pdg);
556  _pi0_tree->Branch("pars_e", "std::vector<float>", &_pars_e);
557 
558  }
559 
560  if (_save_muon_tree) {
561  _muon_tree = fs->make<TTree>("MuonTree","");
562 
563  _muon_tree->Branch("run", &_run, "run/I");
564  _muon_tree->Branch("subrun", &_subrun, "subrun/I");
565  _muon_tree->Branch("event", &_event, "event/I");
566 
567  _muon_tree->Branch("muon_par_e", &_muon_par_e, "muon_par_e/F");
568  _muon_tree->Branch("muon_par_start_x", &_muon_par_start_x, "muon_par_start_x/F");
569  _muon_tree->Branch("muon_par_start_y", &_muon_par_start_y, "muon_par_start_y/F");
570  _muon_tree->Branch("muon_par_start_z", &_muon_par_start_z, "muon_par_start_z/F");
571  _muon_tree->Branch("muon_par_end_x", &_muon_par_end_x, "muon_par_end_x/F");
572  _muon_tree->Branch("muon_par_end_y", &_muon_par_end_y, "muon_par_end_y/F");
573  _muon_tree->Branch("muon_par_end_z", &_muon_par_end_z, "muon_par_end_z/F");
574  _muon_tree->Branch("muon_par_mother_pdg", &_muon_par_mother_pdg, "muon_par_mother_pdg/I");
575  _muon_tree->Branch("muon_par_mother_e", &_muon_par_mother_e, "muon_par_mother_e/F");
576  _muon_tree->Branch("muon_par_mother_end_e", &_muon_par_mother_end_e, "muon_par_mother_end_e/F");
577  _muon_tree->Branch("muon_par_ancestor_trackid", &_muon_par_ancestor_trackid, "muon_par_ancestor_trackid/I");
578  _muon_tree->Branch("muon_par_ancestor_uuid", "std::string", &_muon_par_ancestor_uuid);
579 
580  _muon_tree->Branch("muon_event_particles_pdg", "std::vector<int>", &_muon_event_particles_pdg);
581  _muon_tree->Branch("muon_event_particles_e", "std::vector<float>", &_muon_event_particles_e);
582 
583  _muon_tree->Branch("muon_daughters_pdg", "std::vector<int>", &_muon_daughters_pdg);
584  _muon_tree->Branch("muon_daughters_e", "std::vector<float>", &_muon_daughters_e);
585  _muon_tree->Branch("muon_daughters_startprocess", "std::vector<std::string>", &_muon_daughters_startprocess);
586  _muon_tree->Branch("muon_daughters_endprocess", "std::vector<std::string>", &_muon_daughters_endprocess);
587  _muon_tree->Branch("muon_daughters_start_x", "std::vector<float>", &_muon_daughters_start_x);
588  _muon_tree->Branch("muon_daughters_start_y", "std::vector<float>", &_muon_daughters_start_y);
589  _muon_tree->Branch("muon_daughters_start_z", "std::vector<float>", &_muon_daughters_start_z);
590  _muon_tree->Branch("muon_daughters_end_x", "std::vector<float>", &_muon_daughters_end_x);
591  _muon_tree->Branch("muon_daughters_end_y", "std::vector<float>", &_muon_daughters_end_y);
592  _muon_tree->Branch("muon_daughters_end_z", "std::vector<float>", &_muon_daughters_end_z);
593 
594  _muon_tree->Branch("muon_genealogy_pdg", "std::vector<int>", &_muon_genealogy_pdg);
595  _muon_tree->Branch("muon_genealogy_startprocess", "std::vector<std::string>", &_muon_genealogy_startprocess);
596  _muon_tree->Branch("muon_genealogy_endprocess", "std::vector<std::string>", &_muon_genealogy_endprocess);
597  _muon_tree->Branch("muon_genealogy_mother", "std::vector<int>", &_muon_genealogy_mother);
598  _muon_tree->Branch("muon_genealogy_e", "std::vector<float>", &_muon_genealogy_e);
599  _muon_tree->Branch("muon_genealogy_start_x", "std::vector<float>", &_muon_genealogy_start_x);
600  _muon_tree->Branch("muon_genealogy_start_y", "std::vector<float>", &_muon_genealogy_start_y);
601  _muon_tree->Branch("muon_genealogy_start_z", "std::vector<float>", &_muon_genealogy_start_z);
602  _muon_tree->Branch("muon_genealogy_end_x", "std::vector<float>", &_muon_genealogy_end_x);
603  _muon_tree->Branch("muon_genealogy_end_y", "std::vector<float>", &_muon_genealogy_end_y);
604  _muon_tree->Branch("muon_genealogy_end_z", "std::vector<float>", &_muon_genealogy_end_z);
605  _muon_tree->Branch("muon_genealogy_trackid", "std::vector<float>", &_muon_genealogy_trackid);
606 
607  // Add the neutrino information also to this tree so we can better study pi0s
608  // when looking at beam neutrinos
609  _muon_tree->Branch("nu_e", &_nu_e, "nu_e/F");
610  _muon_tree->Branch("nu_pdg", &_nu_pdg, "nu_pdg/I");
611  _muon_tree->Branch("nu_ccnc", &_nu_ccnc, "nu_ccnc/I");
612  _muon_tree->Branch("nu_mode", &_nu_mode, "nu_mode/I");
613  _muon_tree->Branch("nu_vtx_x", &_nu_vtx_x, "nu_vtx_x/F");
614  _muon_tree->Branch("nu_vtx_y", &_nu_vtx_y, "nu_vtx_y/F");
615  _muon_tree->Branch("nu_vtx_z", &_nu_vtx_z, "nu_vtx_z/F");
616  _muon_tree->Branch("nu_pip_mult", &_nu_pip_mult, "nu_pip_mult/I");
617  _muon_tree->Branch("nu_pi0_mult", &_nu_pi0_mult, "nu_pi0_mult/I");
618  _muon_tree->Branch("nu_p_mult", &_nu_p_mult, "nu_p_mult/I");
619  _muon_tree->Branch("pars_pdg", "std::vector<int>", &_pars_pdg);
620  _muon_tree->Branch("pars_e", "std::vector<float>", &_pars_e);
621 
622  }
623 
624  _sr_tree = fs->make<TTree>("pottree","");
625  _sr_tree->Branch("run", &_sr_run, "run/I");
626  _sr_tree->Branch("subrun", &_sr_subrun, "subrun/I");
627  _sr_tree->Branch("begintime", &_sr_begintime, "begintime/D");
628  _sr_tree->Branch("endtime", &_sr_endtime, "endtime/D");
629  _sr_tree->Branch("pot", &_sr_pot, "pot/D");
630 
631  // Iterate over all TPC's to get bounding box that covers volumes of each individual TPC in the detector
632  art::ServiceHandle<geo::Geometry const> geo;
633  _x_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinX() < rhs.BoundingBox().MinX();})->MinX();
634  _y_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinY() < rhs.BoundingBox().MinY();})->MinY();
635  _z_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MinZ() < rhs.BoundingBox().MinZ();})->MinZ();
636  _x_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxX() < rhs.BoundingBox().MaxX();})->MaxX();
637  _y_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxY() < rhs.BoundingBox().MaxY();})->MaxY();
638  _z_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](auto const &lhs, auto const &rhs){ return lhs.BoundingBox().MaxZ() < rhs.BoundingBox().MaxZ();})->MaxZ();
639 
640  std::cout << "TPC limits: " << std::endl;
641  std::cout << "\tx_max\t" << _x_max << std::endl;
642  std::cout << "\tx_min\t" << _x_min << std::endl;
643  std::cout << "\ty_max\t" << _y_max << std::endl;
644  std::cout << "\ty_min\t" << _y_min << std::endl;
645  std::cout << "\tz_max\t" << _z_max << std::endl;
646  std::cout << "\tz_min\t" << _z_min << std::endl;
647 }
648 
649 void obana::OBAnaICARUS::analyze(art::Event const& e)
650 {
651  // Implementation of required member function here.
652  _run = e.id().run();
653  _subrun = e.id().subRun();
654  _event = e.id().event();
655 
656  // std::cout << "Run: " << _run << ", subrun: " << _subrun <<", event: " << _event << std::endl;
657  _uuid = boost::uuids::random_generator()();
658  _uuid_str = boost::lexical_cast<std::string>(_uuid) + "-" + _event;
659  //std::cout << "Event uuid " << _uuid_str << std::endl;
660 
661 
662  std::set<std::string> volnameset(_overburden_volumes.begin(), _overburden_volumes.end());
663  _part_filter = CreateParticleVolumeFilter(volnameset);
664 
665  const geo::GeometryCore* fGeometry; ///< pointer to Geometry service
666  fGeometry = lar::providerFrom<geo::Geometry>();
667 
668 
669  //
670  // MCTruth
671  //
672  art::Handle<std::vector<simb::MCTruth>> mct_h;
673  e.getByLabel(_mctruth_producer, mct_h);
674  if(mct_h.isValid()){
675  std::vector<art::Ptr<simb::MCTruth>> mct_v;
676  art::fill_ptr_vector(mct_v, mct_h);
677 
678  //
679  // Loop over the neutrino interactions in this event
680  //
681  for (size_t i = 0; i < mct_v.size(); i++) {
682  // if (mct_v.at(i)->Origin() != simb::kBeamNeutrino) {
683  // std::cout << "[OverburdenAna] MCTruth from generator does not have neutrino origin?!" << std::endl;
684  // }
685 
686  if(!mct_v[i]->NeutrinoSet()) {
687  break;
688  }
689 
690  _nu_e = mct_v[i]->GetNeutrino().Nu().E();
691  _nu_pdg = mct_v[i]->GetNeutrino().Nu().PdgCode();
692  _nu_ccnc = mct_v[i]->GetNeutrino().CCNC();
693  _nu_mode = mct_v[i]->GetNeutrino().Mode();
694  _nu_int_type = mct_v[i]->GetNeutrino().InteractionType();
695  _nu_vtx_x = mct_v[i]->GetNeutrino().Nu().Vx();
696  _nu_vtx_y = mct_v[i]->GetNeutrino().Nu().Vy();
697  _nu_vtx_z = mct_v[i]->GetNeutrino().Nu().Vz();
698  _nu_px = mct_v[i]->GetNeutrino().Nu().Px();
699  _nu_py = mct_v[i]->GetNeutrino().Nu().Py();
700  _nu_pz = mct_v[i]->GetNeutrino().Nu().Pz();
701 
702 
703  // std::cout<< _nu_vtx_x << "\t"<<_nu_vtx_y <<"\t"<< _nu_vtx_z << std::endl;
704 
705  // Do not save neutrinos interacting in the detector if we are using a dirt sample
706  if (_simulating_dirt && InDetector(_nu_vtx_x, _nu_vtx_y, _nu_vtx_z)) {
707  return;
708  //break;
709  //continue;
710  }
711 
712  // std::cout << " 2nd time ----- Run: " << _run << ", subrun: " << _subrun <<", event: " << _event << std::endl;
713 
714  _pars_pdg.clear();
715  _pars_e.clear();
716  _nu_pip_mult = 0;
717  _nu_pi0_mult = 0;
718  _nu_p_mult = 0;
719 
720  for (int p = 0; p < mct_v[i]->NParticles(); p++) {
721  auto const & mcp = mct_v[i]->GetParticle(p);
722 
723  if (mcp.StatusCode() != 1) continue;
724 
725  _pars_pdg.push_back(mcp.PdgCode());
726  _pars_e.push_back(mcp.E());
727 
728  if (mcp.PdgCode() == 111) {
729  _nu_pi0_mult++;
730  // std::cout << "There is a GENIE pi0 with energy " << mcp.E() << std::endl;
731  } else if (std::abs(mcp.PdgCode()) == 211) {
732  _nu_pip_mult++;
733  }
734  else if (std::abs(mcp.PdgCode()) == 2112) {
735  _nu_p_mult++;
736  }
737  }
738  // std::cout << "_nu_e " << _nu_e << std::endl;
739  }
740  } else {
741  std::cout << "MCTruth product " << _mctruth_producer << " not found..." << std::endl;
742  }
743 
744  //std::cout << " 3rd time ----------------------- Run: " << _run << ", subrun: " << _subrun <<", event: " << _event << std::endl;
745 
746  art::Handle<std::vector<simb::MCParticle> > mcp_h;
747  e.getByLabel(_mcparticle_producer, mcp_h);
748  if(!mcp_h.isValid()){
749  std::cout << "MCParticle product " << _mcparticle_producer << " not found..." << std::endl;
750  _tree->Fill();
751  return;
752  //throw std::exception();
753  }
754 
755  std::vector<art::Ptr<simb::MCParticle>> mcp_v;
756  art::fill_ptr_vector(mcp_v, mcp_h);
757 
758  clear_vectors();
759 
760  for (size_t i = 0; i < mcp_v.size(); i++) {
761  auto mcp = mcp_v.at(i);
762 
763  _trackid_to_mcparticle[mcp->TrackId()] = *mcp;
764  }
765 
766  for (size_t i = 0; i < mcp_v.size(); i++) {
767  auto mcp = mcp_v.at(i);
768  // bool in_det = InDetector(mcp);
769 
770  // Only save the MCP if it's a primary, or if it crosses the det
771  // if (mcp->Process() == "primary" || in_det) {
772  if (mcp->Process() == "primary") {
773 
774  _mcp_px.push_back(mcp->Px());
775  _mcp_py.push_back(mcp->Py());
776  _mcp_pz.push_back(mcp->Pz());
777  _mcp_e.push_back(mcp->E());
778 
779  _mcp_vx.push_back(mcp->Vx());
780  _mcp_vy.push_back(mcp->Vy());
781  _mcp_vz.push_back(mcp->Vz());
782  _mcp_endx.push_back(mcp->EndX());
783  _mcp_endy.push_back(mcp->EndY());
784  _mcp_endz.push_back(mcp->EndZ());
785 
786  _mcp_pdg.push_back(mcp->PdgCode());
787  _mcp_mother.push_back(mcp->Mother());
788  _mcp_status_code.push_back(mcp->StatusCode());
789  _mcp_process.push_back(mcp->Process());
790  _mcp_end_process.push_back(mcp->EndProcess());
791  _mcp_trackid.push_back(mcp->TrackId());
792 
793  // _mcp_intpc.push_back(InDetector(mcp));
794  // _neut_par_uuid = _uuid_str + "-" + std::to_string(mcp->TrackId());
795 
796  int step = 0;
797  bool in_det = InDetector(mcp, step);
798  _mcp_intpc.push_back(in_det);
799 
800  if (mcp->PdgCode() == 2112 && in_det){ /// save the daughter of neutron entring to TPCs
801  unsigned int nSec = mcp->NumberDaughters();
802  for (size_t d = 0; d < nSec; ++d) {
803  auto d_search = _trackid_to_mcparticle.find(mcp->Daughter(d));
804  if (d_search != _trackid_to_mcparticle.end()) {
805  auto const& daughter = d_search->second;
806  _neut_daughters_pdg.push_back(daughter.PdgCode());
807  _neut_daughters_px.push_back(daughter.Px());
808  _neut_daughters_py.push_back(daughter.Py());
809  _neut_daughters_pz.push_back(daughter.Pz());
810  _neut_daughters_e.push_back(daughter.E());
811  _neut_daughters_startprocess.push_back(daughter.Process());
812  _neut_daughters_endprocess.push_back(daughter.EndProcess());
813  _neut_daughters_start_x.push_back(daughter.Vx());
814  _neut_daughters_start_y.push_back(daughter.Vy());
815  _neut_daughters_start_z.push_back(daughter.Vz());
816  _neut_daughters_end_x.push_back(daughter.EndX());
817  _neut_daughters_end_y.push_back(daughter.EndY());
818  _neut_daughters_end_z.push_back(daughter.EndZ());
819  _neut_daughters_trackid.push_back(daughter.TrackId());
820 
821  // std::cout << "no. of daughter: \t" << nSec <<", pdg of daughter: \t" << daughter.PdgCode()
822  // << ", daughter process: \t" << daughter.Process() << ", trackid: \t" << daughter.TrackId()<< std::endl;
823  /// save the grand daughter of neutron if daughters are from pions
824  if (std::abs(daughter.PdgCode())==211 || daughter.PdgCode()==111 || daughter.PdgCode()==2112){
825  unsigned int ngd = daughter.NumberDaughters();
826  for (size_t gd = 0; gd < ngd ; ++gd) {
827  auto gd_search = _trackid_to_mcparticle.find(daughter.Daughter(gd));
828  if (gd_search != _trackid_to_mcparticle.end()) {
829  auto const& granddaughter = gd_search->second;
830  //std::cout << "no. of grand daughter: \t" << ngd <<", pdg of grand daughter: \t" << granddaughter.PdgCode()
831  // << ", grand daughter process: \t" << granddaughter.Process() << ", trackid: \t" << granddaughter.TrackId()<< std::endl;
832 
833  _neut_grand_daughters_pdg.push_back(granddaughter.PdgCode());
834  _neut_grand_daughters_px.push_back(granddaughter.Px());
835  _neut_grand_daughters_py.push_back(granddaughter.Py());
836  _neut_grand_daughters_pz.push_back(granddaughter.Pz());
837  _neut_grand_daughters_e.push_back(granddaughter.E());
838  _neut_grand_daughters_startprocess.push_back(granddaughter.Process());
839  _neut_grand_daughters_endprocess.push_back(granddaughter.EndProcess());
840  _neut_grand_daughters_start_x.push_back(granddaughter.Vx());
841  _neut_grand_daughters_start_y.push_back(granddaughter.Vy());
842  _neut_grand_daughters_start_z.push_back(granddaughter.Vz());
843  _neut_grand_daughters_end_x.push_back(granddaughter.EndX());
844  _neut_grand_daughters_end_y.push_back(granddaughter.EndY());
845  _neut_grand_daughters_end_z.push_back(granddaughter.EndZ());
846  _neut_grand_daughters_trackid.push_back(granddaughter.TrackId());
847  } // end of grand daughter trackid
848  } // end of loop over grand daughter
849  } // end of searching grand daughter
850  } // end of daughter trackid
851  }// end of loop over daughter
852  } //end of searching daughter
853 
854  if (in_det) {
855  /*
856  if (mcp->PdgCode()==13 && mcp->E() >= 0.01 ){
857  std::cout << "photon: " << mcp->PdgCode() << " , has energy : " << mcp->E()
858  << " , process: " << mcp->Process() << " , and mother is : "
859  << mcp->Mother() << std::endl;
860 
861  std::cout << "step: " << step << " , has energy : " << mcp->E(step) << std::endl;
862  if ((mcp->E(step)-0.105658) > 0.0) std::cout << "step: " << step << " , has energy : " << mcp->E(step)-0.105658 << std::endl;
863 
864  }*/
865  _mcp_intpc_nu_e.push_back(mcp->E(step));
866  _mcp_intpc_e.push_back(mcp->E(step-1));
867  //_mcp_intpc_e_previousstep.push_back(mcp->E(step-1));
868 
869  // std::cout << "step: " << step << " , has energy : " << mcp->E(step) << "\t"<< mcp->E(step)-0.105658 << std::endl;
870  //std::cout << "previous step: " << step-1 << " , has energy : " << mcp->E(step-1) << "\t"<< mcp->E(step-1)-0.105658 << std::endl;
871  } else {
872  _mcp_intpc_e.push_back(-9999.);
873  _mcp_intpc_nu_e.push_back(-9999.);
874  //_mcp_intpc_e_previousstep.push_back(-9999.);
875  }// end of in detector
876  } // end of primary selection
877  } // end of mcp loop
878 
879 /*
880  for (unsigned int i =0; i < _mcp_intpc_e.size(); i++){
881  if (_mcp_pdg[i]==13)
882  std::cout << "event: " <<_event << " , has energy : " << _mcp_intpc_e[i] << std::endl;
883  }
884 */
885 
886  //
887  // MCTrack
888  //
889  art::Handle<std::vector<sim::MCTrack> > mc_track_h;
890  e.getByLabel(_mctrack_producer, mc_track_h);
891  if(!mc_track_h.isValid()){
892  std::cout << "MCTrack product " << _mctrack_producer << " not found..." << std::endl;
893  throw std::exception();
894  }
895 
896  std::vector<art::Ptr<sim::MCTrack>> mc_track_v;
897  art::fill_ptr_vector(mc_track_v, mc_track_h);
898 
899  for (size_t i = 0; i < mc_track_v.size(); i++) {
900  auto mc_track = mc_track_v.at(i);
901 
902  // std::cout << "MCTrack " << i << ": ancestor pdg " << mc_track->AncestorPdgCode()
903  // << ", ancestor process " << mc_track->AncestorProcess()
904  // << ", mother pdg " << mc_track->MotherPdgCode()
905  // << ", mother process " << mc_track->MotherProcess()
906  // << "| PDG " << mc_track->PdgCode()
907  // << ", process " << mc_track->Process()
908  // << std::endl;
909 
910  auto iter = _trackid_to_mcparticle.find(mc_track->TrackID());
911  int mother_in_ob = -1;
912  if (iter != _trackid_to_mcparticle.end()) {
913  mother_in_ob = FindMotherInOverburden(iter->second);
914  }
915 
916  // Don't save MCT with energy less than 1 MeV
917  if (mc_track->Start().E() < 1) { // MeV
918  _n_mct_lt1 ++;
919  if (mother_in_ob != -1){
920  _n_mct_lt1_from_ob ++;
921  }
922  continue;
923  }
924 
925  // Don't save MCS that are not in the TPCs
926  if (mc_track->size() == 0) {
927  continue;
928  }
929 
930  geo::Point_t mctrackstartPoint(mc_track->Start().X(),mc_track->Start().Y(), mc_track->Start().Z());
931  geo::Point_t mctrackendPoint(mc_track->End().X(),mc_track->End().Y(), mc_track->End().Z());
932 
933  const geo::TPCGeo* mctpcstartGeo = fGeometry->PositionToTPCptr(mctrackstartPoint);
934  const geo::TPCGeo* mctpcendGeo = fGeometry->PositionToTPCptr(mctrackendPoint);
935 
936  if (!mctpcstartGeo || !mctpcendGeo) continue;
937 
938  // if (tpcGeo->ID() != C0id) continue; // point not in cryostat 0
939  if (!mctpcstartGeo->ActiveBoundingBox().ContainsPosition(mctrackstartPoint) ||
940  !mctpcendGeo->ActiveBoundingBox().ContainsPosition(mctrackendPoint)) continue; // out of active volume
941 
942 
943  _mct_pdg.push_back(mc_track->PdgCode());
944  _mct_process.push_back(mc_track->Process());
945 
946  _mct_start_x.push_back(mc_track->Start().X());
947  _mct_start_y.push_back(mc_track->Start().Y());
948  _mct_start_z.push_back(mc_track->Start().Z());
949 
950  _mct_end_x.push_back(mc_track->End().X());
951  _mct_end_y.push_back(mc_track->End().Y());
952  _mct_end_z.push_back(mc_track->End().Z());
953 
954  _mct_start_px.push_back(mc_track->Start().Px());
955  _mct_start_py.push_back(mc_track->Start().Py());
956  _mct_start_pz.push_back(mc_track->Start().Pz());
957  _mct_start_e.push_back(mc_track->Start().E());
958 
959  _mct_mother_pdg.push_back(mc_track->MotherPdgCode());
960  _mct_mother_process.push_back(mc_track->MotherProcess());
961  _mct_ancestor_pdg.push_back(mc_track->AncestorPdgCode());
962  _mct_ancestor_process.push_back(mc_track->AncestorProcess());
963 
964  _mct_mother_in_ob_trackid.push_back(mother_in_ob);
965 
966  }
967 
968  //
969  // MCShower
970  //
971  art::Handle<std::vector<sim::MCShower> > mc_shower_h;
972  e.getByLabel(_mcshower_producer, mc_shower_h);
973  if(!mc_shower_h.isValid()){
974  std::cout << "MCShower product " << _mcshower_producer << " not found..." << std::endl;
975  throw std::exception();
976  }
977 
978  std::vector<art::Ptr<sim::MCShower>> mc_shower_v;
979  art::fill_ptr_vector(mc_shower_v, mc_shower_h);
980 
981  for (size_t i = 0; i < mc_shower_v.size(); i++) {
982  auto mc_shower = mc_shower_v.at(i);
983  // std::cout << "MCShower " << i << ": ancestor pdg " << mc_shower->AncestorPdgCode()
984  // << ", ancestor process " << mc_shower->AncestorProcess()
985  // << ", mother pdg " << mc_shower->MotherPdgCode()
986  // << ", mother process " << mc_shower->MotherProcess()
987  // << "| PDG " << mc_shower->PdgCode()
988  // << ", process " << mc_shower->Process()
989  // << std::endl;
990 
991  auto iter = _trackid_to_mcparticle.find(mc_shower->TrackID());
992  int mother_in_ob = -1;
993  if (iter != _trackid_to_mcparticle.end()) {
994  mother_in_ob = FindMotherInOverburden(iter->second);
995  }
996 
997  // Don't save MCS with energy less than 1 MeV
998  if (mc_shower->Start().E() < 1) { // MeV
999  _n_mcs_lt1 ++;
1000  if (mother_in_ob != -1){
1001  _n_mcs_lt1_from_ob ++;
1002  }
1003  continue;
1004  }
1005 
1006  /// Don't save MCS that are not in the TPCs
1007  // Special case for photon showers, which can start outside
1008 
1009  bool end_in_det = InDetector(mc_shower->End().X(), mc_shower->End().Y(), mc_shower->End().Z());
1010 
1011  if (!end_in_det) {
1012  continue;
1013  }
1014 
1015  _mcs_pdg.push_back(mc_shower->PdgCode());
1016  _mcs_process.push_back(mc_shower->Process());
1017 
1018  _mcs_start_x.push_back(mc_shower->Start().X());
1019  _mcs_start_y.push_back(mc_shower->Start().Y());
1020  _mcs_start_z.push_back(mc_shower->Start().Z());
1021 
1022  _mcs_end_x.push_back(mc_shower->End().X());
1023  _mcs_end_y.push_back(mc_shower->End().Y());
1024  _mcs_end_z.push_back(mc_shower->End().Z());
1025 
1026  _mcs_start_px.push_back(mc_shower->Start().Px());
1027  _mcs_start_py.push_back(mc_shower->Start().Py());
1028  _mcs_start_pz.push_back(mc_shower->Start().Pz());
1029  _mcs_start_e.push_back(mc_shower->Start().E());
1030  _mcs_charge_col.push_back(mc_shower->Charge(2));
1031  _mcs_charge_ind2.push_back(mc_shower->Charge(1));
1032  _mcs_charge_ind1.push_back(mc_shower->Charge(0));
1033 
1034  _mcs_mother_pdg.push_back(mc_shower->MotherPdgCode());
1035  _mcs_mother_trackid.push_back(mc_shower->MotherTrackID());
1036  _mcs_mother_start_x.push_back(mc_shower->MotherStart().X());
1037  _mcs_mother_start_y.push_back(mc_shower->MotherStart().Y());
1038  _mcs_mother_start_z.push_back(mc_shower->MotherStart().Z());
1039  _mcs_mother_start_e.push_back(mc_shower->MotherStart().E());
1040  _mcs_mother_end_x.push_back(mc_shower->MotherEnd().X());
1041  _mcs_mother_end_y.push_back(mc_shower->MotherEnd().Y());
1042  _mcs_mother_end_z.push_back(mc_shower->MotherEnd().Z());
1043  _mcs_mother_end_e.push_back(mc_shower->MotherEnd().E());
1044 
1045  _mcs_mother_process.push_back(mc_shower->MotherProcess());
1046  _mcs_ancestor_pdg.push_back(mc_shower->AncestorPdgCode());
1047  _mcs_ancestor_process.push_back(mc_shower->AncestorProcess());
1048  _mcs_ancestor_start_e.push_back(mc_shower->AncestorStart().E());
1049  _mcs_ancestor_end_e.push_back(mc_shower->AncestorEnd().E());
1050  _mcs_mother_in_ob_trackid.push_back(mother_in_ob);
1051 
1052  if (mc_shower->MotherPdgCode() == 111 && _save_pi0_tree) {
1053  SavePi0ShowerInfo(mc_shower->MotherTrackID());
1054  }
1055 
1056  if (std::abs(mc_shower->MotherPdgCode()) == 13 && _save_muon_tree) {
1057  SaveMuonShowerInfo(mc_shower->MotherTrackID());
1058  }
1059 
1060  }
1061 
1062 
1063  _tree->Fill();
1064 }
1065 
1067  //std::cout << "SavePi0ShowerInfo***, pi0_track_id: " << pi0_track_id << std::endl;
1068  auto it = std::find(_pi0_ids.begin(), _pi0_ids.end(), pi0_track_id);
1069  if (it != _pi0_ids.end()) {
1070  return;
1071  }
1072  //std::cout << "SavePi0ShowerInfo***, got it" << std::endl;
1073  _pi0_ids.push_back(pi0_track_id);
1074 
1075  // Get the pi0 MCParticle
1076  auto iter = _trackid_to_mcparticle.find(pi0_track_id);
1077  if (iter == _trackid_to_mcparticle.end()) {
1078  return;
1079  }
1080 
1081 
1082  simb::MCParticle pi0_mcp = iter->second;
1083  // std::cout << "Pi0 MCP, PDG = " << pi0_mcp.PdgCode() << ", E = " << pi0_mcp.E() << ", n daughters " << pi0_mcp.NumberDaughters() << std::endl;
1084 
1085  // Save the information on the pi0 itself
1086  _pi0_par_e = pi0_mcp.E();
1087  _pi0_par_start_x = pi0_mcp.Vx();
1088  _pi0_par_start_y = pi0_mcp.Vy();
1089  _pi0_par_start_z = pi0_mcp.Vz();
1090  _pi0_par_end_x = pi0_mcp.EndX();
1091  _pi0_par_end_y = pi0_mcp.EndY();
1092  _pi0_par_end_z = pi0_mcp.EndZ();
1093 
1094  // Get the pi0 mother MCParticle
1095  // iter = _trackid_to_mcparticle.find(pi0_mcp.Mother());
1096  // if (iter == _trackid_to_mcparticle.end()) {
1097  // return;
1098  // }
1099 
1100  simb::MCParticle pi0_mother_mcp;
1101  if (pi0_mcp.Mother() == 0) {
1102  // Use itself if this pi0 is a primary
1103  pi0_mother_mcp = pi0_mcp;
1104  } else {
1105  iter = _trackid_to_mcparticle.find(pi0_mcp.Mother());
1106  if (iter == _trackid_to_mcparticle.end()) {
1107  return;
1108  }
1109  pi0_mother_mcp = iter->second;
1110  }
1111 
1112  // simb::MCParticle pi0_mother_mcp = iter->second;
1113  _pi0_par_mother_pdg = pi0_mother_mcp.PdgCode();
1114  _pi0_par_mother_e = pi0_mother_mcp.E();
1115  _pi0_par_mother_end_e = pi0_mother_mcp.EndE();
1116 
1117  // std::cout << "Pi0 MCP Mother, PDG = " << pi0_mother_mcp.PdgCode() << ", E = " << pi0_mother_mcp.E() << std::endl;
1118 
1119  // Get the daughters of the pi0 mother
1120  for (int d = 0; d < pi0_mother_mcp.NumberDaughters(); d++) {
1121  iter = _trackid_to_mcparticle.find(pi0_mother_mcp.Daughter(d));
1122  if (iter != _trackid_to_mcparticle.end()) {
1123  simb::MCParticle daughter = iter->second;
1124  _pi0_event_particles_pdg.push_back(daughter.PdgCode());
1125  _pi0_event_particles_e.push_back(daughter.E());
1126  }
1127  }
1128 
1129  // Save the mother first...
1130  _pi0_genealogy_pdg.push_back(pi0_mother_mcp.PdgCode());
1131  _pi0_genealogy_startprocess.push_back(pi0_mother_mcp.Process());
1132  _pi0_genealogy_endprocess.push_back(pi0_mother_mcp.EndProcess());
1133  _pi0_genealogy_mother.push_back(pi0_mother_mcp.Mother());
1134  _pi0_genealogy_e.push_back(pi0_mother_mcp.E());
1135  _pi0_genealogy_start_x.push_back(pi0_mother_mcp.Vx());
1136  _pi0_genealogy_start_y.push_back(pi0_mother_mcp.Vy());
1137  _pi0_genealogy_start_z.push_back(pi0_mother_mcp.Vy());
1138  _pi0_genealogy_end_x.push_back(pi0_mother_mcp.EndX());
1139  _pi0_genealogy_end_y.push_back(pi0_mother_mcp.EndY());
1140  _pi0_genealogy_end_z.push_back(pi0_mother_mcp.EndZ());
1141  _pi0_genealogy_trackid.push_back(pi0_mother_mcp.TrackId());
1142 
1143 
1144  // ... then save all the other ancestors
1145  simb::MCParticle mcp = pi0_mother_mcp;
1146  while(true) {
1147  iter = _trackid_to_mcparticle.find(mcp.Mother());
1148  if (iter == _trackid_to_mcparticle.end()) {
1149  break;
1150  }
1151  mcp = iter->second;
1152  _pi0_genealogy_pdg.push_back(mcp.PdgCode());
1153  _pi0_genealogy_startprocess.push_back(mcp.Process());
1154  _pi0_genealogy_endprocess.push_back(mcp.EndProcess());
1155  _pi0_genealogy_mother.push_back(mcp.Mother());
1156  _pi0_genealogy_e.push_back(mcp.E());
1157  _pi0_genealogy_start_x.push_back(mcp.Vx());
1158  _pi0_genealogy_start_y.push_back(mcp.Vy());
1159  _pi0_genealogy_start_z.push_back(mcp.Vy());
1160  _pi0_genealogy_end_x.push_back(mcp.EndX());
1161  _pi0_genealogy_end_y.push_back(mcp.EndY());
1162  _pi0_genealogy_end_z.push_back(mcp.EndZ());
1163  _pi0_genealogy_trackid.push_back(mcp.TrackId());
1164  }
1165 
1166  _pi0_par_ancestor_trackid = _pi0_genealogy_trackid.back();
1167  _pi0_par_ancestor_uuid = _uuid_str + "-" + std::to_string(_pi0_par_ancestor_trackid);
1168  //std::cout << "Pi0 uuid " << _pi0_par_ancestor_uuid << std::endl;
1169 
1170  // Get the dautghers of this pi0
1171  for (int d = 0; d < pi0_mcp.NumberDaughters(); d++) {
1172  iter = _trackid_to_mcparticle.find(pi0_mcp.Daughter(d));
1173  if (iter != _trackid_to_mcparticle.end()) {
1174  simb::MCParticle daughter = iter->second;
1175  _pi0_daughters_pdg.push_back(daughter.PdgCode());
1176  _pi0_daughters_e.push_back(daughter.E());
1177  _pi0_daughters_startprocess.push_back(daughter.Process());
1178  _pi0_daughters_endprocess.push_back(daughter.EndProcess());
1179  _pi0_daughters_start_x.push_back(daughter.Vx());
1180  _pi0_daughters_start_y.push_back(daughter.Vy());
1181  _pi0_daughters_start_z.push_back(daughter.Vz());
1182  _pi0_daughters_end_x.push_back(daughter.EndX());
1183  _pi0_daughters_end_y.push_back(daughter.EndY());
1184  _pi0_daughters_end_z.push_back(daughter.EndZ());
1185  }
1186  }
1187 
1188  // Fill the tree and reset the variables
1189  _pi0_tree->Fill();
1190 
1191 
1192  _pi0_event_particles_pdg.clear();
1193  _pi0_event_particles_e.clear();
1194 
1195  _pi0_daughters_pdg.clear();
1196  _pi0_daughters_e.clear();
1197  _pi0_daughters_startprocess.clear();
1198  _pi0_daughters_endprocess.clear();
1199  _pi0_daughters_start_x.clear();
1200  _pi0_daughters_start_y.clear();
1201  _pi0_daughters_start_z.clear();
1202  _pi0_daughters_end_x.clear();
1203  _pi0_daughters_end_y.clear();
1204  _pi0_daughters_end_z.clear();
1205 
1206  _pi0_genealogy_pdg.clear();
1207  _pi0_genealogy_startprocess.clear();
1208  _pi0_genealogy_endprocess.clear();
1209  _pi0_genealogy_mother.clear();
1210  _pi0_genealogy_e.clear();
1211  _pi0_genealogy_start_x.clear();
1212  _pi0_genealogy_start_y.clear();
1213  _pi0_genealogy_start_z.clear();
1214  _pi0_genealogy_end_x.clear();
1215  _pi0_genealogy_end_y.clear();
1216  _pi0_genealogy_end_z.clear();
1217  _pi0_genealogy_trackid.clear();
1218 }
1219 
1220 
1222  //std::cout << "SaveMuonShowerInfo***, muon_track_id: " << muon_track_id << std::endl;
1223  auto it = std::find(_muon_ids.begin(), _muon_ids.end(), muon_track_id);
1224  if (it != _muon_ids.end()) {
1225  return;
1226  }
1227  //std::cout << "SaveMuonShowerInfo***, got it" << std::endl;
1228  _muon_ids.push_back(muon_track_id);
1229 
1230  // Get the muon MCParticle
1231  auto iter = _trackid_to_mcparticle.find(muon_track_id);
1232  if (iter == _trackid_to_mcparticle.end()) {
1233  return;
1234  }
1235  simb::MCParticle muon_mcp = iter->second;
1236  // std::cout << "Muon MCP, PDG = " << muon_mcp.PdgCode() << ", E = " << muon_mcp.E() << ", n daughters " << muon_mcp.NumberDaughters() << std::endl;
1237 
1238  // Save the information on the muon itself
1239  _muon_par_e = muon_mcp.E();
1240  _muon_par_start_x = muon_mcp.Vx();
1241  _muon_par_start_y = muon_mcp.Vy();
1242  _muon_par_start_z = muon_mcp.Vz();
1243  _muon_par_end_x = muon_mcp.EndX();
1244  _muon_par_end_y = muon_mcp.EndY();
1245  _muon_par_end_z = muon_mcp.EndZ();
1246 
1247 
1248  simb::MCParticle muon_mother_mcp;
1249  if (muon_mcp.Mother() == 0) {
1250  // Use itself if this pi0 is a primary
1251  muon_mother_mcp = muon_mcp;
1252  } else {
1253  iter = _trackid_to_mcparticle.find(muon_mcp.Mother());
1254  if (iter == _trackid_to_mcparticle.end()) {
1255  return;
1256  }
1257  muon_mother_mcp = iter->second;
1258  }
1259 
1260  // Get the muon mother MCParticle
1261  //iter = _trackid_to_mcparticle.find(muon_mcp.Mother());
1262  //if (iter == _trackid_to_mcparticle.end()) {
1263  // return;
1264  //}
1265 
1266  //simb::MCParticle muon_mother_mcp = iter->second;
1267  _muon_par_mother_pdg = muon_mother_mcp.PdgCode();
1268  _muon_par_mother_e = muon_mother_mcp.E();
1269  _muon_par_mother_end_e = muon_mother_mcp.EndE();
1270 
1271  // std::cout << "Muon MCP Mother, PDG = " << muon_mother_mcp.PdgCode() << ", E = " << muon_mother_mcp.E() << std::endl;
1272 
1273  // Get the daughters of the muon mother
1274  for (int d = 0; d < muon_mother_mcp.NumberDaughters(); d++) {
1275  iter = _trackid_to_mcparticle.find(muon_mother_mcp.Daughter(d));
1276  if (iter != _trackid_to_mcparticle.end()) {
1277  simb::MCParticle daughter = iter->second;
1278  _muon_event_particles_pdg.push_back(daughter.PdgCode());
1279  _muon_event_particles_e.push_back(daughter.E());
1280  }
1281  }
1282 
1283  // Save the mother first...
1284  _muon_genealogy_pdg.push_back(muon_mother_mcp.PdgCode());
1285  _muon_genealogy_startprocess.push_back(muon_mother_mcp.Process());
1286  _muon_genealogy_endprocess.push_back(muon_mother_mcp.EndProcess());
1287  _muon_genealogy_mother.push_back(muon_mother_mcp.Mother());
1288  _muon_genealogy_e.push_back(muon_mother_mcp.E());
1289  _muon_genealogy_start_x.push_back(muon_mother_mcp.Vx());
1290  _muon_genealogy_start_y.push_back(muon_mother_mcp.Vy());
1291  _muon_genealogy_start_z.push_back(muon_mother_mcp.Vy());
1292  _muon_genealogy_end_x.push_back(muon_mother_mcp.EndX());
1293  _muon_genealogy_end_y.push_back(muon_mother_mcp.EndY());
1294  _muon_genealogy_end_z.push_back(muon_mother_mcp.EndZ());
1295  _muon_genealogy_trackid.push_back(muon_mother_mcp.TrackId());
1296 
1297 
1298  // ... then save all the other ancestors
1299  simb::MCParticle mcp = muon_mother_mcp;
1300  while(true) {
1301  iter = _trackid_to_mcparticle.find(mcp.Mother());
1302  if (iter == _trackid_to_mcparticle.end()) {
1303  break;
1304  }
1305  mcp = iter->second;
1306  _muon_genealogy_pdg.push_back(mcp.PdgCode());
1307  _muon_genealogy_startprocess.push_back(mcp.Process());
1308  _muon_genealogy_endprocess.push_back(mcp.EndProcess());
1309  _muon_genealogy_mother.push_back(mcp.Mother());
1310  _muon_genealogy_e.push_back(mcp.E());
1311  _muon_genealogy_start_x.push_back(mcp.Vx());
1312  _muon_genealogy_start_y.push_back(mcp.Vy());
1313  _muon_genealogy_start_z.push_back(mcp.Vy());
1314  _muon_genealogy_end_x.push_back(mcp.EndX());
1315  _muon_genealogy_end_y.push_back(mcp.EndY());
1316  _muon_genealogy_end_z.push_back(mcp.EndZ());
1317  _muon_genealogy_trackid.push_back(mcp.TrackId());
1318  }
1319 
1320  _muon_par_ancestor_trackid = _muon_genealogy_trackid.back();
1321  _muon_par_ancestor_uuid = _uuid_str + "-" + std::to_string(_muon_par_ancestor_trackid);
1322  //std::cout << "Muon uuid " << _muon_par_ancestor_uuid << std::endl;
1323 
1324  // Get the dautghers of this muon
1325  for (int d = 0; d < muon_mcp.NumberDaughters(); d++) {
1326  iter = _trackid_to_mcparticle.find(muon_mcp.Daughter(d));
1327  if (iter != _trackid_to_mcparticle.end()) {
1328  simb::MCParticle daughter = iter->second;
1329  _muon_daughters_pdg.push_back(daughter.PdgCode());
1330  _muon_daughters_e.push_back(daughter.E());
1331  _muon_daughters_startprocess.push_back(daughter.Process());
1332  _muon_daughters_endprocess.push_back(daughter.EndProcess());
1333  _muon_daughters_start_x.push_back(daughter.Vx());
1334  _muon_daughters_start_y.push_back(daughter.Vy());
1335  _muon_daughters_start_z.push_back(daughter.Vz());
1336  _muon_daughters_end_x.push_back(daughter.EndX());
1337  _muon_daughters_end_y.push_back(daughter.EndY());
1338  _muon_daughters_end_z.push_back(daughter.EndZ());
1339  }
1340  }
1341 
1342  // Fill the tree and reset the variables
1343  _muon_tree->Fill();
1344 
1345 
1346  _muon_event_particles_pdg.clear();
1347  _muon_event_particles_e.clear();
1348 
1349  _muon_daughters_pdg.clear();
1350  _muon_daughters_e.clear();
1351  _muon_daughters_startprocess.clear();
1352  _muon_daughters_endprocess.clear();
1353  _muon_daughters_start_x.clear();
1354  _muon_daughters_start_y.clear();
1355  _muon_daughters_start_z.clear();
1356  _muon_daughters_end_x.clear();
1357  _muon_daughters_end_y.clear();
1358  _muon_daughters_end_z.clear();
1359 
1360  _muon_genealogy_pdg.clear();
1361  _muon_genealogy_startprocess.clear();
1362  _muon_genealogy_endprocess.clear();
1363  _muon_genealogy_mother.clear();
1364  _muon_genealogy_e.clear();
1365  _muon_genealogy_start_x.clear();
1366  _muon_genealogy_start_y.clear();
1367  _muon_genealogy_start_z.clear();
1368  _muon_genealogy_end_x.clear();
1369  _muon_genealogy_end_y.clear();
1370  _muon_genealogy_end_z.clear();
1371  _muon_genealogy_trackid.clear();
1372 
1373 }
1374 
1375 
1377 
1378  if (mcp.Process() == "primary") {
1379  return -1;
1380  }
1381 
1382  // We use this filter not to actualy filter, but to check if
1383  // the vertex of this particle is in the OB
1384  bool vtx_in_ob = _part_filter->mustKeep(Point_t{{ mcp.Vx(),
1385  mcp.Vy(),
1386  mcp.Vz() }});
1387 
1388  auto iter = _trackid_to_mcparticle.find(mcp.Mother());
1389  if (iter == _trackid_to_mcparticle.end()) {
1390  return -1;
1391  }
1392  auto mother = iter->second;
1393 
1394 
1395  if (vtx_in_ob // If this particle has a vertex in the OB
1396  && mcp.Process() != "primary" // and this particle is not a primary one
1397  // && mother.Process() == "primary" // and the mother of it is a primary
1398  ) {
1399  return mcp.TrackId(); // Then return it, as is something created by a primary in the OB
1400  }
1401 
1402  return FindMotherInOverburden(mother);
1403 
1404 }
1405 
1406 std::unique_ptr<util::PositionInVolumeFilter> obana::OBAnaICARUS::CreateParticleVolumeFilter
1407 (std::set<std::string> const& vol_names) const
1408 {
1409 
1410  // if we don't have favourite volumes, don't even bother creating a filter
1411  if (vol_names.empty()) return {};
1412 
1413  auto const& geom = *art::ServiceHandle<geo::Geometry const>();
1414 
1415  std::vector<std::vector<TGeoNode const*>> node_paths
1416  = geom.FindAllVolumePaths(vol_names);
1417  //std::cout << "Found " << node_paths.size() << " node paths." << std::endl;
1418 
1419  // collection of interesting volumes
1421  GeoVolumePairs.reserve(node_paths.size()); // because we are obsessed
1422 
1423  //for each interesting volume, follow the node path and collect
1424  //total rotations and translations
1425  for (size_t iVolume = 0; iVolume < node_paths.size(); ++iVolume) {
1426  std::vector<TGeoNode const*> path = node_paths[iVolume];
1427 
1428  TGeoTranslation* pTransl = new TGeoTranslation(0.,0.,0.);
1429  TGeoRotation* pRot = new TGeoRotation();
1430  for (TGeoNode const* node: path) {
1431  TGeoTranslation thistranslate(*node->GetMatrix());
1432  TGeoRotation thisrotate(*node->GetMatrix());
1433  pTransl->Add(&thistranslate);
1434  *pRot=*pRot * thisrotate;
1435  }
1436 
1437  //for some reason, pRot and pTransl don't have tr and rot bits set correctly
1438  //make new translations and rotations so bits are set correctly
1439  TGeoTranslation* pTransl2 = new TGeoTranslation(pTransl->GetTranslation()[0],
1440  pTransl->GetTranslation()[1],
1441  pTransl->GetTranslation()[2]);
1442  double phi=0.,theta=0.,psi=0.;
1443  pRot->GetAngles(phi,theta,psi);
1444  TGeoRotation* pRot2 = new TGeoRotation();
1445  pRot2->SetAngles(phi,theta,psi);
1446 
1447  TGeoCombiTrans* pTransf = new TGeoCombiTrans(*pTransl2,*pRot2);
1448  GeoVolumePairs.emplace_back(node_paths[iVolume].back()->GetVolume(), pTransf);
1449 
1450  }
1451 
1452  return std::make_unique<util::PositionInVolumeFilter>(std::move(GeoVolumePairs));
1453 
1454 } // CreateParticleVolumeFilter()
1455 
1456 
1458 
1459  _n_mct_lt1 = 0;
1460  _n_mct_lt1_from_ob = 0;
1461  _n_mcs_lt1 = 0;
1462  _n_mcs_lt1_from_ob = 0;
1463 
1464 
1465  _mcp_px.clear();
1466  _mcp_py.clear();
1467  _mcp_pz.clear();
1468  _mcp_e.clear();
1469  _mcp_vx.clear();
1470  _mcp_vy.clear();
1471  _mcp_vz.clear();
1472  _mcp_endx.clear();
1473  _mcp_endy.clear();
1474  _mcp_endz.clear();
1475  _mcp_pdg.clear();
1476  _mcp_mother.clear();
1477  _mcp_status_code.clear();
1478  _mcp_process.clear();
1479  _mcp_end_process.clear();
1480  _mcp_intpc.clear();
1481  _mcp_intpc_e.clear();
1482  _mcp_trackid.clear();
1483  _mcp_intpc_nu_e.clear();
1484 
1485  _neut_daughters_pdg.clear();
1486  _neut_daughters_e.clear();
1487  _neut_daughters_px.clear();
1488  _neut_daughters_py.clear();
1489  _neut_daughters_pz.clear();
1490  _neut_daughters_startprocess.clear();
1491  _neut_daughters_endprocess.clear();
1492  _neut_daughters_start_x.clear();
1493  _neut_daughters_start_y.clear();
1494  _neut_daughters_start_z.clear();
1495  _neut_daughters_end_x.clear();
1496  _neut_daughters_end_y.clear();
1497  _neut_daughters_end_z.clear();
1498  _neut_daughters_trackid.clear();
1499 
1500  _neut_grand_daughters_pdg.clear();
1501  _neut_grand_daughters_e.clear();
1502  _neut_grand_daughters_px.clear();
1503  _neut_grand_daughters_py.clear();
1504  _neut_grand_daughters_pz.clear();
1505  _neut_grand_daughters_startprocess.clear();
1506  _neut_grand_daughters_endprocess.clear();
1507  _neut_grand_daughters_start_x.clear();
1508  _neut_grand_daughters_start_y.clear();
1509  _neut_grand_daughters_start_z.clear();
1510  _neut_grand_daughters_end_x.clear();
1511  _neut_grand_daughters_end_y.clear();
1512  _neut_grand_daughters_end_z.clear();
1513  _neut_grand_daughters_trackid.clear();
1514 
1515  _mcs_pdg.clear();
1516  _mcs_process.clear();
1517  _mcs_start_x.clear();
1518  _mcs_start_y.clear();
1519  _mcs_start_z.clear();
1520  _mcs_end_x.clear();
1521  _mcs_end_y.clear();
1522  _mcs_end_z.clear();
1523  _mcs_start_px.clear();
1524  _mcs_start_py.clear();
1525  _mcs_start_pz.clear();
1526  _mcs_start_e.clear();
1527  _mcs_charge_col.clear();
1528  _mcs_charge_ind2.clear();
1529  _mcs_charge_ind1.clear();
1530  _mcs_mother_pdg.clear();
1531  _mcs_mother_trackid.clear();
1532  _mcs_mother_process.clear();
1533  _mcs_mother_start_x.clear();
1534  _mcs_mother_start_y.clear();
1535  _mcs_mother_start_z.clear();
1536  _mcs_mother_start_e.clear();
1537  _mcs_mother_end_x.clear();
1538  _mcs_mother_end_y.clear();
1539  _mcs_mother_end_z.clear();
1540  _mcs_mother_end_e.clear();
1541  _mcs_ancestor_pdg.clear();
1542  _mcs_ancestor_process.clear();
1543  _mcs_ancestor_start_e.clear();
1544  _mcs_ancestor_end_e.clear();
1545  _mcs_mother_in_ob_trackid.clear();
1546 
1547 
1548  _mct_pdg.clear();
1549  _mct_process.clear();
1550  _mct_start_x.clear();
1551  _mct_start_y.clear();
1552  _mct_start_z.clear();
1553  _mct_end_x.clear();
1554  _mct_end_y.clear();
1555  _mct_end_z.clear();
1556  _mct_start_px.clear();
1557  _mct_start_py.clear();
1558  _mct_start_pz.clear();
1559  _mct_start_e.clear();
1560  _mct_mother_pdg.clear();
1561  _mct_mother_process.clear();
1562  _mct_ancestor_pdg.clear();
1563  _mct_ancestor_process.clear();
1564  _mct_mother_in_ob_trackid.clear();
1565 
1566 
1567  _pi0_ids.clear();
1568  _muon_ids.clear();
1569 }
1570 
1572  const double& y,
1573  const double& z) const {
1574 
1575  return (((x > xminc0 && x < xmaxc0)
1576  || (x > xminc1 && x < xmaxc1))
1577  && y > ymin && y < ymax
1578  && z > zmin && z < zmax);
1579 }
1580 
1581 /*
1582 bool obana::OBAnaICARUS::InDetector(art::Ptr<simb::MCTruth> mctruth){
1583  const geo::GeometryCore* fGeometry; ///< pointer to Geometry service
1584  fGeometry = lar::providerFrom<geo::Geometry>();
1585  for (size_t i = 0; i < mctruth.size(); i++) {
1586  geo::Point_t trackPoint(pos.X(),pos.Y(),pos.Z());
1587 
1588  const geo::TPCGeo* tpcGeo = fGeometry->PositionToTPCptr(trackPoint);
1589 }
1590 */
1591 
1592 bool obana::OBAnaICARUS::InDetector(art::Ptr<simb::MCParticle> mcp, int & step) {
1593  auto t = mcp->Trajectory();
1594  // std::cout<< "size of trajectory: "<< mcp->NumberTrajectoryPoints() << "\t" << t.size() << std::endl;
1595  const geo::GeometryCore* fGeometry; ///< pointer to Geometry service
1596  fGeometry = lar::providerFrom<geo::Geometry>();
1597 
1598  for (size_t i = 0; i < t.size(); i++) {
1599  // std::cout << "step: " << i << " , has energy : " << mcp->E(i) << "\t" <<mcp->PdgCode()<< std::endl;
1600  const TLorentzVector& pos = mcp->Position(i);
1601  geo::Point_t trackPoint(pos.X(),pos.Y(),pos.Z());
1602 
1603  const geo::TPCGeo* tpcGeo = fGeometry->PositionToTPCptr(trackPoint);
1604 
1605  if (!tpcGeo) continue;
1606  // if (tpcGeo->ID() != C0id) continue; // point not in cryostat 0
1607  if (tpcGeo->ActiveBoundingBox().ContainsPosition(trackPoint)){
1608  step = i;
1609  // std::cout << "Indide the boundary, step: " << step << " , has energy : " << mcp->E(step) << std::endl;
1610  return true;
1611  }
1612  // if (InDetector(t.X(i), t.Y(i), t.Z(i))) return true;
1613  }
1614  return false;
1615 }
1616 
1617 
1618 void obana::OBAnaICARUS::beginSubRun(art::SubRun const& sr) {
1619 
1620  _sr_run = sr.run();
1621  _sr_subrun = sr.subRun();
1622  _sr_begintime = sr.beginTime().value();
1623  _sr_endtime = sr.endTime().value();
1624 
1625  art::Handle<sumdata::POTSummary> pot_handle;
1626  sr.getByLabel(_mctruth_producer, pot_handle);
1627 
1628  if (pot_handle.isValid()) {
1629  _sr_pot = pot_handle->totpot;
1630  } else {
1631  _sr_pot = 0.;
1632  }
1633  //std::cout << "POT for this subrun: " << _sr_pot << std::endl;
1634 
1635  _sr_tree->Fill();
1636  //std::cout << "POT for this subrun, after filling: " << _sr_pot << std::endl;
1637 }
1638 
1639 
1640 DEFINE_ART_MODULE(obana::OBAnaICARUS)
std::vector< float > _mct_mother_pdg
std::vector< float > _muon_genealogy_end_z
The full muon genealogy, from its mother all the way to the ancestor (end z)
TTree * _muon_tree
A muon TTree, one entry per muon.
std::vector< float > _mcs_mother_start_e
int _nu_pip_mult
Pi0 multiplicity.
float _pi0_par_end_y
The pi0 end y.
process_name opflash particleana ie ie ie z
std::vector< int > _muon_genealogy_mother
The full muon genealogy, from its mother all the way to the ancestor (mother track id) ...
std::vector< float > _mcp_intpc_e
std::vector< float > _mct_start_pz
float _pi0_par_e
The pi0 energy.
std::vector< float > _mcs_mother_start_z
int _n_mcs_lt1
Number of MC showers with energy less than 10 MeV.
float _muon_par_end_z
The muon end z.
std::vector< float > _mcp_vx
std::string _mctruth_producer
std::vector< float > _pi0_daughters_end_z
All the pi0 daughters (usually two photons) (end z)
int _n_mct_lt1
Number of MC tracks with energy less than 10 MeV.
std::vector< float > _pi0_daughters_end_y
All the pi0 daughters (usually two photons) (end y)
std::vector< float > _mcs_start_z
std::vector< std::string > _mcs_ancestor_process
std::vector< float > _pi0_genealogy_start_x
The full pi0 genealogy, from its mother all the way to the ancestor (start x)
std::vector< float > _mcp_pdg
Utilities related to art service access.
std::vector< float > _mct_end_x
void SaveMuonShowerInfo(int muon_track_id)
Saves the muon info to a separate tree, give the muon track id.
std::vector< float > _mcs_mother_end_x
std::vector< float > _neut_grand_daughters_end_z
All the neutrons grand daughters end z.
process_name opflash particleana ie x
float _pi0_par_start_z
The pi0 start z.
std::vector< float > _mcs_ancestor_pdg
std::vector< float > _mcp_status_code
std::map< unsigned int, simb::MCParticle > _trackid_to_mcparticle
std::vector< float > _neut_grand_daughters_px
All the neutrons grand daughters momentrum in x direction.
std::vector< float > _mcs_start_e
std::vector< float > _mcp_endx
std::vector< float > _neut_daughters_pz
All the neutron daughters momentrum in z direction.
bool InDetector(const double &x, const double &y, const double &z) const
Check if the point is in the detector.
std::vector< float > _mcp_endy
std::vector< float > _neut_daughters_end_x
All the neutron daughters end x.
std::vector< float > _mcs_mother_end_e
std::vector< float > _mct_start_py
std::vector< std::string > _muon_daughters_endprocess
void clear_vectors()
Clear vectors.
std::vector< float > _muon_genealogy_e
The full muon genealogy, from its mother all the way to the ancestor (energy)
std::vector< float > _mcs_mother_end_z
std::vector< VolumeInfo_t > AllVolumeInfo_t
pdgs p
Definition: selectors.fcl:22
std::vector< float > _pars_e
All other particles produced - energy.
Geometry information for a single TPC.
Definition: TPCGeo.h:38
std::vector< float > _mcs_ancestor_start_e
std::vector< std::string > _pi0_genealogy_startprocess
The full pi0 genealogy, from its mother all the way to the ancestor (start process) ...
std::vector< float > _neut_daughters_trackid
All the neutron daughters trackid.
std::array< double, 3 > Point_t
std::vector< float > _muon_genealogy_start_z
The full muon genealogy, from its mother all the way to the ancestor (start z)
geo::BoxBoundedGeo const & ActiveBoundingBox() const
Returns the box of the active volume of this TPC.
Definition: TPCGeo.h:320
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point) const
Returns the TPC at specified location.
std::vector< float > _pi0_daughters_end_x
All the pi0 daughters (usually two photons) (end x)
double _z_max
z-max of volume box used to determine whether to save track information
int FindMotherInOverburden(simb::MCParticle)
Finds the ancestors that was created in the Ovrburden, if any.
double _sr_begintime
Subrun start time.
std::vector< float > _mct_start_px
float _pi0_par_mother_e
The pi0 mother energy.
std::vector< float > _muon_daughters_end_y
All the muon daughters (usually two photons) (end y)
std::unique_ptr< util::PositionInVolumeFilter > _part_filter
std::vector< float > _mcp_trackid
std::vector< std::string > _neut_daughters_startprocess
All the neutron daughters start process.
int _muon_par_mother_pdg
The muon mother pdg.
std::vector< float > _neut_grand_daughters_e
All the neutrons grand daughters energy.
std::vector< std::string > _muon_genealogy_startprocess
The full muon genealogy, from its mother all the way to the ancestor (start process) ...
float _muon_par_mother_e
The muon mother energy.
std::vector< float > _mcs_start_pz
int _nu_p_mult
Proton multiplicity.
std::vector< int > _pars_pdg
All other particles produced - pdg code.
std::vector< int > _pi0_genealogy_pdg
The full pi0 genealogy, from its mother all the way to the ancestor (pdg)
std::vector< float > _mct_end_z
std::vector< float > _mcs_mother_pdg
std::vector< float > _muon_event_particles_e
All the particles produced together with the muon.
void analyze(art::Event const &e) override
std::vector< float > _mcs_start_py
double _y_max
y-max of volume box used to determine whether to save track information
std::string _mcparticle_producer
std::vector< float > _mcp_intpc_nu_e
std::vector< float > _mcs_mother_start_y
double _sr_pot
Subrun POT.
float _muon_par_mother_end_e
The muon mother energy at end.
std::vector< float > _mct_start_x
std::vector< float > _mcp_vy
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
std::vector< float > _mcp_mother
float _pi0_par_start_y
The pi0 start y.
std::vector< bool > _mcp_intpc
std::vector< float > _neut_daughters_start_y
All the neutron daughters start y.
std::vector< std::string > _mct_mother_process
std::vector< int > _muon_event_particles_pdg
All the particles produced together with the muon.
int _muon_par_ancestor_trackid
The muon primary particle ancestor track id (allows easy muon clustering by cosmic interaction) ...
std::vector< float > _pi0_genealogy_trackid
The full pi0 genealogy, from its mother all the way to the ancestor (trackid)
T abs(T value)
std::vector< unsigned int > _muon_ids
std::vector< float > _neut_grand_daughters_start_y
All the neutrons grand daughters start y.
std::vector< std::string > _neut_grand_daughters_startprocess
All the neutrons grand daughters start process.
std::vector< float > _muon_genealogy_start_x
The full muon genealogy, from its mother all the way to the ancestor (start x)
std::vector< float > _muon_genealogy_end_y
The full muon genealogy, from its mother all the way to the ancestor (end y)
std::vector< float > _pi0_daughters_e
All the pi0 daughters (usually two photons) (energy)
OBAnaICARUS(fhicl::ParameterSet const &p)
OBAnaICARUS & operator=(OBAnaICARUS const &)=delete
std::vector< float > _mcp_e
process_name opflash particleana ie ie y
std::vector< float > _neut_grand_daughters_end_x
All the neutrons grand daughters end x.
std::vector< std::string > _neut_daughters_endprocess
std::vector< float > _neut_grand_daughters_end_y
All the neutrons grand daughters end y.
std::vector< float > _pi0_genealogy_start_y
The full pi0 genealogy, from its mother all the way to the ancestor (start y)
std::vector< float > _neut_daughters_start_z
All the neutron daughters start z.
std::vector< float > _neut_grand_daughters_start_x
All the neutrons grand daughters start x.
std::vector< float > _mct_pdg
std::vector< float > _mct_start_y
std::vector< float > _mcs_mother_start_x
float _muon_par_end_x
The muon end x.
std::vector< float > _mcs_start_y
std::vector< float > _neut_daughters_start_x
All the neutron daughters start x.
std::string _mctrack_producer
int _pi0_par_mother_pdg
The pi0 mother pdg.
TTree * _sr_tree
TTree filled per subrun.
std::vector< float > _mct_start_z
std::vector< float > _pi0_daughters_start_z
All the pi0 daughters (usually two photons) (start z)
float _muon_par_start_x
The muon start x.
std::vector< float > _mcp_px
std::vector< std::string > _pi0_daughters_endprocess
std::vector< unsigned int > _pi0_ids
int _pi0_par_ancestor_trackid
The pi0 primary particle ancestor track id (allows easy pi0 clustering by cosmic interaction) ...
std::vector< float > _pi0_genealogy_end_y
The full pi0 genealogy, from its mother all the way to the ancestor (end y)
std::string _mcshower_producer
int _n_mct_lt1_from_ob
Number of MC tracks with energy less than 10 MeV and coming from OB.
std::vector< std::string > _neut_grand_daughters_endprocess
TTree * _pi0_tree
A pi0 TTree, one entry per pi0.
Description of geometry of one entire detector.
std::vector< float > _muon_genealogy_start_y
The full muon genealogy, from its mother all the way to the ancestor (start y)
Class def header for mctrack data container.
std::vector< float > _mcs_mother_in_ob_trackid
double _y_min
y-min of volume box used to determine whether to save track information
float _muon_par_start_z
The muon start z.
std::vector< int > _muon_daughters_pdg
All the muon daughters (usually two photons) (pdg)
std::vector< float > _pi0_daughters_start_x
All the pi0 daughters (usually two photons) (start x)
std::vector< float > _mcs_mother_trackid
std::vector< int > _neut_grand_daughters_pdg
All the neutron daughters.
std::vector< float > _mcs_end_y
std::vector< std::string > _mcs_process
std::vector< float > _muon_daughters_end_z
All the muon daughters (usually two photons) (end z)
std::vector< float > _mcs_ancestor_end_e
float _pi0_par_mother_end_e
The pi0 mother energy at end.
std::vector< int > _pi0_daughters_pdg
All the pi0 daughters (usually two photons) (pdg)
int _sr_subrun
Subrun Subrun number.
std::vector< std::string > _mct_ancestor_process
float _pi0_par_end_x
The pi0 end x.
std::vector< double > _mcs_charge_col
std::vector< float > _muon_genealogy_end_x
The full muon genealogy, from its mother all the way to the ancestor (end x)
std::vector< float > _neut_daughters_e
All the neutron daughters energy.
std::string _uuid_str
Same as uuid, but converted to string.
float _pi0_par_start_x
The pi0 start x.
std::unique_ptr< util::PositionInVolumeFilter > CreateParticleVolumeFilter(std::set< std::string > const &vol_names) const
Configures and returns a particle filter.
double _x_min
x-min of volume box used to determine whether to save track information
std::vector< float > _pi0_daughters_start_y
All the pi0 daughters (usually two photons) (start y)
std::vector< double > _mcs_charge_ind1
std::vector< float > _pi0_genealogy_end_x
The full pi0 genealogy, from its mother all the way to the ancestor (end x)
std::vector< float > _mct_end_y
std::vector< float > _muon_daughters_start_y
All the muon daughters (usually two photons) (start y)
std::vector< float > _mcp_vz
std::vector< float > _mcs_pdg
void beginSubRun(art::SubRun const &sr) override
std::vector< float > _neut_grand_daughters_trackid
All the neutrons grand daughters trackid.
std::vector< std::string > _muon_daughters_startprocess
All the muon daughters (usually two photons) (energy) (start process)
boost::uuids::uuid _uuid
A unique ID to identify different events in files with same event number.
float _muon_par_start_y
The muon start y.
std::string to_string(WindowPattern const &pattern)
std::vector< float > _muon_daughters_end_x
All the muon daughters (usually two photons) (end x)
std::vector< int > _pi0_event_particles_pdg
All the particles produced together with the pi0.
std::vector< float > _mcp_endz
int _sr_run
Subrun Run number.
std::vector< float > _neut_daughters_end_y
All the neutron daughters end y.
std::vector< float > _muon_daughters_start_x
All the muon daughters (usually two photons) (start x)
std::vector< float > _mcs_end_x
do i e
double _x_max
x-max of volume box used to determine whether to save track information
Class def header for MCShower data container.
std::vector< float > _muon_daughters_e
All the muon daughters (usually two photons) (energy)
std::vector< std::string > _mct_process
std::vector< std::string > _mcs_mother_process
std::vector< std::string > _mcp_process
std::vector< std::string > _overburden_volumes
int _n_mcs_lt1_from_ob
Number of MC showers with energy less than 10 MeV and coming from OB.
std::vector< std::string > _pi0_genealogy_endprocess
The full pi0 genealogy, from its mother all the way to the ancestor (end process) ...
double _sr_endtime
Subrun end time.
float _pi0_par_end_z
The pi0 end z.
std::vector< float > _mct_ancestor_pdg
std::vector< int > _neut_daughters_pdg
All the neutron daughters.
std::vector< double > _mcs_charge_ind2
Defines classes to filter particles based on their trajectory.
std::vector< float > _neut_grand_daughters_start_z
All the neutrons grand daughters start z.
std::vector< float > _mcp_py
int _nu_pi0_mult
Pi plus multiplicity.
std::vector< float > _pi0_genealogy_end_z
The full pi0 genealogy, from its mother all the way to the ancestor (end z)
std::vector< float > _muon_daughters_start_z
All the muon daughters (usually two photons) (start z)
float _muon_par_end_y
The muon end y.
void SavePi0ShowerInfo(int pi0_track_id)
Saves the pi0 info to a separate tree, give the pi0 track id.
std::vector< float > _pi0_genealogy_e
The full pi0 genealogy, from its mother all the way to the ancestor (energy)
std::string _muon_par_ancestor_uuid
The muon unique ID for the event.
std::string _pi0_par_ancestor_uuid
The pi0 unique ID for the event.
std::vector< float > _muon_genealogy_trackid
The full muon genealogy, from its mother all the way to the ancestor (trackid)
std::vector< float > _pi0_event_particles_e
All the particles produced together with the pi0.
std::vector< float > _mcs_start_px
std::vector< float > _mct_start_e
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
std::vector< std::string > _muon_genealogy_endprocess
The full muon genealogy, from its mother all the way to the ancestor (end process) ...
std::vector< float > _mcs_start_x
std::vector< float > _neut_grand_daughters_py
All the neutrons grand daughters momentrum in y direction.
double _z_min
z-min of volume box used to determine whether to save track information
std::vector< float > _mcs_mother_end_y
std::vector< std::string > _mcp_end_process
std::vector< float > _mcp_pz
std::vector< float > _neut_daughters_end_z
All the neutron daughters end z.
std::vector< float > _neut_grand_daughters_pz
All the neutrons grand daughters momentrum in z direction.
std::vector< std::string > _pi0_daughters_startprocess
All the pi0 daughters (usually two photons) (energy) (start process)
float _muon_par_e
The muon energy.
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
std::vector< int > _pi0_genealogy_mother
The full pi0 genealogy, from its mother all the way to the ancestor (mother track id) ...
std::vector< float > _mcs_end_z
art framework interface to geometry description
std::vector< int > _muon_genealogy_pdg
The full muon genealogy, from its mother all the way to the ancestor (pdg)
BEGIN_PROLOG could also be cout
std::vector< float > _neut_daughters_py
All the neutron daughters momentrum in y direction.
std::vector< float > _pi0_genealogy_start_z
The full pi0 genealogy, from its mother all the way to the ancestor (start z)
std::vector< float > _mct_mother_in_ob_trackid
std::vector< float > _neut_daughters_px
All the neutron daughters momentrum in x direction.