ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentFinder.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef DCMATH_SEGMENTFINDER_H
6#define DCMATH_SEGMENTFINDER_H
7
8
9
12
13#include "TrkDriftCircleMath/DCSLFitter.h" //used in header
15#include "TrkDriftCircleMath/IsSubsetSegment.h" //template
16#include "TrkDriftCircleMath/LocVec2D.h" //member
19
20#include <cmath> //for M_PI_2
21#include <memory>
22#include <mutex>
23#include <vector>
24
25
26namespace TrkDriftCircleMath {
27 class DriftCircle;
28 class Line;
29 class MatchDCWithLine;
30 struct SortDcsByY;
31 class Segment;
32
34 public:
37 SegmentFinder(const SegmentFinder&) = delete;
40 //
41 SegmentFinder(double roadWidth, double deltaCut, bool fullScan);
43 void handleHits(const DCVec& dcs, const CLVec& clusters, ResolvedCollection<Segment, IsSubsetSegment<SortDcsByY>>& segments) const;
44
45 SegVec findSegments(const DCVec& dcs) const;
46 SegVec findSegments(const DCVec& dcs, const CLVec& clusters) const;
47 SegVec cleanSegments(const SegVec& segments) const;
48 SegVec refitSegments(const SegVec& segs) const;
49 bool dropHits(Segment& segment, bool& hasDroppedHit, unsigned int& dropDepth) const;
50
51 void setTGCPullCut(double cut);
52 void setRPCPullCut(double cut);
53 void setRecoverMDT(bool doRecover);
54 void setDropHits(bool doDrop);
55 void setSeedCleaning(bool doCleanup);
56 void setSingleMultiLayerScan(bool doScan);
57 void setChi2DropCut(double chi2);
58 void setDeltaCut(double cut);
59 void setRatioEmptyTubesCut(double ratioEmptyTubesCut);
60 void setMdtGeometry(const ChamberGeometry* mdtGeo) { m_mdtGeometry = mdtGeo; }
61 void setPhiRoad(double phiRoad, double phiChamber, double sinPhiCut = 0.2, bool useRoadPhi = true, bool useChamberPhi = true);
62 void setSortSegmentsUsingAllHits(bool doAllHitsSort);
63 void setUseChamberPhi(bool useChamberPhi);
64 void setRemoveSingleOutliers(bool removeSingleOutliers);
65 void setCurvedSegmentFinder(bool doCurvedSegmentFinder);
66 void setFitter(std::shared_ptr<const DCSLFitter> fitter) { m_fitter = std::move(fitter); }
67 void setMaxDropDepth(int max);
68 void setResidualCutT0(double resCut);
69 void setDeltaCutT0(double deltaCut);
70 void setUseSegmentQuality(bool useQ);
71
73
74 protected:
75 static DCVec selectSeeds(const DCVec& dcs, int maxSerie) ;
76 static std::pair<DCVec, DCVec> splitInMulitlayers(const DCVec& dcs) ;
77 static DCVec removeDCOnSegments(const DCVec& dcs, const SegVec& segs) ;
78
79 unsigned int emptyCrossedTubes(const Line& line, const DCVec& closeEmptyTubes) const;
80 DCVec emptyNeighbours(const DCVec& dcs) const;
81
82 void handleSeedPair(const DriftCircle& seed1, const DriftCircle& seeds2, const DCVec& dcs, const CLVec& cls,
84 void fullScan(const DCVec& seeds, const DCVec& dcs, const CLVec& cls,
86 void twoMultiLayerScan(const DCVec& seeds_ml1, const DCVec& seeds_ml2, const DCVec& dcs, const CLVec& cls,
88
89 bool directionCheck(const LocVec2D& LocVec2D) const;
90
91 void associateClusters(SegVec& segs, const CLVec& cls) const;
92 void associateClusters(Segment& seg, const CLVec& cls) const;
93
94 void crossedTubes(Segment& seg) const;
95 static void updateMatch(Segment& seg, MatchDCWithLine& matchWithLine) ;
96
97 bool goodHitRatio(Segment& seg) const;
98
100 void updateDirections();
101
103 void printSettings() const;
104
105 double tubeRadius() const { return m_mdtGeometry ? m_mdtGeometry->tubeRadius() : 14.6; }
106
107 double m_deltaCut{5.};
108 double m_roadWidth{1.5};
109 double m_phiRoad{M_PI_2};
111 double m_phiChamber{M_PI_2};
113
114 double m_phiDifCut{0.5};
116 double m_chi2Cut{10};
117 double m_tgcPullCut{5};
118 double m_rpcPullCut{5};
119 double m_resCutT0{1.};
120 double m_deltaCutT0{5.};
123
124 std::shared_ptr<const DCSLFitter> m_fitter;
127
129 bool m_fullScan{false};
131 bool m_seedCleaning{false};
132 bool m_doDrop{true};
133 unsigned int m_dropDepthMax{4};
134 bool m_doAllHitSort{false};
136 bool m_useChamberPhi{true};
137 bool m_useRoadPhi{true};
140
141 mutable std::vector<int> m_dropDepthAcceptCounts ATLAS_THREAD_SAFE{(int)m_dropDepthMax + 2, 0}; // Guarded by m_mutex
142 mutable std::vector<int> m_dropDepthRejectCounts ATLAS_THREAD_SAFE{(int)m_dropDepthMax + 1, 0}; // Guarded by m_mutex
143 mutable std::mutex m_mutex;
144 };
145
146 inline bool SegmentFinder::directionCheck(const LocVec2D& lineDir) const {
147 // check whether the
148 if (m_useRoadPhi) {
149 double prodRoad = lineDir * m_roadDir;
150 if (prodRoad < 0.) prodRoad *= -1.;
151 if (prodRoad > m_phiDifCut) return true;
152 }
153 if (m_useChamberPhi) {
154 double prodChamber = lineDir * m_chamberDir;
155 if (prodChamber < 0.) prodChamber *= -1.;
156 if (prodChamber > m_phiDifCut) return true;
157 }
158 return false;
159 }
160
161} // namespace TrkDriftCircleMath
162
163#endif
#define max(a, b)
Definition cfImp.cxx:41
Define macros for attributes used to control the static checker.
This class represents a drift time measurement.
Definition DriftCircle.h:22
Implementation of 2 dimensional vector class.
Definition LocVec2D.h:16
void setDeltaCutT0(double deltaCut)
void fullScan(const DCVec &seeds, const DCVec &dcs, const CLVec &cls, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY > > &segments) const
void printSettings() const
print settings
SegmentFinder(const SegmentFinder &)=delete
copy c'tor deleted to prevent ownership/leak issues
std::shared_ptr< const DCSLFitter > m_fitter
SegmentFinder & operator=(const SegmentFinder &)=delete
assignment deleted to prevent ownership/leak issues
void associateClusters(SegVec &segs, const CLVec &cls) const
void setMdtGeometry(const ChamberGeometry *mdtGeo)
bool dropHits(Segment &segment, bool &hasDroppedHit, unsigned int &dropDepth) const
SegVec findSegments(const DCVec &dcs) const
static DCVec selectSeeds(const DCVec &dcs, int maxSerie)
void setRemoveSingleOutliers(bool removeSingleOutliers)
void handleSeedPair(const DriftCircle &seed1, const DriftCircle &seeds2, const DCVec &dcs, const CLVec &cls, MatchDCWithLine &matchWithLine, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY > > &segments) const
void setPhiRoad(double phiRoad, double phiChamber, double sinPhiCut=0.2, bool useRoadPhi=true, bool useChamberPhi=true)
void setRatioEmptyTubesCut(double ratioEmptyTubesCut)
void setUseChamberPhi(bool useChamberPhi)
DCVec emptyNeighbours(const DCVec &dcs) const
static std::pair< DCVec, DCVec > splitInMulitlayers(const DCVec &dcs)
void debugLevel(int debugLevel)
bool goodHitRatio(Segment &seg) const
void handleHits(const DCVec &dcs, const CLVec &clusters, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY > > &segments) const
static void updateMatch(Segment &seg, MatchDCWithLine &matchWithLine)
void setSeedCleaning(bool doCleanup)
void updateDirections()
update the cached values for the phi road and chamber road
bool directionCheck(const LocVec2D &LocVec2D) const
void twoMultiLayerScan(const DCVec &seeds_ml1, const DCVec &seeds_ml2, const DCVec &dcs, const CLVec &cls, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY > > &segments) const
void setSortSegmentsUsingAllHits(bool doAllHitsSort)
unsigned int emptyCrossedTubes(const Line &line, const DCVec &closeEmptyTubes) const
const ChamberGeometry * m_mdtGeometry
std::vector< int > m_dropDepthAcceptCounts ATLAS_THREAD_SAFE
SegVec cleanSegments(const SegVec &segments) const
SegVec refitSegments(const SegVec &segs) const
static DCVec removeDCOnSegments(const DCVec &dcs, const SegVec &segs)
void setFitter(std::shared_ptr< const DCSLFitter > fitter)
void setCurvedSegmentFinder(bool doCurvedSegmentFinder)
void crossedTubes(Segment &seg) const
void setSingleMultiLayerScan(bool doScan)
double chi2(TH1 *h0, TH1 *h1)
Function object to check whether two Segments are sub/super sets or different.
std::vector< DriftCircle > DCVec