ATLAS Offline Software
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 
14 {
16 
22  return StatusCode::SUCCESS;
23 }
24 
30 ThinTRTStandaloneTrackAlg::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  }
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 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ThinTRTStandaloneTrackAlg::m_doTau
Gaudi::Property< bool > m_doTau
Thin tau tracks.
Definition: ThinTRTStandaloneTrackAlg.h:46
ThinningHandle.h
Handle for requesting thinning for a data object.
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
ThinTRTStandaloneTrackAlg::m_InputElectronContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_InputElectronContainerKey
electron collection input name
Definition: ThinTRTStandaloneTrackAlg.h:62
xAOD::Vertex_v1::trackParticleLinks
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
ThinTRTStandaloneTrackAlg::m_doElectron
Gaudi::Property< bool > m_doElectron
Thin electron tracks.
Definition: ThinTRTStandaloneTrackAlg.h:40
ThinTRTStandaloneTrackAlg::m_InDetTrackParticlesKey
SG::ThinningHandleKey< xAOD::TrackParticleContainer > m_InDetTrackParticlesKey
Track Particle container to thin.
Definition: ThinTRTStandaloneTrackAlg.h:54
ThinTRTStandaloneTrackAlg::m_doTauEleRM
Gaudi::Property< bool > m_doTauEleRM
Thin electron removal tau tracks.
Definition: ThinTRTStandaloneTrackAlg.h:49
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
ThinTRTStandaloneTrackAlg::initialize
StatusCode initialize() override final
initialize method
Definition: ThinTRTStandaloneTrackAlg.cxx:13
xAOD::TauJetParameters::LargeRadiusTrack
@ LargeRadiusTrack
Definition: TauDefs.h:413
ThinTRTStandaloneTrackAlg::m_doPhoton
Gaudi::Property< bool > m_doPhoton
Thin photon tracks.
Definition: ThinTRTStandaloneTrackAlg.h:43
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
SG::ThinningHandle
Handle for requesting thinning for a data object.
Definition: ThinningHandle.h:84
EgammaxAODHelpers.h
ThinTRTStandaloneTrackAlg::m_inputMuonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_inputMuonContainerKey
Muon collection input name.
Definition: ThinTRTStandaloneTrackAlg.h:77
ThinTRTStandaloneTrackAlg::m_streamName
StringProperty m_streamName
Name of the stream being thinned.
Definition: ThinTRTStandaloneTrackAlg.h:58
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
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
ThinTRTStandaloneTrackAlg::m_InputPhotonContainerKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_InputPhotonContainerKey
photon collection input name
Definition: ThinTRTStandaloneTrackAlg.h:66
xAOD::TauHelpers::trackParticleLinks
std::vector< ElementLink< xAOD::TrackParticleContainer > > trackParticleLinks(const xAOD::TauJet *tau, xAOD::TauJetParameters::TauTrackFlag flag=xAOD::TauJetParameters::TauTrackFlag::classifiedCharged)
Definition: TauxAODHelpers.cxx:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
ThinTRTStandaloneTrackAlg::m_InputTauJetContainerKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_InputTauJetContainerKey
TauJets collection input name.
Definition: ThinTRTStandaloneTrackAlg.h:70
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ThinTRTStandaloneTrackAlg.h
ThinTRTStandaloneTrackAlg::m_doMuon
Gaudi::Property< bool > m_doMuon
Definition: ThinTRTStandaloneTrackAlg.h:51
xAOD::EgammaHelpers::getOriginalTrackParticleFromGSF
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...
Definition: ElectronxAODHelpers.cxx:22
xAOD::Electron_v1
Definition: Electron_v1.h:34
ThinTRTStandaloneTrackAlg::execute
StatusCode execute(const EventContext &ctx) const override final
execute method
Definition: ThinTRTStandaloneTrackAlg.cxx:30
DeMoScan.index
string index
Definition: DeMoScan.py:364
xAOD::TRTStandalone
@ TRTStandalone
TRT Standalone.
Definition: TrackingPrimitives.h:125
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:199
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::TauTrack_v1
Definition: TauTrack_v1.h:27
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
ThinTRTStandaloneTrackAlg::m_InputTauJet_EleRMContainerKey
SG::ReadHandleKey< xAOD::TauJetContainer > m_InputTauJet_EleRMContainerKey
TauJets_EleRM collection input name.
Definition: ThinTRTStandaloneTrackAlg.h:74
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17