All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackHisto.cc
Go to the documentation of this file.
1 #include "TrackHisto.h"
2 
3 #include "TH1D.h"
4 #include "TH2D.h"
5 
6 #include "../NumuReco/TrackAlgo.h"
7 
8 namespace ana {
9  namespace SBNOsc {
10 
11 void TrackHistos::Initialize(const std::string &postfix, const geo::BoxBoundedGeo &detector_volume, double max_length) {
12 #define TRACK_HISTO(name, n_bins, lo, hi) name = new TH1D((#name + postfix).c_str(), #name, n_bins, lo, hi); StoreHisto(name)
13 #define TRACK_2DHISTO(name, binx, lo_x, hi_x, biny, lo_y, hi_y) name = new TH2D((#name + postfix).c_str(), #name, binx, lo_x, hi_x, biny, lo_y, hi_y); StoreHisto(name)
14 
15  TRACK_HISTO(chi2_muon_diff, 100, 0., 1000.);
16  TRACK_HISTO(chi2_proton_diff, 100, 0, 1000);
17  TRACK_HISTO(chi2_kaon_diff, 100, 0, 1000);
18  TRACK_HISTO(chi2_pion_diff, 100, 0, 1000);
19 
20  TRACK_HISTO(chi2_muon, 100, 0, 100);
21  TRACK_HISTO(chi2_pion, 100, 0, 100);
22  TRACK_HISTO(chi2_kaon, 100, 0, 100);
23  TRACK_HISTO(chi2_proton, 100, 0, 100);
24 
25  TRACK_HISTO(chi2_proton_m_muon, 200, -1000, 1000);
26 
27  TRACK_HISTO(range_p, 100, 0., 2.);
28  TRACK_HISTO(mcs_p, 100, 0., 2.);
29 
30  TRACK_HISTO(range_p_minus_truth, 100, -2., 2);
31  TRACK_HISTO(mcs_p_minus_truth, 100, -2., 2.);
32 
33  TRACK_2DHISTO(range_p_minus_truth_length, 60, 0., 600., 50, -1., 1);
34  TRACK_2DHISTO(mcs_p_minus_truth_length, 60, 0., 600., 50, -1., 1.);
35  TRACK_2DHISTO(lengh_munus_truth_length, 60, 0., 600., 50, -1., 1);
36 
37  TRACK_HISTO(length, 100, 0., 600.);
38 
39  TRACK_HISTO(reco_momentum, 100, 0., 5.);
40  TRACK_HISTO(is_contained, 2, -0.5, 1.5);
41 
42  //TRACK_2DHISTO(range_p_diff, 25, 0, 2.5, 40, -2., 2.);
43  //TRACK_2DHISTO(mcs_p_diff, 25, 0., 2.5, 40, -2., 2.);
44 
45  TRACK_2DHISTO(range_p_comp, 25, 0, 2.5, 25, 0., 2.5);
46  TRACK_2DHISTO(mcs_p_comp, 25, 0., 2.5, 25, 0., 2.5);
47 
48  //TRACK_2DHISTO(dQdx_length, 100, 0., 1000., 100, 0., max_length);
49 
50  TRACK_HISTO(border_y, 400, detector_volume.MinY(), detector_volume.MaxY());
51  TRACK_HISTO(border_x, 400, detector_volume.MinX(), detector_volume.MaxX());
52  TRACK_HISTO(border_z, 500, detector_volume.MinZ(), detector_volume.MaxZ());
53  TRACK_HISTO(true_start_time, 1400, -4000., 3000.);
54  TRACK_HISTO(true_start_time_zoom, 3000, -1., 2.);
55 
56  TRACK_HISTO(wall_enter, 7, -0.5, 6.5);
57  TRACK_HISTO(wall_exit, 7, -0.5, 6.5);
58 
59  // timing histos
60  TRACK_HISTO(has_crt_track_match, 3, -0.5, 1.5);
61  TRACK_HISTO(has_crt_hit_match, 3, -0.5, 1.5);
62  TRACK_HISTO(crt_hit_distance, 80, 0., 400.);
63  TRACK_HISTO(crt_track_angle, 150, 0., 3.);
64 
65  // TRACK_HISTO(flash_match_time, 2000, -0.2, 1.8);
66  // TRACK_HISTO(crt_v_flash_match_time, 2000, -4., 4.);
67 
68  double min_matchtime_t = -1640;
69  double max_matchtime_t = 3280;
70  int n_matchtime_bins = 1000;
71 
72  double min_comptime = -0.5;
73  double max_comptime = 0.5;
74  int n_comptime_bins = 1000;
75 
76  TRACK_HISTO(crt_match_time, n_matchtime_bins, min_matchtime_t, max_matchtime_t);
77 
78  TRACK_HISTO(completion, 200, -1, 1);
79 
80  TRACK_HISTO(stopping_chisq_start, 100, 0., 10.);
81  TRACK_HISTO(stopping_chisq_finish, 100, 0., 10.);
82  TRACK_HISTO(stopping_chisq, 100., 0., 10.);
83 
84  TRACK_2DHISTO(pid_confusion_tr, 2, -0.5, 1.5, 2, -0.5, 1.5);
85 
86 #undef TRACK_HISTO
87 #undef TRACK_2DHISTO
88 }
89 
91  const numu::RecoTrack &track,
92  const std::map<size_t, numu::TrueParticle> &true_particles) {
93 
94  // Primary track histos
95  if (track.min_chi2 > 0) {
96  chi2_proton_diff->Fill(track.chi2_proton - track.min_chi2);
97  chi2_muon_diff->Fill(track.chi2_muon - track.min_chi2);
98  chi2_pion_diff->Fill(track.chi2_pion - track.min_chi2);
99  chi2_kaon_diff->Fill(track.chi2_kaon - track.min_chi2);
100 
101  chi2_muon->Fill(track.chi2_muon/track.pid_n_dof);
102  chi2_kaon->Fill(track.chi2_kaon/track.pid_n_dof);
103  chi2_pion->Fill(track.chi2_pion/track.pid_n_dof);
104  chi2_proton->Fill(track.chi2_proton/track.pid_n_dof);
105 
106  chi2_proton_m_muon->Fill(track.chi2_proton - track.chi2_muon);
107 
108  bool is_proton_reco = track.chi2_proton < track.chi2_muon;
109  if (track.match.has_match) {
110  bool is_proton_true = abs(track.match.match_pdg) == 2212;
111  bool is_muon_true = abs(track.match.match_pdg) == 13;
112  if (is_proton_true || is_muon_true) {
113  pid_confusion_tr->Fill(is_proton_true, is_proton_reco);
114  }
115  }
116  }
117 
118  range_p->Fill(numu::RangeMomentum(track));
119  mcs_p->Fill(numu::MCSMomentum(track));
120 
121  length->Fill(track.length);
122 
123  reco_momentum->Fill(numu::TrackMomentum(track));
124  is_contained->Fill(track.is_contained);
125 
126  //dQdx_length->Fill(track.mean_trucated_dQdx, track.length);
127 
128  if (std::min(abs(track.start.Y() - border_y->GetBinLowEdge(1)),
129  abs(track.start.Y() - (border_y->GetBinLowEdge(border_y->GetNbinsX()) + border_y->GetBinWidth(border_y->GetNbinsX()))))
130  < std::min(abs(track.end.Y() - border_y->GetBinLowEdge(1)),
131  abs(track.end.Y() - (border_y->GetBinLowEdge(border_y->GetNbinsX()) + border_y->GetBinWidth(border_y->GetNbinsX()))))) {
132  border_y->Fill(track.start.Y());
133  }
134  else {
135  border_y->Fill(track.end.Y());
136  }
137 
138  if (std::min(abs(track.start.X() - border_x->GetBinLowEdge(1)),
139  abs(track.start.X() - (border_x->GetBinLowEdge(border_x->GetNbinsX()) + border_x->GetBinWidth(border_x->GetNbinsX()))))
140  < std::min(abs(track.end.X() - border_x->GetBinLowEdge(1)),
141  abs(track.end.X() - (border_x->GetBinLowEdge(border_x->GetNbinsX()) + border_x->GetBinWidth(border_x->GetNbinsX()))))) {
142  border_x->Fill(track.start.X());
143  }
144  else {
145  border_x->Fill(track.end.X());
146  }
147 
148  if (std::min(abs(track.start.Z() - border_z->GetBinLowEdge(1)),
149  abs(track.start.Z() - (border_z->GetBinLowEdge(border_z->GetNbinsX()) + border_z->GetBinWidth(border_z->GetNbinsX()))))
150  < std::min(abs(track.end.Z() - border_z->GetBinLowEdge(1)),
151  abs(track.end.Z() - (border_z->GetBinLowEdge(border_z->GetNbinsX()) + border_z->GetBinWidth(border_z->GetNbinsX()))))) {
152  border_z->Fill(track.start.Z());
153  }
154  else {
155  border_z->Fill(track.end.Z());
156  }
157 
160  if (track.crt_match.track.present) {
161  crt_match_time->Fill(track.crt_match.track.time);
162  crt_track_angle->Fill(track.crt_match.track.angle);
163  }
164  else if (track.crt_match.hit_match.present) {
165  crt_match_time->Fill(track.crt_match.hit_match.time);
167  }
168 
169  /*
170  has_flash_match->Fill(track.flash_match.present);
171  if (track.flash_match.present) {
172  const numu::FlashMatch &flash_match = track.flash_match;
173  double flash_time = flash_match.match_time_first;
174  flash_match_time->Fill(flash_time);
175  if (track.crt_match.track.present) {
176  crt_v_flash_match_time->Fill(track.crt_match.track.time - flash_time);
177  }
178  else if (track.crt_match.hit_match.present) {
179  crt_v_flash_match_time->Fill(track.crt_match.hit_match.time - flash_time);
180  }
181  }*/
182 
183  // check if truth match
184  if (track.match.has_match && track.match.mcparticle_id >= 0) {
185  const numu::TrueParticle &true_particle = true_particles.at(track.match.mcparticle_id);
186  range_p_minus_truth->Fill((numu::RangeMomentum(track) - true_particle.start_momentum.Mag()) / true_particle.start_momentum.Mag());
187  mcs_p_minus_truth->Fill((numu::MCSMomentum(track) - true_particle.start_momentum.Mag()) / true_particle.start_momentum.Mag());
188 
189  range_p_minus_truth_length->Fill(track.length, (numu::RangeMomentum(track) - true_particle.start_momentum.Mag()) / true_particle.start_momentum.Mag());
190  mcs_p_minus_truth_length->Fill(track.length, (numu::MCSMomentum(track) - true_particle.start_momentum.Mag()) / true_particle.start_momentum.Mag());
191  lengh_munus_truth_length->Fill(track.length, (track.length - true_particle.length) / true_particle.length);
192 
193  //range_p_diff->Fill(true_particle.start_momentum.Mag(), numu::RangeMomentum(track) - true_particle.start_momentum.Mag());
194  //mcs_p_diff->Fill(true_particle.start_momentum.Mag(), numu::MCSMomentum(track) - true_particle.start_momentum.Mag());
195 
196  range_p_comp->Fill(true_particle.start_momentum.Mag(), numu::RangeMomentum(track));
197  mcs_p_comp->Fill(true_particle.start_momentum.Mag(), numu::MCSMomentum(track));
198 
199  completion->Fill(track.match.completion);
200 
201  wall_enter->Fill(true_particle.wall_enter);
202  wall_exit->Fill(true_particle.wall_exit);
203  true_start_time->Fill(true_particle.start_time);
204  true_start_time_zoom->Fill(true_particle.start_time);
205  }
206  else {
207  completion->Fill(-0.5);
208  }
209 
212 
215 
216 }
217  } // namespace SBNOsc
218 } // namespace ana
Track track
CRT Track match.
Definition: CRTMatch.h:30
TVector3 start_momentum
Particle directional momentum for first trajectory point inside TPC AV [GeV].
Definition: TrueParticle.h:24
bool is_contained
is it contained in the &quot;containment volume&quot;?
Definition: RecoTrack.h:52
float chi2_muon
Chi2 of dE/dx to muon hypotheis. Combined agaisnt all planes.
Definition: RecoTrack.h:43
float chi2_kaon
Chi2 of dE/dx to kaon hypotheis. Combined against all planes.
Definition: RecoTrack.h:41
float distance
//!&lt; Distance from projected track to CRT Hit. Nonsense if present is false.
Definition: CRTMatch.h:26
CRTMatch crt_match
CRTMatch.
Definition: RecoTrack.h:59
bool present
Whether this CRTMatch has a matching track.
Definition: CRTMatch.h:16
#define TRACK_2DHISTO(name, binx, lo_x, hi_x, biny, lo_y, hi_y)
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
float min_chi2
Minimum chi2 value across all hypotheses.
Definition: RecoTrack.h:44
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
void Fill(const numu::RecoTrack &track, const std::map< size_t, numu::TrueParticle > &true_particles)
Definition: TrackHisto.cc:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
process_name use argoneut_mc_hitfinder track
void Initialize(const std::string &postfix, const geo::BoxBoundedGeo &detector_volume, double max_length)
Definition: TrackHisto.cc:11
process_name opflashCryoW ana
float length
Length of track contained in any TPC active volume [cm].
Definition: TrueParticle.h:42
float stopping_chisq_finish
Chi2 fraction of stopping vs. not-stopping hypotheis to track end point.
Definition: RecoTrack.h:64
T abs(T value)
float TrackMomentum(const numu::RecoTrack &track)
Definition: TrackAlgo.cc:5
float RangeMomentum(const numu::RecoTrack &track)
Definition: TrackAlgo.cc:15
TVector3 start
start position of track
Definition: RecoTrack.h:54
float chi2_pion
Chi2 of dE/dx to pion hypotheis. Combined against all planes.
Definition: RecoTrack.h:42
float length
Length of track.
Definition: RecoTrack.h:48
float MCSMomentum(const numu::RecoTrack &track)
Definition: TrackAlgo.cc:20
double MinZ() const
Returns the world z coordinate of the start of the box.
bool present
Whether this CRTMatch has a matching hit.
Definition: CRTMatch.h:25
float completion
Fraction of energy deposits by true particle matched by this track.
float stopping_chisq_start
Chi2 fraction of stopping vs. not-stopping hypothesis to track start points.
Definition: RecoTrack.h:63
bool has_match
Whether a track match exists.
#define TRACK_HISTO(name, n_bins, lo, hi)
double MaxY() const
Returns the world y coordinate of the end of the box.
TH2D * range_p_minus_truth_length
Definition: TrackHisto.h:40
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
int pid_n_dof
Number of d.o.f. in chi2 fit.
Definition: RecoTrack.h:45
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
double MaxZ() const
Returns the world z coordinate of the end of the box.
float angle
Angle between TPC track and CRT track.
Definition: CRTMatch.h:18
TVector3 end
end position of track
Definition: RecoTrack.h:55
int match_pdg
PDG of the MCParticle this track matches to.
Wall wall_enter
the face of the TPC that the particle crosses on enter
Definition: TrueParticle.h:35
Wall wall_exit
the face of the TPC that the particle crosses on exit
Definition: TrueParticle.h:36
double MinY() const
Returns the world y coordinate of the start of the box.
HitMatch hit_match
CRT Hit match.
Definition: CRTMatch.h:31
float start_time
start time of track
Definition: TrueParticle.h:32
float time
Matching time [us] of track. T==0 is set to beam spill start time.
Definition: CRTMatch.h:17
float chi2_proton
Chi2 of dE/dx to proton hypothesis. Combined against all planes.
Definition: RecoTrack.h:40