ATLAS Offline Software
Loading...
Searching...
No Matches
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
21Muon::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 &&
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An STL vector of pointers that by default owns its pointed-to elements.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
PublicToolHandle< Muon::MuonEDMPrinterTool > m_printer
virtual StatusCode initialize() override
standard Athena-Algorithm method
Gaudi::Property< bool > m_keepPartial
flag to keep partial overlaps
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.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
MuonAmbiTrackSelectionTool(const std::string &, const std::string &, const IInterface *)
Gaudi::Property< double > m_maxOverlapFraction
maximum hit overlap fraction between two track, if higher track will be rejected
Gaudi::Property< bool > m_keepMoreThanOne
flag to keep overlaps which share more than one presicion layer
Container to associate Cluster with cluster splitting probabilities.
Base class for all CompetingRIOsOnTack implementations, extends the common MeasurementBase.
virtual unsigned int numberOfContainedROTs() const =0
Number of RIO_OnTracks to be contained by this CompetingRIOsOnTrack.
virtual const RIO_OnTrack & rioOnTrack(unsigned int) const =0
returns the RIO_OnTrack (also known as ROT) objects depending on the integer.
This class is the pure abstract base class for all fittable tracking measurements.
bool isUsed(const PrepRawData &prd) const
does this PRD belong to at least one track?
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
StIndex
enum to classify the different station layers in the muon spectrometer
float TrackScore
Definition TrackScore.h:10