ATLAS Offline Software
FTagGhostElectronAssociationAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include <vector>
12 
13 namespace FlavorTagDiscriminants {
14 
16  ISvcLocator* pSvcLocator ) : AthReentrantAlgorithm(name, pSvcLocator) {}
17 
19  ATH_MSG_DEBUG( "Initializing " << name() << "... " );
20 
21  // Initialize Container keys
22  ATH_MSG_DEBUG( "Initializing containers:" );
23  ATH_MSG_DEBUG( " ** " << m_JetContainerKey );
25  ATH_MSG_DEBUG( " ** " << m_ElectronsOutKey );
26 
29  ATH_CHECK( m_ElectronsOutKey.initialize() );
30 
31  return StatusCode::SUCCESS;
32  }
33 
34  StatusCode FTagGhostElectronAssociationAlg::execute(const EventContext& ctx) const {
35  ATH_MSG_DEBUG( "Executing " << name() << "... " );
36 
38  using IPC = xAOD::IParticleContainer;
39  using IPLV = std::vector<ElementLink<xAOD::IParticleContainer>>;
40 
41  // read collections
43  ATH_CHECK(electrons.isValid());
44  ATH_MSG_DEBUG( "Retrieved " << electrons->size() << " electrons..." );
45 
47  ATH_CHECK(jets.isValid());
48  ATH_MSG_DEBUG( "Retrieved " << jets->size() << " jets..." );
49 
51  std::set<size_t> used_electrons_idx;
52 
53  for (auto jet : *jets) {
54  IPLV electrons_in_jet;
55  std::vector<const xAOD::TrackParticle*> jet_tracks;
56  jet_tracks = jet->getAssociatedObjects<const xAOD::TrackParticle>("GhostTrack");
57  for (const auto electron : *electrons){
58  if (used_electrons_idx.count(electron->index())) continue;
59  auto track = xAOD::EgammaHelpers::getOriginalTrackParticle(electron);
60  if(!track) continue;
61  if(xAOD::P4Helpers::deltaR(*jet, *electron) > 0.5) continue;
62  for (unsigned int i = 0; i < jet_tracks.size(); i++){
63  if (track == jet_tracks[i]){
64  electrons_in_jet.push_back(ElementLink<IPC>(*electrons, electron->index()));
65  used_electrons_idx.insert(electron->index());
66  break;
67  }
68  }
69  }
70  electrons_out(*jet) = electrons_in_jet;
71  }
72  return StatusCode::SUCCESS;
73  }
74 }
FlavorTagDiscriminants
This file contains "getter" functions used for accessing tagger inputs from the EDM.
Definition: AssociationEnums.h:11
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAODP4Helpers.h
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
ElectronxAODHelpers.h
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::m_ElectronsOutKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ElectronsOutKey
Definition: FTagGhostElectronAssociationAlg.h:43
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition: xAOD/xAODBase/xAODBase/IParticleContainer.h:32
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: FTagGhostElectronAssociationAlg.cxx:34
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::m_JetContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_JetContainerKey
Definition: FTagGhostElectronAssociationAlg.h:35
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::P4Helpers::deltaR
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Definition: xAODP4Helpers.h:150
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
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ElectronFwd.h
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
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::initialize
virtual StatusCode initialize() override
Definition: FTagGhostElectronAssociationAlg.cxx:18
xAOD::ElectronContainer
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/ElectronContainer.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrackParticleFwd.h
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::m_ElectronContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_ElectronContainerKey
Definition: FTagGhostElectronAssociationAlg.h:38
FTagGhostElectronAssociationAlg.h
xAOD::EgammaHelpers::getOriginalTrackParticle
const xAOD::TrackParticle * getOriginalTrackParticle(const xAOD::Electron *el)
Helper function for getting the "Original" Track Particle (i.e before GSF) via the electron.
Definition: ElectronxAODHelpers.cxx:11
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TRT_PAI_gasdata::EC
const float EC[NC]
Energy levels for Carbon.
Definition: TRT_PAI_gasdata.h:241
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
FlavorTagDiscriminants::FTagGhostElectronAssociationAlg::FTagGhostElectronAssociationAlg
FTagGhostElectronAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: FTagGhostElectronAssociationAlg.cxx:15