All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
ana::SBNOsc Namespace Reference

Classes

class  Chi2Sensitivity
 
class  Covariance
 
class  NueSelection
 Electron neutrino event selection. More...
 
class  NumuSelection
 Electron neutrino event selection. More...
 
struct  VisibleEnergyCalculator
 
class  AuxDetSimChannelPrinter
 Electron neutrino event selection. More...
 
class  CaloPrinter
 Electron neutrino event selection. More...
 
class  CosmicArrivalTimes
 Electron neutrino event selection. More...
 
class  CRTHitTiming
 Electron neutrino event selection. More...
 
class  CRTSimHitViewer
 Electron neutrino event selection. More...
 
class  GetFV
 Electron neutrino event selection. More...
 
class  MCParticleTreePrinter
 Electron neutrino event selection. More...
 
class  OpDetBackTrackerPrinter
 Electron neutrino event selection. More...
 
class  OpDetWaveformMaker
 Electron neutrino event selection. More...
 
class  OpSimHitPrinter
 Electron neutrino event selection. More...
 
class  PandoraIDPrinter
 Electron neutrino event selection. More...
 
class  PandoraMetadataPrinter
 Electron neutrino event selection. More...
 
class  SimPhotonPrinter
 Electron neutrino event selection. More...
 
struct  CosmicHistos
 
struct  CRTHistos
 
class  HistoList
 
struct  InteractionHistos
 
struct  TrackProfiles
 
struct  TrackHistos
 
class  Cuts
 
class  Flatten
 
struct  Histograms
 
class  Normalize
 
struct  ROC
 
class  Selection
 
class  NumuReco
 Electron neutrino event selection. More...
 

Functions

double osc_factor_L_integrated (double energy, double l_min, double l_max, double dm2)
 
double numu_to_numu (double x, double sin, double dm2)
 
double numu_to_nue (double x, double sin, double dm2)
 
double NumuOscillate (ROOT::Math::IntegratorOneDim &integrator, double l_min, double l_max, double e_min, double e_max, double dm2, double sinth)
 
std::vector< float > GetUniWeights (const std::map< std::string, std::vector< float > > &weights, const std::vector< std::string > &keys, int n_unis, int uni_offset)
 
double aaBoxesMin (const std::vector< geoalgo::AABox > &boxes, unsigned dim)
 
double aaBoxesMax (const std::vector< geoalgo::AABox > &boxes, unsigned dim)
 
geoalgo::AABox shaveVolume (const geoalgo::AABox &select_volume, double delta)
 
void hello ()
 
event::Interaction TruthReco (const simb::MCTruth &mctruth)
 
double ECCQE (const TVector3 &l_momentum, double l_energy, double energy_distortion, double angle_distortion)
 
double NuMuOscillation (double numu_energy, double numu_dist, double osc_dm2, double osc_angle)
 
double containedLength (const TVector3 &v0, const TVector3 &v1, const std::vector< geoalgo::AABox > &boxes)
 
double visibleEnergyProposalMCParticles (TRandom &rand, const simb::MCTruth &mctruth, const std::vector< sim::MCTrack > mctrack_list, const VisibleEnergyCalculator &calculator)
 
double visibleEnergyProposal (TRandom &rand, const simb::MCTruth &mctruth, const std::vector< sim::MCTrack > &mctrack_list, const VisibleEnergyCalculator &calculator)
 
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)
 
double smearLeptonEnergy (TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator)
 
static const TDatabasePDG * PDGTable (new TDatabasePDG)
 
double PDGMass (int pdg)
 
double PDGCharge (int pdg)
 
bool isFromNuVertex (const simb::MCTruth &mc, const simb::MCParticle &mcp, float distance)
 
bool isFromNuVertex (const simb::MCTruth &mc, const sim::MCShower &show, float distance)
 
bool isFromNuVertex (const simb::MCTruth &mc, const sim::MCTrack &track, float distance)
 
double closestDistance (const TVector3 &line0, const TVector3 &line1, const TVector3 &p)
 
double closestDistanceDim (const TVector3 &line0, const TVector3 &line1, const TVector3 &p, int dim)
 
template<typename T , std::size_t N1, std::size_t N2>
constexpr std::array< T, N1+N2 > concat (std::array< T, N1 > lhs, std::array< T, N2 > rhs)
 
void SetEvent (numu::RecoEvent &event, const event::Event &core, const ana::SBNOsc::Cuts &cuts, numu::MCType file_type, bool use_calorimetry=true)
 
void DumpTrueStart (const gallery::Event &ev, int mcparticle_id)
 
numu::Wall GetWallCross (const geo::BoxBoundedGeo &volume, const TVector3 p0, const TVector3 p1)
 
sbn::crt::CRTHit ICARUS2SBNDCrtHit (const sbn::crt::CRTHit &inp)
 
double RecoTrackLength (const art::Ptr< recob::Track > &track)
 

Variables

static const TVector3 InvalidTVector3 = TVector3(-999, -999, -999)
 

Function Documentation

double ana::SBNOsc::aaBoxesMax ( const std::vector< geoalgo::AABox > &  boxes,
unsigned  dim 
)

Definition at line 65 of file NumuSelection.cxx.

65  {
66  return std::max_element(boxes.begin(), boxes.end(), [dim](auto &lhs, auto &rhs) { return lhs.Max()[dim] < rhs.Max()[dim]; })->Max()[dim];
67 }
double ana::SBNOsc::aaBoxesMin ( const std::vector< geoalgo::AABox > &  boxes,
unsigned  dim 
)

Definition at line 61 of file NumuSelection.cxx.

61  {
62  return std::min_element(boxes.begin(), boxes.end(), [dim](auto &lhs, auto &rhs) { return lhs.Min()[dim] < rhs.Min()[dim]; })->Min()[dim];
63 }
double ana::SBNOsc::closestDistance ( const TVector3 &  line0,
const TVector3 &  line1,
const TVector3 &  p 
)

Definition at line 490 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

490  {
491  // Return minimum distance between line segment vw and point p
492  // const float l2 = length_squared(v, w); // i.e. |w-v|^2 - avoid a sqrt
493  double length2 = (line0 - line1).Mag2();
494  if (length2 == 0.0) return (line0 - p).Mag();
495  // Consider the line extending the segment, parameterized as v + t (w - v).
496  // We find projection of point p onto the line.
497  // It falls where t = [(p-v) . (w-v)] / |w-v|^2
498  // We clamp t from [0,1] to handle points outside the segment vw.
499  double t = std::max(0., std::min(1., (p - line0).Dot(line1 - line0) / length2));
500  TVector3 projection = line0 + t * (line1 - line0);
501  return (projection - p).Mag();
502 }
pdgs p
Definition: selectors.fcl:22
double ana::SBNOsc::closestDistanceDim ( const TVector3 &  line0,
const TVector3 &  line1,
const TVector3 &  p,
int  dim 
)

Definition at line 504 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

504  {
505  double l0 = line0[dim];
506  double l1 = line1[dim];
507  double pp = p[dim];
508 
509  if ((l0 < pp && pp < l1) || (l1 < pp && pp < l0)) return 0.;
510  return std::min(abs(l0 - pp) , abs(l1 - pp));
511 }
pdgs p
Definition: selectors.fcl:22
T abs(T value)
template<typename T , std::size_t N1, std::size_t N2>
constexpr std::array<T, N1+N2> ana::SBNOsc::concat ( std::array< T, N1 >  lhs,
std::array< T, N2 >  rhs 
)

Definition at line 28 of file Histograms.h.

28  {
29  std::array<T,N1+N2> result{};
30  size_t index = 0;
31  for (auto &el : lhs) {
32  result[index] = std::move(el);
33  index ++;
34  }
35  for (auto &el : rhs) {
36  result[index] = std::move(el);
37  index ++;
38  }
39  return result;
40  }
double ana::SBNOsc::containedLength ( const TVector3 &  v0,
const TVector3 &  v1,
const std::vector< geoalgo::AABox > &  boxes 
)

Finds length of line segment contained inside AABox. Make sure that AABox and TVector's use the same units.

Parameters
v0the first point of the line segment
v1the second point of the line segment
boxesa list of fiducial volumes instantiated as AABoxes
Returns
Length of line segment contained in the list of AABox's.

Definition at line 92 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

93  {
94  static const geoalgo::GeoAlgo algo;
95 
96  // if points are the same, return 0
97  if ((v0 - v1).Mag() < 1e-6) return 0;
98 
99  // construct individual points
100  geoalgo::Point_t p0(v0);
101  geoalgo::Point_t p1(v1);
102 
103  // construct line segment
104  geoalgo::LineSegment line(p0, p1);
105 
106  double length = 0;
107 
108  // total contained length is sum of lengths in all boxes
109  // assuming they are non-overlapping
110  for (auto const &box: boxes) {
111  int n_contained = box.Contain(p0) + box.Contain(p1);
112  // both points contained -- length is total length (also can break out of loop)
113  if (n_contained == 2) {
114  length = (v1 - v0).Mag();
115  break;
116  }
117  // one contained -- have to find intersection point (which must exist)
118  if (n_contained == 1) {
119  auto intersections = algo.Intersection(line, box);
120  // Because of floating point errors, it can sometimes happen
121  // that there is 1 contained point but no "Intersections"
122  // if one of the points is right on the edge
123  if (intersections.size() == 0) {
124  // determine which point is on the edge
125  double tol = 1e-5;
126  bool p0_edge = algo.SqDist(p0, box) < tol;
127  bool p1_edge = algo.SqDist(p1, box) < tol;
128  assert(p0_edge || p1_edge);
129  // contained one is on edge -- can treat both as not contained
130  //
131  // In this case, no length
132  if ((p0_edge && box.Contain(p0)) || (box.Contain(p1) && p1_edge))
133  continue;
134  // un-contaned one is on edge -- treat both as contained
135  else if ((p0_edge && box.Contain(p1)) || (box.Contain(p0) && p1_edge)) {
136  length = (v1 - v0).Mag();
137  break;
138  }
139  else {
140  assert(false); // bad
141  }
142  }
143  // floating point errors can also falsely cause 2 intersection points
144  //
145  // in this case, one of the intersections must be very close to the
146  // "contained" point, so the total contained length will be about
147  // the same as the distance between the two intersection points
148  else if (intersections.size() == 2) {
149  length += (intersections.at(0).ToTLorentzVector().Vect() - intersections.at(1).ToTLorentzVector().Vect()).Mag();
150  continue;
151  }
152  // "Correct"/ideal case -- 1 intersection point
153  else if (intersections.size() == 1) {
154  // get TVector at intersection point
155  TVector3 int_tv(intersections.at(0).ToTLorentzVector().Vect());
156  length += ( box.Contain(p0) ? (v0 - int_tv).Mag() : (v1 - int_tv).Mag() );
157  }
158  else assert(false); // bad
159  }
160  // none contained -- either must have zero or two intersections
161  if (n_contained == 0) {
162  auto intersections = algo.Intersection(line, box);
163  if (!(intersections.size() == 0 || intersections.size() == 2)) {
164  // more floating point error fixes...
165  //
166  // figure out which points are near the edge
167  double tol = 1e-5;
168  bool p0_edge = algo.SqDist(p0, box) < tol;
169  bool p1_edge = algo.SqDist(p1, box) < tol;
170  // and which points are near the intersection
171  TVector3 vint = intersections.at(0).ToTLorentzVector().Vect();
172  bool p0_int = (v0 - vint).Mag() < tol;
173  bool p1_int = (v1 - vint).Mag() < tol;
174  // exactly one of them should produce the intersection
175  assert((p0_int && p0_edge) != (p1_int && p1_edge));
176  // both close to edge -- full length is contained
177  if (p0_edge && p1_edge) {
178  length += (v0 - v1).Mag();
179  }
180  // otherwise -- one of them is not on an edge, no length is contained
181  else {}
182  }
183  // assert(intersections.size() == 0 || intersections.size() == 2);
184  else if (intersections.size() == 2) {
185  TVector3 start(intersections.at(0).ToTLorentzVector().Vect());
186  TVector3 end(intersections.at(1).ToTLorentzVector().Vect());
187  length += (start - end).Mag();
188  }
189  }
190  }
191 
192  return length;
193 }
Algorithm to compute various geometrical relation among geometrical objects. In particular functions ...
auto const tol
Definition: SurfXYZTest.cc:16
double SqDist(const Line_t &line, const Point_t &pt) const
Representation of a simple 3D line segment Defines a finite 3D straight line by having the start and ...
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
do i e
std::vector< Point_t > Intersection(const AABox_t &box, const HalfLine_t &line, bool back=false) const
Intersection between a HalfLine and an AABox.
physics associatedGroupsWithLeft p1
void ana::SBNOsc::DumpTrueStart ( const gallery::Event &  ev,
int  mcparticle_id 
)

Definition at line 67 of file NumuReco.cxx.

67  {
68  // track.match.mcparticle_id);
69  const std::vector<simb::MCParticle> &mcparticle_list = *ev.getValidHandle<std::vector<simb::MCParticle>>("largeant");
70  std::cout << "Track: " << mcparticle_id;
71  for (const simb::MCParticle &part: mcparticle_list) {
72  if (mcparticle_id == part.TrackId()) {
73  std::cout << " start T: " << part.Position().T() << " to: " << part.EndPosition().T() << std::endl;
74  }
75  }
76  return;
77 }
BEGIN_PROLOG could also be cout
double ana::SBNOsc::ECCQE ( const TVector3 &  l_momentum,
double  l_energy,
double  energy_distortion = 0.,
double  angle_distortion = 0. 
)

Calculate CCQE energy from associated lepton information (and optional distortion). Energy in GeV.

Parameters
l_momentumLepton momentum (in any units – used only to get angle info)
l_energyLepton energy in GeV
energy_distortionOptional energy distortion in GeV
angle_distortionOptiona langle distortion
Returns
CCQE energy in GeV.

Definition at line 59 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

60  {
61  // Based on D. Kaleko, LowEnergyExcess LArLite module ECCQECalculator
62  double M_n = 0.939565; // GeV/c^2
63  double M_p = 0.938272; // GeV/c^2
64  double M_e = 0.000511; // GeV/c^2
65  double bindingE = 0.0300; // GeV
66 
67  double mp2 = M_p * M_p;
68  double me2 = M_e * M_e;
69  double mnb = M_n - bindingE;
70 
71  // mess around with lorentz vector
72  TVector3 v(l_momentum);
73  v.SetTheta( v.Theta() + angle_distortion);
74  l_energy = l_energy + energy_distortion;
75  double l_mom = sqrt(l_energy*l_energy - me2);
76  double l_theta = \
77  acos(v.Pz() / sqrt(v.Px()*v.Px() + v.Py()*v.Py() + v.Pz()*v.Pz()));
78  double enu_top = mp2 - mnb*mnb - me2 + 2.0 * mnb * l_energy;
79  double enu_bot = 2.0 * (mnb - l_energy + l_mom * cos(l_theta));
80  return enu_top / enu_bot;
81 }
std::vector<float> ana::SBNOsc::GetUniWeights ( const std::map< std::string, std::vector< float > > &  weights,
const std::vector< std::string > &  keys,
int  n_unis,
int  uni_offset 
)

Definition at line 61 of file Covariance.cxx.

61  {
62  std::vector <float> uweights;
63  for (int u = 0; u < n_unis; u++) {
64  float weight = 1.;
65  for (auto const &key: keys) {
66  const std::vector<float>& this_weights = weights.at(key);
67  int wind = u + uni_offset;
68  weight *= this_weights.at(wind);
69  }
70  uweights.push_back(weight);
71  }
72  return uweights;
73 }
numu::Wall ana::SBNOsc::GetWallCross ( const geo::BoxBoundedGeo volume,
const TVector3  p0,
const TVector3  p1 
)

Definition at line 79 of file NumuReco.cxx.

79  {
80  TVector3 direction = (p1 - p0) * ( 1. / (p1 - p0).Mag());
81  std::vector<TVector3> intersections = volume.GetIntersections(p0, direction);
82 
83  /*
84  std::cout << "p0: " << p0.X() << " " << p0.Y() << " " << p0.Z() << std::endl;
85  std::cout << "p1: " << p1.X() << " " << p1.Y() << " " << p1.Z() << std::endl;
86  std::cout << "i0: " << intersections[0].X() << " " << intersections[0].Y() << " " << intersections[0].Z() << std::endl;
87  std::cout << "i1: " << intersections[1].X() << " " << intersections[1].Y() << " " << intersections[1].Z() << std::endl;
88  */
89 
90  assert(intersections.size() == 2);
91 
92  // get the intersection point closer to p0
93  int intersection_i = ((intersections[0] - p0).Mag() < (intersections[1] - p0).Mag()) ? 0 : 1;
94 
95 
96  double eps = 1e-3;
97  if (abs(intersections[intersection_i].X() - volume.MinX()) < eps) {
98  //std::cout << "Left\n";
99  return numu::wLeft;
100  }
101  else if (abs(intersections[intersection_i].X() - volume.MaxX()) < eps) {
102  //std::cout << "Right\n";
103  return numu::wRight;
104  }
105  else if (abs(intersections[intersection_i].Y() - volume.MinY()) < eps) {
106  //std::cout << "Bottom\n";
107  return numu::wBottom;
108  }
109  else if (abs(intersections[intersection_i].Y() - volume.MaxY()) < eps) {
110  //std::cout << "Top\n";
111  return numu::wTop;
112  }
113  else if (abs(intersections[intersection_i].Z() - volume.MinZ()) < eps) {
114  //std::cout << "Front\n";
115  return numu::wFront;
116  }
117  else if (abs(intersections[intersection_i].Z() - volume.MaxZ()) < eps) {
118  //std::cout << "Back\n";
119  return numu::wBack;
120  }
121  else assert(false);
122  //std::cout << "None\n";
123 
124  return numu::wNone;
125 }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
T abs(T value)
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxY() const
Returns the world y coordinate of the end of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
do i e
std::vector< TVector3 > GetIntersections(TVector3 const &TrajectoryStart, TVector3 const &TrajectoryDirect) const
Calculates the entry and exit points of a trajectory on the box surface.
double MinY() const
Returns the world y coordinate of the start of the box.
physics associatedGroupsWithLeft p1
void ana::SBNOsc::hello ( )

A function that says hello.

Definition at line 21 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

21  {
22  std::cout << "Hello SBNOsc!" << std::endl;
23 }
BEGIN_PROLOG could also be cout
sbn::crt::CRTHit ana::SBNOsc::ICARUS2SBNDCrtHit ( const sbn::crt::CRTHit inp)

Definition at line 138 of file NumuReco.cxx.

138  {
139  sbn::crt::CRTHit ret;
140  ret.feb_id = inp.feb_id;
141  ret.pesmap = inp.pesmap;
142  // convert ADC -> PE's
143  // TODO: fix -- hardcoded for now as temporary hack
144  unsigned n_strip = 2;
145  double baseline = 63.6; // ADC
146  double gain = 70; // ADC / PE
147  ret.peshit = (inp.peshit - n_strip*baseline) / (gain * n_strip);
148  ret.ts0_s = inp.ts0_s;
149  ret.ts0_s_corr = inp.ts0_s_corr;
150  ret.ts0_ns = inp.ts0_ns;
151  ret.ts0_ns_corr = inp.ts0_ns_corr;
152  ret.ts1_ns = inp.ts1_ns;
153  ret.plane = inp.plane;
154  ret.x_pos = inp.x_pos;
155  ret.x_err = inp.x_err;
156  ret.y_pos = inp.y_pos;
157  ret.y_err = inp.y_err;
158  ret.z_pos = inp.z_pos;
159  ret.z_err = inp.z_err;
160  ret.tagger = inp.tagger;
161  return ret;
162 }
float z_err
position uncertainty in z-direction (cm).
Definition: CRTHit.hh:43
float x_err
position uncertainty in x-direction (cm).
Definition: CRTHit.hh:39
std::map< uint8_t, std::vector< std::pair< int, float > > > pesmap
Saves signal hit information (FEB, local-channel and PE) .
Definition: CRTHit.hh:26
std::vector< uint8_t > feb_id
FEB address.
Definition: CRTHit.hh:25
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
Definition: CRTHit.hh:34
int plane
Name of the CRT wall (in the form of numbers).
Definition: CRTHit.hh:36
float peshit
Total photo-electron (PE) in a crt hit.
Definition: CRTHit.hh:27
float y_err
position uncertainty in y-direction (cm).
Definition: CRTHit.hh:41
double ts0_ns_corr
[Honestly, not sure at this point, it was there since long time (BB)]
Definition: CRTHit.hh:33
double ts0_s_corr
[Honestly, not sure at this point, it was there since long time (BB)]
Definition: CRTHit.hh:30
uint64_t ts0_s
Second-only part of timestamp T0.
Definition: CRTHit.hh:29
float z_pos
position in z-direction (cm).
Definition: CRTHit.hh:42
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
Definition: CRTHit.hh:32
BEGIN_PROLOG baseline
float y_pos
position in y-direction (cm).
Definition: CRTHit.hh:40
float x_pos
position in x-direction (cm).
Definition: CRTHit.hh:38
std::string tagger
Name of the CRT wall (in the form of strings).
Definition: CRTHit.hh:45
bool ana::SBNOsc::isFromNuVertex ( const simb::MCTruth &  mc,
const simb::MCParticle &  mcp,
float  distance 
)

Definition at line 468 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

468  {
469  TVector3 nuVtx = mc.GetNeutrino().Nu().Position().Vect();
470  TVector3 partStart = mcp.Position().Vect();
471  return (partStart - nuVtx).Mag() < distance;
472 }
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
bool ana::SBNOsc::isFromNuVertex ( const simb::MCTruth &  mc,
const sim::MCShower show,
float  distance = 5.0 
)

Returns whether track/shower object is from the neutrino vertex

Parameters
mcMCTruth corresponding to neutrino interaction
showThe object to be matched
distancebetween shower start and interaction vertex
Returns
Whether track/shower object is from neutrino vertex

Definition at line 474 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

475  {
476  TVector3 nuVtx = mc.GetNeutrino().Nu().Trajectory().Position(0).Vect();
477  TVector3 showStart = show.Start().Position().Vect();
478  return (showStart - nuVtx).Mag() < distance;
479 }
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
const MCStep & Start() const
Definition: MCShower.h:55
const TLorentzVector & Position() const
Definition: MCStep.h:40
bool ana::SBNOsc::isFromNuVertex ( const simb::MCTruth &  mc,
const sim::MCTrack track,
float  distance = 5.0 
)

Returns whether track/shower object is from the neutrino vertex

Parameters
mcMCTruth corresponding to neutrino interaction
trackThe object to be matched
distancebetween track start and interaction vertex
Returns
Whether track/shower object is from neutrino vertex

Definition at line 482 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

483  {
484  TVector3 nuVtx = mc.GetNeutrino().Nu().Trajectory().Position(0).Vect();
485  TVector3 trkStart = track.Start().Position().Vect();
486  return (trkStart - nuVtx).Mag() < distance;
487 }
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
const MCStep & Start() const
Definition: MCTrack.h:44
const TLorentzVector & Position() const
Definition: MCStep.h:40
double ana::SBNOsc::numu_to_nue ( double  x,
double  sin,
double  dm2 
)

Definition at line 42 of file Chi2Sensitivity.cxx.

42  {
43 
44  // x is L/E, sin is sin^2(2theta) and dm2 is delta m^2
45  return sin * TMath::Power(TMath::Sin(1.27 * dm2 * x), 2);
46 }
process_name opflash particleana ie x
double ana::SBNOsc::numu_to_numu ( double  x,
double  sin,
double  dm2 
)

Definition at line 36 of file Chi2Sensitivity.cxx.

36  {
37 
38  // x is L/E, sin is sin^2(2theta) and dm2 is delta m^2
39  return 1 - sin * TMath::Power(TMath::Sin(1.27 * dm2 * x), 2);
40 }
process_name opflash particleana ie x
double ana::SBNOsc::NumuOscillate ( ROOT::Math::IntegratorOneDim &  integrator,
double  l_min,
double  l_max,
double  e_min,
double  e_max,
double  dm2,
double  sinth 
)

Definition at line 48 of file Chi2Sensitivity.cxx.

48  {
49  auto integrand = [l_min, l_max, dm2](double energy) { return osc_factor_L_integrated(energy, l_min, l_max, dm2); };
50  double integral = integrator.Integral(integrand, e_min, e_max);
51  double factor = (1. / 2. ) + integral / ( (l_max - l_min)*(e_max - e_min));
52  return 1 - sinth * factor;
53 }
double osc_factor_L_integrated(double energy, double l_min, double l_max, double dm2)
double ana::SBNOsc::NuMuOscillation ( double  numu_energy,
double  numu_dis,
double  osc_dm2,
double  osc_angle 
)

Get oscillation probability of muon neutrino in a 3+1 model. I.e. probability that the numu will stay a numu.

Parameters
numu_energyEnergy of incident muon neutrino in GeV
numu_distDistance travelled by muon neutrino in km
osc_dm2dm^2 of sterile netrino in eV^2
osc_angleSterile neutrino mixing angle
Returns
Probability of muon neutrino not oscillating in 3+1 model.

Definition at line 84 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

85  {
86  double overlap = sin(2*osc_angle);
87  double energy_factor = sin(1.27 * osc_dm2 * numu_dist / numu_energy);
88  return 1 - overlap * overlap * energy_factor * energy_factor;
89 }
double ana::SBNOsc::osc_factor_L_integrated ( double  energy,
double  l_min,
double  l_max,
double  dm2 
)

Definition at line 30 of file Chi2Sensitivity.cxx.

30  {
31  double f = 1.27 * dm2;
32  return (energy / (4 * f)) * (TMath::Sin(2 * f * l_min / energy) - TMath::Sin(2 * f * l_max / energy));
33 }
double ana::SBNOsc::PDGCharge ( int  pdg)

Get charge from PDGID of particle in |e|/3.

Parameters
pdgThe Particle Data Group ID of the particle (as returned by i.e. an MCTruth object)
Returns
Charge of particle in |e|/3.

Definition at line 455 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

455  {
456  // regular particle
457  if (pdg < 1000000000) {
458  TParticlePDG* ple = PDGTable->GetParticle(pdg);
459  return ple->Charge();
460  }
461  // ion
462  else {
463  int p = (pdg % 10000000) / 10000;
464  return p * 3;
465  }
466 }
var pdg
Definition: selectors.fcl:14
pdgs p
Definition: selectors.fcl:22
static const TDatabasePDG * PDGTable(new TDatabasePDG)
double ana::SBNOsc::PDGMass ( int  pdg)

Get mass from PDGID of particle in MeV/c^2.

Parameters
pdgThe Particle Data Group ID of the particle (as returned by i.e. an MCTruth object)
Returns
Mass of particle in MeV/c^2

Definition at line 438 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

438  {
439  // regular particle
440  if (pdg < 1000000000) {
441  TParticlePDG* ple = PDGTable->GetParticle(pdg);
442  if (ple == NULL) return -1;
443  return ple->Mass() * 1000.0;
444  }
445  // ion
446  else {
447  int p = (pdg % 10000000) / 10000;
448  int n = (pdg % 10000) / 10 - p;
449  return (PDGTable->GetParticle(2212)->Mass() * p +
450  PDGTable->GetParticle(2112)->Mass() * n) * 1000.0;
451  }
452 }
var pdg
Definition: selectors.fcl:14
pdgs p
Definition: selectors.fcl:22
static const TDatabasePDG * PDGTable(new TDatabasePDG)
static const TDatabasePDG* ana::SBNOsc::PDGTable ( new  TDatabasePDG)
static
double ana::SBNOsc::RecoTrackLength ( const art::Ptr< recob::Track > &  track)

Definition at line 537 of file NumuReco.cxx.

537  {
538  if (track->CountValidPoints() == 0) return 0.;
539  double dist = 0.;
540  geo::Point_t first = track->Start();
541  for (size_t i = 1; i < track->CountValidPoints(); i++) {
542  geo::Point_t second = track->LocationAtPoint(i);
543  dist += sqrt((second - first).Mag2());
544  first = second;
545  }
546  return dist;
547 }
process_name use argoneut_mc_hitfinder track
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
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
void ana::SBNOsc::SetEvent ( numu::RecoEvent event,
const event::Event core,
const ana::SBNOsc::Cuts cuts,
numu::MCType  file_type,
bool  use_calorimetry = true 
)

Definition at line 5 of file SetEvent.cc.

5  {
6  // update each reco Interaction to a smarter primary track selector
7  unsigned i = 0;
8  while (i < event.reco.size()) {
9  for (size_t particle_ind: event.reco[i].slice.tracks) {
10  numu::RecoTrack &track = event.tracks.at(particle_ind);
11 
12  // set containment
13  if (cuts.InCalorimetricContainment(track.start) && cuts.InCalorimetricContainment(track.end)) {
14  track.is_contained = true;
15  }
16  else {
17  track.is_contained = false;
18  }
19  }
20 
21  int primary_track;
22  if (use_calorimetry) {
23  primary_track = numu::SelectLongestIDdMuon(event.tracks, event.reco[i].slice);
24  }
25  else {
26  primary_track = numu::SelectLongestTrack(event.tracks, event.reco[i].slice);
27  }
28 
29  // remove vertices without a good primary track
30  if (primary_track < 0) {
31  event.reco.erase(event.reco.begin() + i);
32  continue;
33  }
34 
35  event.reco[i].slice.primary_track_index = primary_track;
36 
37  // re-do truth matching
38  event.reco[i].match = numu::InteractionTruthMatch(core.truth, event.tracks, event.reco[i]);
39 
40  // if this is an in-time cosmic file, update the cosmic mode
41  if (file_type == numu::fIntimeCosmic) {
42  assert(event.reco[i].match.mode == numu::mCosmic || event.reco[i].match.mode == numu::mOther);
43  event.reco[i].match.mode = numu::mIntimeCosmic;
44  }
45 
46  i += 1;
47  }
48  // make sure no two vertices match to the same true neutrino interaction
49  numu::CorrectMultiMatches(event, event.reco);
50 
51  // re-do the truth matching one more time with the multi-matches fixed
52  for (unsigned i = 0; i < event.reco.size(); i++) {
53  event.reco[i].match = numu::InteractionTruthMatch(core.truth, event.tracks, event.reco[i]);
54  }
55 }
bool is_contained
is it contained in the &quot;containment volume&quot;?
Definition: RecoTrack.h:52
process_name use argoneut_mc_hitfinder track
void CorrectMultiMatches(RecoEvent &event, std::vector< RecoInteraction > &recos)
Definition: TruthMatch.cc:110
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
std::map< size_t, RecoTrack > tracks
Map of track indices to Track information.
Definition: RecoEvent.h:48
TVector3 start
start position of track
Definition: RecoTrack.h:54
TruthMatch InteractionTruthMatch(const std::vector< event::Interaction > &truth, const std::map< size_t, numu::RecoTrack > &reco_tracks, const numu::RecoInteraction &reco)
Definition: TruthMatch.cc:10
int SelectLongestIDdMuon(const std::map< size_t, RecoTrack > &tracks, const RecoSlice &slice)
Definition: PrimaryTrack.cc:22
int SelectLongestTrack(const std::map< size_t, RecoTrack > &tracks, const RecoSlice &slice)
Definition: PrimaryTrack.cc:3
TVector3 end
end position of track
Definition: RecoTrack.h:55
bool InCalorimetricContainment(const TVector3 &v) const
Definition: Cuts.cc:241
std::vector< Interaction > truth
All truth interactions.
Definition: Event.hh:232
geoalgo::AABox ana::SBNOsc::shaveVolume ( const geoalgo::AABox select_volume,
double  delta 
)

Definition at line 69 of file NumuSelection.cxx.

69  {
70 
71  double xmin = select_volume.Min()[0] + 5.;
72  double ymin = select_volume.Min()[1] + 5.;
73  double zmin = select_volume.Min()[2] + 5.;
74 
75  double xmax = select_volume.Max()[0] - 5.;
76  double ymax = select_volume.Max()[1] - 5.;
77  double zmax = select_volume.Max()[2] - 5.;
78 
79  return geoalgo::AABox(xmin, ymin, zmin, xmax, ymax, zmax);
80 }
Representation of a 3D rectangular box which sides are aligned w/ coordinate axis. A representation of an Axis-Aligned-Boundary-Box, a simple &amp; popular representation of 3D boundary box for collision detection. The concept was taken from the reference, Real-Time-Collision-Detection (RTCD), and in particular Ch. 4.2 (page 77): .
const Point_t & Min() const
Minimum point getter.
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
const Point_t & Max() const
Maximum point getter.
double ana::SBNOsc::smearLeptonEnergy ( TRandom &  rand,
const sim::MCTrack mct,
const VisibleEnergyCalculator &  calculator = VisibleEnergyCalculator() 
)

Get the smeared energy from a lepton.

Parameters
mctrackThe MCTrack object corresponding to the lepton
calculatorStruct containing values to be used in energy calculation

Definition at line 407 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

407  {
408  // if not contained and zero length, return
409  if (!calculator.lepton_contained && calculator.lepton_contained_length < 1e-4) {
410  // std::cout << "Out of detector lepton\n";
411  return 0;
412  }
413 
414  double smearing_percentage;
415  if (calculator.lepton_contained) {
416  smearing_percentage = calculator.lepton_energy_distortion_contained;
417  } else {
418  double A = calculator.lepton_energy_distortion_leaving_A;
419  double B = calculator.lepton_energy_distortion_leaving_B;
420  smearing_percentage = -A * TMath::Log(B * calculator.lepton_contained_length);
421  }
422  // smear visible energy
423  double lepton_visible_energy = (mct.Start().E()) / 1000.; /* MeV to GeV */
424  double smeared_lepton_visible_energy = rand.Gaus(lepton_visible_energy, smearing_percentage * lepton_visible_energy);
425  // clamp to 0
426  smeared_lepton_visible_energy = std::max(smeared_lepton_visible_energy, 0.);
427 
428  // std::cout << "Lepton -- is_contained: " << calculator.lepton_contained << " length: " << calculator.lepton_contained_length << " smearing: " << smearing_percentage << " true E: " << lepton_visible_energy << " smeared E: " << smeared_lepton_visible_energy << std::endl;
429 
430  return smeared_lepton_visible_energy;
431 }
do i e
double E() const
Definition: MCStep.h:49
const MCStep & Start() const
Definition: MCTrack.h:44
float A
Definition: dedx.py:137
event::Interaction ana::SBNOsc::TruthReco ( const simb::MCTruth &  mctruth)

Extract truth information to approximate reconstruction.

Definition at line 26 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

26  {
27  event::Interaction interaction;
28 
29  // Neutrino
30  const simb::MCNeutrino& nu = mctruth.GetNeutrino();
31  interaction.neutrino.energy = nu.Nu().EndMomentum().Energy();
32 
33  // Primary lepton
34  const simb::MCParticle& lepton = nu.Lepton();
35  interaction.lepton.pdg = lepton.PdgCode();
36  interaction.lepton.energy = lepton.Momentum(0).Energy();
37  interaction.lepton.momentum = lepton.Momentum(0).Vect();
38 
39  // Hadronic system
40  for (int iparticle=0; iparticle<interaction.finalstate.size(); iparticle++) {
42  const simb::MCParticle& particle = mctruth.GetParticle(iparticle);
43 
44  if (particle.Process() != "primary") {
45  continue;
46  }
47 
48  fsp.pdg = particle.PdgCode();
49  fsp.energy = particle.Momentum(0).Energy();
50  fsp.momentum = particle.Momentum(0).Vect();
51 
52  interaction.finalstate.push_back(fsp);
53  }
54 
55  return interaction;
56 }
TVector3 momentum
Three-momentum.
Definition: Event.hh:129
float energy
Energy.
Definition: Event.hh:128
int pdg
PDG Code.
Definition: Event.hh:127
Final state particle information.
Definition: Event.hh:104
FinalStateParticle lepton
The primary final state lepton.
Definition: Event.hh:153
Neutrino neutrino
The neutrino.
Definition: Event.hh:152
std::vector< FinalStateParticle > finalstate
Other final state particles.
Definition: Event.hh:154
float energy
Neutrino energy (GeV)
Definition: Event.hh:90
BEGIN_PROLOG SN nu
All truth information associated with one neutrino interaction.
Definition: Event.hh:150
double ana::SBNOsc::visibleEnergy ( TRandom &  rand,
const simb::MCTruth &  mctruth,
const std::vector< sim::MCTrack > &  mctrack_list,
const std::vector< sim::MCShower > &  mcshower_list,
const VisibleEnergyCalculator &  calculator = VisibleEnergyCalculator(),
bool  include_showers = true 
)

Get the "visible" energy from a neutrino interaction. Is equal to sum of non-neutral hadronic kinetic energies and lepton total energies.

Parameters
evThe gallery event.
mctruthThe MCTruth object corresponding to the interaction.
mctrack_listVector of MCTrack objects in the gallery event.
mcshower_listVector of MCShower objects in the gallery event.
calculatorStruct containing values to be used in energy calculation
smeared_lepton_energylepton energy to be used in calculation – will default to smearLeptonEnergy(mctruth, calculator) if not set
Returns
Visble energy in GeV.

Definition at line 330 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

331  {
332  double visible_E = 0;
333 
334  // primary leptron track
335  const sim::MCTrack *lepton_track = NULL;
336  bool lepton_track_exists = false;
337 
338  // total up visible energy from tracks...
339  double track_visible_energy = 0.;
340  for (unsigned ind = 0; ind < mctrack_list.size(); ind++) {
341  auto const &mct = mctrack_list[ind];
342  // ignore particles not from nu vertex, non primary particles, and uncharged particles
343  if (!isFromNuVertex(mctruth, mct) || abs(PDGCharge(mct.PdgCode())) < 1e-4 || mct.Process() != "primary")
344  continue;
345  // account for primary lepton later
346  if ((abs(mct.PdgCode()) == 13 || abs(mct.PdgCode()) == 11) && calculator.lepton_index == ind) {
347  continue;
348  }
349  // ignore non-primary pion??
350  //if ((abs(mct.PdgCode()) == 211) && calculator.lepton_index != ind) {
351  // continue;
352  //}
353 
354  double mass = PDGMass(mct.PdgCode());
355  double this_visible_energy = (mct.Start().E() - mass) / 1000. /* MeV to GeV */;
356  if (this_visible_energy > calculator.track_threshold) {
357  track_visible_energy += this_visible_energy;
358  }
359  }
360 
361  // do energy smearing
362  if (calculator.track_energy_distortion > 1e-4) {
363  track_visible_energy = rand.Gaus(track_visible_energy, track_visible_energy*calculator.track_energy_distortion);
364  // clamp to 0
365  track_visible_energy = std::max(track_visible_energy, 0.);
366  }
367 
368  // ...and showers
369  double shower_visible_energy = 0.;
370  if (include_showers) {
371  for (auto const &mcs: mcshower_list) {
372  // ignore particles not from nu vertex, non primary particles, and uncharged particles
373  if (!isFromNuVertex(mctruth, mcs) || abs(PDGCharge(mcs.PdgCode())) < 1e-4 || mcs.Process() != "primary")
374  continue;
375  // account for primary lepton later
376  if ((abs(mcs.PdgCode()) == 13 || abs(mcs.PdgCode()) == 11) && isFromNuVertex(mctruth, mcs))
377  continue;
378 
379  double mass = PDGMass(mcs.PdgCode());
380  double this_visible_energy = (mcs.Start().E() - mass) / 1000. /* MeV to GeV */;
381 
382  if (this_visible_energy > calculator.shower_threshold) {
383  shower_visible_energy += this_visible_energy;
384  }
385  }
386  }
387 
388  // do energy smearing
389  if (calculator.shower_energy_distortion > 1e-4) {
390  shower_visible_energy = rand.Gaus(shower_visible_energy, shower_visible_energy*calculator.shower_energy_distortion);
391  // clamp to 0
392  shower_visible_energy = std::max(shower_visible_energy, 0.);
393  }
394 
395  visible_E = track_visible_energy + shower_visible_energy;
396 
397  // ...and primary lepton energy (for CC events)
398  // only add in extra here if identified "lepton" is actually a lepton
399  if (calculator.lepton_index >= 0 && (abs(mctrack_list[calculator.lepton_index].PdgCode()) == 13 || abs(mctrack_list[calculator.lepton_index].PdgCode()) == 11)) {
400  visible_E += smearLeptonEnergy(rand, mctrack_list[calculator.lepton_index], calculator);
401  }
402 
403  return visible_E;
404 }
double PDGMass(int pdg)
Definition: FillTrue.cxx:44
bool isFromNuVertex(const simb::MCTruth &mc, const sim::MCTrack &track, float distance=5.0)
Definition: FillTrue.cxx:36
T abs(T value)
double smearLeptonEnergy(TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator)
float mass
Definition: dedx.py:47
do i e
double ana::SBNOsc::visibleEnergyProposal ( TRandom &  rand,
const simb::MCTruth &  mctruth,
const std::vector< sim::MCTrack > &  mctrack_list,
const VisibleEnergyCalculator &  calculator 
)

Definition at line 262 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

262  {
263  double total = 0.;
264 
265  // std::cout << "\n\nNew Interaction" << std::endl;
266  // std::cout << "True E: " << mctruth.GetNeutrino().Nu().E() << std::endl;
267  for (unsigned ind = 0; ind < mctrack_list.size(); ind++) {
268  auto const &mct = mctrack_list[ind];
269  int pdg = mct.PdgCode();
270 
271  double track_energy = (mct.Start().E() - PDGMass(pdg)) / 1000. /* MeV -> GeV */;
272  double smear_energy = track_energy;
273 
274  // In the proposal, different PDG codes got different energies
275 
276  // kaons did not have the mass subtracted
277  if (abs(pdg) == 321) {
278  track_energy = mct.Start().E() / 1000.;
279  smear_energy = track_energy;
280  }
281  // pions did not have mass subtracted in the smearing
282  if (abs(pdg) == 211) {
283  smear_energy = mct.Start().E() / 1000.;
284  }
285 
286  bool skip = false;
287 
288  // threshold -- only for protons
289  if (abs(pdg) == 2212 && track_energy < calculator.track_threshold) {
290  skip = true;
291  }
292 
293  // add in smeared energy
294  double this_smeared_energy = rand.Gaus(track_energy, smear_energy * calculator.track_energy_distortion);
295  // clamp to zero
296  this_smeared_energy = std::max(this_smeared_energy, 0.);
297 
298  // Ignore particles not from nu vertex
299  if (!isFromNuVertex(mctruth, mct) || mct.Process() != "primary") {
300  skip = true;
301  }
302  // ignore everything except for protons and kaons and pions
303  if (!(abs(pdg) == 2212 || abs(pdg) == 211 || abs(pdg) == 321)) {
304  skip = true;
305  }
306  // account for primary track later
307  if ((abs(pdg) == 13 || abs(pdg) == 11) && calculator.lepton_index == ind) {
308  skip = true;
309  }
310  // double distance = (mctruth.GetNeutrino().Nu().Trajectory().Position(0).Vect() - mct.Start().Position().Vect()).Mag();
311  // double l_distance = (mctruth.GetNeutrino().Nu().Trajectory().Position(0) - mct.Start().Position()).Mag();
312  // std::cout << "New particle -- true E: " << track_energy << " smeared E: " << this_smeared_energy << " PDG: " << pdg << " is primary: " << (calculator.lepton_index == ind) << " is skipped: " << skip << " distance: " << distance << " lorentz distance: " << l_distance << " process: " << mct.Process() << std::endl;
313  if (skip) continue;
314 
315  total += this_smeared_energy;
316  }
317 
318  // ...and primary lepton energy (for CC events)
319  // only add in extra here if identified "lepton" is actually a lepton
320  if (calculator.lepton_index >= 0 && (abs(mctrack_list[calculator.lepton_index].PdgCode()) == 13 || abs(mctrack_list[calculator.lepton_index].PdgCode()) == 11)) {
321  double lepton_energy = smearLeptonEnergy(rand, mctrack_list[calculator.lepton_index], calculator);
322  total += lepton_energy;
323  }
324  // std::cout << "Reco Energy: " << total << std::endl;
325 
326  return total;
327 }
double PDGMass(int pdg)
Definition: FillTrue.cxx:44
var pdg
Definition: selectors.fcl:14
bool isFromNuVertex(const simb::MCTruth &mc, const sim::MCTrack &track, float distance=5.0)
Definition: FillTrue.cxx:36
T abs(T value)
double smearLeptonEnergy(TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator)
double ana::SBNOsc::visibleEnergyProposalMCParticles ( TRandom &  rand,
const simb::MCTruth &  mctruth,
const std::vector< sim::MCTrack mctrack_list,
const VisibleEnergyCalculator &  calculator 
)

Definition at line 196 of file sbnana/sbnanalysis/ana/SBNOsc/Utilities.cxx.

196  {
197  double total = 0;
198  for (int iparticle=0; iparticle<mctruth.NParticles(); iparticle++) {
199  const simb::MCParticle& particle = mctruth.GetParticle(iparticle);
200 
201  int pdg = particle.PdgCode();
202 
203  // if there's no mass entry, we probably don't care about it
204  if (PDGMass(pdg) < 0) continue;
205 
206  double track_energy = (particle.Momentum().E() - PDGMass(pdg) / 1000. /* MeV -> GeV */);
207  double smear_energy = track_energy;
208 
209  // In the proposal, different PDG codes got different energies
210 
211  // kaons did not have the mass subtracted
212  if (abs(pdg) == 321) {
213  track_energy = particle.Momentum().E();
214  smear_energy = track_energy;
215  }
216  // pions did not have mass subtracted in the smearing
217  if (abs(pdg) == 211) {
218  smear_energy = particle.Momentum().E();
219  }
220 
221  bool skip = false;
222 
223  // threshold -- only for protons
224  if (abs(pdg) == 2212 && track_energy < calculator.track_threshold) {
225  skip = true;
226  }
227 
228  // add in smeared energy
229  double this_smeared_energy = rand.Gaus(track_energy, smear_energy * calculator.track_energy_distortion);
230  // clamp to zero
231  this_smeared_energy = std::max(this_smeared_energy, 0.);
232 
233  // Ignore particles not from nu vertex
234  if (!isFromNuVertex(mctruth, particle) || particle.Process() != "primary") {
235  skip = true;
236  }
237  // ignore everything except for protons and kaons and pions
238  if (!(abs(pdg) == 2212 || abs(pdg) == 211 || abs(pdg) == 321)) {
239  skip = true;
240  }
241  // double distance = (mctruth.GetNeutrino().Nu().Trajectory().Position(0).Vect() - mct.Start().Position().Vect()).Mag();
242  // double l_distance = (mctruth.GetNeutrino().Nu().Trajectory().Position(0) - mct.Start().Position()).Mag();
243  // std::cout << "New particle -- true E: " << track_energy << " smeared E: " << this_smeared_energy << " PDG: " << pdg << " is primary: " << (calculator.lepton_index == ind) << " is skipped: " << skip << " distance: " << distance << " lorentz distance: " << l_distance << " process: " << mct.Process() << std::endl;
244  if (skip) continue;
245 
246  total += this_smeared_energy;
247  }
248 
249  // ...and primary lepton energy (for CC events)
250  // only add in extra here if identified "lepton" is actually a lepton
251  if (calculator.lepton_index >= 0 && (abs(mctrack_list[calculator.lepton_index].PdgCode()) == 13 || abs(mctrack_list[calculator.lepton_index].PdgCode()) == 11)) {
252  double lepton_energy = smearLeptonEnergy(rand, mctrack_list[calculator.lepton_index], calculator);
253  total += lepton_energy;
254  }
255  // std::cout << "Reco Energy: " << total << std::endl;
256 
257  return total;
258 
259  }
double PDGMass(int pdg)
Definition: FillTrue.cxx:44
var pdg
Definition: selectors.fcl:14
bool isFromNuVertex(const simb::MCTruth &mc, const sim::MCTrack &track, float distance=5.0)
Definition: FillTrue.cxx:36
T abs(T value)
double smearLeptonEnergy(TRandom &rand, const sim::MCTrack &mct, const VisibleEnergyCalculator &calculator)

Variable Documentation

const TVector3 ana::SBNOsc::InvalidTVector3 = TVector3(-999, -999, -999)
static

Definition at line 65 of file NumuReco.cxx.