ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
11
14#include "GaudiKernel/IPartPropSvc.h"
15#include "HepPDT/ParticleData.hh"
16#include "HepPDT/ParticleDataTable.hh"
18
19namespace D3PD {
20
21
29 const std::string& name,
30 const IInterface* parent)
31 : Base (type, name, parent),
32 m_ppsvc ("PartPropSvc", name)
33{
34 declareProperty ("PDGIDVariable", m_PDGIDVariable = "pdgId");
35 declareProperty ("PartPropSvc", m_ppsvc,
36 "Particle property service.");
37
38 book().ignore(); // Avoid coverity warnings.
39}
40
41
46{
47 CHECK( m_ppsvc.retrieve() );
48 return StatusCode::SUCCESS;
49}
50
51
56{
57 CHECK( addVariable("status", m_status) );
58 CHECK( addVariable("barcode", m_uniqueID) ); // TODO Rename variable to be consistent?
60 CHECK( addVariable("charge", m_charge) );
61 return StatusCode::SUCCESS;
62}
63
64
74{
75 *m_status = p.status();
77 *m_pdgId = p.pdgId();
78
79 const HepPDT::ParticleDataTable* pdt = m_ppsvc->PDT();
80 const HepPDT::ParticleData* pd = pdt->particle (std::abs(p.pdgId()));
81 *m_charge = pd ? pd->charge() : 0;
82 if (p.pdgId() < 0)
83 *m_charge = - *m_charge;
84
85 return StatusCode::SUCCESS;
86}
87
88
89} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Block filler tool for TruthParticle's.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
ServiceHandle< IPartPropSvc > m_ppsvc
Property: Particle property service.
BlockFillerTool< xAOD::TruthParticle > Base
int * m_uniqueID
Variable: Unique Identifier for the particle.
std::string m_PDGIDVariable
Property: Name for pdgId variable.
float * m_charge
Variable: Particle charge.
int * m_status
Variable: Status code for the particle.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
TruthParticleFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
int * m_pdgId
Variable: Particle ID code.
virtual StatusCode book() final
Book variables for this block.
virtual StatusCode fill(const xAOD::TruthParticle &p) override
Fill one block — type-safe version.
Block filler tool for noisy FEB information.
int uniqueID(const T &p)
TruthParticle_v1 TruthParticle
Typedef to implementation.