forked from DeepLearnPhysics/Supera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SuperaMCTruth.cxx
140 lines (119 loc) · 4.15 KB
/
SuperaMCTruth.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef __SUPERAMCTRUTH_CXX__
#define __SUPERAMCTRUTH_CXX__
#include "SuperaMCTruth.h"
#include "larcv/core/DataFormat/EventParticle.h"
#include "larcv/core/DataFormat/EventNeutrino.h"
#include "larcv/core/DataFormat/Neutrino.h"
namespace larcv {
static SuperaMCTruthProcessFactory __global_SuperaMCTruthProcessFactory__;
SuperaMCTruth::SuperaMCTruth(const std::string name)
: SuperaBase(name)
{}
void SuperaMCTruth::configure(const PSet& cfg)
{
SuperaBase::configure(cfg);
_output_label = cfg.get<std::string>("OutParticleLabel");
_pass_origin = cfg.get<unsigned short>("Origin");
}
void SuperaMCTruth::initialize()
{
SuperaBase::initialize();
}
bool SuperaMCTruth::process(IOManager& mgr)
{
SuperaBase::process(mgr);
auto& ev_part = mgr.get_data<larcv::EventParticle>(_output_label);
auto& ev_nu = mgr.get_data<larcv::EventNeutrino>(_output_label);
auto const& mct_v = LArData<supera::LArMCTruth_t>();
for(size_t mct_index=0; mct_index<mct_v.size(); ++mct_index) {
auto const& mct = mct_v[mct_index];
if(_pass_origin && mct.Origin() != _pass_origin)
continue;
if(mct.NeutrinoSet()) {
auto const& mcnu = mct.GetNeutrino().Nu();
auto const& mcnuint = mct.GetNeutrino();
larcv::Particle nu;
nu.mct_index(mct_index);
nu.track_id(mcnu.TrackId());
nu.pdg_code(mcnu.PdgCode());
nu.momentum(mcnu.Momentum(0).X()*1.e3,
mcnu.Momentum(0).Y()*1.e3,
mcnu.Momentum(0).Z()*1.e3);
nu.position(mcnu.Position(0).X(),
mcnu.Position(0).Y(),
mcnu.Position(0).Z(),
mcnu.Position(0).T());
nu.energy_init(mcnu.Momentum(0).T());
nu.creation_process(mcnu.Process());
nu.parent_track_id(mcnu.TrackId());
nu.parent_pdg_code(mcnu.PdgCode());
nu.ancestor_track_id(mcnu.TrackId());
nu.ancestor_pdg_code(mcnu.PdgCode());
nu.nu_interaction_type(mcnuint.InteractionType());
nu.nu_current_type(mcnuint.CCNC());
//nu.nu_interaction_mode(mcnuint.Mode());
//nu.nu_nucleon(mcnuint.HitNuc());
//nu.nu_quark(mcnuint.HitQuark());
//nu.nu_momentum_transfer(mcnuint.QSqr());
//nu.nu_bjorken_x(mcnuint.X());
LARCV_INFO() << nu.dump() << std::endl;
LARCV_INFO() << mcnuint << std::endl;
ev_part.emplace_back(std::move(nu));
larcv::Neutrino neutrino;
neutrino.mct_index(mct_index);
neutrino.nu_track_id(mcnu.TrackId());
neutrino.lepton_track_id(mcnuint.Lepton().TrackId());
neutrino.current_type(mcnuint.CCNC());
neutrino.interaction_mode(mcnuint.Mode());
neutrino.interaction_type(mcnuint.InteractionType());
neutrino.target(mcnuint.Target());
neutrino.nucleon(mcnuint.HitNuc());
neutrino.quark(mcnuint.HitQuark());
neutrino.hadronic_invariant_mass(mcnuint.W());
neutrino.bjorken_x(mcnuint.X());
neutrino.inelasticity(mcnuint.Y());
neutrino.momentum_transfer(mcnuint.QSqr());
neutrino.theta(mcnuint.Theta());
neutrino.pdg_code(mcnu.PdgCode());
neutrino.momentum(mcnu.Px(), mcnu.Py(), mcnu.Pz());
neutrino.position(mcnu.Vx(), mcnu.Vy(), mcnu.Vz(), mcnu.T());
neutrino.energy_init(mcnu.Momentum(0).T());
neutrino.creation_process(mcnu.Process());
auto& traj = mcnu.Trajectory();
//auto& processes = traj.TrajectoryProcesses();
for(size_t j = 0; j < traj.size(); ++j) {
neutrino.add_trajectory_point(
traj.X(j), traj.Y(j), traj.Z(j), traj.T(j),
traj.Px(j), traj.Py(j), traj.Pz(j), traj.E(j)
);
}
ev_nu.emplace_back(std::move(neutrino));
}
for(int i=0; i<mct.NParticles(); ++i) {
auto const& mcp = mct.GetParticle(i);
if(mcp.StatusCode() != 1) continue;
auto const& pos = mcp.Position(0);
auto const& mom = mcp.Momentum(0);
larcv::Particle p;
p.mct_index(mct_index);
p.track_id(mcp.TrackId());
p.shape((mcp.PdgCode() == 11 || mcp.PdgCode() == 22 ? larcv::kShapeShower : larcv::kShapeTrack) );
p.pdg_code(mcp.PdgCode());
p.momentum(mom.X()*1.e3,mom.Y()*1.e3,mom.Z()*1.e3);
p.position(pos.X(),pos.Y(),pos.Z(),pos.T());
p.energy_init(mom.T());
p.creation_process(mcp.Process());
p.parent_track_id(mcp.TrackId());
p.parent_pdg_code(mcp.PdgCode());
p.ancestor_track_id(mcp.TrackId());
p.ancestor_pdg_code(mcp.PdgCode());
LARCV_INFO() << p.dump() << std::endl;
ev_part.emplace_back(std::move(p));
}
}
return true;
}
void SuperaMCTruth::finalize()
{}
}
#endif