All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InteractionHisto.cc
Go to the documentation of this file.
1 #include "InteractionHisto.h"
2 #include "Derived.h"
3 #include "../TriggerEmulator/PMTTrigger.h"
4 
5 #include "TH1D.h"
6 #include "TH2D.h"
7 
8 namespace ana {
9  namespace SBNOsc {
10 
11 void InteractionHistos::Initialize(const std::string &postfix, const geo::BoxBoundedGeo &detector_volume, const std::vector<double> &tagger_volume) {
12 #define INT_HISTO(name, n_bins, lo, hi) name = new TH1D((#name + postfix).c_str(), #name, n_bins, lo, hi); StoreHisto(name)
13 #define INT_HISTO2D(name, n_binsx, xlo, xhi, n_binsy, ylo, yhi) name = new TH2D((#name + postfix).c_str(), #name, n_binsx, xlo, xhi, n_binsy, ylo, yhi); StoreHisto(name)
14 #define INT_HISTO2D_BINSY(name, n_binsx, xlo, xhi, n_binsy, binsy) name = new TH2D((#name + postfix).c_str(), #name, n_binsx, xlo, xhi, n_binsy, binsy); StoreHisto(name)
15 
16  INT_HISTO(track_length, 100, 0., 600.);
17  INT_HISTO(track_p, 50, 0., 5.);
18  INT_HISTO(nuE, 50, 0., 5.);
19  INT_HISTO(beam_center_distance, 60, 0., 300.);
20  INT_HISTO(Q2, 50, 0., 10.);
21  INT_HISTO(true_contained_length, 100, 0., 600.);
23  INT_HISTO(crosses_tpc, 2, -0.5, 1.5);
24  INT_HISTO(dist_to_match, 101, -1., 100.);
25  INT_HISTO(primary_track_completion, 100, 0., 1.);
26  INT_HISTO(n_reco_vertices, 10, -0.5, 9.5);
27  INT_HISTO(maxpe_crt_intime_hit, 1000, 0., 1000.);
28  INT_HISTO(crt_pes, 1000, 0., 1000.);
29 
30  INT_HISTO(crt_hit_times, 300, -20., 10.);
31  INT_HISTO(closest_crt_hit_time, 300, -20., 10.);
32 
33  INT_HISTO(fmatch_score, 200, 0., 200.);
34  INT_HISTO2D(fmatch_score_true_time, 100, 0., 100., 1400, -4000., 3000.);
35  INT_HISTO2D(fmatch_score_true_time_zoom, 100, 0., 100., 100, -5., 5.);
36  double intout_times[4] = {-3000., 0., 1.6, 3000.};
37  INT_HISTO(fmatch_score_intime, 100, 0., 100.);
38  INT_HISTO(fmatch_score_outtime, 100, 0., 100.);
39  INT_HISTO2D(fmatch_time_true_time_zoom, 100, -5., 5., 100, -5., 5.);
40  INT_HISTO(fmatch_time_real_time, 4000, -2, 2);
41  INT_HISTO(fmatch_time, 700, -5., 2.);
42 
43  // INT_HISTO2D(light_trigger, 20, 0.5, 20.5, 200, 6000, 8000);
44 
45  INT_HISTO2D(intime_crt_hits_xy, 100, tagger_volume[0], tagger_volume[3], 100, tagger_volume[1], tagger_volume[4]);
46  INT_HISTO2D(intime_crt_hits_xz, 100, tagger_volume[0], tagger_volume[3], 100, tagger_volume[2], tagger_volume[5]);
47  INT_HISTO2D(intime_crt_hits_yz, 100, tagger_volume[1], tagger_volume[4], 100, tagger_volume[2], tagger_volume[5]);
48 
49  INT_HISTO2D(vertex_xy, 100, detector_volume.MinX(), detector_volume.MaxX(), 100, detector_volume.MinY(), detector_volume.MaxY());
50  INT_HISTO2D(vertex_yz, 100, detector_volume.MinY(), detector_volume.MaxY(), 100, detector_volume.MinZ(), detector_volume.MaxZ());
51  INT_HISTO2D(vertex_xz, 100, detector_volume.MinX(), detector_volume.MaxX(), 100, detector_volume.MinZ(), detector_volume.MaxZ());
52 
53  INT_HISTO(vertex_x, 100, detector_volume.MinX(), detector_volume.MaxX());
54  INT_HISTO(vertex_y, 100, detector_volume.MinY(), detector_volume.MaxY());
55  INT_HISTO(vertex_z, 100, detector_volume.MinZ(), detector_volume.MaxZ());
56 
57 #undef INT_HISTO
58 }
59 
60 void InteractionHistos::Fill(const event::Interaction &interaction, unsigned mctruth_id, const numu::RecoEvent &event) {
61  double dist = numu::dist2Match(interaction, event.reco);
62  dist_to_match->Fill(dist);
63  primary_track_completion->Fill(numu::trackMatchCompletion(mctruth_id, event));
64 
65  vertex_xy->Fill(interaction.neutrino.position.X(), interaction.neutrino.position.Y());
66  vertex_yz->Fill(interaction.neutrino.position.Y(), interaction.neutrino.position.Z());
67  vertex_xz->Fill(interaction.neutrino.position.X(), interaction.neutrino.position.Z());
68 
69  vertex_x->Fill(interaction.neutrino.position.X());
70  vertex_y->Fill(interaction.neutrino.position.Y());
71  vertex_z->Fill(interaction.neutrino.position.Z());
72 
73 
74  // TODO: how to fix these histograms?
75  // crosses_tpc
76 
77  // only fill for muon tracks (CC interactions)
78  if (abs(interaction.lepton.pdg) == 13) {
79  track_p->Fill(interaction.lepton.momentum.Mag());
81  }
82 
83  true_track_multiplicity->Fill(interaction.nfinalstate);
84  nuE->Fill(interaction.neutrino.energy);
85  Q2->Fill(interaction.neutrino.Q2);
86 
87  FillEvent(event);
88 }
89 
92  const numu::RecoEvent &event,
93  const std::vector<event::Interaction> &truth) {
94 
95  const numu::RecoTrack &primary_track = event.tracks.at(vertex.slice.primary_track_index);
96 
98  primary_track_completion->Fill(primary_track.match.completion);
99 
100  vertex_xy->Fill(vertex.position.X(), vertex.position.Y());
101  vertex_yz->Fill(vertex.position.Y(), vertex.position.Z());
102  vertex_xz->Fill(vertex.position.X(), vertex.position.Z());
103 
104  vertex_x->Fill(vertex.position.X());
105  vertex_y->Fill(vertex.position.Y());
106  vertex_z->Fill(vertex.position.Z());
107 
108 
109  if (vertex.slice.flash_match.present) {
110  fmatch_score->Fill(vertex.slice.flash_match.score);
111  fmatch_time->Fill(vertex.slice.flash_match.time);
112  if (vertex.slice.primary_track_index >= 0 && event.tracks.at(vertex.slice.primary_track_index).match.has_match) {
113  int mcparticle_id = event.tracks.at(vertex.slice.primary_track_index).match.mcparticle_id;
114  double true_time = event.particles.at(mcparticle_id).start_time;
115  fmatch_score_true_time->Fill(vertex.slice.flash_match.score, true_time);
116  fmatch_score_true_time_zoom->Fill(vertex.slice.flash_match.score, true_time);
117  fmatch_time_true_time_zoom->Fill(vertex.slice.flash_match.time, true_time);
118  if (true_time < 0. || true_time > 1.6) {
120  }
121  else {
123  }
124 
125  fmatch_time_real_time->Fill(vertex.slice.flash_match.time - true_time);
126  }
127  }
128 
129  track_length->Fill(primary_track.length);
130  if (primary_track.match.has_match) {
131  int mcparticle_id = primary_track.match.mcparticle_id;
132 
133  double true_track_momentum = event.particles.at(mcparticle_id).start_momentum.Mag();
134  track_p->Fill(true_track_momentum);
135 
136  int crosses_tpc_val = event.particles.at(mcparticle_id).crosses_tpc;
137  crosses_tpc->Fill(crosses_tpc_val);
138 
139  double length = event.particles.at(mcparticle_id).length;
140  true_contained_length->Fill(length);
141  }
142 
143  if (vertex.match.mctruth_track_id >= 0) {
144  int mctruth_id = vertex.match.mctruth_track_id;
145 
146  true_track_multiplicity->Fill(truth[mctruth_id].nfinalstate);
147  nuE->Fill(truth[mctruth_id].neutrino.energy);
148  Q2->Fill(truth[mctruth_id].neutrino.Q2);
149  // get the distance from the beam center
150  /*
151  float beam_center_distance = sqrt( (truth[mctruth_id].neutrino.position.X() - _config.beamCenterX) *
152  (truth[mctruth_id].neutrino.position.X() - _config.beamCenterX) +
153  (truth[mctruth_id].neutrino.position.Y() - _config.beamCenterY) *
154  (truth[mctruth_id].neutrino.position.Y() - _config.beamCenterY));
155 
156  beam_center_distance->Fill(beam_center_distance);
157  */
158  }
159 
160  // fill the event-info based histograms
161  FillEvent(event);
162 }
163 
165  n_reco_vertices->Fill(event.reco.size());
166 
167  double maxpe = 0.;
168  double closest_time_dist = -1;
169  double closest_time = 0.;
170  for (const numu::CRTHit &hit: event.in_time_crt_hits) {
171  intime_crt_hits_xy->Fill(hit.location.X(), hit.location.Y());
172  intime_crt_hits_xz->Fill(hit.location.X(), hit.location.Z());
173  intime_crt_hits_yz->Fill(hit.location.Y(), hit.location.Z());
174 
175  crt_pes->Fill(hit.pes);
176  if (hit.pes > maxpe) maxpe = hit.pes;
177 
178  //if (hit.pes < 100.) continue;
179 
180  crt_hit_times->Fill(hit.time);
181 
182  if (closest_time_dist < 0. || closest_time_dist > 1e-3) {
183  double this_time_dist = -1;
184  if (hit.time > -0.2 && hit.time < 1.8) this_time_dist = 0.;
185  else if (hit.time < 0.) this_time_dist = -hit.time -0.2;
186  if (this_time_dist >= 0. && (this_time_dist < closest_time_dist || closest_time_dist < 0.)) {
187  closest_time = hit.time;
188  closest_time_dist = this_time_dist;
189  }
190  }
191  }
192  if (closest_time_dist >= 0.) {
193  closest_crt_hit_time->Fill(closest_time);
194  }
195  else {
196  closest_crt_hit_time->Fill(30.);
197  }
198 
199  std::cout << "Max PE: " << maxpe << std::endl;
200  if (event.in_time_crt_hits.size() == 0) {
201  maxpe_crt_intime_hit->Fill(-1);
202  }
203  else {
204  maxpe_crt_intime_hit->Fill(maxpe);
205  }
206 }
207 
208  } // namespace SBNOsc
209 } // namespace ana
210 
process_name vertex
Definition: cheaterreco.fcl:51
TVector3 momentum
Three-momentum.
Definition: Event.hh:129
TH1D * true_contained_length
True contained length of primary track.
void FillEvent(const numu::RecoEvent &event)
int pdg
PDG Code.
Definition: Event.hh:127
FinalStateParticle lepton
The primary final state lepton.
Definition: Event.hh:153
TH1D * track_p
Primary track momentum.
TH1D * dist_to_match
Distance from this vertex to the closest matching vertex reco-&gt;truth and truth-&gt;reco.
TH1D * n_reco_vertices
Number of reconstructed vertices in the event with this vertex.
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
TH1D * nuE
Neutrino energy.
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
int primary_track_index
Index of the primary track.
Definition: RecoEvent.h:27
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
Neutrino neutrino
The neutrino.
Definition: Event.hh:152
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
float Q2
Q squared.
Definition: Event.hh:82
process_name hit
Definition: cheaterreco.fcl:51
process_name opflashCryoW ana
std::vector< CRTHit > in_time_crt_hits
List of crt hits in time with the beam spill.
Definition: RecoEvent.h:51
TH1D * beam_center_distance
Distance of the neutrino interaction to the beam center.
TVector3 location
Location of the hit.
Definition: DetInfo.h:16
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
T abs(T value)
TVector3 position
location of the vertex
Definition: RecoEvent.h:40
std::map< size_t, RecoTrack > tracks
Map of track indices to Track information.
Definition: RecoEvent.h:48
void Initialize(const std::string &prefix, const geo::BoxBoundedGeo &detector_volume, const std::vector< double > &tagger_volume)
FlashMatch flash_match
Result of flash matching algorithm on this slice.
Definition: RecoEvent.h:30
TH1D * maxpe_crt_intime_hit
Maximum number of PE&#39;s in a single CRT hit in time with the beam.
TH1D * Q2
Q2 of the interaction.
float length
Length of track.
Definition: RecoTrack.h:48
double MinZ() const
Returns the world z coordinate of the start of the box.
float completion
Fraction of energy deposits by true particle matched by this track.
float time
CRT Hit time.
Definition: DetInfo.h:13
bool has_match
Whether a track match exists.
double MaxY() const
Returns the world y coordinate of the end of the box.
float dist2Match(const event::Interaction &truth, const std::vector< numu::RecoInteraction > &candidates)
Definition: Derived.cc:3
size_t nfinalstate
Size of finalstate.
Definition: Event.hh:155
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
RecoSlice slice
Particle content of the interaction.
Definition: RecoEvent.h:39
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
float energy
Neutrino energy (GeV)
Definition: Event.hh:90
double MaxZ() const
Returns the world z coordinate of the end of the box.
float pes
Number of PE&#39;s in hit.
Definition: DetInfo.h:15
TVector3 position
Neutrino interaction position.
Definition: Event.hh:92
#define INT_HISTO(name, n_bins, lo, hi)
float truth_vertex_distance
Distance from truth interaction vertex to this vertex.
do i e
TH1D * track_length
Length of the reconstructed primary track.
float trackMatchCompletion(unsigned truth_index, const numu::RecoEvent &event)
Definition: Derived.cc:13
int mctruth_track_id
index of the primary track into the list of MCTruths. -1 if no match.
TH1D * crosses_tpc
Whether the primary track crosses a TPC boundary.
TH1D * primary_track_completion
Completion of the primary track.
double MinY() const
Returns the world y coordinate of the start of the box.
void Fill(const numu::RecoInteraction &vertex, const numu::RecoEvent &event, const std::vector< event::Interaction > &core_truth)
TH1D * true_track_multiplicity
True particle multiplicity of the interaction.
All truth information associated with one neutrino interaction.
Definition: Event.hh:150
BEGIN_PROLOG could also be cout
#define INT_HISTO2D(name, n_binsx, xlo, xhi, n_binsy, ylo, yhi)