ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCombinedInDetCandidateAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
12
13using namespace MuonCombined;
14MuonCombinedInDetCandidateAlg::MuonCombinedInDetCandidateAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 AthReentrantAlgorithm(name, pSvcLocator) {}
16
18 ATH_CHECK(m_trackSelector.retrieve(DisableTool{m_trackSelector.empty()}));
25 ATH_CHECK(m_forwardTrackSelector.retrieve(DisableTool{!m_doSiliconForwardMuons}));
26 ATH_MSG_INFO("Successfully initialized using the following configuration -- SAF: "
27 << (m_doSiliconForwardMuons ? "si" : "no") << ", "
28 << "MS extension bulk: " << (m_extendBulk ? "si" : "no")
29 << ", MS extension SAF: " << (m_doSiliconForwardMuons && m_extendSAF ? "si" : "no")
30 << ", Require MS estension: " << (m_requireExtension ? "si" : "no") << " min pT for extension " << m_extThreshold);
31 return StatusCode::SUCCESS;
32}
33
34StatusCode MuonCombinedInDetCandidateAlg::execute(const EventContext& ctx) const {
35 InDetCandidateCache output_cache{};
36 unsigned int counter{0};
38 if (!readHandle.isValid()) {
39 ATH_MSG_FATAL("Failed to retrieve " << readHandle.key());
40 return StatusCode::FAILURE;
41 }
42 output_cache.inDetContainer = readHandle.cptr();
43 output_cache.trackSelector = !m_trackSelector.empty() ? m_trackSelector.get() : nullptr;
44 if (counter < m_caloExtensionLocation.size()) {
46 if (!caloExtension.isValid()) {
47 ATH_MSG_FATAL("Failed to retrieve " << m_caloExtensionLocation[counter].fullKey());
48 return StatusCode::FAILURE;
49 }
50 output_cache.extensionContainer = caloExtension.cptr();
51 } else
52 output_cache.extensionContainer = nullptr;
53 ++counter;
54 ATH_CHECK(create(ctx, output_cache));
55 }
58 if (!readHandle.isValid()) {
59 ATH_MSG_FATAL("Failed to retrieve " << readHandle.key());
60 return StatusCode::FAILURE;
61 }
62 if (!m_caloFwdExtensionLocation.empty()) {
64 if (!caloExtension.isValid()) {
65 ATH_MSG_FATAL("Failed to retrieve " << m_caloFwdExtensionLocation.fullKey());
66 return StatusCode::FAILURE;
67 }
68 output_cache.extensionContainer = caloExtension.cptr();
69 } else
70 output_cache.extensionContainer = nullptr;
71
72 output_cache.inDetContainer = readHandle.cptr();
73 output_cache.trackSelector = !m_forwardTrackSelector.empty() ? m_forwardTrackSelector.get() : nullptr;
74 output_cache.flagAsSAF = true;
75 ATH_CHECK(create(ctx, output_cache));
76 }
77
79 ATH_CHECK(indetCandidateCollection.record(std::move(output_cache.outputContainer)));
80
81 return StatusCode::SUCCESS;
82}
83
84StatusCode MuonCombinedInDetCandidateAlg::create(const EventContext& ctx, InDetCandidateCache& output_cache) const {
85 ATH_MSG_DEBUG("Producing InDetCandidates for " << output_cache.inDetContainer->size());
86 for (const xAOD::TrackParticle* tp : *output_cache.inDetContainer) {
87 if (!isValidTrackParticle(output_cache.trackSelector, tp)) continue;
88
89 ElementLink<xAOD::TrackParticleContainer> link(*output_cache.inDetContainer, tp->index());
90 if (!link.isValid()) {
91 ATH_MSG_WARNING("Bad element link ");
92 continue;
93 } else if (*link != tp) {
94 ATH_MSG_WARNING("Dereferenced Link not equal to TrackParticle, skipping track ");
95 continue;
96 }
97 link.toPersistent();
98 printTrackParticleInfo(tp, "Creating");
99
100 if (msgLvl(MSG::VERBOSE)) {
102 if (truth_part) {
103 static const SG::ConstAccessor<int> truthTypeAcc("truthType");
104 static const SG::ConstAccessor<int> truthOriginAcc("truthOrigin");
105 ATH_MSG_VERBOSE(" Truth particle: pdgId " << truth_part->pdgId() << " type " << truthTypeAcc(*tp) << " origin "
106 << truthOriginAcc(*tp) << " pt " << truth_part->pt() << " eta "
107 << truth_part->eta() << " phi " << truth_part->phi());
108 }
109 }
111 cache.extensionContainer = output_cache.extensionContainer;
112 cache.candidate = std::make_unique<InDetCandidate>(link);
113 cache.candidate->setSiliconAssociated(output_cache.flagAsSAF); // Si-associated candidates don't need these
114 cache.useHitSectors = false;
116 cache.createSystemExtension = (tp->pt() >= m_extThreshold) && ((m_extendSAF && cache.candidate->isSiliconAssociated()) ||
119 if (!m_muonSystemExtensionTool->muonSystemExtension(ctx, cache)) continue;
120 output_cache.outputContainer->push_back(std::move(cache.candidate));
121 }
122 ATH_MSG_DEBUG("InDetCandidates selected " << output_cache.outputContainer->size());
123 return StatusCode::SUCCESS;
124}
125
127 const xAOD::TrackParticle* const tp) const {
128 if (!tp->perigeeParameters().covariance()) {
129 ATH_MSG_WARNING("InDet TrackParticle without perigee! ");
130 return false;
131 }
132 if (!tp->track()) {
133 ATH_MSG_WARNING("The track particle has not an associated track");
134 return false;
135 }
136 if (currentTrackSelector && !currentTrackSelector->decision(*tp)) {
137 if (msgLvl(MSG::VERBOSE) && tp->pt() > 5000.) printTrackParticleInfo(tp, "Discarding");
138 return false;
139 }
140 return true;
141}
142
143void MuonCombinedInDetCandidateAlg::printTrackParticleInfo(const xAOD::TrackParticle* const tp, const std::string& what) const {
144 ATH_MSG_DEBUG(what << " InDet TrackParticle: pt " << tp->pt() << " eta " << tp->eta() << " phi " << tp->phi() << " Pixel "
146 << getCount(*tp, xAOD::numberOfSCTHits) << " TRT " << getCount(*tp, xAOD::numberOfTRTHits));
147}
148
150 uint8_t val{0};
151 if (!tp.summaryValue(val, type)) return 0;
152 return static_cast<int>(val);
153}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#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
An algorithm that can be simultaneously executed in multiple threads.
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
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
MuonCombinedInDetCandidateAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< Trk::ITrackSelectorTool > m_trackSelector
ToolHandle< Trk::ITrackSelectorTool > m_forwardTrackSelector
int getCount(const xAOD::TrackParticle &tp, xAOD::SummaryType type) const
StatusCode execute(const EventContext &ctx) const override
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::ReadHandleKeyArray< CaloExtensionCollection > m_caloExtensionLocation
bool isSiliconAssociated() const
Returns true if this candidate was formed from a special far forward InDet track.
void setSiliconAssociated(bool)
Pass true if this candiate was created from a special far forward InDet track.
Helper class to provide constant type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
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
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 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.
bool requireSystemExtension
Require that the muon system extension was successful.
bool createSystemExtension
Try to create the muon system extension.
bool useHitSectors
Switch to restrict the intersection search only to the sectors with hits.
const CaloExtensionCollection * extensionContainer
Cache of the CaloExtensions.
std::unique_ptr< MuonCombined::InDetCandidate > candidate
Inner detector candidate.