9 #ifndef TRAJCLUSTERALGUTILS_H
10 #define TRAJCLUSTERALGUTILS_H
20 #include "messagefacility/MessageLogger/MessageLogger.h"
25 class DetectorClocksData;
26 class DetectorPropertiesData;
51 void MakeHaloTj(TCSlice& slc, Trajectory& muTj,
bool prt);
54 int PDGCodeVote(
const TCSlice& slc,
const std::vector<int>& tjIDs);
56 int PrimaryID(
const TCSlice& slc,
const Trajectory& tj);
57 int PrimaryUID(
const TCSlice& slc,
const PFPStruct& pfp);
58 bool MergeTjIntoPFP(TCSlice& slc,
int mtjid, PFPStruct& pfp,
bool prt);
60 bool CompatibleMerge(
const TCSlice& slc, std::vector<int>& tjIDs,
bool prt);
61 bool CompatibleMerge(
const TCSlice& slc,
const Trajectory& tj1,
const Trajectory& tj2,
bool prt);
62 float OverlapFraction(
const TCSlice& slc,
const Trajectory& tj1,
const Trajectory& tj2);
63 unsigned short AngleRange(TrajPoint
const& tp);
66 void FitTraj(TCSlice& slc, Trajectory& tj);
69 unsigned short originPt,
73 unsigned short GetPFPIndex(
const TCSlice& slc,
int tjID);
76 bool StoreTraj(TCSlice& slc, Trajectory& tj);
77 void FitPar(
const TCSlice& slc,
79 unsigned short originPt,
83 unsigned short usePar);
84 bool InTrajOK(TCSlice& slc, std::string someText);
86 bool BraggSplit(TCSlice& slc,
unsigned short itj);
87 void ChkEndKink(TCSlice& slc, Trajectory& tj,
bool prt);
92 const std::vector<float>& fQualityCuts,
99 const float& MinWireSignalFraction);
103 const float& MinWireSignalFraction);
104 float ChgFracBetween(
const TCSlice& slc, TrajPoint tp,
float toPos0);
106 const std::vector<unsigned int>& iHitsInMultiplet,
107 const std::vector<unsigned int>& jHitsInMultiplet);
108 bool TrajHitsOK(TCSlice& slc,
const unsigned int iht,
const unsigned int jht);
113 float TpSumHitChg(
const TCSlice& slc, TrajPoint
const& tp);
114 unsigned short NumPtsWithCharge(
const TCSlice& slc,
const Trajectory& tj,
bool includeDeadWires);
116 const Trajectory& tj,
117 bool includeDeadWires,
118 unsigned short firstPt,
119 unsigned short lastPt);
120 float DeadWireCount(
const TCSlice& slc,
const TrajPoint& tp1,
const TrajPoint& tp2);
122 const float& inWirePos1,
123 const float& inWirePos2,
145 unsigned short& closePt,
148 float PointTrajDOCA(
const TCSlice& slc,
unsigned int iht, TrajPoint
const& tp);
150 float PointTrajDOCA(
const TCSlice& slc,
float wire,
float time, TrajPoint
const& tp);
152 float PointTrajDOCA2(
const TCSlice& slc,
float wire,
float time, TrajPoint
const& tp);
157 std::array<int, 2>
const& wireWindow,
159 const unsigned short plane,
163 unsigned short NearbyCleanPt(
const TCSlice& slc,
const Trajectory& tj,
unsigned short nearPt);
165 const TrajPoint& fromTp,
166 const TrajPoint& toTp,
167 const float& maxDelta);
174 unsigned short nPtsFit,
179 unsigned short kinkPt,
180 unsigned short nPtsFit,
187 unsigned short CloseEnd(
const TCSlice& slc,
const Trajectory& tj,
const Point2_t& pos);
189 float PointTrajSep2(
float wire,
float time, TrajPoint
const& tp);
195 Trajectory
const& tj,
196 unsigned short& closePt,
200 void TrajIntersection(TrajPoint
const& tp1, TrajPoint
const& tp2,
float&
x,
float&
y);
201 float MaxTjLen(
const TCSlice& slc, std::vector<int>& tjIDs);
206 float HitSep2(
const TCSlice& slc,
unsigned int iht,
unsigned int jht);
209 const Trajectory& tp1,
210 const Trajectory& tp2,
211 unsigned short& ipt1,
212 unsigned short& ipt2,
215 const Trajectory& tp1,
216 const Trajectory& tp2,
217 unsigned short& ipt1,
218 unsigned short& ipt2,
220 bool considerDeadWires);
222 float TwoTPAngle(
const TrajPoint& tp1,
const TrajPoint& tp2);
223 void TagJunkTj(TCSlice& slc, Trajectory& tj,
bool prt);
225 PFPStruct
const& pfp,
239 return v1[0] * v2[0] + v1[1] * v2[1];
250 const std::vector<unsigned int>& hitsInMultiplet,
253 const std::vector<unsigned int>& hitsInMultiplet,
256 const std::vector<unsigned int>& hitsInMultiplet,
260 const std::vector<unsigned int>& hitsInMultiplet,
264 unsigned short NumUsedHitsInTj(
const TCSlice& slc,
const Trajectory& tj);
265 unsigned short NearestPtWithChg(
const TCSlice& slc,
const Trajectory& tj,
unsigned short thePt);
267 short MCSMom(
const TCSlice& slc,
const std::vector<int>& tjIDs);
268 short MCSMom(
const TCSlice& slc,
const Trajectory& tj);
269 short MCSMom(
const TCSlice& slc,
270 const Trajectory& tj,
271 unsigned short FirstPt,
272 unsigned short lastPt);
275 const Trajectory& tj,
276 unsigned short firstPt,
277 unsigned short lastPt);
279 float MCSThetaRMS(
const TCSlice& slc,
const Trajectory& tj);
281 const Trajectory& tj,
282 unsigned short firstPt,
283 unsigned short lastPt,
285 unsigned short& cnt);
288 bool TrajIsClean(TCSlice& slc, Trajectory& tj,
bool prt);
303 unsigned int fromHit,
315 const TrajPoint& tpIn1,
316 const TrajPoint& tpIn2,
318 unsigned short FarEnd(TCSlice& slc,
const Trajectory& tj,
const Point2_t& pos);
320 void SetPDGCode(TCSlice& slc, Trajectory& tj);
321 void SetPDGCode(TCSlice& slc,
unsigned short itj);
330 bool MergeAndStore(TCSlice& slc,
unsigned int itj1,
unsigned int itj2,
bool doPrt);
331 std::vector<int>
GetAssns(TCSlice& slc, std::string type1Name,
int id, std::string type2Name);
335 unsigned int fromhit,
337 unsigned short pass);
345 unsigned short pass);
352 std::pair<unsigned short, unsigned short>
GetSliceIndex(std::string typeName,
int uID);
353 template <
typename T>
354 std::vector<T>
SetIntersection(
const std::vector<T>& set1,
const std::vector<T>& set2);
355 template <
typename T>
356 std::vector<T>
SetDifference(
const std::vector<T>& set1,
const std::vector<T>& set2);
362 void PrintP(std::string someText, mf::LogVerbatim& myprt, PFPStruct& pfp,
bool& printHeader);
364 std::string someText,
365 mf::LogVerbatim& myprt,
368 void Print2V(std::string someText, mf::LogVerbatim& myprt, VtxStore& vx2,
bool& printHeader);
370 std::string someText,
371 mf::LogVerbatim& myprt,
372 ShowerStruct3D& ss3);
373 void PrintT(std::string someText, mf::LogVerbatim& myprt, Trajectory& tj,
bool& printHeader);
376 const Trajectory& tj,
377 unsigned short tPoint);
379 std::string someText,
383 bool printVtx =
true);
385 void PrintTP(std::string someText,
390 const TrajPoint& tp);
392 void PrintPFP(std::string someText, TCSlice& slc,
const PFPStruct& pfp,
bool printHeader);
393 void PrintPFPs(std::string someText, TCSlice& slc);
400 std::string
PrintPos(
const TCSlice& slc,
const TrajPoint& tp);
406 template <
typename T>
414 std::vector<T> shared;
416 if (set1.empty())
return shared;
417 if (set2.empty())
return shared;
418 for (
auto element1 : set1) {
420 if (std::find(set2.begin(), set2.end(), element1) == set2.end())
continue;
422 if (std::find(shared.begin(), shared.end(), element1) != shared.end())
continue;
423 shared.push_back(element1);
429 template <
typename T>
434 std::vector<T> different;
435 if (set1.empty() && set2.empty())
return different;
436 if (!set1.empty() && set2.empty())
return set1;
437 if (set1.empty() && !set2.empty())
return set2;
438 for (
auto element1 : set1) {
440 if (std::find(set2.begin(), set2.end(), element1) != set2.end())
continue;
442 if (std::find(different.begin(), different.end(), element1) != different.end())
continue;
443 different.push_back(element1);
445 for (
auto element2 : set2) {
447 if (std::find(set1.begin(), set1.end(), element2) != set1.end())
continue;
449 if (std::find(different.begin(), different.end(), element2) != different.end())
continue;
450 different.push_back(element2);
457 #endif // ifndef TRAJCLUSTERALGUTILS_H
void PrintAll(detinfo::DetectorPropertiesData const &detProp, std::string someText)
float HitsPosTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
void ReleaseHits(TCSlice &slc, Trajectory &tj)
short MCSMom(const TCSlice &slc, const std::vector< int > &tjIDs)
unsigned short FarEnd(const TCSlice &slc, const PFPStruct &pfp, const Point3_t &pos)
void SetEndPoints(Trajectory &tj)
void FitPar(const TCSlice &slc, const Trajectory &tj, unsigned short originPt, unsigned short npts, short fitDir, ParFit &pFit, unsigned short usePar)
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
bool InTrajOK(TCSlice &slc, std::string someText)
unsigned short CloseEnd(const TCSlice &slc, const Trajectory &tj, const Point2_t &pos)
std::vector< int > GetAssns(TCSlice &slc, std::string type1Name, int id, std::string type2Name)
std::vector< unsigned int > PutTrajHitsInVector(const Trajectory &tj, HitStatus_t hitRequest)
process_name opflash particleana ie x
std::array< double, 3 > Point3_t
bool SignalAtTp(TrajPoint &tp)
void SetPDGCode(TCSlice &slc, unsigned short itj)
void Print2V(std::string someText, mf::LogVerbatim &myprt, VtxStore &vx2, bool &printHeader)
void Print3V(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, Vtx3Store &vx3, bool &printHeader)
void PrintPFP(std::string someText, TCSlice &slc, const PFPStruct &pfp, bool printHeader)
void FindAlongTrans(Point3_t pos1, Vector3_t dir1, Point3_t pos2, Point2_t &alongTrans)
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
void PrintTP(std::string someText, const TCSlice &slc, unsigned short ipt, short dir, unsigned short pass, const TrajPoint &tp)
The data type to uniquely identify a Plane.
bool WireHitRangeOK(TCSlice &slc, const CTP_t &inCTP)
void UnsetUsedHits(TCSlice &slc, TrajPoint &tp)
std::string PrintEndFlag(const PFPStruct &pfp, unsigned short end)
void PrintT(std::string someText, mf::LogVerbatim &myprt, Trajectory &tj, bool &printHeader)
bool StoreTraj(TCSlice &slc, Trajectory &tj)
float TpSumHitChg(const TCSlice &slc, TrajPoint const &tp)
std::string PrintPos(const TCSlice &slc, const TrajPoint &tp)
void ChkChgAsymmetry(TCSlice &slc, Trajectory &tj, bool prt)
float ExpectedHitsRMS(TCSlice &slc, const TrajPoint &tp)
bool TrajClosestApproach(Trajectory const &tj, float x, float y, unsigned short &closePt, float &DOCA)
void FillWireHitRange(geo::TPCID inTPCID)
float TrajPointSeparation(const TrajPoint &tp1, const TrajPoint &tp2)
void SetAngleCode(TrajPoint &tp)
void PrintP(std::string someText, mf::LogVerbatim &myprt, PFPStruct &pfp, bool &printHeader)
float PointTrajDOCA(const TCSlice &slc, unsigned int iht, TrajPoint const &tp)
double DeltaAngle(const Vector3_t v1, const Vector3_t v2)
bool StartTraj(TCSlice &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
bool MakeBareTrajPoint(const TCSlice &slc, unsigned int fromHit, unsigned int toHit, TrajPoint &tp)
bool LongPulseHit(const recob::Hit &hit)
float MCSThetaRMS(const TCSlice &slc, const Trajectory &tj)
float TPHitsRMSTime(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
unsigned short NumUsedHitsInTj(const TCSlice &slc, const Trajectory &tj)
std::string TPEnvString(const TrajPoint &tp)
void PrintPFPs(std::string someText, TCSlice &slc)
float MaxTjLen(const TCSlice &slc, std::vector< int > &tjIDs)
void Print3S(detinfo::DetectorPropertiesData const &detProp, std::string someText, mf::LogVerbatim &myprt, ShowerStruct3D &ss3)
bool MergeTjIntoPFP(TCSlice &slc, int mtjid, PFPStruct &pfp, bool prt)
double DeltaAngle2(double Ang1, double Ang2)
std::vector< T > SetIntersection(const std::vector< T > &set1, const std::vector< T > &set2)
std::string PrintHitShort(const TCHit &tch)
TrajPoint MakeBareTP(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, const Point3_t &pos, CTP_t inCTP)
float OverlapFraction(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2)
float HitsRMSTime(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
bool CompatibleMerge(const TCSlice &slc, std::vector< int > &tjIDs, bool prt)
std::vector< unsigned int > PutHitsInVector(const TCSlice &slc, PFPStruct const &pfp, HitStatus_t hitRequest)
float HitSep2(const TCSlice &slc, unsigned int iht, unsigned int jht)
int NeutrinoPrimaryTjID(const TCSlice &slc, const Trajectory &tj)
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
void PrintAllTraj(detinfo::DetectorPropertiesData const &detProp, std::string someText, TCSlice &slc, unsigned short itj, unsigned short ipt, bool prtVtx)
int PrimaryID(const TCSlice &slc, const Trajectory &tj)
process_name opflash particleana ie ie y
std::array< float, 2 > Point2_t
int PDGCodeVote(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
bool TrajIsClean(TCSlice &slc, Trajectory &tj, bool prt)
float DeadWireCount(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2)
bool BraggSplit(TCSlice &slc, unsigned short itj)
unsigned short NearbyCleanPt(const TCSlice &slc, const Trajectory &tj, unsigned short end)
Vector3_t PointDirection(const Point3_t p1, const Point3_t p2)
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
float ElectronLikelihood(const TCSlice &slc, const Trajectory &tj)
float TwoTPAngle(const TrajPoint &tp1, const TrajPoint &tp2)
float KinkSignificance(TCSlice &slc, Trajectory &tj1, unsigned short end1, Trajectory &tj2, unsigned short end2, unsigned short nPtsFit, bool useChg, bool prt)
float ChgFracNearPos(const TCSlice &slc, const Point2_t &pos, const std::vector< int > &tjIDs)
std::vector< unsigned int > FindCloseHits(const TCSlice &slc, std::array< int, 2 > const &wireWindow, Point2_t const &timeWindow, const unsigned short plane, HitStatus_t hitRequest, bool usePeakTime, bool &hitsNear)
float ChgFracBetween(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, Point3_t pos1, Point3_t pos2)
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
auto end(FixedBins< T, C > const &) noexcept
bool PointInsideEnvelope(const Point2_t &Point, const std::vector< Point2_t > &Envelope)
void ChkEndKink(TCSlice &slc, Trajectory &tj, bool prt)
void TagJunkTj(TCSlice &slc, Trajectory &tj, bool prt)
void MakeTrajectoryObsolete(TCSlice &slc, unsigned int itj)
float PointTrajDOCA2(const TCSlice &slc, float wire, float time, TrajPoint const &tp)
double PosSep2(const Point3_t &pos1, const Point3_t &pos2)
unsigned short GetPFPIndex(const TCSlice &slc, int tjID)
void FitTraj(TCSlice &slc, Trajectory &tj)
std::string PrintHit(const TCHit &tch)
bool Fit2D(short mode, Point2_t inPt, float &inPtErr, Vector2_t &outVec, Vector2_t &outVecErr, float &chiDOF)
bool SplitTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, unsigned short itj, float XPos, bool makeVx2, bool prt)
void TrajPointTrajDOCA(const TCSlice &slc, TrajPoint const &tp, Trajectory const &tj, unsigned short &closePt, float &minSep)
The data type to uniquely identify a TPC.
float MaxChargeAsymmetry(TCSlice &slc, std::vector< int > &tjIDs)
unsigned short NearestPtWithChg(const TCSlice &slc, const Trajectory &tj, unsigned short thePt)
bool valsIncreasing(const SortEntry &c1, const SortEntry &c2)
bool SetMag(Vector3_t &v1, double mag)
std::array< double, 2 > Vector2_t
void ReverseTraj(TCSlice &slc, Trajectory &tj)
unsigned short NumHitsInTP(const TrajPoint &tp, HitStatus_t hitRequest)
void TrimEndPts(std::string fcnLabel, TCSlice &slc, Trajectory &tj, const std::vector< float > &fQualityCuts, bool prt)
void DefineTjParents(TCSlice &slc, bool prt)
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
void UpdateTjChgProperties(std::string inFcnLabel, TCSlice &slc, Trajectory &tj, bool prt)
bool MergeAndStore(TCSlice &slc, unsigned int itj1, unsigned int itj2, bool doPrt)
float PointPull(const PFPStruct &pfp, const TP3D &tp3d)
void RestoreObsoleteTrajectory(TCSlice &slc, unsigned int itj)
void TrajIntersection(TrajPoint const &tp1, TrajPoint const &tp2, Point2_t &pos)
double DotProd(const Vector3_t &v1, const Vector3_t &v2)
bool DecodeDebugString(std::string strng)
Contains all timing reference information for the detector.
float MaxHitDelta(TCSlice &slc, Trajectory &tj)
float TrajLength(const Trajectory &tj)
void UpdateVxEnvironment(TCSlice &slc)
double PosSep(const Point3_t &pos1, const Point3_t &pos2)
void TrimHiChgEndPts(TCSlice &slc, Trajectory &tj, bool prt)
unsigned short PDGCodeIndex(int PDGCode)
bool valsDecreasing(const SortEntry &c1, const SortEntry &c2)
std::pair< unsigned short, unsigned short > GetSliceIndex(std::string typeName, int uID)
float PointTrajSep2(float wire, float time, TrajPoint const &tp)
std::array< double, 3 > Vector3_t
bool SignalAtTpInSlc(const TCSlice &slc, const TrajPoint &tp)
std::vector< T > SetDifference(const std::vector< T > &set1, const std::vector< T > &set2)
finds tracks best matching by angle
bool NearbySrcHit(geo::PlaneID plnID, unsigned int wire, float loTick, float hiTick)
void TjDeltaRMS(const TCSlice &slc, const Trajectory &tj, unsigned short firstPt, unsigned short lastPt, double &rms, unsigned short &cnt)
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
std::vector< int > FindCloseTjs(const TCSlice &slc, const TrajPoint &fromTp, const TrajPoint &toTp, const float &maxDelta)
bool SignalBetween(const TCSlice &slc, const TrajPoint &tp1, const TrajPoint &tp2, const float &MinWireSignalFraction)
2D representation of charge deposited in the TDC/wire plane
void MoveTPToWire(TrajPoint &tp, float wire)
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
void MergeGhostTjs(TCSlice &slc, CTP_t inCTP)
int PrimaryUID(const TCSlice &slc, const PFPStruct &pfp)
bool TrajTrajDOCA(const TCSlice &slc, const Trajectory &tj1, const Trajectory &tj2, unsigned short &ipt1, unsigned short &ipt2, float &minSep)
float TPHitsRMSTick(const TCSlice &slc, const TrajPoint &tp, HitStatus_t hitRequest)
physics associatedGroupsWithLeft p1
void PrintTPHeader(std::string someText)
unsigned short AngleRange(TrajPoint const &tp)
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
bool HasDuplicateHits(const TCSlice &slc, Trajectory const &tj, bool prt)
void ChkMissedKink(TCSlice &slc, Trajectory &tj, bool prt)