LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PMAlgCosmicTagger.h
Go to the documentation of this file.
1 // Class: PMAlgCosmicTagger
3 // Author: L. Whitehead (leigh.howard.whitehead@cern.ch),
4 // R. Sulej (robert.sulej@cern.ch) March 2017
6 
7 #ifndef PMAlgCosmicTagger_h
8 #define PMAlgCosmicTagger_h
9 
11 
12 #include "fhiclcpp/types/Atom.h"
13 #include "fhiclcpp/types/Comment.h"
14 #include "fhiclcpp/types/Name.h"
15 
16 class TVector3;
17 
18 namespace detinfo {
19  class DetectorClocksData;
20 }
21 
22 namespace pma {
23  class PMAlgCosmicTagger;
24  class TrkCandidateColl;
25 }
26 
27 #include <vector>
28 
30 
31 public:
32  struct Config {
33  using Name = fhicl::Name;
35 
36  fhicl::Atom<bool> TagOutOfDriftTracks{Name("TagOutOfDriftTracks"),
37  Comment("Tag tracks sticking out of 1 drift window.")};
38  fhicl::Atom<double> OutOfDriftMargin{
39  Name("OutOfDriftMargin"),
40  Comment("The minimum distance beyond 1 drift window required for tagging track as a cosmic "
41  "background.")};
42 
43  fhicl::Atom<bool> TagFullHeightTracks{Name("TagFullHeightTracks"),
44  Comment("Tag tracks crossing full detector height")};
45  fhicl::Atom<bool> TagFullWidthTracks{Name("TagFullWidthTracks"),
46  Comment("Tag tracks crossing full detector width")};
47  fhicl::Atom<bool> TagFullLengthTracks{Name("TagFullLengthTracks"),
48  Comment("Tag tracks crossing full detector length")};
49  fhicl::Atom<double> FullCrossingMargin{
50  Name("FullCrossingMargin"),
51  Comment("The maximum distance between the track length and detector length for full detector "
52  "crossing tracks.")};
53  fhicl::Atom<bool> TagNonBeamT0Tracks{
54  Name("TagNonBeamT0Tracks"),
55  Comment("Tag particles with reconstructed T0 not consistent with the beam")};
56  fhicl::Atom<double> NonBeamT0Margin{
57  Name("NonBeamT0Margin"),
58  Comment("Tag only those events at least <margin> from the beam time")};
59  fhicl::Atom<bool> TagTopFrontBack{Name("TagTopFrontBack"),
60  Comment("Tag tracks that enter through the top of the "
61  "detector and exit through the front or back")};
62  fhicl::Atom<double> TopFrontBackMargin{
63  Name("TopFrontBackMargin"),
64  Comment("Distance tolerence from the top, front and back of the detector")};
65  fhicl::Atom<bool> TagApparentStopper{
66  Name("TagApparentStopper"),
67  Comment("Tag tracks that enter through the top of the detector appear to stop (without "
68  "seeing evidence of stopping)")};
69  fhicl::Atom<double> ApparentStopperMargin{
70  Name("ApparentStopperMargin"),
71  Comment(
72  "Distance tolerence from the top of the detector to be considered coming in from the top")};
73  fhicl::Atom<bool> VetoActualStopper{
74  Name("VetoActualStopper"),
75  Comment("If true: use de/dx information to identify stopping muons but do not tag them")};
76  fhicl::Atom<double> StopperBuffer{
77  Name("StopperBuffer"),
78  Comment(
79  "Should find no tracks starting within this distance from the end point of the track")};
80  };
81 
83  : fTagOutOfDriftTracks(config.TagOutOfDriftTracks())
84  , fOutOfDriftMargin(config.OutOfDriftMargin())
85  ,
86 
87  fTagFullHeightTracks(config.TagFullHeightTracks())
88  , fTagFullWidthTracks(config.TagFullWidthTracks())
89  , fTagFullLengthTracks(config.TagFullLengthTracks())
90  , fFullCrossingMargin(config.FullCrossingMargin())
91  ,
92 
93  fTagNonBeamT0Tracks(config.TagNonBeamT0Tracks())
94  , fNonBeamT0Margin(config.NonBeamT0Margin())
95  , fTagTopFrontBack(config.TagTopFrontBack())
96  , fTopFrontBackMargin(config.TopFrontBackMargin())
97  , fTagApparentStopper(config.TagApparentStopper())
98  , fApparentStopperMargin(config.ApparentStopperMargin())
99  , fVetoActualStopper(config.VetoActualStopper())
100  , fStopperBuffer(config.StopperBuffer())
101  {}
102 
103  bool tagAny() const
104  {
105  return (fTagOutOfDriftTracks || fTagFullHeightTracks || fTagFullWidthTracks ||
106  fTagFullLengthTracks || fTagNonBeamT0Tracks || fTagApparentStopper || fTagTopFrontBack);
107  }
108 
109  void tag(detinfo::DetectorClocksData const& clockData, pma::TrkCandidateColl& tracks);
110 
111 private:
112  size_t outOfDriftWindow(pma::TrkCandidateColl& tracks) const;
113  size_t fullHeightCrossing(pma::TrkCandidateColl& tracks) const;
114  size_t fullWidthCrossing(pma::TrkCandidateColl& tracks) const;
115  size_t fullLengthCrossing(pma::TrkCandidateColl& tracks) const;
116  size_t fullCrossingTagger(pma::TrkCandidateColl& tracks, int direction) const;
117  size_t nonBeamT0Tag(detinfo::DetectorClocksData const& clockData,
118  pma::TrkCandidateColl& tracks) const;
119  size_t tagTopFrontBack(pma::TrkCandidateColl& tracks) const;
120  size_t tagApparentStopper(pma::TrkCandidateColl& tracks) const;
121 
122  // Convenience functions to see if we have a vertex at the top of the detector
123  bool isTopVertex(const TVector3& pos, double tolerance, short int dirIndx) const;
124  // or at the front / back walls
125  bool isFrontBackVertex(const TVector3& pos, double tolerance, short int dirIndx) const;
126 
127  void GetDimensions(); // Use the geometry to get the extent of the detector in x, y and z.
128  short int ConvertDirToInt(const geo::Vector_t& dir) const; // Is the direction along x, y or z?
129  // Tagging parameters
130  bool fTagOutOfDriftTracks; // Tag tracks sticking out of 1 drift window.
131  double fOutOfDriftMargin; // Min distance [cm] beyond 1 drift window required
132  // for tagging track as a cosmic background.
133 
134  bool fTagFullHeightTracks; // Tag tracks crossing full height
135  bool fTagFullWidthTracks; // Tag tracks crossing full heightwidth
136  bool fTagFullLengthTracks; // Tag tracks crossing full heightlength
137  double fFullCrossingMargin; // Max distance [cm] between track dimension and
138  // detector dimension for crossing tracks.
139 
140  bool fTagNonBeamT0Tracks; // Tag tracks that have a reconstructed T0 outside of the beam range.
141  double fNonBeamT0Margin; // Range outside which we should consider events not beam related.
142 
145 
149  double fStopperBuffer; // A distance from the end of the track within which we
150  // should find no other track starting. Helps to
151  // prevent identifying broken tracks or interacting
152  // particles as stoppers.
153 
154  // The dimensions of the detector from the geometry
155  std::vector<double> fDimensionsMin;
156  std::vector<double> fDimensionsMax;
157 };
158 
159 #endif
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
std::vector< double > fDimensionsMin
PMAlgCosmicTagger(const pma::PMAlgCosmicTagger::Config &config)
Definitions of geometry vector data types.
std::vector< double > fDimensionsMax
General LArSoft Utilities.
Contains all timing reference information for the detector.
TDirectory * dir
Definition: macro.C:5