All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
ana::SBNOsc::Cuts Class Reference

#include <Cuts.h>

Classes

struct  Config
 
struct  VolYZ
 

Public Member Functions

void Initialize (const fhicl::ParameterSet &cfg, const geo::GeometryCore *geometry)
 
std::array< bool, nCutsProcessRecoCuts (const numu::RecoEvent &event, unsigned reco_vertex_index, bool fSequentialCuts=true) const
 
std::array< bool, nTruthCutsProcessTruthCuts (const numu::RecoEvent &event, const event::Event &core, unsigned truth_vertex_index, bool SequentialCuts=true) const
 
bool SelectReco (std::array< bool, nCuts > &cuts)
 
bool InFV (const TVector3 &v) const
 
bool InFV (const geo::Point_t &v) const
 
bool InCosmicContainment (const TVector3 &v) const
 
bool InCalorimetricContainment (const TVector3 &v) const
 
float CRTMatchTime (const numu::RecoTrack &track) const
 
bool HasCRTHitMatch (const numu::RecoTrack &track) const
 
bool TimeInSpill (float time) const
 
bool TimeInCRTActiveSpill (float time) const
 
bool HasCRTTrackMatch (const numu::RecoTrack &track) const
 
bool PassFlashTrigger (const numu::RecoEvent &event) const
 
const std::vector< std::string > & CutOrder () const
 
const std::vector< std::string > & TruthCutOrder () const
 

Static Public Attributes

static const unsigned nCuts = 11
 total number of cuts More...
 
static const unsigned nTruthCuts = 6
 Total number of truth cuts. More...
 
static constexpr std::array
< const char *, nTruthCuts
truthCutNames = { "Truth", "T_fid", "T_trig", "T_vqual", "T_tqual", "T_reco"}
 
static constexpr std::array
< const char *, nCuts
cutNames
 

Private Attributes

Config fConfig
 

Detailed Description

Definition at line 18 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

Member Function Documentation

float ana::SBNOsc::Cuts::CRTMatchTime ( const numu::RecoTrack track) const

Gets the time of the CRT match to a track.

Parameters
trackThe track object
Returns
The time [us] of the CRT match. Returns nonsense if no such match exists.

Definition at line 211 of file Cuts.cc.

211  {
212  if (HasCRTTrackMatch(track)) return track.crt_match.track.time;
213  if (HasCRTHitMatch(track)) return track.crt_match.hit_match.time;
214  return -99999;
215 }
Track track
CRT Track match.
Definition: CRTMatch.h:30
bool HasCRTHitMatch(const numu::RecoTrack &track) const
Definition: Cuts.cc:205
CRTMatch crt_match
CRTMatch.
Definition: RecoTrack.h:59
bool HasCRTTrackMatch(const numu::RecoTrack &track) const
Definition: Cuts.cc:199
HitMatch hit_match
CRT Hit match.
Definition: CRTMatch.h:31
float time
Matching time [us] of track. T==0 is set to beam spill start time.
Definition: CRTMatch.h:17
const std::vector<std::string>& ana::SBNOsc::Cuts::CutOrder ( ) const
inline

Definition at line 126 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

126  {
127  return fConfig.CutOrder;
128  }
bool ana::SBNOsc::Cuts::HasCRTHitMatch ( const numu::RecoTrack track) const

Whether a TPC track has a CRT hit match

Parameters
trackthe TPC track
Returns
Whether a TPC track has a CRT hit match

Definition at line 205 of file Cuts.cc.

205  {
206  return track.crt_match.hit_match.present &&
207  (fConfig.CRTHitDist < 0. ||
209 }
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 hit.
Definition: CRTMatch.h:25
HitMatch hit_match
CRT Hit match.
Definition: CRTMatch.h:31
bool ana::SBNOsc::Cuts::HasCRTTrackMatch ( const numu::RecoTrack track) const

Whether a TPC track has a CRT track match

Parameters
trackthe TPC track
Returns
Whether a TPC track has a CRT track match

Definition at line 199 of file Cuts.cc.

199  {
200  return track.crt_match.track.present &&
201  (fConfig.CRTTrackAngle < 0. ||
203 }
Track track
CRT Track match.
Definition: CRTMatch.h:30
CRTMatch crt_match
CRTMatch.
Definition: RecoTrack.h:59
bool present
Whether this CRTMatch has a matching track.
Definition: CRTMatch.h:16
float angle
Angle between TPC track and CRT track.
Definition: CRTMatch.h:18
bool ana::SBNOsc::Cuts::InCalorimetricContainment ( const TVector3 &  v) const

Test whether a point is in the configured track containment volume

Parameters
vThe point to test
Returns
Whether the point is in the configured track containment volume

Definition at line 241 of file Cuts.cc.

241  {
242  for (auto const& FV: fConfig.calorimetric_containment_volumes) {
243  if (FV.ContainsPosition(v)) return true;
244  }
245  return false;
246 }
std::vector< geo::BoxBoundedGeo > calorimetric_containment_volumes
bool ana::SBNOsc::Cuts::InCosmicContainment ( const TVector3 &  v) const

Test whether a point is in the configured track containment volume

Parameters
vThe point to test
Returns
Whether the point is in the configured track containment volume

Definition at line 248 of file Cuts.cc.

248  {
249  for (auto const& CV: fConfig.cosmic_containment_volumes) {
250  if (CV.Z[0] < v.Z()
251  && CV.Z[1] > v.Z()
252  && CV.Y[0] < v.Y()
253  && CV.Y[1] > v.Y()) {
254  return true;
255  }
256  }
257  return false;
258 }
bool ana::SBNOsc::Cuts::InFV ( const TVector3 &  v) const

Test whether a point is in the configured fiducial volume

Parameters
vThe point to test
Returns
Whether the point is in the configured fiducial volume

Definition at line 234 of file Cuts.cc.

234  {
235  for (auto const& FV: fConfig.fiducial_volumes) {
236  if (FV.ContainsPosition(v)) return true;
237  }
238  return false;
239 }
std::vector< geo::BoxBoundedGeo > fiducial_volumes
bool ana::SBNOsc::Cuts::InFV ( const geo::Point_t v) const

Test whether a point is in the configured fiducial volume

Parameters
vThe point to test
Returns
Whether the point is in the configured fiducial volume

Definition at line 227 of file Cuts.cc.

227  {
228  for (auto const& FV: fConfig.fiducial_volumes) {
229  if (FV.ContainsPosition(v)) return true;
230  }
231  return false;
232 }
std::vector< geo::BoxBoundedGeo > fiducial_volumes
void ana::SBNOsc::Cuts::Initialize ( const fhicl::ParameterSet &  cfg,
const geo::GeometryCore geometry 
)

Initialize this class.

Parameters
cfgfhicl configuration for the class A pointer to the geoemtry of the detector to configure

Definition at line 10 of file Cuts.cc.

10  {
11  fConfig.active_volumes.clear();
12  fConfig.fiducial_volumes.clear();
13 
14  fConfig.UseTrueVertex = cfg.get<bool>("UseTrueVertex", false);
15  fConfig.trackMatchCompletionCut = cfg.get<double>("trackMatchCompletionCut", -1);
17  fConfig.TruthCompletion = cfg.get<float>("TruthCompletion", 0.5);
18  fConfig.TruthMatchDist = cfg.get<float>("TruthMatchDist", 5.);
19 
20  fConfig.MCSTrackLength = cfg.get<float>("MCSTrackLength", 100.);
21  fConfig.TrackLength = cfg.get<float>("TrackLength", 50.);
22 
23  fConfig.CRTHitDist = cfg.get<float>("CRTHitDist", 35.);
24  fConfig.CRTHitTimeRange = cfg.get<std::array<float, 2>>("CRTHitTimeRange", {-0.2, 2.0});
25  fConfig.CRTActivityTimeRange = cfg.get<std::array<float, 2>>("CRTActivityTimeRange", {-0.2, 2.0});
26  fConfig.CRTTrackAngle = cfg.get<float>("CRTTrackAngle", 0.4);
27 
28  fConfig.TruthFlashMatch = cfg.get<bool>("TruthFlashMatch", false);
29  fConfig.FlashMatchScore = cfg.get<float>("FlashMatchScore", 10.);
30 
31  fConfig.PMTTriggerTreshold = cfg.get<int>("PMTTriggerTreshold", 7950);
32  fConfig.PMTNAboveThreshold = cfg.get<unsigned>("PMTNAboveThreshold", 5);
33 
34  fConfig.CRTActivityPEThreshold = cfg.get<float>("CRTActivityPEThreshold", 100.);
35 
36  fConfig.CutOrder = cfg.get<std::vector<std::string>>("CutOrder");
37  fConfig.TruthCutOrder = cfg.get<std::vector<std::string>>("TruthCutOrder");
38 
39  {
40  fhicl::ParameterSet dFV = \
41  cfg.get<fhicl::ParameterSet>("fiducial_volume_inset");
42  double dx = dFV.get<double>("x");
43  double dy = dFV.get<double>("y");
44  double zfront = dFV.get<double>("zfront");
45  double zback = dFV.get<double>("zback");
46  for (const geo::BoxBoundedGeo &geo: fConfig.active_volumes) {
47  fConfig.fiducial_volumes.emplace_back(geo.MinX() + dx, geo.MaxX() - dx, geo.MinY() + dy, geo.MaxY() - dy, geo.MinZ() + zfront, geo.MaxZ() - zback);
48  }
49  }
50 
51  {
52  fhicl::ParameterSet dFV = \
53  cfg.get<fhicl::ParameterSet>("calorimetric_containment_volume_inset");
54  double dx = dFV.get<double>("x");
55  double dy = dFV.get<double>("y");
56  double zfront = dFV.get<double>("zfront");
57  double zback = dFV.get<double>("zback");
58  for (const geo::BoxBoundedGeo &geo: fConfig.active_volumes) {
59  fConfig.calorimetric_containment_volumes.emplace_back(geo.MinX() + dx,
60  geo.MaxX() - dx,
61  geo.MinY() + dy,
62  geo.MaxY() - dy,
63  geo.MinZ() +
64  zfront,
65  geo.MaxZ() -zback);
66  }
67  }
68 
69  {
70  fhicl::ParameterSet dFV = \
71  cfg.get<fhicl::ParameterSet>("cosmic_containment_volume_inset");
72  double ytop = dFV.get<double>("ytop");
73  double ybottom = dFV.get<double>("ybottom");
74  double zfront = dFV.get<double>("zfront");
75  double zback = dFV.get<double>("zback");
76  for (const geo::BoxBoundedGeo &geo: fConfig.active_volumes) {
77  VolYZ contain;
78  contain.Y = {geo.MinY() + ybottom, geo.MaxY() - ytop};
79  contain.Z = {geo.MinZ() + zfront, geo.MaxZ() - zback};
80  fConfig.cosmic_containment_volumes.emplace_back(contain);
81  }
82  }
83 
84 }
std::vector< geo::BoxBoundedGeo > ActiveVolumes(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:3
std::vector< geo::BoxBoundedGeo > active_volumes
std::vector< geo::BoxBoundedGeo > calorimetric_containment_volumes
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:88
std::vector< geo::BoxBoundedGeo > fiducial_volumes
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:91
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.
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.
double MinY() const
Returns the world y coordinate of the start of the box.
bool ana::SBNOsc::Cuts::PassFlashTrigger ( const numu::RecoEvent event) const

Definition at line 121 of file Cuts.cc.

121  {
123 }
std::vector< FlashTriggerPrimitive > flash_trigger_primitives
List of trigger primitives from optical detectors.
Definition: RecoEvent.h:52
bool HasTrigger(const std::vector< FlashTriggerPrimitive > &primitives, int threshold, unsigned n_above_threshold)
Definition: PMTTrigger.cc:65
std::array< bool, Cuts::nCuts > ana::SBNOsc::Cuts::ProcessRecoCuts ( const numu::RecoEvent event,
unsigned  reco_vertex_index,
bool  fSequentialCuts = true 
) const

Process each cut associated with reconstructed events

Parameters
eventThe reconstructed event information
reco_vertex_indexThe index of the candidate reconstructed neutrino vertex into the list of such vertices in the RecoEvent
Returns
A list of bool's of whether the reco event passes each cut

Definition at line 125 of file Cuts.cc.

127  {
128  std::map<std::string, bool> cuts;
129  cuts["Reco"] = true;
130 
131  cuts["R_trig"] = PassFlashTrigger(event);
132 
133  // require an in-time flash time
134  bool has_intime_flash = false;
135  for (const numu::RecoInteraction &reco: event.reco) {
136  if (reco.slice.flash_match.present && reco.slice.flash_match.time > 0. /*intime*/) {
137  has_intime_flash = true;
138  break;
139  }
140  }
141  cuts["R_flashtime"] = has_intime_flash;
142 
143  // require fiducial
144  if (fConfig.UseTrueVertex) {
145  cuts["R_fid"] = false; // TODO: implement
146  }
147  else {
148  cuts["R_fid"] = InFV(event.reco[reco_vertex_index].position);
149  }
150 
151  const numu::RecoTrack &primary_track = event.tracks.at(event.reco[reco_vertex_index].slice.primary_track_index);
152 
153  // good_mcs = track contain OR (range momentum OR mcs trk length)
154  cuts["R_goodmcs"] = ( ( InCalorimetricContainment(primary_track.start) &&
155  InCalorimetricContainment(primary_track.end) ) ||
156  ( numu::MCSMomentum(primary_track) < 7. /*garbage value*/&&
157  (fConfig.MCSTrackLength <0. ||
158  primary_track.length > fConfig.MCSTrackLength) )
159  );
160 
161  // allow truth-based flash matching or reco based
162  bool time_in_spill = false;
163  if (primary_track.match.has_match) {
164  time_in_spill = TimeInSpill(event.particles.at(primary_track.match.mcparticle_id).start_time);
165  }
166 
167  if (fConfig.TruthFlashMatch) cuts["R_flashmatch"] = time_in_spill;
168  else cuts["R_flashmatch"] = fConfig.FlashMatchScore < 0. || (event.reco[reco_vertex_index].slice.flash_match.present && event.reco[reco_vertex_index].slice.flash_match.score < fConfig.FlashMatchScore);
169 
170  cuts["R_crttrack"] = !HasCRTTrackMatch(primary_track);
171 
172  cuts["R_crthit"] = ( !HasCRTHitMatch(primary_track) ||
173  TimeInSpill(CRTMatchTime(primary_track)) );
174 
175  cuts["R_length"] = fConfig.TrackLength < 0. ||
176  primary_track.length > fConfig.TrackLength;
177 
178  cuts["R_contained"] = ( InCosmicContainment(primary_track.start) &&
179  InCosmicContainment(primary_track.end) );
180 
181 
182  cuts["R_crtactive"] = true; //is_contained;
183  for (const numu::CRTHit &crt_hit: event.in_time_crt_hits) {
184  if ( TimeInSpill(crt_hit.time) &&
185  crt_hit.pes > fConfig.CRTActivityPEThreshold ) {
186  cuts["R_crtactive"] = false;
187  break;
188  }
189  }
190 
191  std::array<bool, Cuts::nCuts> ret;
192  for (unsigned i = 0; i < fConfig.CutOrder.size(); i++) {
193  if (fSequentialCuts && i > 0) ret[i] = ret[i-1] && cuts.at(fConfig.CutOrder[i]);
194  else ret[i] = cuts.at(fConfig.CutOrder[i]);
195  }
196  return ret;
197 }
bool TimeInSpill(float time) const
Definition: Cuts.cc:217
bool HasCRTHitMatch(const numu::RecoTrack &track) const
Definition: Cuts.cc:205
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
bool HasCRTTrackMatch(const numu::RecoTrack &track) const
Definition: Cuts.cc:199
bool InCosmicContainment(const TVector3 &v) const
Definition: Cuts.cc:248
std::map< size_t, TrueParticle > particles
Map of indices to True particle information.
Definition: RecoEvent.h:49
std::vector< CRTHit > in_time_crt_hits
List of crt hits in time with the beam spill.
Definition: RecoEvent.h:51
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
process_name standard_reco_uboone reco
TVector3 start
start position of track
Definition: RecoTrack.h:54
FlashMatch flash_match
Result of flash matching algorithm on this slice.
Definition: RecoEvent.h:30
float length
Length of track.
Definition: RecoTrack.h:48
float MCSMomentum(const numu::RecoTrack &track)
Definition: TrackAlgo.cc:20
bool InFV(const TVector3 &v) const
Definition: Cuts.cc:234
float time
CRT Hit time.
Definition: DetInfo.h:13
float CRTMatchTime(const numu::RecoTrack &track) const
Definition: Cuts.cc:211
bool PassFlashTrigger(const numu::RecoEvent &event) const
Definition: Cuts.cc:121
bool has_match
Whether a track match exists.
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
RecoSlice slice
Particle content of the interaction.
Definition: RecoEvent.h:39
float pes
Number of PE&#39;s in hit.
Definition: DetInfo.h:15
TVector3 end
end position of track
Definition: RecoTrack.h:55
bool InCalorimetricContainment(const TVector3 &v) const
Definition: Cuts.cc:241
std::array< bool, Cuts::nTruthCuts > ana::SBNOsc::Cuts::ProcessTruthCuts ( const numu::RecoEvent event,
const event::Event core,
unsigned  truth_vertex_index,
bool  SequentialCuts = true 
) const

Process each cut associated with true events

Parameters
eventEvent information
truth_vertex_indexThe index of the true neutrino vertex into the lsit of true interactions in the RecoEvent
Returns
A list of bool's of whether the true event passes each cut

Definition at line 86 of file Cuts.cc.

86  {
87  std::map<std::string, bool> cuts;
88  cuts["Truth"] = true;
89 
90 
91  cuts["T_fid"] = InFV(core.truth[truth_vertex_index].neutrino.position);
92 
93  cuts["T_trig"] = PassFlashTrigger(event);
94 
95  cuts["T_vqual"] = (fConfig.TruthMatchDist < 0. ||
96  dist2Match(core.truth[truth_vertex_index], event.reco) < fConfig.TruthMatchDist);
97  cuts["T_tqual"] = (fConfig.TruthCompletion < 0. ||
98  trackMatchCompletion(truth_vertex_index, event) > fConfig.TruthCompletion);
99 
100  bool has_reco = false;
101  for (unsigned i = 0; i < event.reco.size(); i++) {
102  const numu::RecoTrack &primary_track = event.tracks.at(event.reco[i].slice.primary_track_index);
103  if (event.reco[i].match.has_match &&
104  event.reco[i].match.mctruth_track_id == truth_vertex_index &&
105  primary_track.match.is_primary) {
106  has_reco = true;
107  break;
108  }
109  }
110  cuts["T_reco"] = has_reco;
111 
112  std::array<bool, Cuts::nTruthCuts> ret;
113  for (unsigned i = 0; i < fConfig.TruthCutOrder.size(); i++) {
114  if (SequentialCuts && i > 0) ret[i] = ret[i-1] && cuts.at(fConfig.TruthCutOrder[i]);
115  else ret[i] = cuts.at(fConfig.TruthCutOrder[i]);
116  }
117  return ret;
118 
119 }
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
bool InFV(const TVector3 &v) const
Definition: Cuts.cc:234
bool PassFlashTrigger(const numu::RecoEvent &event) const
Definition: Cuts.cc:121
float dist2Match(const event::Interaction &truth, const std::vector< numu::RecoInteraction > &candidates)
Definition: Derived.cc:3
bool is_primary
Whether this track was produced as the &quot;primary&quot; process.
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
float trackMatchCompletion(unsigned truth_index, const numu::RecoEvent &event)
Definition: Derived.cc:13
std::vector< Interaction > truth
All truth interactions.
Definition: Event.hh:232
bool ana::SBNOsc::Cuts::SelectReco ( std::array< bool, nCuts > &  cuts)

Select a reco event based on the cut values provided by ProcessRecoCuts

Parameters
cutsthe list of cuts returned by ProcessRecoCuts
Returns
whether to select this reconstructed neutrino vertex candidate
bool ana::SBNOsc::Cuts::TimeInCRTActiveSpill ( float  time) const

Definition at line 222 of file Cuts.cc.

222  {
223  return time > fConfig.CRTActivityTimeRange[0] &&
224  time < fConfig.CRTActivityTimeRange[1];
225 }
bool ana::SBNOsc::Cuts::TimeInSpill ( float  time) const

Returns whether a time value is within the configured beam spill window

Parameters
timeThe time to test
Returns
True when the time is in the beam spill window.

Definition at line 217 of file Cuts.cc.

217  {
218  return time > fConfig.CRTHitTimeRange[0] &&
219  time < fConfig.CRTHitTimeRange[1];
220 }
const std::vector<std::string>& ana::SBNOsc::Cuts::TruthCutOrder ( ) const
inline

Definition at line 130 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

Member Data Documentation

constexpr std::array<const char *, nCuts> ana::SBNOsc::Cuts::cutNames
static
Initial value:
=
{"Reco", "R_trig", "R_flashtime", "R_fid", "R_goodmcs", "R_flashmatch",
"R_crttrack", "R_crthit", "R_crtactive", "R_contained", "R_length"}

Definition at line 122 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

Config ana::SBNOsc::Cuts::fConfig
private

Definition at line 164 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

const unsigned ana::SBNOsc::Cuts::nCuts = 11
static

total number of cuts

Definition at line 20 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

const unsigned ana::SBNOsc::Cuts::nTruthCuts = 6
static

Total number of truth cuts.

Definition at line 21 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.

constexpr std::array<const char *, nTruthCuts> ana::SBNOsc::Cuts::truthCutNames = { "Truth", "T_fid", "T_trig", "T_vqual", "T_tqual", "T_reco"}
static

Definition at line 121 of file ysis/ana/SBNOscReco/PostProcess/Cuts.h.


The documentation for this class was generated from the following files: