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