ATLAS Offline Software
MuonAmbiTrackSelectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cstdio>
8 
9 #include <ext/functional>
10 #include <iostream>
11 
17 #include "TrkTrack/Track.h"
18 
19 //================ Constructor =================================================
20 
21 Muon::MuonAmbiTrackSelectionTool::MuonAmbiTrackSelectionTool(const std::string &t, const std::string &n, const IInterface *p) :
22  AthAlgTool(t, n, p) {
23  declareInterface<IAmbiTrackSelectionTool>(this);
24 }
25 
26 //================ Initialisation =================================================
27 
29  ATH_CHECK(m_printer.retrieve());
30  ATH_CHECK(m_idHelperSvc.retrieve());
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 //============================================================================================
37  const Trk::Track *track, const Trk::TrackScore /*score*/, Trk::ClusterSplitProbabilityContainer & /*splitProbContainer*/,
38  Trk::PRDtoTrackMap &prd_to_track_map, int trackId /*= -1*/, int subtrackId /*= -1*/) const {
39  unsigned int numshared{0}, numhits{0}, numPhiHits{0};
40 
41  if (!track) {
42  return std::make_tuple(nullptr, false); // "reject" invalid input track
43  }
44 
45  ATH_MSG_VERBOSE("New Track " << m_printer->print(*track));
46  ATH_MSG_VERBOSE("trackId " << trackId << ", subtrackId " << subtrackId);
47 
48  std::map<Muon::MuonStationIndex::StIndex, int> sharedPrecisionPerLayer;
49  std::map<Muon::MuonStationIndex::StIndex, int> precisionPerLayer;
50  auto is_shared = [&sharedPrecisionPerLayer, &precisionPerLayer, this, &numshared, &numhits, &prd_to_track_map,
51  &numPhiHits](const Trk::RIO_OnTrack *rot) {
52  if (!rot || !rot->prepRawData()) return;
53  const Identifier rot_id = rot->prepRawData()->identify();
54  numPhiHits += m_idHelperSvc->isMuon(rot_id) && m_idHelperSvc->measuresPhi(rot_id);
55  if (!m_idHelperSvc->isMdt(rot_id) && !m_idHelperSvc->isMM(rot_id) && !m_idHelperSvc->issTgc(rot_id) &&
56  (!m_idHelperSvc->isCsc(rot_id) || m_idHelperSvc->measuresPhi(rot_id))) {
57  ATH_MSG_VERBOSE("Measurement " << m_printer->print(*rot) << " is not a precision one");
58  return;
59  }
60  const Muon::MuonStationIndex::StIndex stIndex = m_idHelperSvc->stationIndex(rot_id);
61  ++precisionPerLayer[stIndex];
62  ++numhits;
63  if (!prd_to_track_map.isUsed(*(rot->prepRawData()))) { return; }
64 
65  ATH_MSG_VERBOSE("Track overlap found! " << m_idHelperSvc->toString(rot_id));
66  ++numshared;
67  ++sharedPrecisionPerLayer[stIndex];
68  };
69  for (const Trk::TrackStateOnSurface *iTsos : *track->trackStateOnSurfaces()) {
70  // get measurment from TSOS
71  const Trk::MeasurementBase *meas = iTsos->measurementOnTrack();
72  if (!meas) continue;
73 
74  // only look at measurements
75  if (!iTsos->type(Trk::TrackStateOnSurface::Measurement)) continue;
76  const Trk::RIO_OnTrack *rot = dynamic_cast<const Trk::RIO_OnTrack *>(meas);
77  if (!rot) {
78  // we are only interested in precision hits since only they have the resolution to distinguish between
79  // close-by tracks so we only take competing ROTs if they are CSC eta hits
80  const Trk::CompetingRIOsOnTrack *competingROT = dynamic_cast<const Trk::CompetingRIOsOnTrack *>(meas);
81  if (competingROT) {
82  const unsigned int numROTs = competingROT->numberOfContainedROTs();
83  for (unsigned int i = 0; i < numROTs; ++i) {
84  const Trk::RIO_OnTrack *comp_rot = &competingROT->rioOnTrack(i);
85  is_shared(comp_rot);
86  }
87  }
88  } else {
89  is_shared(rot);
90  }
91  }
92  if (!numhits) {
94  if (!numPhiHits)
95  ATH_MSG_WARNING("Got track without Muon hits " << m_printer->print(*track) << std::endl
96  << m_printer->printMeasurements(*track));
97  return std::make_tuple(nullptr, false); // reject input track
98  }
99  const double overlapFraction = (double)numshared / (double)numhits;
100 
101  ATH_MSG_VERBOSE("Track " << m_printer->print(*track) << " has " << numhits << " hit, shared " << numshared << " overlap fraction "
102  << overlapFraction << " layers " << precisionPerLayer.size() << " shared " << sharedPrecisionPerLayer.size());
103 
104  if (overlapFraction > m_maxOverlapFraction) {
105  if (m_keepPartial) {
106  if (sharedPrecisionPerLayer.empty()) {
107  ATH_MSG_DEBUG("Track is not sharing precision hits, keeping ");
108  return std::make_tuple(nullptr, true); // keep input track
109  }
110  if (overlapFraction < 0.25 && precisionPerLayer.size() > 2 && precisionPerLayer.size() - sharedPrecisionPerLayer.size() == 1) {
111  ATH_MSG_DEBUG("Three station track differing by one precision layer, keeping ");
112  return std::make_tuple(nullptr, true); // keep input track
113  }
114  if (overlapFraction < 0.35 && precisionPerLayer.size() > 2 && precisionPerLayer.size() - sharedPrecisionPerLayer.size() > 1 &&
115  m_keepMoreThanOne) {
116  ATH_MSG_DEBUG("Three station track differing by more than one precision layer, keeping ");
117  return std::make_tuple(nullptr, true); // keep input track
118  }
119  }
120  return std::make_tuple(nullptr, false); // reject input track
121  }
122 
123  return std::make_tuple(nullptr, true); // keep input track
124 }
MuonAmbiTrackSelectionTool.h
PRDtoTrackMap.h
MeasurementBase.h
CompetingRIOsOnTrack.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Trk::PRDtoTrackMap
Definition: PRDtoTrackMap.h:17
Muon::MuonAmbiTrackSelectionTool::getCleanedOutTrack
virtual std::tuple< Trk::Track *, bool > getCleanedOutTrack(const Trk::Track *track, const Trk::TrackScore score, Trk::ClusterSplitProbabilityContainer &splitProbContainer, Trk::PRDtoTrackMap &prd_to_track_map, int trackId=-1, int subtrackId=-1) const override
Performs cleaning of a track from already used hits.
Definition: MuonAmbiTrackSelectionTool.cxx:36
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Track.h
Trk::CompetingRIOsOnTrack::rioOnTrack
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::CompetingRIOsOnTrack::numberOfContainedROTs
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
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
Trk::CompetingRIOsOnTrack
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
Definition: CompetingRIOsOnTrack.h:64
Trk::TrackScore
float TrackScore
Definition: TrackScore.h:10
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
Muon::MuonAmbiTrackSelectionTool::MuonAmbiTrackSelectionTool
MuonAmbiTrackSelectionTool(const std::string &, const std::string &, const IInterface *)
Definition: MuonAmbiTrackSelectionTool.cxx:21
RIO_OnTrack.h
Trk::ClusterSplitProbabilityContainer
Container to associate Cluster with cluster splitting probabilities.
Definition: ClusterSplitProbabilityContainer.h:17
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::MuonStationIndex::StIndex
StIndex
enum to classify the different station layers in the muon spectrometer
Definition: MuonStationIndex.h:23
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
AthAlgTool
Definition: AthAlgTool.h:26
Muon::MuonAmbiTrackSelectionTool::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: MuonAmbiTrackSelectionTool.cxx:28
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
Identifier
Definition: IdentifierFieldParser.cxx:14