LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
TrackMomentumCalculator.h
Go to the documentation of this file.
1 // \author sowjanyag@phys.ksu.edu
3 
4 #ifndef TrackMomentumCalculator_H
5 #define TrackMomentumCalculator_H
6 
9 
10 #include "TGraph.h"
11 #include "TVector3.h"
12 
13 #include <optional>
14 #include <tuple>
15 #include <vector>
16 
17 class TPolyLine3D;
18 
19 namespace trkf {
20 
22  public:
32  TrackMomentumCalculator(double minLength = 100.0,
33  double maxLength = 1350.0,
34  double steps_size = 10.,
35  int angleMethod = 1,
36  int nsteps = 6);
37 
38  double GetTrackMomentum(double trkrange, int pdg) const;
51  const bool checkValidPoints = false,
52  const int maxMomentum_MeV = 7500,
53  const double min_resolution = 0,
54  const double max_resolution = 45);
75  const bool checkValidPoints = false,
76  const int maxMomentum_MeV = 7500,
77  const double min_resolution = 0.001,
78  const double max_resolution = 800,
79  const bool check_valid_scattered = false,
80  const double angle_correction = 0.757);
81  double GetMuMultiScatterLLHD3(art::Ptr<recob::Track> const& trk, bool dir);
83 
84  private:
85  bool plotRecoTracks_(std::vector<double> const& xxx,
86  std::vector<double> const& yyy,
87  std::vector<double> const& zzz);
88 
96  void compute_max_fluctuation_vector(const std::vector<double> segx,
97  const std::vector<double> segy,
98  const std::vector<double> segz,
99  std::vector<double>& segnx,
100  std::vector<double>& segny,
101  std::vector<double>& segnz,
102  std::vector<bool>& segn_isvalid,
103  std::vector<double>& vx,
104  std::vector<double>& vy,
105  std::vector<double>& vz,
106  bool check_valid_scattered);
115  struct Segments {
116  std::vector<double> x, nx;
117  std::vector<double> y, ny;
118  std::vector<double> z, nz;
119  std::vector<double> L;
120  std::vector<bool> nvalid;
121  };
122 
137  std::optional<Segments> getSegTracks_(std::vector<double> const& xxx,
138  std::vector<double> const& yyy,
139  std::vector<double> const& zzz,
140  double seg_size,
141  bool check_valid_scattered = false);
142 
153  std::tuple<double, double, double> getDeltaThetaRMS_(Segments const& segments,
154  double thick) const;
155 
167  int getDeltaThetaij_(std::vector<double>& ei,
168  std::vector<double>& ej,
169  std::vector<double>& th,
170  std::vector<double>& ind,
171  Segments const& segments,
172  double thick,
173  double const angle_correction) const;
174 
184  double my_g(double xx, double Q, double s) const;
185 
200  double my_mcs_llhd(std::vector<double> const& dEi,
201  std::vector<double> const& dEj,
202  std::vector<double> const& dthij,
203  std::vector<double> const& ind,
204  double x0,
205  double x1) const;
206 
207  double seg_stop{-1.};
208  int n_seg{};
209 
210  double x_seg[50000];
211  double y_seg[50000];
212  double z_seg[50000];
213 
222  double find_angle(double vz, double vy) const;
223 
224  std::vector<double> steps;
225 
226  double minLength;
227  double maxLength;
228  double steps_size;
229  double rad_length{14.0};
230 
232  kAnglezx = 1,
235  };
236 
238  int n_steps;
239 
240  // The following are objects that are created but not drawn or
241  // saved. This class should consider accepting a "debug"
242  // parameter where if it is specified, then the graphs will be
243  // created; otherwise, their creation is unnecessary and impedes
244  // efficiency.
245  //
246  // N.B. TPolyLine3D objects are owned by ROOT, and we thus refer
247  // to them by pointer. It is important that 'delete' is not
248  // called on the TPolyLine3D pointers during destruction of a
249  // TrackMomentumCalculator object.
250  TPolyLine3D* gr_reco_xyz{nullptr};
251  TGraph gr_reco_xy{};
252  TGraph gr_reco_yz{};
253  TGraph gr_reco_xz{};
254 
255  TPolyLine3D* gr_seg_xyz{nullptr};
256  TGraph gr_seg_xy{};
257  TGraph gr_seg_yz{};
258  TGraph gr_seg_xz{};
259  };
260 
261 } // namespace trkf
262 
263 #endif // TrackMomentumCalculator_H
double GetMomentumMultiScatterLLHD(art::Ptr< recob::Track > const &trk, const bool checkValidPoints=false, const int maxMomentum_MeV=7500, const double min_resolution=0.001, const double max_resolution=800, const bool check_valid_scattered=false, const double angle_correction=0.757)
Calculate muon momentum (GeV) using multiple coulomb scattering by log likelihood.
Double_t xx
Definition: macro.C:12
double GetMomentumMultiScatterChi2(art::Ptr< recob::Track > const &trk, const bool checkValidPoints=false, const int maxMomentum_MeV=7500, const double min_resolution=0, const double max_resolution=45)
Calculate muon momentum (GeV) using multiple coulomb scattering. Chi2 minimization of the Highland fo...
double my_g(double xx, double Q, double s) const
chi square minizer using Minuit2, it will minize (xx-Q)/s
Float_t x1[n_points_granero]
Definition: compare.C:5
std::optional< Segments > getSegTracks_(std::vector< double > const &xxx, std::vector< double > const &yyy, std::vector< double > const &zzz, double seg_size, bool check_valid_scattered=false)
Split tracks into segments to calculate the scattered angle later. Check DOI 10.1088/1748-0221/12/10/...
int getDeltaThetaij_(std::vector< double > &ei, std::vector< double > &ej, std::vector< double > &th, std::vector< double > &ind, Segments const &segments, double thick, double const angle_correction) const
Gets the scatterd angle for all the segments.
TrackMomentumCalculator(double minLength=100.0, double maxLength=1350.0, double steps_size=10., int angleMethod=1, int nsteps=6)
Constructor.
Use scattered angle z-x (z is along the particle&#39;s direction)
double find_angle(double vz, double vy) const
Gets angle between two vy and vz.
double my_mcs_llhd(std::vector< double > const &dEi, std::vector< double > const &dEj, std::vector< double > const &dthij, std::vector< double > const &ind, double x0, double x1) const
Minimizer of log likelihood for scattered angle.
Float_t thick
Definition: plot.C:23
bool plotRecoTracks_(std::vector< double > const &xxx, std::vector< double > const &yyy, std::vector< double > const &zzz)
Struct to store segments. x, y and z are the 3D points of the segment nx, ny, nz forms the vector tha...
std::tuple< double, double, double > getDeltaThetaRMS_(Segments const &segments, double thick) const
Gets the scattered angle RMS for a all segments.
Use space angle: sqrt( zx^2 + zy^2 )/sqrt(2)
void compute_max_fluctuation_vector(const std::vector< double > segx, const std::vector< double > segy, const std::vector< double > segz, std::vector< double > &segnx, std::vector< double > &segny, std::vector< double > &segnz, std::vector< bool > &segn_isvalid, std::vector< double > &vx, std::vector< double > &vy, std::vector< double > &vz, bool check_valid_scattered)
Computes the vector with most scattering inside a segment with size steps_size.
double GetMuMultiScatterLLHD3(art::Ptr< recob::Track > const &trk, bool dir)
Provides recob::Track data product.
TDirectory * dir
Definition: macro.C:5
TVector3 GetMultiScatterStartingPoint(art::Ptr< recob::Track > const &trk)
double GetTrackMomentum(double trkrange, int pdg) const