48 TVector3 min (tpcGeo.
MinX(), tpcGeo.
MinY(), tpcGeo.
MinZ());
49 TVector3 max (tpcGeo.
MaxX(), tpcGeo.
MaxY(), tpcGeo.
MaxZ());
52 if(intersection.first.X() != -99999)
return intersection;
59 if(intersection.first.X() != -99999)
return intersection;
74 for(
size_t t = 0; t < cryostat.
NTPC(); t++){
76 std::pair<TVector3, TVector3> intersection =
TpcIntersection(tpcGeo, track);
77 if(intersection.first.X() != -99999)
return true;
85 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event) {
86 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
87 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
88 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
95 std::pair<sbn::crt::CRTTrack, double> closest;
98 if(closest.second == -99999 || closest.second >
fMaxAngleDiff)
return -99999;
102 if(closest.second == -99999 || closest.second >
fMaxDistance)
return -99999;
106 if(closest.second == -99999 || closest.second >
fMaxScore)
return -99999;
109 double crtTime = ((double)(
int)closest.first.ts1_ns) * 1
e-3;
116 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event){
129 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event){
130 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
131 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
132 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
140 std::pair<int, double> null = std::make_pair(-99999, -99999);
142 std::pair<sbn::crt::CRTTrack, double> closest;
145 if(closest.second == -99999 || closest.second >
fMaxAngleDiff)
return null;
149 if(closest.second == -99999 || closest.second >
fMaxDistance)
return null;
153 if(closest.second == -99999 || closest.second >
fMaxScore)
return null;
157 for(
auto const&
track : crtTracks){
167 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event){
168 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
169 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
170 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
179 std::vector<sbn::crt::CRTTrack> trackCandidates;
191 for(
auto const& crtTrack : crtTracks){
193 std::pair<TVector3, TVector3> intersection =
TpcIntersection(tpcGeo, crtTrack);
196 if(intersection.first.X() == -99999)
continue;
199 double crtTime = ((double)(
int)crtTrack.ts1_ns) * 1
e-3;
203 start.SetX(start.X() +
shift);
204 end.SetX(end.X() +
shift);
210 trackCandidates.push_back(crtTrack);
214 return trackCandidates;
218 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event,
double minDCA){
219 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
220 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
221 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
227 recob::Track tpcTrack,
std::vector<art::Ptr<recob::Hit>> hits, std::vector<sbn::crt::CRTTrack> crtTracks,
double minDCA){
232 std::vector<sbn::crt::CRTTrack> possTracks =
AllPossibleCRTTracks(detProp, tpcTrack, hits, crtTracks);
234 std::vector<std::pair<sbn::crt::CRTTrack, double>> candidates;
235 for(
auto const& possTrack : possTracks){
240 double crtTime = ((double)(
int)possTrack.ts1_ns) * 1
e-3;
243 if(DCA > minDCA)
continue;
246 candidates.push_back(std::make_pair(possTrack, angle));
249 std::sort(candidates.begin(), candidates.end(), [](
auto&
left,
auto&
right){
252 if(candidates.size() > 0){
253 return candidates[0];
256 return std::make_pair(track, -99999);
260 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event,
double minAngle) {
261 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
262 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
263 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
269 recob::Track tpcTrack,
std::vector<art::Ptr<recob::Hit>> hits, std::vector<sbn::crt::CRTTrack> crtTracks,
double minAngle){
274 std::vector<sbn::crt::CRTTrack> possTracks =
AllPossibleCRTTracks(detProp, tpcTrack, hits, crtTracks);
276 std::vector<std::pair<sbn::crt::CRTTrack, double>> candidates;
277 for(
auto const& possTrack : possTracks){
279 double crtTime = ((double)(
int)possTrack.ts1_ns) * 1
e-3;
287 if(angle > minAngle)
continue;
289 candidates.push_back(std::make_pair(possTrack, DCA));
292 std::sort(candidates.begin(), candidates.end(), [](
auto&
left,
auto&
right){
295 if(candidates.size() > 0){
296 return candidates[0];
299 return std::make_pair(track, -99999);
305 recob::Track tpcTrack, std::vector<sbn::crt::CRTTrack> crtTracks,
const art::Event& event) {
306 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
307 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
308 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
319 std::vector<sbn::crt::CRTTrack> possTracks =
AllPossibleCRTTracks(detProp, tpcTrack, hits, crtTracks);
321 std::vector<std::pair<sbn::crt::CRTTrack, double>> candidates;
322 for(
auto const& possTrack : possTracks){
324 double crtTime = ((double)(
int)possTrack.ts1_ns) * 1
e-3;
331 candidates.push_back(std::make_pair(possTrack, score));
334 std::sort(candidates.begin(), candidates.end(), [](
auto&
left,
auto&
right){
337 if(candidates.size() > 0){
338 return candidates[0];
341 return std::make_pair(track, -99999);
352 if(crtStart.Y() < crtEnd.Y()) std::swap(crtStart, crtEnd);
354 TVector3 tpcStart = tpcTrack.
Vertex<TVector3>();
355 TVector3 tpcEnd = tpcTrack.
End<TVector3>();
356 if(tpcStart.Y() < tpcEnd.Y()) std::swap(tpcStart, tpcEnd);
358 return (tpcStart - tpcEnd).Angle(crtStart - crtEnd);
368 if(crtStart.Y() < crtEnd.Y()) std::swap(crtStart, crtEnd);
369 double denominator = (crtEnd - crtStart).Mag();
375 for(
size_t i = 0; i < npts; i++){
381 point.SetX(point.X() +
shift);
382 aveDCA += (point - crtStart).Cross(point - crtEnd).Mag()/denominator;
386 return aveDCA/usedPts;
392 auto tpcTrackHandle =
event.getValidHandle<std::vector<recob::Track>>(
fTPCTrackLabel);
393 art::FindManyP<recob::Hit> findManyHits(tpcTrackHandle, event,
fTPCTrackLabel);
394 std::vector<art::Ptr<recob::Hit>> hits = findManyHits.at(tpcTrack.
ID());
405 double crtTime = ((double)(
int)crtTrack.
ts1_ns) * 1
e-3;
410 if(crtStart.Y() < crtEnd.Y()) std::swap(crtStart, crtEnd);
411 double denominator = (crtEnd - crtStart).Mag();
417 for(
size_t i = 0; i < npts; i++){
423 point.SetX(point.X() +
shift);
424 aveDCA += (point - crtStart).Cross(point - crtEnd).Mag()/denominator;
428 return aveDCA/usedPts;
void reconfigure(const Config &config)
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
T::provider_type const * providerFrom()
Returns a constant pointer to the provider of specified service.
Point_t const & LocationAtPoint(size_t i) const
double MinX() const
Returns the world x coordinate of the start of the box.
Geometry information for a single TPC.
BEGIN_PROLOG or score(default)}sbnd_crttrackmatchingalg_crID
bool CrossesTPC(sbn::crt::CRTTrack track)
bool HasValidPoint(size_t i) const
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
int GetMatchedCRTTrackId(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
float x1_pos
X position of first CRTHit.
double MaxX() const
Returns the world x coordinate of the end of the box.
process_name use argoneut_mc_hitfinder track
double AngleBetweenTracks(recob::Track tpcTrack, sbn::crt::CRTTrack crtTrack)
float y1_err
Y position error of first CRTHit.
fhicl::Atom< art::InputTag > TPCTrackLabel
Geometry information for a single cryostat.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
bool TrackCompare(const sbn::crt::CRTTrack &track1, const sbn::crt::CRTTrack &track2)
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.
float z1_err
Z position error of first CRTHit.
float y2_err
Y position error of second CRTHit.
double ts1_ns
Average T1 (nanosecond) of the two hits making the track.
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
bool InsideTPC(geo::Point_t point, const geo::TPCGeo &tpc, double buffer)
geo::GeometryCore const * fGeometryService
Point_t const & Vertex() const
auto end(FixedBins< T, C > const &) noexcept
double MinZ() const
Returns the world z coordinate of the start of the box.
unsigned int NTPC() const
Number of TPCs in this cryostat.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
fhicl::Atom< double > MaxAngleDiff
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
fhicl::Atom< double > MaxScore
The data type to uniquely identify a TPC.
Description of geometry of one entire detector.
fhicl::Atom< std::string > SelectionMetric
double MaxY() const
Returns the world y coordinate of the end of the box.
std::vector< sbn::crt::CRTTrack > AllPossibleCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
constexpr TPCID const & asTPCID() const
Conversion to TPCID (for convenience of notation).
CRTTrackMatchAlg(const Config &config)
float z1_pos
Z position of first CRTHit.
CRTBackTracker fCrtBackTrack
std::pair< TVector3, TVector3 > TpcIntersection(const geo::TPCGeo &tpcGeo, sbn::crt::CRTTrack track)
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
int DriftDirectionFromHits(const geo::GeometryCore *GeometryService, std::vector< art::Ptr< recob::Hit >> hits)
float z2_pos
Z position of second CRTHit.
double MaxZ() const
Returns the world z coordinate of the end of the box.
float y2_pos
Y position of second CRTHit.
float y1_pos
Y position of first CRTHit.
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.)
Point_t const & End() const
float x2_pos
X position of second CRTHit.
stream1 can override from command line with o or output services user sbnd
std::pair< TVector3, TVector3 > CubeIntersection(TVector3 min, TVector3 max, TVector3 start, TVector3 end)
finds tracks best matching by angle
double T0FromCRTTracks(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
std::string fSelectionMetric
std::pair< int, double > GetMatchedCRTTrackIdAndScore(detinfo::DetectorPropertiesData const &detProp, recob::Track tpcTrack, std::vector< sbn::crt::CRTTrack > crtTracks, const art::Event &event)
float x1_err
X position error of first CRTHit.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
double MinY() const
Returns the world y coordinate of the start of the box.
float z2_err
Z position error of second CRTHit.
float x2_err
X position error of second CRTHit.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" 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)