ATLAS Offline Software
Loading...
Searching...
No Matches
ThinTRTStandaloneTrackAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration.
3*/
4
8
12StatusCode
24
29StatusCode
30ThinTRTStandaloneTrackAlg::execute(const EventContext& ctx) const
31{
32 // Retrieve InDet TrackParticles
35
36 if (!indetTrackPC.isValid()) {
37 ATH_MSG_FATAL("Failed to retrieve " << m_InDetTrackParticlesKey.key());
38 return StatusCode::FAILURE;
39 }
40 ATH_MSG_DEBUG("Number of InDet TrackParticles " << indetTrackPC->size());
41
42 // We set to false ONLY the TRT standalone track particles
43 // We then reset to true whatever is to be kept
44 // from the domains
45 std::vector<bool> keptInDetTrackParticles;
46 keptInDetTrackParticles.resize(indetTrackPC->size(), true);
47 for (const auto* track : *indetTrackPC) {
48 if (track->patternRecoInfo().test(xAOD::TRTStandalone)) {
49 keptInDetTrackParticles[track->index()] = false;
50 }
51 }
52
53 if (m_doElectron) {
54 // Retrieve electrons
57 if (!electrons.isValid()) {
58 ATH_MSG_FATAL("Failed to retrieve " << m_InputElectronContainerKey.key());
59 return StatusCode::FAILURE;
60 }
61
62 // Loop over electrons
63 for (const xAOD::Electron* electron : *electrons) {
64 auto trackParticleLinks = electron->trackParticleLinks();
65 for (const auto& link : trackParticleLinks) {
66 if (!link.isValid()) {
67 continue;
68 }
70 "Electons : Keeping InDet Track Particle with index : "
72 ->index());
73 keptInDetTrackParticles
75 ->index()] = true;
76 }
77 }
78 }
79
80 if (m_doPhoton) {
81 // Retrieve photons
83 ctx);
84 if (!photons.isValid()) {
85 ATH_MSG_FATAL("Failed to retrieve " << m_InputPhotonContainerKey.key());
86 return StatusCode::FAILURE;
87 }
88
89 // Loop over photons
90 for (const xAOD::Photon* photon : *photons) {
91 auto vertexLinks = photon->vertexLinks();
92 for (const auto& vxlink : vertexLinks) {
93 if (!vxlink.isValid()) {
94 continue;
95 }
96 const xAOD::Vertex* vx = *(vxlink);
97 if (!vx) {
98 continue;
99 }
100 auto trackParticleLinks = vx->trackParticleLinks();
101 for (const auto& link : trackParticleLinks) {
102 if (!link.isValid()) {
103 continue;
104 }
106 "Photons : Keeping InDet Track Particle with index : "
108 ->index());
109 keptInDetTrackParticles
111 ->index()] = true;
112 }
113 }
114 }
115 }
116
117 if (m_doTau) {
118 // Retrieve taus
120 if (!taus.isValid()) {
121 ATH_MSG_FATAL("Failed to retrieve " << m_InputTauJetContainerKey.key());
122 return StatusCode::FAILURE;
123 }
124 static const SG::AuxElement::ConstAccessor<char> acc_passThinning(
125 "passThinning");
126
127 // Loop over taus
128 for (const xAOD::TauJet* tau : *taus) {
129 if (!acc_passThinning(*tau)) {
130 continue;
131 }
132 for (const xAOD::TauTrack* track : tau->allTracks()) {
133 // LRTs are not in the InDetTrackParticles container, so skip them
134 if (!track->flag(
136 keptInDetTrackParticles[track->track()->index()] = true;
137 }
138 }
139 }
140 }
141
142 if (m_doTauEleRM) {
143 // Retrieve ele rm taus
145 if (!taus_elerm.isValid()) {
146 ATH_MSG_FATAL("Failed to retrieve " << m_InputTauJet_EleRMContainerKey.key());
147 return StatusCode::FAILURE;
148 }
149 static const SG::AuxElement::ConstAccessor<char> acc_passThinning(
150 "passThinning");
151
152 // Loop over taus
153 for (const xAOD::TauJet* elerm_tau : *taus_elerm) {
154 if (!acc_passThinning(*elerm_tau)) {
155 continue;
156 }
157 for (const xAOD::TauTrack* erm_track : elerm_tau->allTracks()) {
158 // LRTs are not in the InDetTrackParticles container, so skip them
159 if (!erm_track->flag(
161 keptInDetTrackParticles[erm_track->track()->index()] = true;
162 }
163 }
164 }
165 }
166
167 if (m_doMuon) {
169 if (!muons.isValid()) {
170 ATH_MSG_FATAL("Failed to retrieve " << m_inputMuonContainerKey.key());
171 return StatusCode::FAILURE;
172 }
173 for (const xAOD::Muon* muon : *muons) {
174 const xAOD::TrackParticle* trk =
175 muon->trackParticle(xAOD::Muon::InnerDetectorTrackParticle);
177 if (muon->muonType() != xAOD::Muon::SiliconAssociatedForwardMuon && trk)
178 keptInDetTrackParticles[trk->index()] = true;
179 }
180 }
181
182 // Do the thinning
183 indetTrackPC.keep(keptInDetTrackParticles);
184
185 return StatusCode::SUCCESS;
186}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
static Double_t taus
Handle for requesting thinning for a data object.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:569
size_t index() const
Return the index of this element within its container.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
Handle for requesting thinning for a data object.
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_InDetTrackParticlesKey
Track Particle container to thin.
StringProperty m_streamName
Name of the stream being thinned.
SG::ReadHandleKey< xAOD::TauJetContainer > m_InputTauJet_EleRMContainerKey
TauJets_EleRM collection input name.
Gaudi::Property< bool > m_doPhoton
Thin photon tracks.
Gaudi::Property< bool > m_doElectron
Thin electron tracks.
StatusCode initialize() override final
initialize method
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputElectronContainerKey
electron collection input name
SG::ReadHandleKey< xAOD::PhotonContainer > m_InputPhotonContainerKey
photon collection input name
Gaudi::Property< bool > m_doTau
Thin tau tracks.
SG::ReadHandleKey< xAOD::TauJetContainer > m_InputTauJetContainerKey
TauJets collection input name.
Gaudi::Property< bool > m_doTauEleRM
Thin electron removal tau tracks.
StatusCode execute(const EventContext &ctx) const override final
execute method
SG::ReadHandleKey< xAOD::MuonContainer > m_inputMuonContainerKey
Muon collection input name.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
Definition index.py:1
const xAOD::TrackParticle * getOriginalTrackParticleFromGSF(const xAOD::TrackParticle *trkPar)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the GSF Track Particle...
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TauTrack_v1 TauTrack
Definition of the current version.
Definition TauTrack.h:16
TauJet_v3 TauJet
Definition of the current "tau version".
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
@ TRTStandalone
TRT Standalone.