ATLAS Offline Software
MdtMathSegmentFinder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MdtMathSegmentFinder.h"
6 
12 
13 
14 
15 namespace Muon {
16 
17  MdtMathSegmentFinder::MdtMathSegmentFinder(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t, n, p) {
18  declareInterface<IMdtSegmentFinder>(this);
19  }
20 
22  if (!m_dcslFitProvider.empty()) {
23  ATH_CHECK(m_dcslFitProvider.retrieve());
24  ATH_MSG_INFO(" Using fitter from " << m_dcslFitProvider);
25  }
26  ATH_CHECK(m_idHelperSvc.retrieve());
27  return StatusCode::SUCCESS;
28  }
29 
31  const TrkDriftCircleMath::CLVec& clvec,
32  const TrkDriftCircleMath::Road& road,
33  const TrkDriftCircleMath::DCStatistics& dcstats,
34  const TrkDriftCircleMath::ChamberGeometry* multiGeo) const {
35  // setup finder
37 
38  // set debug level
39  segmentFinder.debugLevel(m_finderDebugLevel);
40 
41  // configure uasge of chamber position for angular seeding
42  segmentFinder.setUseChamberPhi(m_useChamberTheta);
43 
44  // enable dropping of hits
45  segmentFinder.setDropHits(m_doDrop);
46 
47  // enable seed cleaing
48  segmentFinder.setSeedCleaning(m_enableSeedCleaning);
49 
50  // do single multilayer scan?
51  segmentFinder.setSingleMultiLayerScan(m_doSingleMultiLayerScan);
52 
53  // set chi2/ndof threshold for cleaning of segments
54  segmentFinder.setChi2DropCut(m_chi2PerDofDrop);
55 
56  // set ratio for dropping segments with many empty tubes
57  segmentFinder.setRatioEmptyTubesCut(m_ratioEmptyTubesCut);
58 
59  // set sort mode segment finder
60  segmentFinder.setSortSegmentsUsingAllHits(m_doAllHitSort);
61 
62  // set RPC pull cut
63  segmentFinder.setRPCPullCut(m_rpcAssociationPullCut);
64 
65  // set TGC pull cut
66  segmentFinder.setTGCPullCut(m_tgcAssociationPullCut);
67 
68  // set MDT outlier recovery
69  segmentFinder.setRecoverMDT(m_recoverMdtOutliers);
70 
71  // set removal of single outliers
72  segmentFinder.setRemoveSingleOutliers(m_removeSingleOutliers);
73 
74  // set the curved segment finder
75  segmentFinder.setCurvedSegmentFinder(m_doCurvedSegmentFinder);
76 
77  // set removal of single outliers
78  segmentFinder.setDeltaCutT0(m_deltaCutT0Segments); // reset defaults
79 
80  // set removal of single outliers
81  segmentFinder.setResidualCutT0(m_residualCutT0Segments);
82 
83  // set use of segment quality
84  segmentFinder.setUseSegmentQuality(m_useSegmentQuality);
85 
86  if (!m_dcslFitProvider.empty()) {
87  std::shared_ptr<const TrkDriftCircleMath::DCSLFitter> fitter(m_dcslFitProvider->getFitter(), Muon::IDCSLFitProvider::Unowned{});
88  segmentFinder.setFitter(fitter);
89  } else {
90  segmentFinder.setFitter(std::make_shared<TrkDriftCircleMath::DCSLFitter>());
91  }
92 
93  // set angle prediction from road
94  segmentFinder.setPhiRoad(road.angle(), road.chamberAngle(), road.width(), m_doRoadAngleSeeding, m_doIPAngleSeeding);
95 
96  // set pointer to geometry
97  segmentFinder.setMdtGeometry(multiGeo);
98 
99  // set seed cleaning
100  bool highOccupancy = false;
101  bool aboveOccupancyCut = false;
102  double occupancyMax = 0.;
103  unsigned int nmdtHits = 0;
104  // calculate multi layer occupancy
105  TrkDriftCircleMath::DCStatCit mit = dcstats.begin();
106  TrkDriftCircleMath::DCStatCit mit_end = dcstats.end();
107  for (; mit != mit_end; ++mit) {
108  unsigned int channels = mit->first->getNLayers() * mit->first->getNtubesperlayer();
109  double occupancy = (double)mit->second / (double)channels;
110 
111  nmdtHits += mit->second;
112 
113  occupancyMax = std::max(occupancy, occupancyMax);
114 
115  if (occupancy > m_occupancyThreshold) highOccupancy = true;
116 
117  if (occupancy > m_occupancyCutOff) aboveOccupancyCut = true;
118  }
119 
120  // sanity check
121  if (nmdtHits != dcvec.size()) {
122  ATH_MSG_WARNING(" inconsistent number of mdt hits " << nmdtHits << " from vec " << dcvec.size());
123  nmdtHits = dcvec.size();
124  }
125 
126  if (aboveOccupancyCut) {
127  ATH_MSG_DEBUG(" layer with occupancy above threshold, aborting segment finding "
128  << occupancyMax << " cut " << m_occupancyCutOff << " nhits " << nmdtHits << " cut " << m_maxHitsPerFullSearch);
129  return {};
130  }
131 
132  // enable seed cleaning
133  if (highOccupancy || nmdtHits > m_maxHitsPerFullSearch) {
134  ATH_MSG_DEBUG(" switch to fast search: occupancy " << occupancyMax << " cut " << m_occupancyThreshold << " nhits " << nmdtHits
135  << " cut " << m_maxHitsPerFullSearch);
136 
137  // to speed up reconstruction use default fitter
138  if (!m_dcslFitProvider.empty()) {
139  segmentFinder.setFitter(std::make_shared<TrkDriftCircleMath::DCSLFitter>());
140  }
141 
142  // use tight road cuts and only look for pointing segments
143  segmentFinder.setPhiRoad(road.chamberAngle(), road.chamberAngle(), m_tightRoadCut);
144  }
145 
146  return segmentFinder.findSegments(dcvec, clvec);
147  }
148 
149 } // namespace Muon
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
MdtReadoutElement.h
Muon::MdtMathSegmentFinder::m_doRoadAngleSeeding
Gaudi::Property< bool > m_doRoadAngleSeeding
Definition: MdtMathSegmentFinder.h:60
Muon::MdtMathSegmentFinder::m_doSingleMultiLayerScan
Gaudi::Property< bool > m_doSingleMultiLayerScan
Definition: MdtMathSegmentFinder.h:67
Muon::MdtMathSegmentFinder::m_doDrop
Gaudi::Property< bool > m_doDrop
Definition: MdtMathSegmentFinder.h:44
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Muon::MdtMathSegmentFinder::m_rpcAssociationPullCut
Gaudi::Property< double > m_rpcAssociationPullCut
Definition: MdtMathSegmentFinder.h:54
SegmentFinder.h
TrkDriftCircleMath::ChamberGeometry
Definition: ChamberGeometry.h:17
Muon::MdtMathSegmentFinder::m_doCurvedSegmentFinder
Gaudi::Property< bool > m_doCurvedSegmentFinder
Definition: MdtMathSegmentFinder.h:72
TrkDriftCircleMath::CLVec
std::vector< Cluster > CLVec
Definition: Tracking/TrkUtilityPackages/TrkDriftCircleMath/TrkDriftCircleMath/Cluster.h:70
Muon::IDCSLFitProvider::Unowned
Helper struct to overload the destructors of smart pointers.
Definition: IDCSLFitProvider.h:39
Muon::MdtMathSegmentFinder::MdtMathSegmentFinder
MdtMathSegmentFinder(const std::string &t, const std::string &n, const IInterface *p)
Definition: MdtMathSegmentFinder.cxx:17
Muon::MdtMathSegmentFinder::m_mdtAssociationPullCut
Gaudi::Property< double > m_mdtAssociationPullCut
Definition: MdtMathSegmentFinder.h:56
Muon::MdtMathSegmentFinder::m_dcslFitProvider
ToolHandle< IDCSLFitProvider > m_dcslFitProvider
Definition: MdtMathSegmentFinder.h:31
TrkDriftCircleMath::DCStatCit
DCStatistics::const_iterator DCStatCit
Definition: DCStatistics.h:21
Muon::MdtMathSegmentFinder::m_finderDebugLevel
Gaudi::Property< int > m_finderDebugLevel
Definition: MdtMathSegmentFinder.h:43
DCSLFitter.h
Muon::MdtMathSegmentFinder::m_doAllHitSort
Gaudi::Property< bool > m_doAllHitSort
Definition: MdtMathSegmentFinder.h:58
Muon::MdtMathSegmentFinder::m_residualCutT0Segments
Gaudi::Property< double > m_residualCutT0Segments
Definition: MdtMathSegmentFinder.h:74
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
TrkDriftCircleMath::Road::chamberAngle
double chamberAngle() const
returns the angle of the line from the chamber center to the IP in local AMDB chamber coordinates
Definition: Road.h:35
Muon::MdtMathSegmentFinder::m_chi2PerDofDrop
Gaudi::Property< double > m_chi2PerDofDrop
Definition: MdtMathSegmentFinder.h:51
Muon::MdtMathSegmentFinder::m_occupancyCutOff
Gaudi::Property< double > m_occupancyCutOff
Definition: MdtMathSegmentFinder.h:49
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
Muon::MdtMathSegmentFinder::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtMathSegmentFinder.h:37
TrkDriftCircleMath::DCVec
std::vector< DriftCircle > DCVec
Definition: DriftCircle.h:117
Muon::MdtMathSegmentFinder::m_deltaCutT0Segments
Gaudi::Property< double > m_deltaCutT0Segments
Definition: MdtMathSegmentFinder.h:73
Muon::MdtMathSegmentFinder::m_occupancyThreshold
Gaudi::Property< double > m_occupancyThreshold
Definition: MdtMathSegmentFinder.h:48
TrkDriftCircleMath::Road
TrkDriftCircleMath::Road - encodes the road given to the segment finder in station coordinates.
Definition: Road.h:15
MdtMathSegmentFinder.h
Muon::MdtMathSegmentFinder::findSegments
virtual const TrkDriftCircleMath::SegVec findSegments(const TrkDriftCircleMath::DCVec &dcvec, const TrkDriftCircleMath::CLVec &clvec, const TrkDriftCircleMath::Road &road, const TrkDriftCircleMath::DCStatistics &dcstats, const TrkDriftCircleMath::ChamberGeometry *multiGeo) const
IMdtMdtMathSegmentFinder interface implementation
Definition: MdtMathSegmentFinder.cxx:30
TrkDriftCircleMath::Road::width
double width() const
returns the width angle of the road
Definition: Road.h:38
beamspotman.n
n
Definition: beamspotman.py:731
TrkDriftCircleMath::Road::angle
double angle() const
returns the angle of the road in local coordinates
Definition: Road.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Muon::MdtMathSegmentFinder::m_useChamberTheta
Gaudi::Property< bool > m_useChamberTheta
Definition: MdtMathSegmentFinder.h:45
Muon::MdtMathSegmentFinder::m_ratioEmptyTubesCut
Gaudi::Property< double > m_ratioEmptyTubesCut
Definition: MdtMathSegmentFinder.h:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Muon::MdtMathSegmentFinder::m_roadWidth
Gaudi::Property< double > m_roadWidth
Definition: MdtMathSegmentFinder.h:50
Road.h
Muon::MdtMathSegmentFinder::m_removeSingleOutliers
Gaudi::Property< bool > m_removeSingleOutliers
Definition: MdtMathSegmentFinder.h:71
Muon::MdtMathSegmentFinder::m_enableSeedCleaning
Gaudi::Property< bool > m_enableSeedCleaning
Definition: MdtMathSegmentFinder.h:47
Muon::MdtMathSegmentFinder::m_maxHitsPerFullSearch
Gaudi::Property< unsigned int > m_maxHitsPerFullSearch
Definition: MdtMathSegmentFinder.h:77
Muon::MdtMathSegmentFinder::m_tgcAssociationPullCut
Gaudi::Property< double > m_tgcAssociationPullCut
Definition: MdtMathSegmentFinder.h:55
DCStatistics.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::MdtMathSegmentFinder::m_doIPAngleSeeding
Gaudi::Property< bool > m_doIPAngleSeeding
Definition: MdtMathSegmentFinder.h:63
Muon::MdtMathSegmentFinder::m_recoverMdtOutliers
Gaudi::Property< bool > m_recoverMdtOutliers
Definition: MdtMathSegmentFinder.h:69
TrkDriftCircleMath::SegVec
std::vector< Segment > SegVec
Definition: TrkUtilityPackages/TrkDriftCircleMath/TrkDriftCircleMath/Segment.h:122
Muon::MdtMathSegmentFinder::initialize
virtual StatusCode initialize()
Definition: MdtMathSegmentFinder.cxx:21
TrkDriftCircleMath::SegmentFinder
Definition: SegmentFinder.h:32
Muon::MdtMathSegmentFinder::m_tightRoadCut
Gaudi::Property< double > m_tightRoadCut
Definition: MdtMathSegmentFinder.h:64
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MdtMathSegmentFinder::m_useSegmentQuality
Gaudi::Property< bool > m_useSegmentQuality
Definition: MdtMathSegmentFinder.h:75
TrkDriftCircleMath::DCStatistics
This class offers no functionality, but to define a standard device for the maker to transfer to the ...
Definition: DCStatistics.h:19