45 std::vector<std::pair<double, std::pair<double, bool>>> matchCandidates;
46 double matchedTime = -99999;
47 std::pair<double, bool> returnVal = std::make_pair(matchedTime,
false);
49 TVector3 trk1Front = t1.
Vertex<TVector3>();
50 TVector3 trk1Back = t1.
End<TVector3>();
51 double closestX1 = std::min(
std::abs(trk1Front.X()),
std::abs(trk1Back.X()));
54 for(
auto &
track : tracks){
56 TVector3 trk2Front =
track.Vertex<TVector3>();
57 TVector3 trk2Back =
track.End<TVector3>();
58 double closestX2 = std::min(
std::abs(trk2Front.X()),
std::abs(trk2Back.X()));
64 TVector3 t1Pos = trk1Front;
65 TVector3 t1PosEnd = trk1Back;
67 if(
std::abs(trk1Back.X()) == closestX1){
73 TVector3 t2Pos = trk2Front;
74 TVector3 t2PosEnd = trk2Back;
75 TVector3 t2Dir =
track.VertexDirection<TVector3>();
76 if(
std::abs(trk2Back.X()) == closestX2){
79 t2Dir =
track.EndDirection<TVector3>();
83 double trkCos =
std::abs(t1Dir.Dot(t2Dir));
87 double dist = (t1Pos-t2Pos).Mag();
90 geo::Point_t mergeStart {t1PosEnd.X(), t1PosEnd.Y(), t1PosEnd.Z()};
91 geo::Point_t mergeEnd {t2PosEnd.X(), t2PosEnd.Y(), t2PosEnd.Z()};
97 if(dist < fCpaStitchDistance && trkCos > cos(TMath::Pi() *
fCpaStitchAngle / 180.)){
98 matchCandidates.push_back(std::make_pair(trkCos, std::make_pair(closestX1, exits)));
103 if(matchCandidates.size() > 0){
104 std::sort(matchCandidates.begin(), matchCandidates.end(), [](
auto&
left,
auto&
right){
106 double shiftX = matchCandidates[0].second.first;
108 returnVal = std::make_pair(matchedTime, matchCandidates[0].
second.second);
119 std::vector<recob::Track> tpcTracksTPC0;
120 std::vector<recob::Track> tpcTracksTPC1;
122 for(
auto const& tpcTrack : tracks){
124 std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(tpcTrack.ID());
126 double startX = tpcTrack.Start().X();
127 double endX = tpcTrack.End().X();
128 if(tpc == 0 && !(startX>0 || endX>0)) tpcTracksTPC0.push_back(tpcTrack);
129 else if(tpc == 1 && !(startX<0 || endX<0)) tpcTracksTPC1.push_back(tpcTrack);
132 std::vector<art::Ptr<recob::Hit>> hits = hitAssoc.at(track.
ID());
135 double stitchTime = -99999;
136 bool stitchExit =
false;
139 std::pair<double, bool> stitchResults =
T0FromCpaStitching(detProp, track, tpcTracksTPC1);
140 stitchTime = stitchResults.first;
141 stitchExit = stitchResults.second;
144 std::pair<double, bool> stitchResults =
T0FromCpaStitching(detProp, track, tpcTracksTPC0);
145 stitchTime = stitchResults.first;
146 stitchExit = stitchResults.second;
150 if(stitchTime != -99999 && (stitchTime < fBeamTimeMin || stitchTime >
fBeamTimeMax || stitchExit))
return true;
fhicl::Atom< double > CpaXDifference
ClusterModuleLabel join with tracks
bool CpaCrossCosmicId(detinfo::DetectorPropertiesData const &detProp, recob::Track track, std::vector< recob::Track > tracks, art::FindManyP< recob::Hit > hitAssoc)
void reconfigure(const Config &config)
Vector_t VertexDirection() const
process_name use argoneut_mc_hitfinder track
fhicl::Atom< double > CpaStitchAngle
Point_t const & Vertex() const
fhicl::Table< BeamTime > BeamTimeLimits
std::pair< double, bool > T0FromCpaStitching(detinfo::DetectorPropertiesData const &detProp, recob::Track t1, std::vector< recob::Track > tracks)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
int DetectedInTPC(std::vector< art::Ptr< recob::Hit >> hits)
double fCpaStitchDistance
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
fhicl::Table< Fiducial > FiducialCuts
Vector_t EndDirection() const
Point_t const & End() const
stream1 can override from command line with o or output services user sbnd
CpaCrossCosmicIdAlg(const Config &config)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
fhicl::Atom< double > CpaStitchDistance
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
bool InFiducial(geo::Point_t point, double fiducial)