61 return StatusCode::SUCCESS;
67 if (!parts.isValid()) {
69 return StatusCode::FAILURE;
74 return StatusCode::FAILURE;
76 std::map<int, std::vector<const xAOD::TruthParticle*>> truth_map_calo;
77 std::map<int, std::vector<const xAOD::TruthParticle*>> truth_map_track;
81 for (
size_t parti = 0; parti <
event->nTruthParticles(); ++parti) {
84 const int sector = sector_mapping.getSector(tpart->
phi());
85 truth_map_calo[sector].push_back(tpart);
87 truth_map_track[sector].push_back(tpart);
92 const float varradius20 = std::min(10e3 / part->pt(), 0.2);
93 const float varradius30 = std::min(10e3 / part->pt(), 0.3);
94 const xAOD::TruthParticle*
const truthLink = (acc_tpl(*part).isValid() ? *acc_tpl(*part) :
nullptr);
96 std::vector<int> sectors;
97 sector_mapping.getSectors(part->phi(), sectors);
99 float new_topoetcone20{0}, new_ptcone20{0}, new_ptvarcone20{0}, new_ptvarcone30{0},
100 new_ptcone20_pt500{0}, new_ptvarcone20_pt500{0}, new_ptvarcone30_pt500{0};
102 for (
const int sector : sectors) {
103 const std::vector<const xAOD::TruthParticle*>& calo_container = truth_map_calo[sector];
108 if (dR < 0.05 || dR > 0.2)
continue;
109 new_topoetcone20 += calo_part->pt();
112 const std::vector<const xAOD::TruthParticle*>& truth_container = truth_map_track[sector];
116 const float pt = trk_part->pt();
117 if (dR > 0.3)
continue;
118 new_ptcone20_pt500 += (dR < 0.2) * pt;
119 new_ptvarcone20_pt500 += (dR < varradius20) * pt;
120 new_ptvarcone30_pt500 += (dR < varradius30) * pt;
121 if (pt < 1000)
continue;
122 new_ptcone20 += (dR < 0.2) * pt;
123 new_ptvarcone20 += (dR < varradius20) * pt;
124 new_ptvarcone30 += (dR < varradius30) * pt;
128 decorator_topoetcone20(*part) = new_topoetcone20;
129 decorator_ptcone20(*part) = new_ptcone20;
130 decorator_ptvarcone20(*part) = new_ptvarcone20;
131 decorator_ptvarcone30(*part) = new_ptvarcone30;
132 decorator_ptcone20_pt500(*part) = new_ptcone20_pt500;
133 decorator_ptvarcone20_pt500(*part) = new_ptvarcone20_pt500;
134 decorator_ptvarcone30_pt500(*part) = new_ptvarcone30_pt500;
136 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
ATLAS-specific HepMC functions.
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptcone20_pt500_Key
PtCone20.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptvarcone20_pt500_Key
PtVarCone20.
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_topoetcone20_Key
Decor handle keys. Never set them via the JO as they're overwritten.
StatusCode initialize() override
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptvarcone30_Key
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptvarcone20_Key
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptvarcone30_pt500_Key
Pt varcone 30.
MuonTruthIsolationDecorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters.
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthSGKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_partSGKey
SG::WriteDecorHandleKey< xAOD::IParticleContainer > m_ptcone20_Key
SG::ConstAccessor< T, ALLOC > ConstAccessor
SG::Decorator< T, ALLOC > Decorator
Handle mappings between names and auxid_t.
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Class providing the definition of the 4-vector interface.
bool isNeutrino() const
Whether the particle is a neutrino (or antineutrino)
double abseta() const
The absolute pseudorapidity ( ) of the particle.
bool isCharged() const
Whether the particle is electrically charged.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
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...
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
TruthEvent_v1 TruthEvent
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.