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);
Vector_t VertexDirection() const
detinfo::DetectorPropertiesStandard const * fDetectorProperties
process_name use argoneut_mc_hitfinder track
Point_t const & Vertex() const
double DriftVelocity(double efield=0., double temperature=0.) const override
cm/us
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
Vector_t EndDirection() const
Point_t const & End() const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.