ATLAS Offline Software
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 
13 using namespace MuonCombined;
14 MuonCombinedInDetCandidateAlg::MuonCombinedInDetCandidateAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15  AthReentrantAlgorithm(name, pSvcLocator) {}
16 
18  ATH_CHECK(m_trackSelector.retrieve(DisableTool{m_trackSelector.empty()}));
21  ATH_CHECK(m_caloExtensionLocation.initialize());
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 
34 StatusCode 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 
84 StatusCode 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()) ||
117  (m_extendBulk && !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 
144  ATH_MSG_DEBUG(what << " InDet TrackParticle: pt " << tp->pt() << " eta " << tp->eta() << " phi " << tp->phi() << " Pixel "
147 }
148 
150  uint8_t val{0};
151  if (!tp.summaryValue(val, type)) return 0;
152  return static_cast<int>(val);
153 }
Trk::ITrackSelectorTool
The abstract interface base class for track selector tools.
Definition: ITrackSelectorTool.h:35
MuonCombinedInDetCandidateAlg::isValidTrackParticle
bool isValidTrackParticle(const Trk::ITrackSelectorTool *currentTrackSelector, const xAOD::TrackParticle *const tp) const
Definition: MuonCombinedInDetCandidateAlg.cxx:126
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonCombinedInDetCandidateAlg::m_caloFwdExtensionLocation
SG::ReadHandleKey< CaloExtensionCollection > m_caloFwdExtensionLocation
Definition: MuonCombinedInDetCandidateAlg.h:40
MuonCombinedInDetCandidateAlg::initialize
StatusCode initialize() override
Definition: MuonCombinedInDetCandidateAlg.cxx:17
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
MuonCombinedInDetCandidateAlg::create
StatusCode create(const EventContext &ctx, InDetCandidateCache &output_cache) const
Definition: MuonCombinedInDetCandidateAlg.cxx:84
MuonCombinedInDetCandidateAlg::m_trackSelector
ToolHandle< Trk::ITrackSelectorTool > m_trackSelector
Definition: MuonCombinedInDetCandidateAlg.h:44
MuonCombinedInDetCandidateAlg::m_requireExtension
Gaudi::Property< bool > m_requireExtension
Reject muon candidates without a muon system extension – only effective if the candidate shall actual...
Definition: MuonCombinedInDetCandidateAlg.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Muon::IMuonSystemExtensionTool::SystemExtensionCache::candidate
std::unique_ptr< MuonCombined::InDetCandidate > candidate
Inner detector candidate.
Definition: IMuonSystemExtensionTool.h:44
TruthParticleContainer.h
Muon::IMuonSystemExtensionTool::SystemExtensionCache::requireSystemExtension
bool requireSystemExtension
Require that the muon system extension was successful.
Definition: IMuonSystemExtensionTool.h:56
ParticleTest.tp
tp
Definition: ParticleTest.py:25
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
MuonCombinedInDetCandidateAlg::InDetCandidateCache
Definition: MuonCombinedInDetCandidateAlg.h:51
xAOD::numberOfTRTHits
@ numberOfTRTHits
number of TRT hits [unit8_t].
Definition: TrackingPrimitives.h:275
SG::ConstAccessor< int >
Muon::IMuonSystemExtensionTool::SystemExtensionCache::extensionContainer
const CaloExtensionCollection * extensionContainer
Cache of the CaloExtensions.
Definition: IMuonSystemExtensionTool.h:49
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonCombinedInDetCandidateAlg::InDetCandidateCache::flagAsSAF
bool flagAsSAF
Flag the candidates as sillicion forward associated.
Definition: MuonCombinedInDetCandidateAlg.h:57
xAODTruthHelpers.h
MuonCombinedInDetCandidateAlg::m_doSiliconForwardMuons
Gaudi::Property< bool > m_doSiliconForwardMuons
Definition: MuonCombinedInDetCandidateAlg.h:71
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
MuonCombinedInDetCandidateAlg::m_indetTrackParticleLocation
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_indetTrackParticleLocation
Definition: MuonCombinedInDetCandidateAlg.h:30
xAOD::SummaryType
SummaryType
Enumerates the different types of information stored in Summary.
Definition: TrackingPrimitives.h:228
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::IMuonSystemExtensionTool::SystemExtensionCache::createSystemExtension
bool createSystemExtension
Try to create the muon system extension.
Definition: IMuonSystemExtensionTool.h:54
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
Trk::ITrackSelectorTool::decision
virtual bool decision(const Trk::Track &track, const Vertex *vertex=0) const =0
MuonCombinedInDetCandidateAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: MuonCombinedInDetCandidateAlg.cxx:34
MuonCombinedInDetCandidateAlg::InDetCandidateCache::extensionContainer
const CaloExtensionCollection * extensionContainer
Cache of the CaloExtensions.
Definition: MuonCombinedInDetCandidateAlg.h:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonCombinedInDetCandidateAlg::m_extThreshold
Gaudi::Property< float > m_extThreshold
Minimum pt threshold of the IdCandidate to be extrapolated through the spectrometer.
Definition: MuonCombinedInDetCandidateAlg.h:73
MuonCombinedInDetCandidateAlg::m_extendSAF
Gaudi::Property< bool > m_extendSAF
Shall SAF tracks be equiped with a muon system extension used by MuGirl later.
Definition: MuonCombinedInDetCandidateAlg.h:75
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
MuonCombinedInDetCandidateAlg::getCount
int getCount(const xAOD::TrackParticle &tp, xAOD::SummaryType type) const
Definition: MuonCombinedInDetCandidateAlg.cxx:149
MuonCombinedInDetCandidateAlg.h
MuonCombinedInDetCandidateAlg::InDetCandidateCache::outputContainer
std::unique_ptr< InDetCandidateCollection > outputContainer
Output container for the StoreGate.
Definition: MuonCombinedInDetCandidateAlg.h:59
MuonCombinedInDetCandidateAlg::InDetCandidateCache::trackSelector
const Trk::ITrackSelectorTool * trackSelector
Corresponding track selector.
Definition: MuonCombinedInDetCandidateAlg.h:61
MuonSystemExtension.h
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
MuonCombinedInDetCandidateAlg::m_muonSystemExtensionTool
ToolHandle< Muon::IMuonSystemExtensionTool > m_muonSystemExtensionTool
Definition: MuonCombinedInDetCandidateAlg.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::TruthHelpers::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const xAOD::IParticle &p)
Return the truthParticle associated to the given IParticle (if any)
Definition: xAODTruthHelpers.cxx:25
xAOD::TruthParticle_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: TruthParticle_v1.cxx:174
MuonCombinedInDetCandidateAlg::m_caloExtensionLocation
SG::ReadHandleKeyArray< CaloExtensionCollection > m_caloExtensionLocation
Definition: MuonCombinedInDetCandidateAlg.h:32
Muon::IMuonSystemExtensionTool::SystemExtensionCache
Helper struct to pipe all data needed by the tool to equip the Id track with a MuonSystemExtension.
Definition: IMuonSystemExtensionTool.h:41
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonSectorMapping.h
MuonCombinedInDetCandidateAlg::printTrackParticleInfo
void printTrackParticleInfo(const xAOD::TrackParticle *const tp, const std::string &what) const
Definition: MuonCombinedInDetCandidateAlg.cxx:143
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::TruthParticle_v1::phi
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
Definition: TruthParticle_v1.cxx:181
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonCombined
The MuonTagToSegMap is an auxillary construct that links the MuonSegments associated with a combined ...
Definition: IMuonSystemExtensionTool.h:23
xAOD::TruthParticle_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: TruthParticle_v1.cxx:166
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
MuonCombinedInDetCandidateAlg::m_candidateCollectionName
SG::WriteHandleKey< InDetCandidateCollection > m_candidateCollectionName
Definition: MuonCombinedInDetCandidateAlg.h:42
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Muon::IMuonSystemExtensionTool::SystemExtensionCache::useHitSectors
bool useHitSectors
Switch to restrict the intersection search only to the sectors with hits.
Definition: IMuonSystemExtensionTool.h:52
MuonCombinedInDetCandidateAlg::MuonCombinedInDetCandidateAlg
MuonCombinedInDetCandidateAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonCombinedInDetCandidateAlg.cxx:14
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
MuonCombinedInDetCandidateAlg::m_forwardTrackSelector
ToolHandle< Trk::ITrackSelectorTool > m_forwardTrackSelector
Definition: MuonCombinedInDetCandidateAlg.h:46
MuonCombinedInDetCandidateAlg::m_extendBulk
Gaudi::Property< bool > m_extendBulk
Shall ordinary ID tracks be equiped with a muon system extension used by MuGirl later.
Definition: MuonCombinedInDetCandidateAlg.h:77
xAOD::TruthParticle_v1::pdgId
int pdgId() const
PDG ID code.
test_pyathena.counter
counter
Definition: test_pyathena.py:15
MuonCombinedInDetCandidateAlg::m_indetForwardTrackParticleLocation
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_indetForwardTrackParticleLocation
Definition: MuonCombinedInDetCandidateAlg.h:37
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237
MuonCombinedInDetCandidateAlg::InDetCandidateCache::inDetContainer
const xAOD::TrackParticleContainer * inDetContainer
Track particle container.
Definition: MuonCombinedInDetCandidateAlg.h:53