All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrajectoryMCSFitterICARUS.h
Go to the documentation of this file.
1 #ifndef TrajectoryMCSFitterICARUS_H
2 #define TrajectoryMCSFitterICARUS_H
3 
4 #include "fhiclcpp/ParameterSet.h"
5 #include "fhiclcpp/types/Atom.h"
6 #include "fhiclcpp/types/Table.h"
7 #include "canvas/Persistency/Common/Ptr.h"
12 
13 namespace trkf {
14  /**
15  * @file larreco/RecoAlg/TrajectoryMCSFitterICARUS.h
16  * @class trkf::TrajectoryMCSFitterICARUS
17  *
18  * @brief Class for Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Track or Trajectory
19  *
20  * Class for Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Track or Trajectory.
21  *
22  * Inputs are: a Track or Trajectory, and various fit parameters (pIdHypothesis, minNumSegments, segmentLength, pMin, pMax, pStep, angResol)
23  *
24  * Outputs are: a recob::MCSFitResult, containing:
25  * resulting momentum, momentum uncertainty, and best likelihood value (both for fwd and bwd fit);
26  * vector of segment (radiation) lengths, vector of scattering angles, and PID hypothesis used in the fit.
27  *
28  * For configuration options see TrajectoryMCSFitterICARUS#Configs
29  *
30  * @author G. Cerati (FNAL, MicroBooNE)
31  * @date 2017
32  * @version 1.0
33  */
35  {
36  //
37  public:
38  //
39  struct Config {
40  using Name = fhicl::Name;
41  using Comment = fhicl::Comment;
42  fhicl::Atom<int> pIdHypothesis {
43  Name("pIdHypothesis"),
44  Comment("Default particle Id Hypothesis to be used in the fit when not specified."),
45  13
46  };
47  fhicl::Atom<int> minNumSegments {
48  Name("minNumSegments"),
49  Comment("Minimum number of segments the track is split into."),
50  3
51  };
52  fhicl::Atom<double> segmentLength {
53  Name("segmentLength"),
54  Comment("Nominal length of track segments used in the fit."),
55  14.
56  };
57  fhicl::Atom<int> minHitsPerSegment {
58  Name("minHitsPerSegment"),
59  Comment("Exclude segments with less hits than this value."),
60  2
61  };
62  fhicl::Atom<int> nElossSteps {
63  Name("nElossSteps"),
64  Comment("Number of steps for computing energy loss uptream to current segment."),
65  10
66  };
67  fhicl::Atom<int> eLossMode {
68  Name("eLossMode"),
69  Comment("Default is MPV Landau. Choose 1 for MIP (constant); 2 for Bethe-Bloch."),
70  0
71  };
72  fhicl::Atom<double> pMin {
73  Name("pMin"),
74  Comment("Minimum momentum value in likelihood scan."),
75  0.01
76  };
77  fhicl::Atom<double> pMax {
78  Name("pMax"),
79  Comment("Maximum momentum value in likelihood scan."),
80  7.50
81  };
82  fhicl::Atom<double> pStep {
83  Name("pStep"),
84  Comment("Step in momentum value in likelihood scan."),
85  0.01
86  };
87  fhicl::Atom<double> angResol {
88  Name("angResol"),
89  Comment("Angular resolution parameter used in modified Highland formula. Unit is mrad."),
90  3.0
91  };
92  };
93  using Parameters = fhicl::Table<Config>;
94  //
95  TrajectoryMCSFitterICARUS(int pIdHyp, int minNSegs, double segLen, int minHitsPerSegment, int nElossSteps, int eLossMode, double pMin, double pMax, double pStep, double angResol){
96  pIdHyp_ = pIdHyp;
97  minNSegs_ = minNSegs;
98  segLen_ = segLen;
99  minHitsPerSegment_ = minHitsPerSegment;
100  nElossSteps_ = nElossSteps;
101  eLossMode_ = eLossMode;
102  pMin_ = pMin;
103  pMax_ = pMax;
104  pStep_ = pStep;
105  angResol_ = angResol;
106  }
108  : TrajectoryMCSFitterICARUS(p().pIdHypothesis(),p().minNumSegments(),p().segmentLength(),p().minHitsPerSegment(),p().nElossSteps(),p().eLossMode(),p().pMin(),p().pMax(),p().pStep(),p().angResol()) {}
109  //
110  recob::MCSFitResult fitMcs(const recob::TrackTrajectory& traj, bool momDepConst = true) const { return fitMcs(traj,pIdHyp_,momDepConst); }
111  recob::MCSFitResult fitMcs(const recob::Track& track, bool momDepConst = true) const { return fitMcs(track,pIdHyp_,momDepConst); }
112  recob::MCSFitResult fitMcs(const recob::Trajectory& traj, bool momDepConst = true) const { return fitMcs(traj,pIdHyp_,momDepConst); }
113  //
114  recob::MCSFitResult fitMcs(const recob::TrackTrajectory& traj, int pid, bool momDepConst = true) const;
115  recob::MCSFitResult fitMcs(const recob::Track& track, int pid, bool momDepConst = true) const { return fitMcs(track.Trajectory(),pid,momDepConst); }
116  recob::MCSFitResult fitMcs(const recob::Trajectory& traj, int pid, bool momDepConst = true) const {
118  const recob::TrackTrajectory tt(traj,std::move(flags));
119  return fitMcs(tt,pid,momDepConst);
120  }
121  //
122  void breakTrajInSegments(const recob::TrackTrajectory& traj, std::vector<size_t>& breakpoints, std::vector<float>& segradlengths, std::vector<float>& cumseglens) const;
123  void findSegmentBarycenter(const recob::TrackTrajectory& traj, const size_t firstPoint, const size_t lastPoint, recob::tracking::Vector_t& pcdir) const;
124  void linearRegression(const recob::TrackTrajectory& traj, const size_t firstPoint, const size_t lastPoint, recob::tracking::Vector_t& pcdir) const;
125  double mcsLikelihood(double p, double theta0x, std::vector<float>& dthetaij, std::vector<float>& seg_nradl, std::vector<float>& cumLen, bool fwd, bool momDepConst, int pid) const;
126 double GetOptimalSegLen(const double guess_p, const int n_points, const int plane, const double length_travelled) const;
127 double computeResidual(int i, double& alfa) const;
128 void ComputeD3P() ;
129 
130 
131  //
132  struct ScanResult {
133  public:
134  ScanResult(double ap, double apUnc, double alogL) : p(ap), pUnc(apUnc), logL(alogL) {}
135  double p, pUnc, logL;
136  };
137  //
138  const ScanResult doLikelihoodScan(std::vector<float>& dtheta, std::vector<float>& seg_nradlengths, std::vector<float>& cumLen, bool fwdFit, bool momDepConst, int pid) const;
139  //
140  inline double MomentumDependentConstant(const double p) const {
141  //these are from https://arxiv.org/abs/1703.06187
142  constexpr double a = 0.1049;
143  constexpr double c = 11.0038;
144  return (a/(p*p)) + c;
145  }
146  double mass(int pid) const {
147  if (abs(pid)==13) { return mumass; }
148  if (abs(pid)==211) { return pimass; }
149  if (abs(pid)==321) { return kmass; }
150  if (abs(pid)==2212) { return pmass; }
151  return util::kBogusD;
152  }
153  double energyLossBetheBloch(const double mass,const double e2) const;
154  double energyLossLandau(const double mass2,const double E2, const double x) const;
155  //
156  double GetE(const double initial_E, const double length_travelled, const double mass) const;
157  void set2DHits(std::vector<recob::Hit> h) {hits2d=h;}
158  // void projectHitsOnPlane(art::Event & e,const recob::Track& traj,int p) const
159  //
160  private:
161  int pIdHyp_;
163  double segLen_;
167  double pMin_;
168  double pMax_;
169  double pStep_;
170  double angResol_;
171 
172  std::vector<recob::Hit> hits2d;
173  float d3p;
174  };
175 }
176 
177 #endif
double energyLossBetheBloch(const double mass, const double e2) const
void linearRegression(const recob::TrackTrajectory &traj, const size_t firstPoint, const size_t lastPoint, recob::tracking::Vector_t &pcdir) const
process_name opflash particleana ie x
recob::MCSFitResult fitMcs(const recob::Track &track, int pid, bool momDepConst=true) const
recob::MCSFitResult fitMcs(const recob::Trajectory &traj, int pid, bool momDepConst=true) const
void breakTrajInSegments(const recob::TrackTrajectory &traj, std::vector< size_t > &breakpoints, std::vector< float > &segradlengths, std::vector< float > &cumseglens) const
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Declaration of signal hit object.
pdgs p
Definition: selectors.fcl:22
process_name use argoneut_mc_hitfinder track
void set2DHits(std::vector< recob::Hit > h)
void findSegmentBarycenter(const recob::TrackTrajectory &traj, const size_t firstPoint, const size_t lastPoint, recob::tracking::Vector_t &pcdir) const
double GetE(const double initial_E, const double length_travelled, const double mass) const
process_name gaushit a
while getopts h
double energyLossLandau(const double mass2, const double E2, const double x) const
T abs(T value)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Definition: TrackingTypes.h:29
recob::MCSFitResult fitMcs(const recob::Track &track, bool momDepConst=true) const
TrajectoryMCSFitterICARUS(int pIdHyp, int minNSegs, double segLen, int minHitsPerSegment, int nElossSteps, int eLossMode, double pMin, double pMax, double pStep, double angResol)
size_t NPoints() const
Returns the number of stored trajectory points.
Definition: Trajectory.h:167
A trajectory in space reconstructed from hits.
const ScanResult doLikelihoodScan(std::vector< float > &dtheta, std::vector< float > &seg_nradlengths, std::vector< float > &cumLen, bool fwdFit, bool momDepConst, int pid) const
double GetOptimalSegLen(const double guess_p, const int n_points, const int plane, const double length_travelled) const
double mcsLikelihood(double p, double theta0x, std::vector< float > &dthetaij, std::vector< float > &seg_nradl, std::vector< float > &cumLen, bool fwd, bool momDepConst, int pid) const
BEGIN_PROLOG vertical distance to the surface Name
std::vector< PointFlags_t > Flags_t
Type of point flag list.
recob::MCSFitResult fitMcs(const recob::Trajectory &traj, bool momDepConst=true) const
Provides recob::Track data product.
Class storing the result of the Maximum Likelihood fit of Multiple Coulomb Scattering angles between ...
Definition: MCSFitResult.h:19
A trajectory in space reconstructed from hits.
Definition: Trajectory.h:67
Class for Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Trac...
recob::MCSFitResult fitMcs(const recob::TrackTrajectory &traj, bool momDepConst=true) const
double MomentumDependentConstant(const double p) const
constexpr double kBogusD
obviously bogus double value
double computeResidual(int i, double &alfa) const
ScanResult(double ap, double apUnc, double alogL)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track: