20#include "GaudiKernel/SystemOfUnits.h"
25using Gaudi::Units::GeV;
26using Gaudi::Units::MeV;
46 "Prefix to add to aux data items.");
49 "Minimum pt for electrons.");
51 "Minimum pt for photons.");
55 "Isolation cone width.");
57 "Maximum isolation cone energy allowed to keep a photon.");
66 CHECK( AthReentrantAlgorithm::initialize() );
71 return StatusCode::SUCCESS;
82 auto pout = std::make_unique<xAOD::TruthParticleContainer>();
83 auto pout_aux = std::make_unique<xAOD::TruthParticleAuxContainer>();
84 pout->setStore (pout_aux.get());
86#define DECOR(TYPE,N) xAOD::TruthParticle::Decorator<TYPE> N (m_auxPrefix + #N)
87 DECOR(
float, etaCalo);
88 DECOR(
float, phiCalo);
89 DECOR(
float, depthCalo);
90 DECOR(
float, Etcone20);
96 pout->push_back (std::make_unique<xAOD::TruthParticle>());
100 etaCalo(*pout->back()),
101 phiCalo(*pout->back()),
102 depthCalo(*pout->back())) );
103 Etcone20(*pout->back()) = iso;
108 CHECK( output.record (std::move(pout), std::move(pout_aux)) );
110 return StatusCode::SUCCESS;
135 if (fabs(tp.eta()) >
m_etaMax)
return false;
139 if( tp.hasDecayVtx() ) {
141 size_t sz = v->nOutgoingParticles();
142 for (
size_t i = 0; i <
sz; i++) {
175 if (tp.p4().DeltaR (p->p4()) <
m_isoCone)
194 float& depthCalo)
const
200 std::unique_ptr<Trk::CaloExtension> extension =
201 m_exten->caloExtension(Gaudi::Hive::currentContext(), tp);
204 return StatusCode::FAILURE;
209 for (
const auto& [sampling, entry, exit] : lvec) {
210 if (sampling == CaloSampling::EMB2) {
211 etaCalo = entry.eta();
212 phiCalo = entry.phi();
213 depthCalo = entry.perp();
216 else if (sampling == CaloSampling::EME2) {
217 etaCalo = entry.eta();
218 phiCalo = entry.phi();
219 depthCalo = std::abs(entry.z());
223 return StatusCode::SUCCESS;
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
ATLAS-specific HepMC functions.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
float m_photonEtIsoMax
Property: Maximum isolation cone energy allowed to keep a photon.
float computeIso(const xAOD::TruthParticle &tp, const xAOD::TruthParticleContainer &cont) const
Compute isolation around a particle.
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_outputKey
Property: Name of the output container.
float m_electronPtMin
Property: Minimum pt for electrons.
float m_etaMax
Property: Maximum eta.
egammaTruthAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_inputKey
Property: Name of the input container.
float m_isoCone
Property: Isolation cone width.
std::string m_auxPrefix
Property: Prefix to add to aux data items.
StatusCode findImpact(const xAOD::TruthParticle &tp, float &etaCalo, float &phiCalo, float &depthCalo) const
Find the impact of a particle in the calorimeter.
virtual StatusCode execute(const EventContext &ctx) const override
Standard Gaudi execute method.
bool isAccepted(const xAOD::TruthParticle &tp, const xAOD::TruthParticleContainer &cont, float &iso) const
Test to see if we accept a particle.
ToolHandle< Trk::IParticleCaloExtensionTool > m_exten
Property: Extrapolation tool to calorimeter.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
float m_photonPtMin
Property: Minimum pt for photons.
int pdgId() const
PDG ID code.
Select egtruth particles.
void entryExitPerLayerVector(const Trk::CaloExtension &extension, EntryExitPerLayerVector &result, const LayersToSelect *selection=nullptr)
std::vector< std::tuple< CaloSampling::CaloSample, Amg::Vector3D, Amg::Vector3D > > EntryExitPerLayerVector
Block filler tool for noisy FEB information.
bool is_same_particle(const T1 &p1, const T2 &p2)
Method to establish if two particles in the GenEvent actually represent the same particle.
bool is_simulation_particle(const T &p)
Method to establish if a particle (or barcode) was created during the simulation (TODO update to be s...
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...
bool isZeroEnergyPhoton(const T &p)
Identify a photon with zero energy. Probably a workaround for a generator bug.
bool isStableOrSimDecayed(const T &p)
Identify if particle is satble or decayed in simulation.
bool isPhoton(const T &p)
bool isSpecialNonInteracting(const T &p)
Identify a special non-interacting particles.
static const int ELECTRON
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.