All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbndcode/sbndcode/CosmicId/Algs/ApaCrossCosmicIdAlg.cc
Go to the documentation of this file.
1 #include "ApaCrossCosmicIdAlg.h"
2 
4 
5 namespace sbnd{
6 
8 
9  this->reconfigure(config);
10 
11 }
12 
13 
15 
16 }
17 
18 
20 
21 }
22 
23 
25 
26  fDistanceLimit = config.DistanceLimit();
28  fBeamTimeMin = config.BeamTimeLimits().BeamTimeMin();
29  fBeamTimeMax = config.BeamTimeLimits().BeamTimeMax();
30 
31  return;
32 }
33 
34 
35 // Get the minimum distance from track to APA for different times
37  recob::Track track, std::vector<double> t0List, int tpc){
38 
39  double crossTime = -99999;
40  double xmax = fTpcGeo.MaxX();
41 
42  double minDist = 99999;
43  double startX = track.Vertex().X();
44  double endX = track.End().X();
45  geo::Point_t point = track.Vertex();
46 
47  // Don't try to shift tracks near the APA (may give artificially small distances)
48  if(std::abs(startX) > xmax - fMaxApaDistance
49  || std::abs(endX) > xmax - fMaxApaDistance) return std::make_pair(minDist, crossTime);
50 
51  // If in TPC 0 use start/end with lowest X
52  if(tpc == 0 && endX < startX) point = track.End();
53 
54  // If in TPC 1 use start/end with highest X
55  if(tpc == 1 && endX > startX) point = track.End();
56 
57  // If in both TPCs (stitched) return null values
58  if(tpc == -1) return std::make_pair(minDist, crossTime);
59 
60  // Shift track by all t0's
61  for(auto const& t0 : t0List){
62  // If particle crosses the APA before t = 0 the crossing point won't be reconstructed
63  if(t0 < 0) continue;
64  double shiftedX = point.X();
65  double shift = t0 * detProp.DriftVelocity();
66  if(tpc == 0) shiftedX = point.X() - shift;
67  if(tpc == 1) shiftedX = point.X() + shift;
68 
69  //Check track still in TPC
70  if(std::abs(shiftedX) > (xmax + fDistanceLimit)) continue;
71  //Calculate distance between start/end and APA
72  double dist = std::abs(std::abs(shiftedX) - xmax);
73  if(dist < minDist) {
74  minDist = dist;
75  crossTime = t0;
76  }
77  }
78 
79  return std::make_pair(minDist, crossTime);
80 
81 }
82 
83 
84 // Get time by matching tracks which cross the APA
86  recob::Track track, std::vector<double> t0List, int tpc){
87 
88  // Get the minimum distance to the APA and corresponding time
89  std::pair<double, double> min = MinApaDistance(detProp, track, t0List, tpc);
90  // Check the distance is within allowed limit
91  if(min.first < fDistanceLimit) return min.second;
92  return -99999;
93 
94 }
95 
96 
97 // Get the distance from track to APA at fixed time
99  recob::Track track, double t0, std::vector<art::Ptr<recob::Hit>> hits){
100 
101  std::vector<double> t0List {t0};
102  // Determine the TPC from hit collection
103  int tpc = fTpcGeo.DetectedInTPC(hits);
104  // Get the distance to the APA at the given time
105  std::pair<double, double> min = MinApaDistance(detProp, track, t0List, tpc);
106  return min.first;
107 
108 }
109 
110 // Work out what TPC track is in and get the minimum distance from track to APA for different times
112  recob::Track track, std::vector<art::Ptr<recob::Hit>> hits, std::vector<double> t0Tpc0, std::vector<double> t0Tpc1){
113 
114  // Determine the TPC from hit collection
115  int tpc = fTpcGeo.DetectedInTPC(hits);
116  // Get the minimum distance from the APA in the corresponding TPC (with corresponding flashes)
117  if(tpc == 0){
118  return MinApaDistance(detProp, track, t0Tpc0, tpc);
119  }
120  if(tpc == 1){
121  return MinApaDistance(detProp, track, t0Tpc1, tpc);
122  }
123  return std::make_pair(-99999, -99999);
124 }
125 
126 
127 // Tag tracks with times outside the beam
129  recob::Track track, std::vector<art::Ptr<recob::Hit>> hits, std::vector<double> t0Tpc0, std::vector<double> t0Tpc1){
130 
131  // Determine the TPC from hit collection
132  int tpc = fTpcGeo.DetectedInTPC(hits);
133 
134  // Get the minimum distance from the APA in the corresponding TPC (with corresponding flashes)
135  if(tpc == 0){
136  // Get the closest matched time with distance below limit
137  double crossTimeThrough = T0FromApaCross(detProp, track, t0Tpc0, tpc);
138  // If the matched time is outside of the beam time then tag as a cosmic
139  if(crossTimeThrough != -99999 && (crossTimeThrough < fBeamTimeMin || crossTimeThrough > fBeamTimeMax)) return true;
140  }
141  if(tpc == 1){
142  double crossTimeThrough = T0FromApaCross(detProp, track, t0Tpc1, tpc);
143  if(crossTimeThrough != -99999 && (crossTimeThrough < fBeamTimeMin || crossTimeThrough > fBeamTimeMax)) return true;
144  }
145 
146  return false;
147 
148 }
149 
150 }
process_name use argoneut_mc_hitfinder track
shift
Definition: fcl_checks.sh:26
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
double ApaDistance(detinfo::DetectorPropertiesData const &detProp, recob::Track track, double t0, std::vector< art::Ptr< recob::Hit >> hits)
T abs(T value)
Point_t const & Vertex() const
std::pair< double, double > MinApaDistance(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< double > t0List, int tpc)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Point_t const & End() const
bool ApaCrossCosmicId(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< art::Ptr< recob::Hit >> hits, std::vector< double > t0Tpc0, std::vector< double > t0Tpc1)
stream1 can override from command line with o or output services user sbnd
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
auto const detProp
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
double T0FromApaCross(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< double > t0List, int tpc)