All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRTTrackMatchAlg.h
Go to the documentation of this file.
1 #ifndef CRTTRACKMATCHALG_H_SEEN
2 #define CRTTRACKMATCHALG_H_SEEN
3 
4 
5 ///////////////////////////////////////////////
6 // CRTTrackMatchAlg.h
7 //
8 // Functions for CRT TPC track matching
9 // T Brooks (tbrooks@fnal.gov), November 2018
10 ///////////////////////////////////////////////
11 
12 // framework
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "canvas/Persistency/Common/Ptr.h"
18 #include "canvas/Persistency/Common/PtrVector.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 #include "canvas/Persistency/Common/FindManyP.h"
22 
23 // LArSoft
27 #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom()
31 
32 // Utility libraries
33 #include "messagefacility/MessageLogger/MessageLogger.h"
34 #include "fhiclcpp/ParameterSet.h"
35 #include "fhiclcpp/types/Table.h"
36 #include "fhiclcpp/types/Atom.h"
37 #include "cetlib/pow.h" // cet::sum_of_squares()
38 
43 
44 // c++
45 #include <iostream>
46 #include <stdio.h>
47 #include <sstream>
48 #include <vector>
49 #include <map>
50 #include <utility>
51 #include <cmath>
52 #include <memory>
53 
54 // ROOT
55 #include "TVector3.h"
56 #include "TGeoManager.h"
57 
58 
59 namespace sbnd{
60 
62  public:
63 
64  struct Config {
65  using Name = fhicl::Name;
66  using Comment = fhicl::Comment;
67 
68  fhicl::Atom<double> MaxAngleDiff {
69  Name("MaxAngleDiff"),
70  Comment("")
71  };
72 
73  fhicl::Atom<double> MaxDistance {
74  Name("MaxDistance"),
75  Comment("")
76  };
77 
78  fhicl::Atom<double> MaxScore {
79  Name("MaxScore"),
80  Comment("")
81  };
82 
83  fhicl::Atom<art::InputTag> TPCTrackLabel {
84  Name("TPCTrackLabel"),
85  Comment("")
86  };
87 
88  fhicl::Atom<std::string> SelectionMetric {
89  Name("SelectionMetric"),
90  Comment("")
91  };
92 
93  };
94 
95  CRTTrackMatchAlg(const Config& config);
96  CRTTrackMatchAlg(const Config& config, geo::GeometryCore const* GeometryService);
97 
98  CRTTrackMatchAlg(const fhicl::ParameterSet& pset) :
99  CRTTrackMatchAlg(fhicl::Table<Config>(pset, {})()) {}
100  CRTTrackMatchAlg(const fhicl::ParameterSet& pset, geo::GeometryCore const* GeometryService) :
101  CRTTrackMatchAlg(fhicl::Table<Config>(pset, {})(), GeometryService) {}
102 
104 
106 
107  void reconfigure(const Config& config);
108 
109  // Calculate intersection between CRT track and TPC
110  std::pair<TVector3, TVector3> TpcIntersection(const geo::TPCGeo& tpcGeo, sbn::crt::CRTTrack track);
111 
112  // Function to calculate if a CRTTrack crosses the TPC volume
114 
115  // Function to calculate if a CRTTrack crosses the TPC volume
117 
119  recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks, const art::Event& event);
121  recob::Track tpcTrack, std::vector<art::Ptr<recob::Hit>> hits, std::vector<sbn::crt::CRTTrack> crtTracks);
122 
123  // Find the closest valid matching CRT track ID
125  recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks, const art::Event& event);
127  recob::Track tpcTrack, std::vector<art::Ptr<recob::Hit>> hits, std::vector<sbn::crt::CRTTrack> crtTracks);
128 
129  // Find the closest valid matching CRT track ID and return the minimised matching metric
131  recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks, const art::Event& event);
133  recob::Track tpcTrack, std::vector<art::Ptr<recob::Hit>> hits, std::vector<sbn::crt::CRTTrack> crtTracks);
134 
135  // Get all CRT tracks that cross the right TPC within an allowed time
136  std::vector<sbn::crt::CRTTrack> AllPossibleCRTTracks(detinfo::DetectorPropertiesData const& detProp,
137  recob::Track tpcTrack,
138  std::vector<sbn::crt::CRTTrack> crtTracks,
139  const art::Event& event);
140 
141  std::vector<sbn::crt::CRTTrack> AllPossibleCRTTracks(detinfo::DetectorPropertiesData const& detProp,
142  recob::Track tpcTrack,
143  std::vector<art::Ptr<recob::Hit>> hits,
144  std::vector<sbn::crt::CRTTrack> crtTracks);
145 
146  // Find the closest matching crt track by angle between tracks within angle and DCA limits
147  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByAngle(detinfo::DetectorPropertiesData const& detProp,
148  recob::Track tpcTrack,
149  std::vector<sbn::crt::CRTTrack> crtTracks,
150  const art::Event& event,
151  double minDCA = 0.);
152  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByAngle(detinfo::DetectorPropertiesData const& detProp,
153  recob::Track tpcTrack,
154  std::vector<art::Ptr<recob::Hit>> hits,
155  std::vector<sbn::crt::CRTTrack> crtTracks,
156  double minDCA = 0.);
157  // Find the closest matching crt track by average DCA between tracks within angle and DCA limits
158  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByDCA(detinfo::DetectorPropertiesData const& detProp,
159  recob::Track tpcTrack,
160  std::vector<sbn::crt::CRTTrack> crtTracks,
161  const art::Event& event,
162  double minAngle = 0.);
163  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByDCA(detinfo::DetectorPropertiesData const& detProp,
164  recob::Track tpcTrack,
165  std::vector<art::Ptr<recob::Hit>> hits,
166  std::vector<sbn::crt::CRTTrack> crtTracks,
167  double minAngle = 0.);
168  // Find the closest matching crt track by average DCA between tracks within angle and DCA limits
169  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByScore(detinfo::DetectorPropertiesData const& detProp,
170  recob::Track tpcTrack,
171  std::vector<sbn::crt::CRTTrack> crtTracks,
172  const art::Event& event);
173  std::pair<sbn::crt::CRTTrack, double> ClosestCRTTrackByScore(detinfo::DetectorPropertiesData const& detProp,
174  recob::Track tpcTrack,
175  std::vector<art::Ptr<recob::Hit>> hits,
176  std::vector<sbn::crt::CRTTrack> crtTracks);
177 
178  // Calculate the angle between tracks assuming start is at the largest Y
179  double AngleBetweenTracks(recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack);
180 
181  // Calculate the average DCA between tracks
182  double AveDCABetweenTracks(recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack, double shift);
184  recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack, const art::Event& event);
186  recob::Track tpcTrack, std::vector<art::Ptr<recob::Hit>> hits,sbn:: crt::CRTTrack crtTrack);
187 
188  private:
189 
191 
193 
195  double fMaxDistance;
196  double fMaxScore;
197  std::string fSelectionMetric;
198 
199  art::InputTag fTPCTrackLabel;
200 
201  };
202 
203 }
204 
205 #endif
void reconfigure(const Config &config)
Utilities related to art service access.
bool CrossesAPA(sbn::crt::CRTTrack track)
Declaration of signal hit object.
Geometry information for a single TPC.
Definition: TPCGeo.h:38
bool CrossesTPC(sbn::crt::CRTTrack track)
int GetMatchedCRTTrackId(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
CRTTrackMatchAlg(const fhicl::ParameterSet &pset)
process_name use argoneut_mc_hitfinder track
double AngleBetweenTracks(recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack)
fhicl::Atom< art::InputTag > TPCTrackLabel
shift
Definition: fcl_checks.sh:26
double AveDCABetweenTracks(recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack, double shift)
fhicl::Atom< double > MaxDistance
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByDCA(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event, double minAngle=0.)
art::InputTag fTPCTrackLabel
geo::GeometryCore const * fGeometryService
BEGIN_PROLOG vertical distance to the surface Name
fhicl::Atom< double > MaxAngleDiff
fhicl::Atom< double > MaxScore
Description of geometry of one entire detector.
Provides recob::Track data product.
fhicl::Atom< std::string > SelectionMetric
std::vector< sbn::crt::CRTTrack > AllPossibleCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
CRTTrackMatchAlg(const Config &config)
CRTBackTracker fCrtBackTrack
std::pair< TVector3, TVector3 > TpcIntersection(const geo::TPCGeo &tpcGeo, sbn::crt::CRTTrack track)
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByAngle(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event, double minDCA=0.)
stream1 can override from command line with o or output services user sbnd
double T0FromCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
std::pair< int, double > GetMatchedCRTTrackIdAndScore(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
art framework interface to geometry description
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:
std::pair< sbn::crt::CRTTrack, double > ClosestCRTTrackByScore(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)