All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbnana/sbnanalysis/ana/SBNOsc/Utilities.h
Go to the documentation of this file.
1 #ifndef __sbnanalysis_ana_SBNOsc_Utilities__
2 #define __sbnanalysis_ana_SBNOsc_Utilities__
3 
4 /**
5  * \file Utilities.h
6  *
7  * Common utilties
8  *
9  * This is some auxiliary code that is not a selection, but does a piece
10  * of the analysis. We can define any number of other functions, classes,
11  * etc. which we use in the selection.
12  *
13  * Author: A. Mastbaum <mastbaum@uchicago.edu>
14  */
15 
16 #include "nusimdata/SimulationBase/MCTruth.h"
17 
20 #include "gallery/Event.h"
21 
22 #include "core/Event.hh"
23 
24 #include "ubcore/LLBasicTool/GeoAlgo/GeoAABox.h"
25 #include "TRandom.h"
26 
27 namespace ana {
28  namespace SBNOsc {
29 
30 /** A function that says hello. */
31 void hello();
32 
33 
34 /** Extract truth information to approximate reconstruction. */
35 event::Interaction TruthReco(const simb::MCTruth& mctruth);
36 
37 
38 /**
39  * Get oscillation probability of muon neutrino in a 3+1 model. I.e.
40  * probability that the numu will stay a numu.
41  *
42  * \param numu_energy Energy of incident muon neutrino in GeV
43  * \param numu_dist Distance travelled by muon neutrino in km
44  * \param osc_dm2 dm^2 of sterile netrino in eV^2
45  * \param osc_angle Sterile neutrino mixing angle
46  *
47  * \return Probability of muon neutrino not oscillating in 3+1 model.
48  */
49 double NuMuOscillation(double numu_energy, double numu_dis,
50  double osc_dm2, double osc_angle);
51 
52 
53 /**
54  * Finds length of line segment contained inside AABox. Make sure that
55  * AABox and TVector's use the same units.
56  *
57  * \param v0 the first point of the line segment
58  * \param v1 the second point of the line segment
59  * \param boxes a list of fiducial volumes instantiated as AABoxes
60  *
61  * \return Length of line segment contained in the list of AABox's.
62  */
63 double containedLength(const TVector3 &v0, const TVector3 &v1,
64  const std::vector<geoalgo::AABox> &boxes);
65 
66 
67 /**
68  * Get mass from PDGID of particle in MeV/c^2.
69  *
70  * \param pdg The Particle Data Group ID of the particle (as returned
71  * by i.e. an MCTruth object)
72  *
73  * \return Mass of particle in MeV/c^2
74  */
75 double PDGMass(int pdg);
76 
77 
78 /**
79  * Get charge from PDGID of particle in |e|/3.
80  * \param pdg The Particle Data Group ID of the particle (as returned by
81  * i.e. an MCTruth object)
82  *
83  * \return Charge of particle in |e|/3.
84  */
85 double PDGCharge(int pdg);
86 
87 
88 /**
89  * Returns whether track/shower object is from the neutrino vertex
90  *
91  * \param mc MCTruth corresponding to neutrino interaction
92  * \param show The object to be matched
93  * \param distance between shower start and interaction vertex
94  * \return Whether track/shower object is from neutrino vertex
95  */
96 bool isFromNuVertex(const simb::MCTruth& mc, const sim::MCShower& show,
97  float distance=5.0);
98 
99 
100 /**
101  * Returns whether track/shower object is from the neutrino vertex
102  *
103  * \param mc MCTruth corresponding to neutrino interaction
104  * \param track The object to be matched
105  * \param distance between track start and interaction vertex
106  * \return Whether track/shower object is from neutrino vertex
107  */
108 bool isFromNuVertex(const simb::MCTruth& mc, const sim::MCTrack& track,
109  float distance=5.0);
110 
111 bool isFromNuVertex(const simb::MCTruth& mc, const simb::MCParticle& mcp, float distance=5.0);
112 
113 
114 /**
115  * Calculate CCQE energy from associated lepton information (and optional
116  * distortion). Energy in GeV.
117  *
118  * \param l_momentum Lepton momentum (in any units -- used only to
119  * get angle info)
120  * \param l_energy Lepton energy in GeV
121  * \param energy_distortion Optional energy distortion in GeV
122  * \param angle_distortion Optiona langle distortion
123  *
124  * \return CCQE energy in GeV.
125  */
126 double ECCQE(const TVector3& l_momentum, double l_energy,
127  double energy_distortion=0., double angle_distortion=0.);
128 
129 
130 /**
131  * \class Struct containing information used in calculation of visible Energy
132  *
133  */
135  int lepton_pdgid; //!< PDGID of lepton in the interaction. Used to add
136  // in energy corresponding to lepton mass for CC events (and confused NC
137  // events). If you don't want to add in a lepton mass to the energy
138  // accounting, set it to 0.
139  double track_threshold; //!< Energy threshold of track energy counted in calculation [GeV].
140  double shower_threshold; //!< Energy threshold of shower energy counted in calculation [GeV].
141  double track_energy_distortion; //!< Distortion of energies of tracks (%).
142  double shower_energy_distortion; //!< Distortion of energies of showers (%).
143 
144  double lepton_energy_distortion_contained; //!< Distortion of energies of primary lepton whose tracks are contained within the TPC (%).
145  double lepton_energy_distortion_leaving_A; //!< Parameter in function to calculate primary lepton energy resolution.
146  // (%) = -A * Log(B * L) where L is the lepton contained length
147  double lepton_energy_distortion_leaving_B; //!< Parameter in function to calculate primary lepton energy resolution.
148  // (%) = -A * Log(B * L) where L is the lepton contained length
149  int lepton_index; //!< Index of lepton in the mctrack object
150  bool lepton_contained; //!< True if primary lepton's track is contained within TPC.
151  double lepton_contained_length; //!< Length of section of primary lepton's track that is contained within the TPC.
152 
154  lepton_pdgid(0),
155  track_threshold(0),
156  shower_threshold(0),
164  {}
165 };
166 
167 
168 /**
169  * Get the "visible" energy from a neutrino interaction. Is equal to sum of
170  * non-neutral hadronic kinetic energies and lepton total energies.
171  *
172  * \param ev The gallery event.
173  * \param mctruth The MCTruth object corresponding to the interaction.
174  * \param mctrack_list Vector of MCTrack objects in the gallery event.
175  * \param mcshower_list Vector of MCShower objects in the gallery event.
176  * \param calculator Struct containing values to be used in energy calculation
177  * \param smeared_lepton_energy lepton energy to be used in calculation -- will default to smearLeptonEnergy(mctruth, calculator) if not set
178  *
179  * \return Visble energy in GeV.
180  * */
181 double visibleEnergy(TRandom &rand, const simb::MCTruth &mctruth, const std::vector<sim::MCTrack> &mctrack_list, const std::vector<sim::MCShower> &mcshower_list,
182  const VisibleEnergyCalculator &calculator=VisibleEnergyCalculator(), bool include_showers=true);
183 
184 double visibleEnergyProposal(TRandom &rand, const simb::MCTruth &mctruth, const std::vector<sim::MCTrack> &mctrack_list, const VisibleEnergyCalculator &calculator);
185 double visibleEnergyProposalMCParticles(TRandom &rand, const simb::MCTruth &mctruth, const std::vector<sim::MCTrack> mctrack_list, const VisibleEnergyCalculator &calculator);
186 
187 /** Get the smeared energy from a lepton.
188  * \param mctrack The MCTrack object corresponding to the lepton
189  * \param calculator Struct containing values to be used in energy calculation
190  *
191  * */
192 double smearLeptonEnergy(TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator=VisibleEnergyCalculator());
193 
194 double closestDistance(const TVector3 &line0, const TVector3 &line1, const TVector3 &p);
195 double closestDistanceDim(const TVector3 &line0, const TVector3 &line1, const TVector3 &p, int dim);
196 
197  } // namespace SBNOsc
198 } // namespace ana
199 
200 #endif // __sbnanalysis_ana_SBNOsc_Utilities__
double visibleEnergyProposalMCParticles(TRandom &rand, const simb::MCTruth &mctruth, const std::vector< sim::MCTrack > mctrack_list, const VisibleEnergyCalculator &calculator)
int lepton_index
Index of lepton in the mctrack object.
double track_energy_distortion
Distortion of energies of tracks (%).
double visibleEnergyProposal(TRandom &rand, const simb::MCTruth &mctruth, const std::vector< sim::MCTrack > &mctrack_list, const VisibleEnergyCalculator &calculator)
var pdg
Definition: selectors.fcl:14
double lepton_energy_distortion_leaving_A
Parameter in function to calculate primary lepton energy resolution.
bool isFromNuVertex(const simb::MCTruth &mc, const simb::MCParticle &mcp, float distance)
double closestDistance(const TVector3 &line0, const TVector3 &line1, const TVector3 &p)
pdgs p
Definition: selectors.fcl:22
double lepton_energy_distortion_contained
Distortion of energies of primary lepton whose tracks are contained within the TPC (%)...
process_name use argoneut_mc_hitfinder track
double visibleEnergy(TRandom &rand, const simb::MCTruth &mctruth, const std::vector< sim::MCTrack > &mctrack_list, const std::vector< sim::MCShower > &mcshower_list, const VisibleEnergyCalculator &calculator, bool include_showers)
process_name opflashCryoW ana
double shower_threshold
Energy threshold of shower energy counted in calculation [GeV].
double lepton_energy_distortion_leaving_B
Parameter in function to calculate primary lepton energy resolution.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
double smearLeptonEnergy(TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator)
event::Interaction TruthReco(const simb::MCTruth &mctruth)
Class def header for mctrack data container.
double track_threshold
Energy threshold of track energy counted in calculation [GeV].
double shower_energy_distortion
Distortion of energies of showers (%).
double NuMuOscillation(double numu_energy, double numu_dist, double osc_dm2, double osc_angle)
double ECCQE(const TVector3 &l_momentum, double l_energy, double energy_distortion, double angle_distortion)
double containedLength(const TVector3 &v0, const TVector3 &v1, const std::vector< geoalgo::AABox > &boxes)
double lepton_contained_length
Length of section of primary lepton&#39;s track that is contained within the TPC.
Class def header for MCShower data container.
double closestDistanceDim(const TVector3 &line0, const TVector3 &line1, const TVector3 &p, int dim)
int lepton_pdgid
PDGID of lepton in the interaction. Used to add.
All truth information associated with one neutrino interaction.
Definition: Event.hh:150
bool lepton_contained
True if primary lepton&#39;s track is contained within TPC.