37 std::vector<std::pair<double, std::pair<double, bool>>> matchCandidates;
38 double matchedTime = -99999;
39 std::pair<double, bool> returnVal = std::make_pair(matchedTime,
false);
41 TVector3 trk1Front = t1.
Vertex<TVector3>();
42 TVector3 trk1Back = t1.
End<TVector3>();
43 double closestX1 = std::min(
std::abs(trk1Front.X()),
std::abs(trk1Back.X()));
46 for(
auto &
track : tracks){
48 TVector3 trk2Front =
track.Vertex<TVector3>();
49 TVector3 trk2Back =
track.End<TVector3>();
50 double closestX2 = std::min(
std::abs(trk2Front.X()),
std::abs(trk2Back.X()));
56 TVector3 t1Pos = trk1Front;
57 TVector3 t1PosEnd = trk1Back;
59 if(
std::abs(trk1Back.X()) == closestX1){
65 TVector3 t2Pos = trk2Front;
66 TVector3 t2PosEnd = trk2Back;
67 TVector3 t2Dir =
track.VertexDirection<TVector3>();
68 if(
std::abs(trk2Back.X()) == closestX2){
71 t2Dir =
track.EndDirection<TVector3>();
75 double trkCos =
std::abs(t1Dir.Dot(t2Dir));
79 double dist = (t1Pos-t2Pos).Mag();
82 geo::Point_t mergeStart {t1PosEnd.X(), t1PosEnd.Y(), t1PosEnd.Z()};
83 geo::Point_t mergeEnd {t2PosEnd.X(), t2PosEnd.Y(), t2PosEnd.Z()};
89 if(dist < fCpaStitchDistance && trkCos > cos(TMath::Pi() *
fCpaStitchAngle / 180.)){
90 matchCandidates.push_back(std::make_pair(trkCos, std::make_pair(closestX1, exits)));
95 if(matchCandidates.size() > 0){
96 std::sort(matchCandidates.begin(), matchCandidates.end(), [](
auto&
left,
auto&
right){
98 double shiftX = matchCandidates[0].second.first;
100 returnVal = std::make_pair(matchedTime, matchCandidates[0].
second.second);
110 std::vector<recob::Track> tpcTracksTPC0;
111 std::vector<recob::Track> tpcTracksTPC1;
113 for(
auto const& tpcTrack : tracks){
115 std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(tpcTrack.ID());
116 int tpc =
fTpcGeo.DetectedInTPC(hits);
117 double startX = tpcTrack.Start().X();
118 double endX = tpcTrack.End().X();
119 if(tpc == 0 && !(startX>0 || endX>0)) tpcTracksTPC0.push_back(tpcTrack);
120 else if(tpc == 1 && !(startX<0 || endX<0)) tpcTracksTPC1.push_back(tpcTrack);
123 std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(track.
ID());
124 int tpc =
fTpcGeo.DetectedInTPC(hits);
126 double stitchTime = -99999;
127 bool stitchExit =
false;
131 stitchTime = stitchResults.first;
132 stitchExit = stitchResults.second;
136 stitchTime = stitchResults.first;
137 stitchExit = stitchResults.second;
141 if(stitchTime != -99999 && (stitchTime < fBeamTimeMin || stitchTime >
fBeamTimeMax || stitchExit))
return true;
void reconfigure(const Config &config)
ClusterModuleLabel join with tracks
const detinfo::DetectorPropertiesStandard * GetDetectorPropertiesProvider() const
Vector_t VertexDirection() const
detinfo::DetectorPropertiesStandard const * fDetectorProperties
process_name use argoneut_mc_hitfinder track
fhicl::Table< BeamTime > BeamTimeLimits
process_name opflashCryoW ana
CpaCrossCosmicIdAlg(const core::ProviderManager &manager, const Config &config)
fhicl::Atom< double > CpaStitchAngle
Interface to LArSoft services.
fhicl::Atom< double > CpaStitchDistance
Point_t const & Vertex() const
bool CpaCrossCosmicId(recob::Track track, std::vector< recob::Track > tracks, art::FindManyP< recob::Hit > hitAssoc)
fhicl::Atom< double > CpaXDifference
double DriftVelocity(double efield=0., double temperature=0.) const override
cm/us
fhicl::Table< Fiducial > FiducialCuts
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Vector_t EndDirection() const
Point_t const & End() const
std::pair< double, bool > T0FromCpaStitching(recob::Track t1, std::vector< recob::Track > tracks)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
double fCpaStitchDistance