ATLAS Offline Software
SegmentFinder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef DCMATH_SEGMENTFINDER_H
6 #define DCMATH_SEGMENTFINDER_H
7 
8 #include <cmath>
9 #include <memory>
10 #include <mutex>
11 #include <vector>
12 
29 
30 namespace TrkDriftCircleMath {
31 
32  class SegmentFinder {
33  public:
34  SegmentFinder();
36  SegmentFinder(const SegmentFinder&) = delete;
39  //
40  SegmentFinder(double roadWidth, double deltaCut, bool fullScan);
42  void handleHits(const DCVec& dcs, const CLVec& clusters, ResolvedCollection<Segment, IsSubsetSegment<SortDcsByY>>& segments) const;
43 
44  SegVec findSegments(const DCVec& dcs) const;
45  SegVec findSegments(const DCVec& dcs, const CLVec& clusters) const;
46  SegVec cleanSegments(const SegVec& segments) const;
47  SegVec refitSegments(const SegVec& segs) const;
48  bool dropHits(Segment& segment, bool& hasDroppedHit, unsigned int& dropDepth) const;
49 
50  void setTGCPullCut(double cut);
51  void setRPCPullCut(double cut);
52  void setRecoverMDT(bool doRecover);
53  void setDropHits(bool doDrop);
54  void setSeedCleaning(bool doCleanup);
55  void setSingleMultiLayerScan(bool doScan);
56  void setChi2DropCut(double chi2);
57  void setDeltaCut(double cut);
58  void setRatioEmptyTubesCut(double ratioEmptyTubesCut);
59  void setMdtGeometry(const ChamberGeometry* mdtGeo) { m_mdtGeometry = mdtGeo; }
60  void setPhiRoad(double phiRoad, double phiChamber, double sinPhiCut = 0.2, bool useRoadPhi = true, bool useChamberPhi = true);
61  void setSortSegmentsUsingAllHits(bool doAllHitsSort);
62  void setUseChamberPhi(bool useChamberPhi);
63  void setRemoveSingleOutliers(bool removeSingleOutliers);
64  void setCurvedSegmentFinder(bool doCurvedSegmentFinder);
65  void setFitter(std::shared_ptr<const DCSLFitter> fitter) { m_fitter = fitter; }
66  void setMaxDropDepth(int max);
67  void setResidualCutT0(double resCut);
68  void setDeltaCutT0(double deltaCut);
69  void setUseSegmentQuality(bool useQ);
70 
72 
73  protected:
74  static DCVec selectSeeds(const DCVec& dcs, int maxSerie) ;
75  static std::pair<DCVec, DCVec> splitInMulitlayers(const DCVec& dcs) ;
76  static DCVec removeDCOnSegments(const DCVec& dcs, const SegVec& segs) ;
77 
78  unsigned int emptyCrossedTubes(const Line& line, const DCVec& closeEmptyTubes) const;
79  DCVec emptyNeighbours(const DCVec& dcs) const;
80 
81  void handleSeedPair(const DriftCircle& seed1, const DriftCircle& seeds2, const DCVec& dcs, const CLVec& cls,
82  MatchDCWithLine& matchWithLine, ResolvedCollection<Segment, IsSubsetSegment<SortDcsByY>>& segments) const;
83  void fullScan(const DCVec& seeds, const DCVec& dcs, const CLVec& cls,
85  void twoMultiLayerScan(const DCVec& seeds_ml1, const DCVec& seeds_ml2, const DCVec& dcs, const CLVec& cls,
87 
88  bool directionCheck(const LocVec2D& LocVec2D) const;
89 
90  void associateClusters(SegVec& segs, const CLVec& cls) const;
91  void associateClusters(Segment& seg, const CLVec& cls) const;
92 
93  void crossedTubes(Segment& seg) const;
94  static void updateMatch(Segment& seg, MatchDCWithLine& matchWithLine) ;
95 
96  bool goodHitRatio(Segment& seg) const;
97 
99  void updateDirections();
100 
102  void printSettings() const;
103 
104  double tubeRadius() const { return m_mdtGeometry ? m_mdtGeometry->tubeRadius() : 14.6; }
105 
106  double m_deltaCut{5.};
107  double m_roadWidth{1.5};
108  double m_phiRoad{M_PI_2};
110  double m_phiChamber{M_PI_2};
112 
113  double m_phiDifCut{0.5};
115  double m_chi2Cut{10};
116  double m_tgcPullCut{5};
117  double m_rpcPullCut{5};
118  double m_resCutT0{1.};
119  double m_deltaCutT0{5.};
120  bool m_useSegmentQuality{false};
121  bool m_recoverMdtHits{true};
122 
123  std::shared_ptr<const DCSLFitter> m_fitter;
126 
128  bool m_fullScan{false};
130  bool m_seedCleaning{false};
131  bool m_doDrop{true};
132  unsigned int m_dropDepthMax{4};
133  bool m_doAllHitSort{false};
135  bool m_useChamberPhi{true};
136  bool m_useRoadPhi{true};
138  int m_debugLevel{0};
139 
140  mutable std::vector<int> m_dropDepthAcceptCounts ATLAS_THREAD_SAFE{(int)m_dropDepthMax + 2, 0}; // Guarded by m_mutex
141  mutable std::vector<int> m_dropDepthRejectCounts ATLAS_THREAD_SAFE{(int)m_dropDepthMax + 1, 0}; // Guarded by m_mutex
143  };
144 
145  inline bool SegmentFinder::directionCheck(const LocVec2D& lineDir) const {
146  // check whether the
147  if (m_useRoadPhi) {
148  double prodRoad = lineDir * m_roadDir;
149  if (prodRoad < 0.) prodRoad *= -1.;
150  if (prodRoad > m_phiDifCut) return true;
151  }
152  if (m_useChamberPhi) {
153  double prodChamber = lineDir * m_chamberDir;
154  if (prodChamber < 0.) prodChamber *= -1.;
155  if (prodChamber > m_phiDifCut) return true;
156  }
157  return false;
158  }
159 
160 } // namespace TrkDriftCircleMath
161 
162 #endif
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
SortDcsByY.h
TrkDriftCircleMath::SegmentFinder::findSegments
SegVec findSegments(const DCVec &dcs) const
Definition: SegmentFinder.cxx:122
TrkDriftCircleMath::SegmentFinder::setRemoveSingleOutliers
void setRemoveSingleOutliers(bool removeSingleOutliers)
Definition: SegmentFinder.cxx:69
TrkDriftCircleMath::SegmentFinder::setDeltaCutT0
void setDeltaCutT0(double deltaCut)
Definition: SegmentFinder.cxx:61
ResidualWithLine.h
checkFileSG.line
line
Definition: checkFileSG.py:75
TrkDriftCircleMath::SegmentFinder::operator=
SegmentFinder & operator=(const SegmentFinder &)=delete
assignment deleted to prevent ownership/leak issues
TrkDriftCircleMath::SegmentFinder::m_doAllHitSort
bool m_doAllHitSort
Definition: SegmentFinder.h:133
TrkDriftCircleMath::SegmentFinder::setRatioEmptyTubesCut
void setRatioEmptyTubesCut(double ratioEmptyTubesCut)
Definition: SegmentFinder.cxx:85
TrkDriftCircleMath::SegmentFinder::m_fullScan
bool m_fullScan
Definition: SegmentFinder.h:128
TrkDriftCircleMath::SegmentFinder::handleSeedPair
void handleSeedPair(const DriftCircle &seed1, const DriftCircle &seeds2, const DCVec &dcs, const CLVec &cls, MatchDCWithLine &matchWithLine, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY >> &segments) const
Definition: SegmentFinder.cxx:718
TrkDriftCircleMath::SegmentFinder::setSortSegmentsUsingAllHits
void setSortSegmentsUsingAllHits(bool doAllHitsSort)
Definition: SegmentFinder.cxx:57
TrkDriftCircleMath::SegmentFinder::setChi2DropCut
void setChi2DropCut(double chi2)
Definition: SegmentFinder.cxx:79
TrkDriftCircleMath::SegmentFinder::m_chi2Cut
double m_chi2Cut
Definition: SegmentFinder.h:115
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrkDriftCircleMath::SegmentFinder::emptyNeighbours
DCVec emptyNeighbours(const DCVec &dcs) const
TrkDriftCircleMath::SegmentFinder::m_fitter
std::shared_ptr< const DCSLFitter > m_fitter
Definition: SegmentFinder.h:123
TrkDriftCircleMath::SegmentFinder::m_ratioEmptyTubesCut
double m_ratioEmptyTubesCut
Definition: SegmentFinder.h:114
MatchDCWithLine.h
TrkDriftCircleMath::ChamberGeometry
Definition: ChamberGeometry.h:17
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
TrkDriftCircleMath::SegmentFinder::m_seedCleaning
bool m_seedCleaning
Definition: SegmentFinder.h:130
TrkDriftCircleMath::CLVec
std::vector< Cluster > CLVec
Definition: Tracking/TrkUtilityPackages/TrkDriftCircleMath/TrkDriftCircleMath/Cluster.h:70
TrkDriftCircleMath::SegmentFinder::setDeltaCut
void setDeltaCut(double cut)
Definition: SegmentFinder.cxx:81
TrkDriftCircleMath::SegmentFinder::setCurvedSegmentFinder
void setCurvedSegmentFinder(bool doCurvedSegmentFinder)
Definition: SegmentFinder.cxx:67
TrkDriftCircleMath::SegmentFinder::ATLAS_THREAD_SAFE
std::vector< int > m_dropDepthAcceptCounts ATLAS_THREAD_SAFE
Definition: SegmentFinder.h:140
TrkDriftCircleMath
Function object to check whether two Segments are sub/super sets or different.
Definition: IMdtSegmentFinder.h:13
CaloClusterListBadChannel.cls
cls
Definition: CaloClusterListBadChannel.py:8
TrkDriftCircleMath::SegmentFinder::refitSegments
SegVec refitSegments(const SegVec &segs) const
Definition: SegmentFinder.cxx:305
TrkDriftCircleMath::SegmentFinder::setMaxDropDepth
void setMaxDropDepth(int max)
Definition: SegmentFinder.cxx:46
TrkDriftCircleMath::SegmentFinder::m_useSegmentQuality
bool m_useSegmentQuality
Definition: SegmentFinder.h:120
TrkDriftCircleMath::SegmentFinder::setTGCPullCut
void setTGCPullCut(double cut)
Definition: SegmentFinder.cxx:71
Segment.h
DriftCircle.h
TrkDriftCircleMath::SegmentFinder::cleanSegments
SegVec cleanSegments(const SegVec &segments) const
Definition: SegmentFinder.cxx:616
DCSLFitter.h
TrkDriftCircleMath::ChamberGeometry::tubeRadius
virtual double tubeRadius() const =0
TrkDriftCircleMath::SegmentFinder::m_phiChamber
double m_phiChamber
Definition: SegmentFinder.h:110
TrkDriftCircleMath::DriftCircle
This class represents a drift time measurement.
Definition: DriftCircle.h:22
TrkDriftCircleMath::SegmentFinder::m_useChamberPhi
bool m_useChamberPhi
Definition: SegmentFinder.h:135
TrkDriftCircleMath::SegmentFinder::m_removeSingleOutliers
bool m_removeSingleOutliers
Definition: SegmentFinder.h:127
TrkDriftCircleMath::SegmentFinder::m_deltaCut
double m_deltaCut
Definition: SegmentFinder.h:106
TrkDriftCircleMath::SegmentFinder::m_matchCrossed
MatchCrossedTubes m_matchCrossed
Definition: SegmentFinder.h:125
TrkDriftCircleMath::SegmentFinder::setRPCPullCut
void setRPCPullCut(double cut)
Definition: SegmentFinder.cxx:73
TrkDriftCircleMath::Segment
Definition: Tracking/TrkUtilityPackages/TrkDriftCircleMath/TrkDriftCircleMath/Segment.h:18
TrkDriftCircleMath::SegmentFinder::m_tgcPullCut
double m_tgcPullCut
Definition: SegmentFinder.h:116
TrkDriftCircleMath::LocVec2D
Implementation of 2 dimensional vector class.
Definition: LocVec2D.h:16
TrkDriftCircleMath::DCVec
std::vector< DriftCircle > DCVec
Definition: DriftCircle.h:117
TrkDriftCircleMath::SegmentFinder::updateDirections
void updateDirections()
update the cached values for the phi road and chamber road
Definition: SegmentFinder.cxx:104
ChamberGeometry.h
TrkDriftCircleMath::Line
Definition: Line.h:17
TrkDriftCircleMath::SegmentFinder::selectSeeds
static DCVec selectSeeds(const DCVec &dcs, int maxSerie)
Definition: SegmentFinder.cxx:268
IsSubsetSegment.h
TrkDriftCircleMath::SegmentFinder::emptyCrossedTubes
unsigned int emptyCrossedTubes(const Line &line, const DCVec &closeEmptyTubes) const
MatchCrossedTubes.h
TrkDriftCircleMath::SegmentFinder::setResidualCutT0
void setResidualCutT0(double resCut)
Definition: SegmentFinder.cxx:59
TrkDriftCircleMath::SegmentFinder::SegmentFinder
SegmentFinder()
Definition: SegmentFinder.cxx:21
TrkDriftCircleMath::SegmentFinder::setUseChamberPhi
void setUseChamberPhi(bool useChamberPhi)
Definition: SegmentFinder.cxx:65
TrkDriftCircleMath::SegmentFinder::m_rpcPullCut
double m_rpcPullCut
Definition: SegmentFinder.h:117
TrkDriftCircleMath::SegmentFinder::m_singleMultiLayerScan
bool m_singleMultiLayerScan
Definition: SegmentFinder.h:129
TrkDriftCircleMath::SegmentFinder::updateMatch
static void updateMatch(Segment &seg, MatchDCWithLine &matchWithLine)
Definition: SegmentFinder.cxx:841
Line.h
TrkDriftCircleMath::DCSLHitSelector
Definition: DCSLHitSelector.h:13
TrkDriftCircleMath::SegmentFinder::crossedTubes
void crossedTubes(Segment &seg) const
Definition: SegmentFinder.cxx:793
TrkDriftCircleMath::SegmentFinder::m_useRoadPhi
bool m_useRoadPhi
Definition: SegmentFinder.h:136
TrkDriftCircleMath::SegmentFinder::setSeedCleaning
void setSeedCleaning(bool doCleanup)
Definition: SegmentFinder.cxx:77
TrkDriftCircleMath::SegmentFinder::setSingleMultiLayerScan
void setSingleMultiLayerScan(bool doScan)
Definition: SegmentFinder.cxx:83
TrkDriftCircleMath::SegmentFinder::splitInMulitlayers
static std::pair< DCVec, DCVec > splitInMulitlayers(const DCVec &dcs)
Definition: SegmentFinder.cxx:255
TrkDriftCircleMath::SegmentFinder::m_phiDifCut
double m_phiDifCut
Definition: SegmentFinder.h:113
TrkDriftCircleMath::SegmentFinder::setUseSegmentQuality
void setUseSegmentQuality(bool useQ)
Definition: SegmentFinder.cxx:63
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:523
TrkDriftCircleMath::SegmentFinder::m_debugLevel
int m_debugLevel
Definition: SegmentFinder.h:138
BindingsTest.cut
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
Definition: BindingsTest.py:13
DCSLHitSelector.h
TrkDriftCircleMath::SegmentFinder::m_recoverMdtHits
bool m_recoverMdtHits
Definition: SegmentFinder.h:121
TrkDriftCircleMath::MatchDCWithLine
Definition: MatchDCWithLine.h:16
TrkDriftCircleMath::SegmentFinder::setFitter
void setFitter(std::shared_ptr< const DCSLFitter > fitter)
Definition: SegmentFinder.h:65
TrkDriftCircleMath::SegmentFinder::m_hitSelector
DCSLHitSelector m_hitSelector
Definition: SegmentFinder.h:124
TrkDriftCircleMath::SegmentFinder::goodHitRatio
bool goodHitRatio(Segment &seg) const
Definition: SegmentFinder.cxx:970
TrkDriftCircleMath::SegmentFinder::m_roadDir
LocVec2D m_roadDir
Definition: SegmentFinder.h:109
TrkDriftCircleMath::SegmentFinder::handleHits
void handleHits(const DCVec &dcs, const CLVec &clusters, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY >> &segments) const
Definition: SegmentFinder.cxx:150
TrkDriftCircleMath::MatchCrossedTubes
Definition: MatchCrossedTubes.h:17
TrkDriftCircleMath::SegmentFinder::associateClusters
void associateClusters(SegVec &segs, const CLVec &cls) const
Definition: SegmentFinder.cxx:913
TrkDriftCircleMath::SegmentFinder::m_chamberDir
LocVec2D m_chamberDir
Definition: SegmentFinder.h:111
TrkDriftCircleMath::SegmentFinder::directionCheck
bool directionCheck(const LocVec2D &LocVec2D) const
Definition: SegmentFinder.h:145
TrkDriftCircleMath::SegmentFinder::twoMultiLayerScan
void twoMultiLayerScan(const DCVec &seeds_ml1, const DCVec &seeds_ml2, const DCVec &dcs, const CLVec &cls, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY >> &segments) const
Definition: SegmentFinder.cxx:849
ResolvedCollection.h
TrkDriftCircleMath::SegmentFinder::tubeRadius
double tubeRadius() const
Definition: SegmentFinder.h:104
TrkDriftCircleMath::SegmentFinder::setDropHits
void setDropHits(bool doDrop)
Definition: SegmentFinder.cxx:75
TrkDriftCircleMath::SegmentFinder::printSettings
void printSettings() const
print settings
Definition: SegmentFinder.cxx:127
TrkDriftCircleMath::SegmentFinder::fullScan
void fullScan(const DCVec &seeds, const DCVec &dcs, const CLVec &cls, ResolvedCollection< Segment, IsSubsetSegment< SortDcsByY >> &segments) const
Definition: SegmentFinder.cxx:865
TrkDriftCircleMath::SegmentFinder::m_resCutT0
double m_resCutT0
Definition: SegmentFinder.h:118
TrkDriftCircleMath::SegmentFinder::m_roadWidth
double m_roadWidth
Definition: SegmentFinder.h:107
TrkDriftCircleMath::SegmentFinder::setPhiRoad
void setPhiRoad(double phiRoad, double phiChamber, double sinPhiCut=0.2, bool useRoadPhi=true, bool useChamberPhi=true)
Definition: SegmentFinder.cxx:87
TrkDriftCircleMath::SegmentFinder::m_deltaCutT0
double m_deltaCutT0
Definition: SegmentFinder.h:119
TrkDriftCircleMath::SegmentFinder::m_mutex
std::mutex m_mutex
Definition: SegmentFinder.h:142
genPbPbJobOpt.seed1
seed1
Definition: genPbPbJobOpt.py:56
TrkDriftCircleMath::SegmentFinder::dropHits
bool dropHits(Segment &segment, bool &hasDroppedHit, unsigned int &dropDepth) const
Definition: SegmentFinder.cxx:409
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
TrkDriftCircleMath::ResolvedCollection
Definition: ResolvedCollection.h:13
TrkDriftCircleMath::SegVec
std::vector< Segment > SegVec
Definition: Tracking/TrkUtilityPackages/TrkDriftCircleMath/TrkDriftCircleMath/Segment.h:122
TrkDriftCircleMath::IsSubsetSegment
Definition: IsSubsetSegment.h:18
TrkDriftCircleMath::SegmentFinder
Definition: SegmentFinder.h:32
TrkDriftCircleMath::SegmentFinder::m_phiRoad
double m_phiRoad
Definition: SegmentFinder.h:108
TrkDriftCircleMath::SegmentFinder::setMdtGeometry
void setMdtGeometry(const ChamberGeometry *mdtGeo)
Definition: SegmentFinder.h:59
TrkDriftCircleMath::SegmentFinder::SegmentFinder
SegmentFinder(const SegmentFinder &)=delete
copy c'tor deleted to prevent ownership/leak issues
TrkDriftCircleMath::SegmentFinder::~SegmentFinder
~SegmentFinder()
Definition: SegmentFinder.cxx:37
TrkDriftCircleMath::SegmentFinder::m_doCurvedSegmentFinder
bool m_doCurvedSegmentFinder
Definition: SegmentFinder.h:134
checker_macros.h
Define macros for attributes used to control the static checker.
TrkDriftCircleMath::SegmentFinder::m_mdtGeometry
const ChamberGeometry * m_mdtGeometry
Definition: SegmentFinder.h:137
Cluster.h
TrkDriftCircleMath::SegmentFinder::m_dropDepthMax
unsigned int m_dropDepthMax
Definition: SegmentFinder.h:132
CurvedSegmentFinder.h
LocVec2D.h
TrkDriftCircleMath::SegmentFinder::m_doDrop
bool m_doDrop
Definition: SegmentFinder.h:131
TrkDriftCircleMath::SegmentFinder::removeDCOnSegments
static DCVec removeDCOnSegments(const DCVec &dcs, const SegVec &segs)
Definition: SegmentFinder.cxx:888
TrkDriftCircleMath::SegmentFinder::setRecoverMDT
void setRecoverMDT(bool doRecover)
Definition: SegmentFinder.cxx:55
TrkDriftCircleMath::SegmentFinder::debugLevel
void debugLevel(int debugLevel)
Definition: SegmentFinder.h:71
NSWL1::PadTriggerAdapter::segment
Muon::NSW_PadTriggerSegment segment(const NSWL1::PadTrigger &data)
Definition: PadTriggerAdapter.cxx:5