LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
pma::PMAlgCosmicTagger Class Reference

#include "PMAlgCosmicTagger.h"

Classes

struct  Config
 

Public Member Functions

 PMAlgCosmicTagger (const pma::PMAlgCosmicTagger::Config &config)
 
bool tagAny () const
 
void tag (detinfo::DetectorClocksData const &clockData, pma::TrkCandidateColl &tracks)
 

Private Member Functions

size_t outOfDriftWindow (pma::TrkCandidateColl &tracks) const
 
size_t fullHeightCrossing (pma::TrkCandidateColl &tracks) const
 
size_t fullWidthCrossing (pma::TrkCandidateColl &tracks) const
 
size_t fullLengthCrossing (pma::TrkCandidateColl &tracks) const
 
size_t fullCrossingTagger (pma::TrkCandidateColl &tracks, int direction) const
 
size_t nonBeamT0Tag (detinfo::DetectorClocksData const &clockData, pma::TrkCandidateColl &tracks) const
 
size_t tagTopFrontBack (pma::TrkCandidateColl &tracks) const
 
size_t tagApparentStopper (pma::TrkCandidateColl &tracks) const
 
bool isTopVertex (const TVector3 &pos, double tolerance, short int dirIndx) const
 
bool isFrontBackVertex (const TVector3 &pos, double tolerance, short int dirIndx) const
 
void GetDimensions ()
 
short int ConvertDirToInt (const geo::Vector_t &dir) const
 

Private Attributes

bool fTagOutOfDriftTracks
 
double fOutOfDriftMargin
 
bool fTagFullHeightTracks
 
bool fTagFullWidthTracks
 
bool fTagFullLengthTracks
 
double fFullCrossingMargin
 
bool fTagNonBeamT0Tracks
 
double fNonBeamT0Margin
 
bool fTagTopFrontBack
 
double fTopFrontBackMargin
 
bool fTagApparentStopper
 
double fApparentStopperMargin
 
bool fVetoActualStopper
 
double fStopperBuffer
 
std::vector< double > fDimensionsMin
 
std::vector< double > fDimensionsMax
 

Detailed Description

Definition at line 29 of file PMAlgCosmicTagger.h.

Constructor & Destructor Documentation

pma::PMAlgCosmicTagger::PMAlgCosmicTagger ( const pma::PMAlgCosmicTagger::Config config)
inline

Definition at line 82 of file PMAlgCosmicTagger.h.

85  ,
86 
91  ,
92 
100  , fStopperBuffer(config.StopperBuffer())
101  {}
fhicl::Atom< bool > TagFullHeightTracks
fhicl::Atom< bool > TagNonBeamT0Tracks
fhicl::Atom< double > TopFrontBackMargin
fhicl::Atom< double > NonBeamT0Margin
fhicl::Atom< bool > TagTopFrontBack
fhicl::Atom< bool > TagOutOfDriftTracks
fhicl::Atom< bool > TagApparentStopper
fhicl::Atom< double > FullCrossingMargin
fhicl::Atom< double > OutOfDriftMargin
fhicl::Atom< double > ApparentStopperMargin
fhicl::Atom< bool > TagFullWidthTracks
fhicl::Atom< double > StopperBuffer
fhicl::Atom< bool > VetoActualStopper
fhicl::Atom< bool > TagFullLengthTracks

Member Function Documentation

short int pma::PMAlgCosmicTagger::ConvertDirToInt ( const geo::Vector_t dir) const
private

Definition at line 443 of file PMAlgCosmicTagger.cxx.

Referenced by fullHeightCrossing(), fullLengthCrossing(), fullWidthCrossing(), tagApparentStopper(), and tagTopFrontBack().

444 {
445 
446  if (dir.X() > 0.99) return 0;
447  if (dir.Y() > 0.99) return 1;
448  if (dir.Z() > 0.99)
449  return 2;
450 
451  else
452  return -1;
453 }
TDirectory * dir
Definition: macro.C:5
size_t pma::PMAlgCosmicTagger::fullCrossingTagger ( pma::TrkCandidateColl tracks,
int  direction 
) const
private

Definition at line 339 of file PMAlgCosmicTagger.cxx.

References fDimensionsMax, fDimensionsMin, fFullCrossingMargin, pma::Track3D::kCosmic, pma::Track3D::kGeometry_XX, pma::Track3D::kGeometry_YY, pma::Track3D::kGeometry_ZZ, pma::Track3D::kNotTagged, n, and pma::TrkCandidateColl::tracks().

Referenced by fullHeightCrossing(), fullLengthCrossing(), and fullWidthCrossing().

341 {
342 
343  if (direction == -1) {
344  mf::LogWarning("pma::PMAlgCosmicTagger")
345  << " - Could not recognise direction, not attempting to perform fullCrossingTagger.";
346  return 0;
347  }
348 
349  size_t n = 0;
350 
351  double detDim = fDimensionsMax[direction] - fDimensionsMin[direction];
352 
354  switch (direction) {
355  case 0: dirTag = pma::Track3D::kGeometry_XX; break;
356  case 1: dirTag = pma::Track3D::kGeometry_YY; break;
357  case 2: dirTag = pma::Track3D::kGeometry_ZZ; break;
358  default: dirTag = pma::Track3D::kNotTagged; break;
359  }
360 
361  // Loop over the tracks
362  for (auto& t : tracks.tracks()) {
363 
364  // Get the first and last positions from the track.
365  auto const& node0 = *(t.Track()->Nodes()[0]);
366  auto const& node1 = *(t.Track()->Nodes()[t.Track()->Nodes().size() - 1]);
367 
368  // Get the length of the track in the requested direction
369  double trkDim = fabs(node0.Point3D()[direction] - node1.Point3D()[direction]);
370 
371  if ((detDim - trkDim) < fFullCrossingMargin) {
372  ++n;
373  t.Track()->SetTagFlag(pma::Track3D::kCosmic);
374  t.Track()->SetTagFlag(dirTag);
375  mf::LogInfo("pma::PMAlgCosmicTagger") << " -- track tagged in direction " << direction
376  << " with " << trkDim << " (c.f. " << detDim << ")";
377  }
378  }
379 
380  return n;
381 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< double > fDimensionsMin
std::vector< double > fDimensionsMax
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Char_t n[5]
std::vector< TrkCandidate > const & tracks() const
size_t pma::PMAlgCosmicTagger::fullHeightCrossing ( pma::TrkCandidateColl tracks) const
private

Definition at line 297 of file PMAlgCosmicTagger.cxx.

References ConvertDirToInt(), dir, fullCrossingTagger(), and n.

Referenced by tag().

298 {
299 
300  // Just use the first tpc to get the height dimension (instead of assuming y).
301  auto const* geom = lar::providerFrom<geo::Geometry>();
302  auto const dir = geom->TPC().HeightDir();
303 
304  size_t n = fullCrossingTagger(tracks, ConvertDirToInt(dir));
305 
306  mf::LogInfo("pma::PMAlgCosmicTagger")
307  << " - Tagged " << n << " tracks crossing the full detector height";
308  return n;
309 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
short int ConvertDirToInt(const geo::Vector_t &dir) const
TDirectory * dir
Definition: macro.C:5
Char_t n[5]
size_t fullCrossingTagger(pma::TrkCandidateColl &tracks, int direction) const
size_t pma::PMAlgCosmicTagger::fullLengthCrossing ( pma::TrkCandidateColl tracks) const
private

Definition at line 325 of file PMAlgCosmicTagger.cxx.

References ConvertDirToInt(), dir, fullCrossingTagger(), and n.

Referenced by tag().

326 {
327 
328  // Just use the first tpc to get the length dimension (instead of assuming z).
329  auto const* geom = lar::providerFrom<geo::Geometry>();
330  auto const dir = geom->TPC().LengthDir();
331 
332  size_t n = fullCrossingTagger(tracks, ConvertDirToInt(dir));
333 
334  mf::LogInfo("pma::PMAlgCosmicTagger")
335  << " - Tagged " << n << " tracks crossing the full detector length";
336  return n;
337 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
short int ConvertDirToInt(const geo::Vector_t &dir) const
TDirectory * dir
Definition: macro.C:5
Char_t n[5]
size_t fullCrossingTagger(pma::TrkCandidateColl &tracks, int direction) const
size_t pma::PMAlgCosmicTagger::fullWidthCrossing ( pma::TrkCandidateColl tracks) const
private

Definition at line 311 of file PMAlgCosmicTagger.cxx.

References ConvertDirToInt(), dir, fullCrossingTagger(), and n.

Referenced by tag().

312 {
313 
314  // Just use the first tpc to get the width dimension (instead of assuming x).
315  auto const* geom = lar::providerFrom<geo::Geometry>();
316  auto const dir = geom->TPC().WidthDir();
317 
318  size_t n = fullCrossingTagger(tracks, ConvertDirToInt(dir));
319 
320  mf::LogInfo("pma::PMAlgCosmicTagger")
321  << " - Tagged " << n << " tracks crossing the full detector width";
322  return n;
323 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
short int ConvertDirToInt(const geo::Vector_t &dir) const
TDirectory * dir
Definition: macro.C:5
Char_t n[5]
size_t fullCrossingTagger(pma::TrkCandidateColl &tracks, int direction) const
void pma::PMAlgCosmicTagger::GetDimensions ( )
private

Definition at line 402 of file PMAlgCosmicTagger.cxx.

References fDimensionsMax, fDimensionsMin, maxY, and minY.

Referenced by tag().

403 {
404 
405  // Need to find the minimum and maximum height values from the geometry.
406  double minX = 1.e6;
407  double maxX = -1.e6;
408  double minY = 1.e6;
409  double maxY = -1.e6;
410  double minZ = 1.e6;
411  double maxZ = -1.e6;
412 
413  auto const* geom = lar::providerFrom<geo::Geometry>();
414 
415  // Since we can stack TPCs, we can't just use geom::TPCGeom::Height()
416  for (geo::TPCGeo const& TPC : geom->Iterate<geo::TPCGeo>()) {
417  // We need to make sure we only include the real TPCs We have dummy TPCs in the
418  // protoDUNE and DUNE geometries The dummy ones have a drift distance of only ~13 cm.
419  if (TPC.DriftDistance() < 25.0) { continue; }
420 
421  // get center in world coordinates
422  auto const center = TPC.GetCenter();
423  double tpcDim[3] = {TPC.HalfWidth(), TPC.HalfHeight(), 0.5 * TPC.Length()};
424 
425  if (center.X() - tpcDim[0] < minX) minX = center.X() - tpcDim[0];
426  if (center.X() + tpcDim[0] > maxX) maxX = center.X() + tpcDim[0];
427  if (center.Y() - tpcDim[1] < minY) minY = center.Y() - tpcDim[1];
428  if (center.Y() + tpcDim[1] > maxY) maxY = center.Y() + tpcDim[1];
429  if (center.Z() - tpcDim[2] < minZ) minZ = center.Z() - tpcDim[2];
430  if (center.Z() + tpcDim[2] > maxZ) maxZ = center.Z() + tpcDim[2];
431  } // for all TPC
432 
433  fDimensionsMin.clear();
434  fDimensionsMax.clear();
435  fDimensionsMin.push_back(minX);
436  fDimensionsMin.push_back(minY);
437  fDimensionsMin.push_back(minZ);
438  fDimensionsMax.push_back(maxX);
439  fDimensionsMax.push_back(maxY);
440  fDimensionsMax.push_back(maxZ);
441 }
double minY
Definition: plot_hist.C:9
Geometry information for a single TPC.
Definition: TPCGeo.h:33
double maxY
Definition: plot_hist.C:10
std::vector< double > fDimensionsMin
std::vector< double > fDimensionsMax
bool pma::PMAlgCosmicTagger::isFrontBackVertex ( const TVector3 &  pos,
double  tolerance,
short int  dirIndx 
) const
private

Definition at line 391 of file PMAlgCosmicTagger.cxx.

References fDimensionsMax, and fDimensionsMin.

Referenced by tagTopFrontBack().

394 {
395 
396  bool front = (fabs(pos[dirIndx] - fDimensionsMin[dirIndx]) < tolerance);
397  bool back = (fabs(pos[dirIndx] - fDimensionsMax[dirIndx]) < tolerance);
398 
399  return front || back;
400 }
std::vector< double > fDimensionsMin
std::vector< double > fDimensionsMax
bool pma::PMAlgCosmicTagger::isTopVertex ( const TVector3 &  pos,
double  tolerance,
short int  dirIndx 
) const
private

Definition at line 383 of file PMAlgCosmicTagger.cxx.

References fDimensionsMax.

Referenced by tagTopFrontBack().

386 {
387 
388  return (fabs(pos[dirIndx] - fDimensionsMax[dirIndx]) < tolerance);
389 }
std::vector< double > fDimensionsMax
size_t pma::PMAlgCosmicTagger::nonBeamT0Tag ( detinfo::DetectorClocksData const &  clockData,
pma::TrkCandidateColl tracks 
) const
private

Definition at line 103 of file PMAlgCosmicTagger.cxx.

References fNonBeamT0Margin, pma::Track3D::kBeamIncompatible, pma::Track3D::kCosmic, n, pma::TrkCandidateColl::tracks(), and detinfo::trigger_offset().

Referenced by tag().

105 {
106  size_t n = 0;
107 
108  // Search through all of the tracks
109  for (auto& t : tracks.tracks()) {
110 
111  // Non zero T0 means we reconstructed it
112  if (t.Track()->GetT0() != 0.0) {
113  mf::LogInfo("pma::PMAlgCosmicTagger") << " - track with T0 = " << t.Track()->GetT0();
114 
115  if (fabs(t.Track()->GetT0() - trigger_offset(clockData)) > fNonBeamT0Margin) {
116  ++n;
117  t.Track()->SetTagFlag(pma::Track3D::kCosmic);
118  t.Track()->SetTagFlag(pma::Track3D::kBeamIncompatible);
119  }
120  }
121  }
122 
123  mf::LogInfo("pma::PMAlgCosmicTagger") << " - Tagged " << n << " non-beam T0 tracks.";
124  return n;
125 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int trigger_offset(DetectorClocksData const &data)
Char_t n[5]
std::vector< TrkCandidate > const & tracks() const
size_t pma::PMAlgCosmicTagger::outOfDriftWindow ( pma::TrkCandidateColl tracks) const
private

Definition at line 46 of file PMAlgCosmicTagger.cxx.

References fOutOfDriftMargin, pma::Track3D::kCosmic, pma::Track3D::kOutsideDrift_Complete, pma::Track3D::kOutsideDrift_Partial, n, pma::Track3D::Nodes(), pma::Track3D::SetTagFlag(), geo::to_int(), pma::TrkCandidateColl::tracks(), geo::X, geo::Y, and geo::Z.

Referenced by tag().

47 {
48  mf::LogInfo("pma::PMAlgCosmicTagger") << " - tag tracks out of 1 drift window;";
49  size_t n = 0;
50 
51  auto const* geom = lar::providerFrom<geo::Geometry>();
52 
53  for (auto& t : tracks.tracks()) {
54 
55  pma::Track3D& trk = *(t.Track());
56 
57  bool node_out_of_drift_min = false;
58  bool node_out_of_drift_max = false;
59  for (size_t nidx = 0; nidx < trk.Nodes().size(); ++nidx) {
60  auto const& node = *(trk.Nodes()[nidx]);
61  auto const& tpcGeo = geom->TPC(geo::TPCID(node.Cryo(), node.TPC()));
62  double min{std::numeric_limits<double>::max()};
63  double max{std::numeric_limits<double>::min()};
64  auto const [axis, _] = tpcGeo.DriftAxisWithSign();
65  switch (axis) {
66  case geo::Coordinate::X:
67  min = tpcGeo.MinX();
68  max = tpcGeo.MaxX();
69  break;
70  case geo::Coordinate::Y:
71  min = tpcGeo.MinY();
72  max = tpcGeo.MaxY();
73  break;
74  case geo::Coordinate::Z:
75  min = tpcGeo.MinZ();
76  max = tpcGeo.MaxZ();
77  break;
78  }
79  double const p = node.Point3D()[to_int(axis)];
80  if (p < min - fOutOfDriftMargin) { node_out_of_drift_min = true; }
81  if (p > max + fOutOfDriftMargin) { node_out_of_drift_max = true; }
82  }
83 
84  if (node_out_of_drift_min && node_out_of_drift_max) {
87  ++n;
88  }
89  else if (node_out_of_drift_min || node_out_of_drift_max) {
92  ++n;
93  }
94  }
95 
96  mf::LogInfo("pma::PMAlgCosmicTagger") << " - Tagged " << n << " tracks out of 1 drift window.";
97 
98  return n;
99 }
void SetTagFlag(ETag value)
Definition: PmaTrack3D.h:68
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
constexpr int to_int(Coordinate const coord) noexcept
Enumerate the possible plane projections.
Definition: geo_types.h:124
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
Char_t n[5]
std::vector< pma::Node3D * > const & Nodes() const noexcept
Definition: PmaTrack3D.h:274
std::vector< TrkCandidate > const & tracks() const
void pma::PMAlgCosmicTagger::tag ( detinfo::DetectorClocksData const &  clockData,
pma::TrkCandidateColl tracks 
)

Definition at line 24 of file PMAlgCosmicTagger.cxx.

References fTagApparentStopper, fTagFullHeightTracks, fTagFullLengthTracks, fTagFullWidthTracks, fTagNonBeamT0Tracks, fTagOutOfDriftTracks, fTagTopFrontBack, fullHeightCrossing(), fullLengthCrossing(), fullWidthCrossing(), GetDimensions(), n, nonBeamT0Tag(), outOfDriftWindow(), pma::TrkCandidateColl::size(), tagApparentStopper(), and tagTopFrontBack().

Referenced by pma::PMAlgTracker::build().

26 {
27  // Get the detector dimensions
28  GetDimensions();
29 
30  mf::LogInfo("pma::PMAlgCosmicTagger")
31  << "Passed " << tracks.size() << " tracks for tagging cosmics.";
32 
33  size_t n = 0;
34 
35  if (fTagOutOfDriftTracks) n += outOfDriftWindow(tracks);
36  if (fTagFullHeightTracks) n += fullHeightCrossing(tracks);
37  if (fTagFullWidthTracks) n += fullWidthCrossing(tracks);
38  if (fTagFullLengthTracks) n += fullLengthCrossing(tracks);
39  if (fTagNonBeamT0Tracks) n += nonBeamT0Tag(clockData, tracks);
40  if (fTagTopFrontBack) n += tagTopFrontBack(tracks);
41  if (fTagApparentStopper) n += tagApparentStopper(tracks);
42 
43  mf::LogInfo("pma::PMAlgCosmicTagger") << "...tagged " << n << " cosmic-like tracks.";
44 }
size_t fullWidthCrossing(pma::TrkCandidateColl &tracks) const
size_t size() const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
size_t tagApparentStopper(pma::TrkCandidateColl &tracks) const
size_t outOfDriftWindow(pma::TrkCandidateColl &tracks) const
size_t nonBeamT0Tag(detinfo::DetectorClocksData const &clockData, pma::TrkCandidateColl &tracks) const
size_t tagTopFrontBack(pma::TrkCandidateColl &tracks) const
size_t fullHeightCrossing(pma::TrkCandidateColl &tracks) const
Char_t n[5]
size_t fullLengthCrossing(pma::TrkCandidateColl &tracks) const
bool pma::PMAlgCosmicTagger::tagAny ( ) const
inline
size_t pma::PMAlgCosmicTagger::tagApparentStopper ( pma::TrkCandidateColl tracks) const
private

Definition at line 170 of file PMAlgCosmicTagger.cxx.

References util::begin(), ConvertDirToInt(), d, util::end(), fApparentStopperMargin, fDimensionsMax, fDimensionsMin, fStopperBuffer, fVetoActualStopper, Get, pma::Track3D::kCosmic, pma::Track3D::kGeometry_Y, pmtana::mean(), n, sum, and pma::TrkCandidateColl::tracks().

Referenced by tag().

171 {
172 
173  size_t n = 0;
174 
175  // Tracks entering from the top of the detector that stop in the fiducial volume
176  // are very likely to be cosmics that leave through the APA, but have their
177  // drift coordinate incorrectly set due to lack of T0
178  auto const* geom = lar::providerFrom<geo::Geometry>();
179  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout>()->Get();
180 
181  short int hIdx = ConvertDirToInt(geom->TPC().HeightDir());
182 
183  // Loop over the tracks
184  for (auto& t : tracks.tracks()) {
185 
186  // Get the first and last positions from the track.
187  auto const& node0 = *(t.Track()->Nodes()[0]);
188  auto const& node1 = *(t.Track()->Nodes()[t.Track()->Nodes().size() - 1]);
189 
190  // Check which end is the vertex (assume the largest height)
191  TVector3 vtx =
192  (node0.Point3D()[hIdx] > node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
193  TVector3 end =
194  (node0.Point3D()[hIdx] <= node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
195 
196  if (fabs(vtx[hIdx] - fDimensionsMax[hIdx]) < fApparentStopperMargin) {
197  // Check the other element to see if it ends away from the bottom of the detector
198  if (fabs(end[hIdx] - fDimensionsMin[hIdx]) > 5. * fApparentStopperMargin) {
199 
200  // We now need to loop over all of the tracks to see if any start within fStopperBuffer of our end point.
201  bool foundTrack = false;
202  for (auto const& tt : tracks.tracks()) {
203  // Don't match with itself!
204  if ((&tt) == (&t)) continue;
205 
206  // Compare this track with our main track
207  TVector3 trkVtx = (tt.Track()->Nodes()[0])->Point3D();
208  TVector3 trkEnd = (tt.Track()->Nodes()[tt.Track()->Nodes().size() - 1])->Point3D();
209 
210  if ((end - trkVtx).Mag() < fStopperBuffer || (end - trkEnd).Mag() < fStopperBuffer) {
211  foundTrack = true;
212  break;
213  }
214  }
215  if (foundTrack) {
216  // This isn't really a stopping particle, so move on
217  continue;
218  }
219 
220  // If we don't mind about tagging all stopping particles then this satisfies our requirements
221  if (!fVetoActualStopper) {
222  ++n;
223  t.Track()->SetTagFlag(pma::Track3D::kCosmic);
224  t.Track()->SetTagFlag(pma::Track3D::kGeometry_Y);
225  continue;
226  }
227 
228  // If we want to actually ignore the stopping particles, use de/dx...
229  // Store the number of sigma from the mean for the final dedx point in each view
230  std::vector<float> nSigmaPerView;
231 
232  // Loop over the views
233  for (auto const view : wireReadoutGeom.Views()) {
234 
235  // Get the dedx for this track and view
236  std::map<size_t, std::vector<double>> dedx;
237  t.Track()->GetRawdEdxSequence(dedx, view);
238 
239  std::vector<double> trk_dedx;
240 
241  for (int h = t.Track()->NextHit(-1, view); h != -1; h = t.Track()->NextHit(h, view)) {
242  // If this is the last hit then this method won't work
243  if (h > t.Track()->PrevHit(t.Track()->size(), view)) break;
244  // Make sure we have a reasonable value
245  if (dedx[h][5] / dedx[h][6] <= 0 || dedx[h][5] / dedx[h][6] > 1e6) continue;
246  trk_dedx.push_back(dedx[h][5] / dedx[h][6]);
247  }
248 
249  if (trk_dedx.size() == 0) {
250  mf::LogInfo("pma::PMAlgCosmicTagger")
251  << "View " << view << " has no hits." << std::endl;
252  continue;
253  }
254 
255  double sum = std::accumulate(std::begin(trk_dedx), std::end(trk_dedx), 0.0);
256  double mean = sum / static_cast<double>(trk_dedx.size());
257  double accum = 0.0;
258  std::for_each(std::begin(trk_dedx), std::end(trk_dedx), [&](const double d) {
259  accum += (d - mean) * (d - mean);
260  });
261  double stdev = sqrt(accum / static_cast<double>(trk_dedx.size() - 1));
262 
263  mf::LogInfo("pma::PMAlgCosmicTagger")
264  << " View " << view << " has average dedx " << mean << " +/- " << stdev
265  << " and final dedx " << trk_dedx[trk_dedx.size() - 1] << std::endl;
266 
267  nSigmaPerView.push_back(fabs((trk_dedx[trk_dedx.size() - 1] - mean) / stdev));
268  }
269 
270  bool notStopper = true;
271  short unsigned int n2Sigma = 0;
272  short unsigned int n3Sigma = 0;
273  for (auto const nSigma : nSigmaPerView) {
274  if (nSigma >= 2.0) ++n2Sigma;
275  if (nSigma >= 3.0) ++n3Sigma;
276  }
277 
278  if (n3Sigma > 0) notStopper = false;
279  if (n2Sigma == nSigmaPerView.size()) notStopper = false;
280 
281  if (notStopper) {
282  ++n;
283  t.Track()->SetTagFlag(pma::Track3D::kCosmic);
284  t.Track()->SetTagFlag(pma::Track3D::kGeometry_Y);
285  }
286  } // Check on bottom position
287  } // Check on top position
288  } // End loop over tracks
289 
290  mf::LogInfo("pma::PMAlgCosmicTagger")
291  << " - Tagged " << n << " tracks stopping in the detector after starting at the top."
292  << std::endl;
293 
294  return n;
295 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
short int ConvertDirToInt(const geo::Vector_t &dir) const
std::vector< double > fDimensionsMin
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
Definition: type_traits.h:61
Float_t d
Definition: plot.C:235
std::vector< double > fDimensionsMax
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
Char_t n[5]
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
Double_t sum
Definition: plot.C:31
std::vector< TrkCandidate > const & tracks() const
size_t pma::PMAlgCosmicTagger::tagTopFrontBack ( pma::TrkCandidateColl tracks) const
private

Definition at line 127 of file PMAlgCosmicTagger.cxx.

References ConvertDirToInt(), util::end(), fTopFrontBackMargin, isFrontBackVertex(), isTopVertex(), pma::Track3D::kCosmic, pma::Track3D::kGeometry_YZ, n, and pma::TrkCandidateColl::tracks().

Referenced by tag().

128 {
129 
130  size_t n = 0;
131 
132  auto const* geom = lar::providerFrom<geo::Geometry>();
133 
134  short int hIdx = ConvertDirToInt(geom->TPC().HeightDir());
135  short int lIdx = ConvertDirToInt(geom->TPC().LengthDir());
136 
137  // Loop over the tracks
138  for (auto& t : tracks.tracks()) {
139 
140  // Get the first and last positions from the track.
141  auto const& node0 = *(t.Track()->Nodes()[0]);
142  auto const& node1 = *(t.Track()->Nodes()[t.Track()->Nodes().size() - 1]);
143 
144  // Check which end is the vertex (assume the largest height)
145  TVector3 vtx =
146  (node0.Point3D()[hIdx] > node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
147  TVector3 end =
148  (node0.Point3D()[hIdx] <= node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
149 
150  // Check we have a track starting at the top of the detector
151  bool top = isTopVertex(vtx, fTopFrontBackMargin, hIdx);
152 
153  // Check the track ends at the front or back of the detector
154  bool frontBack = isFrontBackVertex(end, fTopFrontBackMargin, lIdx);
155 
156  // Check we path both criteria but without letting either the start or end of the track fulfill both
157  if (top && frontBack) {
158  ++n;
159  t.Track()->SetTagFlag(pma::Track3D::kCosmic);
160  t.Track()->SetTagFlag(pma::Track3D::kGeometry_YZ);
161  }
162  }
163 
164  mf::LogInfo("pma::PMAlgCosmicTagger")
165  << " - Tagged " << n << " tracks crossing from top to front/back." << std::endl;
166 
167  return n;
168 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
short int ConvertDirToInt(const geo::Vector_t &dir) const
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool isFrontBackVertex(const TVector3 &pos, double tolerance, short int dirIndx) const
Char_t n[5]
bool isTopVertex(const TVector3 &pos, double tolerance, short int dirIndx) const
std::vector< TrkCandidate > const & tracks() const

Member Data Documentation

double pma::PMAlgCosmicTagger::fApparentStopperMargin
private

Definition at line 147 of file PMAlgCosmicTagger.h.

Referenced by tagApparentStopper().

std::vector<double> pma::PMAlgCosmicTagger::fDimensionsMax
private
std::vector<double> pma::PMAlgCosmicTagger::fDimensionsMin
private
double pma::PMAlgCosmicTagger::fFullCrossingMargin
private

Definition at line 137 of file PMAlgCosmicTagger.h.

Referenced by fullCrossingTagger().

double pma::PMAlgCosmicTagger::fNonBeamT0Margin
private

Definition at line 141 of file PMAlgCosmicTagger.h.

Referenced by nonBeamT0Tag().

double pma::PMAlgCosmicTagger::fOutOfDriftMargin
private

Definition at line 131 of file PMAlgCosmicTagger.h.

Referenced by outOfDriftWindow().

double pma::PMAlgCosmicTagger::fStopperBuffer
private

Definition at line 149 of file PMAlgCosmicTagger.h.

Referenced by tagApparentStopper().

bool pma::PMAlgCosmicTagger::fTagApparentStopper
private

Definition at line 146 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagFullHeightTracks
private

Definition at line 134 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagFullLengthTracks
private

Definition at line 136 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagFullWidthTracks
private

Definition at line 135 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagNonBeamT0Tracks
private

Definition at line 140 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagOutOfDriftTracks
private

Definition at line 130 of file PMAlgCosmicTagger.h.

Referenced by tag().

bool pma::PMAlgCosmicTagger::fTagTopFrontBack
private

Definition at line 143 of file PMAlgCosmicTagger.h.

Referenced by tag().

double pma::PMAlgCosmicTagger::fTopFrontBackMargin
private

Definition at line 144 of file PMAlgCosmicTagger.h.

Referenced by tagTopFrontBack().

bool pma::PMAlgCosmicTagger::fVetoActualStopper
private

Definition at line 148 of file PMAlgCosmicTagger.h.

Referenced by tagApparentStopper().


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