18 #include "art/Framework/Core/EDAnalyzer.h"
19 #include "art/Framework/Core/ModuleMacros.h"
20 #include "art/Framework/Principal/Event.h"
21 #include "art/Framework/Principal/Handle.h"
22 #include "art/Framework/Principal/Run.h"
23 #include "art/Framework/Principal/SubRun.h"
24 #include "canvas/Utilities/InputTag.h"
25 #include "fhiclcpp/ParameterSet.h"
26 #include "messagefacility/MessageLogger/MessageLogger.h"
27 #include "art_root_io/TFileService.h"
30 #include "TGeoManager.h"
33 #include "TDatabasePDG.h"
35 #include "nusimdata/SimulationBase/MCFlux.h"
36 #include "nusimdata/SimulationBase/MCTruth.h"
54 void analyze(art::Event
const&
e)
override;
72 TVector3
GetIntersection(TVector3 nu_pos, TVector3 nu_dir,
float z_location=0);
111 _flux_label =
p.get<std::string>(
"FluxLabel",
"flux");
113 _baseline =
p.get<
float>(
"Baseline");
114 _x_shift =
p.get<
float>(
"XShift", 0.);
116 _nu_intersection_z =
p.get<
float>(
"NuIntersectionZ", 0.);
117 _nu_other_intersection_z =
p.get<
float>(
"NuOtherIntersectionZ");
121 _apply_position_cuts =
p.get<
bool>(
"ApplyPositionCuts",
false);
122 _x_cut =
p.get<
float>(
"XCut");
123 _y_cut =
p.get<
float>(
"YCut");
126 art::ServiceHandle<art::TFileService> fs;
127 _tree = fs->make<TTree>(
"tree",
"");
128 _tree->Branch(
"nu_hit", &_nu_hit,
"nu_hit/O");
129 _tree->Branch(
"nu_pdg", &_nu_pdg,
"nu_pdg/I");
130 _tree->Branch(
"nu_e", &_nu_e,
"nu_e/F");
131 _tree->Branch(
"nu_t", &_nu_t,
"nu_t/F");
132 _tree->Branch(
"nu_w", &_nu_w,
"nu_w/F");
133 _tree->Branch(
"nu_x", &_nu_x,
"nu_x/F");
134 _tree->Branch(
"nu_y", &_nu_y,
"nu_y/F");
135 _tree->Branch(
"nu_z", &_nu_z,
"nu_z/F");
136 _tree->Branch(
"nu_vx", &_nu_vx,
"nu_vx/F");
137 _tree->Branch(
"nu_vy", &_nu_vy,
"nu_vy/F");
138 _tree->Branch(
"nu_vz", &_nu_vz,
"nu_vz/F");
139 _tree->Branch(
"nu_px", &_nu_px,
"nu_px/F");
140 _tree->Branch(
"nu_py", &_nu_py,
"nu_py/F");
141 _tree->Branch(
"nu_pz", &_nu_pz,
"nu_pz/F");
142 _tree->Branch(
"nu_decay", &_nu_decay,
"nu_decay/I");
143 _tree->Branch(
"nu_dk2gen", &_nu_dk2gen,
"nu_dk2gen/F");
144 _tree->Branch(
"nu_p_angle", &_nu_p_angle,
"nu_p_angle/F");
145 _tree->Branch(
"nu_p_type", &_nu_p_type,
"nu_p_type/I");
146 _tree->Branch(
"nu_p_dpx", &_nu_p_dpx,
"nu_p_dpx/F");
147 _tree->Branch(
"nu_p_dpy", &_nu_p_dpy,
"nu_p_dpy/F");
148 _tree->Branch(
"nu_p_dpz", &_nu_p_dpz,
"nu_p_dpz/F");
149 _tree->Branch(
"nu_p_e", &_nu_p_e,
"nu_p_e/F");
150 _tree->Branch(
"nu_r", &_nu_r,
"nu_r/F");
151 _tree->Branch(
"nu_oaa", &_nu_oaa,
"nu_oaa/F");
153 _tree->Branch(
"nu_other_x", &_nu_other_x,
"nu_other_x/F");
154 _tree->Branch(
"nu_other_y", &_nu_other_y,
"nu_other_y/F");
155 _tree->Branch(
"nu_other_z", &_nu_other_z,
"nu_other_z/F");
156 _tree->Branch(
"nu_other_t", &_nu_other_t,
"nu_other_t/F");
162 art::Handle< std::vector<simb::MCFlux> > mcFluxHandle;
164 std::vector<simb::MCFlux>
const& fluxlist = *mcFluxHandle;
166 art::Handle< std::vector<simb::MCTruth> > mctruthHandle;
168 std::vector<simb::MCTruth>
const& mclist = *mctruthHandle;
170 for(
unsigned int inu = 0; inu < mclist.size(); inu++) {
171 simb::MCParticle
nu = mclist[inu].GetNeutrino().Nu();
172 simb::MCFlux flux = fluxlist[inu];
178 TVector3 intersection =
GetIntersection(TVector3(nu.Vx(),nu.Vy(),nu.Vz()),
179 TVector3(nu.Px(),nu.Py(),nu.Pz()),
182 float dist = (TVector3(nu.Vx(),nu.Vy(),nu.Vz()) - intersection).Mag();
185 TVector3 intersection_other =
GetIntersection(TVector3(nu.Vx(),nu.Vy(),nu.Vz()),
186 TVector3(nu.Px(),nu.Py(),nu.Pz()),
188 float other_dist = (TVector3(nu.Vx(),nu.Vy(),nu.Vz()) - intersection_other).Mag();
190 float light_speed = TMath::C() / 1e7;
194 _nu_t = nu.T() + dist / light_speed;
195 _nu_w = flux.fnimpwt;
196 _nu_x = intersection.X();
197 _nu_y = intersection.Y();
198 _nu_z = intersection.Z();
212 _nu_p_e = std::sqrt(flux.fpdpx * flux.fpdpx +
213 flux.fpdpy * flux.fpdpy +
214 flux.fpdpz * flux.fpdpz +
215 parent_mass * parent_mass);
226 if (_nu_x < -_x_cut || _nu_x >
_x_cut || _nu_y < -_y_cut || _nu_y >
_y_cut) {
237 TVector3 plane_point(0, 0, z_location);
238 TVector3 plane_normal(0, 0, 1);
240 TVector3 diff = nu_pos - plane_point;
241 double prod1 = diff.Dot(plane_normal);
242 double prod2 = nu_dir.Dot(plane_normal);
243 double prod3 = prod1 / prod2;
244 return nu_pos - nu_dir * prod3;
float _nu_vz
Y poisition of neutrino at neutrino production point.
void analyze(art::Event const &e) override
std::string _flux_label
Label for flux dataproduct (to be set via fcl)
float _nu_p_dpy
Neutrino parent momentum x.
float _nu_other_x
Neutrino off axis angle.
float _nu_p_dpx
Neutrino parent pdg.
float _nu_py
X momentum of neutrino.
float _nu_vy
X poisition of neutrino at neutrino production point.
float _nu_dk2gen
Neutrino parent decay code.
float _nu_other_intersection_z
Additional Z position where to evaluate the flux (to be set via fcl)
int _nu_p_type
Angle between neutrino and parent direction.
float _nu_other_t
Z poisition of neutrino at the front face of the TPC (other)
float _nu_other_y
X poisition of neutrino at the front face of the TPC (other)
FluxReaderAna & operator=(FluxReaderAna const &)=delete
float _nu_r
Neutrino parent energy.
float _nu_px
Z poisition of neutrino at neutrino production point.
TVector3 GetIntersection(TVector3 nu_pos, TVector3 nu_dir, float z_location=0)
Returns the intersection point with the front face of the TPC.
bool _apply_position_cuts
float _nu_y
X poisition of neutrino at the front face of the TPC.
float _nu_z
Y poisition of neutrino at the front face of the TPC.
float _nu_intersection_z
Z position where to evaluate the flux (to be set via fcl)
float _nu_x
Neutrino weight.
int _nu_pdg
True if the neutrino hit the requested volumes.
float _nu_p_e
Neutrino parent momentum x.
float _nu_w
Time of the neutrino.
float _nu_t
Energy of the neutrino.
const TDatabasePDG * _pdg_database
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
float _nu_vx
Z poisition of neutrino at the front face of the TPC.
int _nu_decay
Z momentum of neutrino.
float _nu_p_angle
Distance from decay to ray origin.
float _nu_p_dpz
Neutrino parent momentum x.
FluxReaderAna(fhicl::ParameterSet const &p)
float _nu_pz
Y momentum of neutrino.
float _nu_e
PDG of neutrino.
art framework interface to geometry description
float _nu_other_z
Y poisition of neutrino at the front face of the TPC (other)