ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCombinedInDetCandidateAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
12
13using namespace MuonCombined;
14
15
16
18 ATH_CHECK(m_trackSelector.retrieve(DisableTool{m_trackSelector.empty()}));
25 ATH_CHECK(m_forwardTrackSelector.retrieve(DisableTool{!m_doSiliconForwardMuons}));
26 for (const auto& key : m_indetTrackParticleLocation) {
27 m_trkLinkKey.emplace_back(key, "trackLink");
28 }
30 m_trkLinkKey.emplace_back(m_indetForwardTrackParticleLocation, "trackLink");
31 }
33 ATH_MSG_INFO("Successfully initialized using the following configuration -- SAF: "
34 << (m_doSiliconForwardMuons ? "si" : "no") << ", "
35 << "MS extension bulk: " << (m_extendBulk ? "si" : "no")
36 << ", MS extension SAF: " << (m_doSiliconForwardMuons && m_extendSAF ? "si" : "no")
37 << ", Require MS estension: " << (m_requireExtension ? "si" : "no") << " min pT for extension " << m_extThreshold);
38 return StatusCode::SUCCESS;
39}
40
41StatusCode MuonCombinedInDetCandidateAlg::execute(const EventContext& ctx) const {
42 InDetCandidateCache output_cache{};
43 unsigned int counter{0};
45 ATH_CHECK(SG::get(output_cache.inDetContainer, key, ctx));
46 output_cache.trackSelector = !m_trackSelector.empty() ? m_trackSelector.get() : nullptr;
47 if (counter < m_caloExtensionLocation.size()) {
48 ATH_CHECK(SG::get(output_cache.extensionContainer, m_caloExtensionLocation[counter], ctx));
49 } else {
50 output_cache.extensionContainer = nullptr;
51 }
52 ++counter;
53 ATH_CHECK(create(ctx, output_cache));
54 }
58 output_cache.trackSelector = !m_forwardTrackSelector.empty() ? m_forwardTrackSelector.get() : nullptr;
59 output_cache.flagAsSAF = true;
60 ATH_CHECK(create(ctx, output_cache));
61 }
62
63 SG::WriteHandle indetCandidateCollection(m_candidateCollectionName, ctx);
64 ATH_CHECK(indetCandidateCollection.record(std::move(output_cache.outputContainer)));
65
66 return StatusCode::SUCCESS;
67}
68
69StatusCode MuonCombinedInDetCandidateAlg::create(const EventContext& ctx, InDetCandidateCache& output_cache) const {
70 ATH_MSG_DEBUG("Producing InDetCandidates for " << output_cache.inDetContainer->size());
71 for (const xAOD::TrackParticle* tp : *output_cache.inDetContainer) {
72 if (!isValidTrackParticle(output_cache.trackSelector, tp)) continue;
73
74 ElementLink<xAOD::TrackParticleContainer> link(*output_cache.inDetContainer, tp->index());
75 if (!link.isValid()) {
76 ATH_MSG_WARNING("Bad element link ");
77 continue;
78 } else if (*link != tp) {
79 ATH_MSG_WARNING("Dereferenced Link not equal to TrackParticle, skipping track ");
80 continue;
81 }
82 link.toPersistent();
83 printTrackParticleInfo(tp, "Creating");
84
85 if (msgLvl(MSG::VERBOSE)) {
87 if (truth_part) {
88 static const SG::ConstAccessor<int> truthTypeAcc("truthType");
89 static const SG::ConstAccessor<int> truthOriginAcc("truthOrigin");
90 ATH_MSG_VERBOSE(" Truth particle: pdgId " << truth_part->pdgId() << " type " << truthTypeAcc(*tp) << " origin "
91 << truthOriginAcc(*tp) << " pt " << truth_part->pt() << " eta "
92 << truth_part->eta() << " phi " << truth_part->phi());
93 }
94 }
96 cache.extensionContainer = output_cache.extensionContainer;
97 cache.candidate = std::make_unique<InDetCandidate>(link);
98 cache.candidate->setSiliconAssociated(output_cache.flagAsSAF); // Si-associated candidates don't need these
99 cache.useHitSectors = false;
101 cache.createSystemExtension = (tp->pt() >= m_extThreshold) && ((m_extendSAF && cache.candidate->isSiliconAssociated()) ||
102 (m_extendBulk && !cache.candidate->isSiliconAssociated()));
103 cache.requireSystemExtension = m_requireExtension;
104 if (!m_muonSystemExtensionTool->muonSystemExtension(ctx, cache)) continue;
105 output_cache.outputContainer->push_back(std::move(cache.candidate));
106 }
107 ATH_MSG_DEBUG("InDetCandidates selected " << output_cache.outputContainer->size());
108 return StatusCode::SUCCESS;
109}
110
112 const xAOD::TrackParticle* const tp) const {
113 if (!tp->perigeeParameters().covariance()) {
114 ATH_MSG_WARNING("InDet TrackParticle without perigee! ");
115 return false;
116 }
117 if (!tp->track()) {
118 ATH_MSG_WARNING("The track particle has not an associated track");
119 return false;
120 }
121 if (currentTrackSelector && !currentTrackSelector->decision(*tp)) {
122 if (msgLvl(MSG::VERBOSE) && tp->pt() > 5000.) printTrackParticleInfo(tp, "Discarding");
123 return false;
124 }
125 return true;
126}
127
128void MuonCombinedInDetCandidateAlg::printTrackParticleInfo(const xAOD::TrackParticle* const tp, const std::string& what) const {
129 ATH_MSG_DEBUG(what << " InDet TrackParticle: pt " << tp->pt() << " eta " << tp->eta() << " phi " << tp->phi() << " Pixel "
131 << getCount(*tp, xAOD::numberOfSCTHits) << " TRT " << getCount(*tp, xAOD::numberOfTRTHits));
132}
133
135 uint8_t val{0};
136 if (!tp.summaryValue(val, type)) return 0;
137 return static_cast<int>(val);
138}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
bool msgLvl(const MSG::Level lvl) const
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< bool > m_requireExtension
Reject muon candidates without a muon system extension – only effective if the candidate shall actual...
Gaudi::Property< float > m_extThreshold
Minimum pt threshold of the IdCandidate to be extrapolated through the spectrometer.
SG::ReadHandleKey< CaloExtensionCollection > m_caloFwdExtensionLocation
Gaudi::Property< bool > m_waitForTrackLink
Schedule the data dependency on the trackLink decoration.
static int getCount(const xAOD::TrackParticle &tp, const xAOD::SummaryType type)
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_indetTrackParticleLocation
Gaudi::Property< bool > m_extendBulk
Shall ordinary ID tracks be equiped with a muon system extension used by MuGirl later.
Gaudi::Property< bool > m_extendSAF
Shall SAF tracks be equiped with a muon system extension used by MuGirl later.
SG::WriteHandleKey< InDetCandidateCollection > m_candidateCollectionName
ToolHandle< Muon::IMuonSystemExtensionTool > m_muonSystemExtensionTool
void printTrackParticleInfo(const xAOD::TrackParticle *const tp, const std::string &what) const
virtual StatusCode execute(const EventContext &ctx) const override final
ToolHandle< Trk::ITrackSelectorTool > m_trackSelector
ToolHandle< Trk::ITrackSelectorTool > m_forwardTrackSelector
virtual StatusCode initialize() override final
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_indetForwardTrackParticleLocation
StatusCode create(const EventContext &ctx, InDetCandidateCache &output_cache) const
bool isValidTrackParticle(const Trk::ITrackSelectorTool *currentTrackSelector, const xAOD::TrackParticle *const tp) const
SG::ReadDecorHandleKeyArray< xAOD::TrackParticleContainer > m_trkLinkKey
SG::ReadHandleKeyArray< CaloExtensionCollection > m_caloExtensionLocation
Helper class to provide constant type-safe access to aux data.
Property holding a SG store/key/clid from which a ReadHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The abstract interface base class for track selector tools.
virtual bool decision(const Trk::Track &track, const Vertex *vertex=0) const =0
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
int pdgId() const
PDG ID code.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
The MuonTagToSegMap is an auxillary construct that links the MuonSegments associated with a combined ...
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any).
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
SummaryType
Enumerates the different types of information stored in Summary.
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
const CaloExtensionCollection * extensionContainer
Cache of the CaloExtensions.
bool flagAsSAF
Flag the candidates as sillicion forward associated.
std::unique_ptr< InDetCandidateCollection > outputContainer
Output container for the StoreGate.
const Trk::ITrackSelectorTool * trackSelector
Corresponding track selector.
const xAOD::TrackParticleContainer * inDetContainer
Track particle container.
Helper struct to pipe all data needed by the tool to equip the Id track with a MuonSystemExtension.