ATLAS Offline Software
Public Member Functions | Static Public Member Functions | List of all members
RootTruthParticleCnvTool Class Reference

#include <RootTruthParticleCnvTool.h>

Inheritance diagram for RootTruthParticleCnvTool:
Collaboration diagram for RootTruthParticleCnvTool:

Public Member Functions

double chargeFromPdgId (int pdgId) const
 Helper method to get the charge of a particle given its PDG Id. More...
 
StatusCode convert (const McEventCollection *mcCollection, TruthParticleContainer *container) const
 Convert the first element of a McEventCollection into a TruthParticleContainer. More...
 
Function(s) inherited from ITruthParticleCnvTool
virtual StatusCode execute () const override
 A hook for Athena algorithms. More...
 
virtual StatusCode execute (const EventContext &ctx) const override
 
virtual StatusCode convert (const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor) const override
 Converts a McEventCollection into an TruthParticleContainer (ie: converts it into an AOD compliant collection). More...
 
Function(s) inherited from IInterface
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface) override
 
virtual unsigned long addRef () override
 
virtual unsigned long release () override
 
virtual unsigned long refCount () const override
 
Function(s) inherited from IProperty
virtual StatusCode setProperty (const std::string &s) override
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 
virtual StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 
virtual StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 
virtual const Gaudi::Details::PropertyBase & getProperty (std::string_view name) const override
 
virtual StatusCode getProperty (std::string_view n, std::string &v) const override
 
virtual const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 
virtual bool hasProperty (std::string_view name) const override
 
Function(s) inherited from IAlgTool
virtual const std::string & type () const override
 
virtual const IInterface * parent () const override
 
virtual StatusCode configure () override
 
virtual StatusCode initialize () override
 
virtual StatusCode sysInitialize () override
 
virtual StatusCode reinitialize () override
 
virtual StatusCode sysReinitialize () override
 
virtual StatusCode start () override
 
virtual StatusCode sysStart () override
 
virtual StatusCode restart () override
 
virtual StatusCode sysRestart () override
 
virtual StatusCode stop () override
 
virtual StatusCode sysStop () override
 
virtual StatusCode finalize () override
 
virtual StatusCode sysFinalize () override
 
virtual StatusCode terminate () override
 
virtual Gaudi::StateMachine::State FSMState () const override
 
Function(s) inherited from INamedInterface
virtual const std::string & name () const override
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:
More...
 

Detailed Description

Definition at line 13 of file RootTruthParticleCnvTool.h.

Member Function Documentation

◆ addRef()

unsigned long RootTruthParticleCnvTool::addRef ( )
overridevirtual

Definition at line 131 of file RootTruthParticleCnvTool.cxx.

131 { abort(); }

◆ chargeFromPdgId()

double RootTruthParticleCnvTool::chargeFromPdgId ( int  pdgId) const

Helper method to get the charge of a particle given its PDG Id.

Definition at line 120 of file RootTruthParticleCnvTool.cxx.

121 {
122  return MC::charge(pdgId);
123 }

◆ configure()

StatusCode RootTruthParticleCnvTool::configure ( )
overridevirtual

Definition at line 168 of file RootTruthParticleCnvTool.cxx.

168 { abort(); }

◆ convert() [1/2]

StatusCode ITruthParticleCnvTool::convert ( const McEventCollection mcCollection,
TruthParticleContainer container 
) const
inlineinherited

Convert the first element of a McEventCollection into a TruthParticleContainer.

Definition at line 112 of file ITruthParticleCnvTool.h.

114 {
115  const unsigned int genEvtIndex = 0;
116  const ITruthParticleVisitor* dummyVisitor = 0;
117  return this->convert( mcCollection, genEvtIndex, container, dummyVisitor );
118 }

◆ convert() [2/2]

StatusCode RootTruthParticleCnvTool::convert ( const McEventCollection mcEvts,
const unsigned int  genEvtIndex,
TruthParticleContainer mcParts,
const ITruthParticleVisitor visitor 
) const
overridevirtual

Converts a McEventCollection into an TruthParticleContainer (ie: converts it into an AOD compliant collection).

@in mcEvts the McEventCollection holding the HepMC::GenEvent we want to convert into a TruthParticleContainer @in genEvtIndex the index to the HepMC::GenEvent to be converted @out mcParts a valid pointer to a TruthParticleContainer which will be filled with adaptors to HepMC::GenParticles.

Create a map to enhance access between GenParticles and TruthParticles

Implements ITruthParticleCnvTool.

Definition at line 27 of file RootTruthParticleCnvTool.cxx.

32 {
33  container->clear();
34 
35  if ( 0 == mcCollection ) {
36  ::Warning ("RootTruthParticleCnvTool",
37  "Null pointer to McEventCollection !");
38  return StatusCode::RECOVERABLE;
39  }
40 
41  if ( mcCollection->size() <= genEventIndex ) {
42  ::Warning ("RootTruthParticleCnvTool",
43  "McEventCollection size: %ui; Requested element nbr : %ui !!",
44  // we could use %zd instead of using %ui and casting size_t to
45  // unsigned int, but %zd is not ANSI...
46  (unsigned int)mcCollection->size(),
47  genEventIndex);
48  return StatusCode::RECOVERABLE;
49  }
50 
51  const HepMC::GenEvent * evt = (*mcCollection)[genEventIndex];
52  container->setGenEvent( mcCollection, genEventIndex );
53 
54  // reserve enough space for the container so we don't have to relocate it
55  container->reserve( evt->particles_size() );
56 
59 
60  for ( const auto& hepMcPart: *evt) {
61 
62  TruthParticle * mcPart = new TruthParticle( hepMcPart, container );
63  container->push_back( mcPart );
64 
65  if ( visitor ) {
66  visitor->visit( mcPart );
67  }
68 
69  mcPart->setCharge( chargeFromPdgId( mcPart->pdgId() ) );
70  mcPart->setGenEventIndex( genEventIndex);
71 
72  if ( hepMcPart != mcPart->genParticle() ) {
73  ::Error ("RootTruthParticleCnvTool",
74  "TruthParticle is not wrapping the GenParticle : %d !!",
75  HepMC::barcode(hepMcPart));
76  }
77  HepMcParticleLink mcLink( HepMC::barcode(hepMcPart), genEventIndex, HepMcParticleLink::IS_POSITION, HepMcParticleLink::IS_BARCODE ); // FIXME barcode-based
78  bcToMcPart[ mcLink.compress() ] = mcPart;
79 
80  }//> end loop over particles
81 
82  // at this point the whole GenEvent has been proxied.
83  // so we can setup its VectorMap
84  container->setParticles( bcToMcPart );
85 
86 #if 0
87  // connect the TruthParticleContainer to the container of TruthEtIsolations
88  // if it exists and if we are asked for
89  if ( m_doEtIsolation.value() ) {
90  const std::string& etIsolName
91  = m_isolationTool->etIsolationsName( container->genEventName() );
92  if ( etIsolName.empty() ) {
93  m_msg << MSG::WARNING
94  << "Could not retrieve the name of the TruthEtIsolations container"
95  << endmsg;
96  return StatusCode::RECOVERABLE;
97  }
98 
99  const TruthEtIsolationsContainer* etIsols = 0;
100  if ( !m_storeGate->retrieve( etIsols, etIsolName ).isSuccess() ) {
101  m_msg << MSG::WARNING
102  << "Could not retrieve the TruthEtIsolations container at ["
103  << etIsolName << "] !!"
104  << endmsg;
105  return StatusCode::RECOVERABLE;
106  }
107 
108  // index of HepMC::GenEvent within the McEventCollection is the same
109  // than the one of the TruthEtIsolations within the TruthEtIsolationsCont.
110  container->setEtIsolations( etIsols, genEventIndex );
111  }
112 #endif
113 
114  return StatusCode::SUCCESS;
115 }

◆ convertMcEventCollection()

StatusCode ITruthParticleCnvTool::convertMcEventCollection ( const McEventCollection mcCollection,
TruthParticleContainer container 
) const
inlineinherited

Convert a McEventCollection into an TruthParticleContainer.

deprecated Note that the pointer to the TruthParticleContainer MUST be valid.

Definition at line 121 of file ITruthParticleCnvTool.h.

123 {
124  const unsigned int genEvtIndex = 0;
125  const ITruthParticleVisitor* dummyVisitor = 0;
126  return this->convert( mcCollection, genEvtIndex, container, dummyVisitor );
127 }

◆ execute() [1/2]

StatusCode RootTruthParticleCnvTool::execute ( ) const
overridevirtual

A hook for Athena algorithms.

Implements ITruthParticleCnvTool.

Definition at line 23 of file RootTruthParticleCnvTool.cxx.

23 { abort(); }

◆ execute() [2/2]

StatusCode RootTruthParticleCnvTool::execute ( const EventContext &  ctx) const
overridevirtual

Implements ITruthParticleCnvTool.

Definition at line 24 of file RootTruthParticleCnvTool.cxx.

24 { abort(); }

◆ finalize()

StatusCode RootTruthParticleCnvTool::finalize ( )
overridevirtual

Definition at line 179 of file RootTruthParticleCnvTool.cxx.

179 { abort(); }

◆ FSMState()

Gaudi::StateMachine::State RootTruthParticleCnvTool::FSMState ( ) const
overridevirtual

Definition at line 182 of file RootTruthParticleCnvTool.cxx.

182  {
183  abort(); }

◆ getProperties()

const std::vector< Gaudi::Details::PropertyBase * > & RootTruthParticleCnvTool::getProperties ( ) const
overridevirtual

Definition at line 154 of file RootTruthParticleCnvTool.cxx.

154 { abort(); }

◆ getProperty() [1/3]

StatusCode RootTruthParticleCnvTool::getProperty ( Gaudi::Details::PropertyBase *  p) const
overridevirtual

Definition at line 147 of file RootTruthParticleCnvTool.cxx.

147 { abort(); }

◆ getProperty() [2/3]

StatusCode RootTruthParticleCnvTool::getProperty ( std::string_view  n,
std::string &  v 
) const
overridevirtual

Definition at line 150 of file RootTruthParticleCnvTool.cxx.

151  {
152  abort(); }

◆ getProperty() [3/3]

const Gaudi::Details::PropertyBase & RootTruthParticleCnvTool::getProperty ( std::string_view  name) const
overridevirtual

Definition at line 149 of file RootTruthParticleCnvTool.cxx.

149 { abort(); }

◆ hasProperty()

bool RootTruthParticleCnvTool::hasProperty ( std::string_view  name) const
overridevirtual

Definition at line 155 of file RootTruthParticleCnvTool.cxx.

155  {
156  abort(); }

◆ initialize()

StatusCode RootTruthParticleCnvTool::initialize ( )
overridevirtual

Definition at line 169 of file RootTruthParticleCnvTool.cxx.

169 { abort(); }

◆ interfaceID()

const InterfaceID & ITruthParticleCnvTool::interfaceID ( )
inlinestaticinherited

Inline methods:

Definition at line 106 of file ITruthParticleCnvTool.h.

107 {
108  return IID_ITruthParticleCnvTool;
109 }

◆ name()

const std::string & RootTruthParticleCnvTool::name ( ) const
overridevirtual

Definition at line 193 of file RootTruthParticleCnvTool.cxx.

193 {abort();}

◆ parent()

const IInterface * RootTruthParticleCnvTool::parent ( ) const
overridevirtual

Definition at line 167 of file RootTruthParticleCnvTool.cxx.

167 { abort(); }

◆ queryInterface()

StatusCode RootTruthParticleCnvTool::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
)
overridevirtual

Definition at line 129 of file RootTruthParticleCnvTool.cxx.

130  { abort(); }

◆ refCount()

unsigned long RootTruthParticleCnvTool::refCount ( ) const
overridevirtual

Definition at line 133 of file RootTruthParticleCnvTool.cxx.

133 { abort(); }

◆ reinitialize()

StatusCode RootTruthParticleCnvTool::reinitialize ( )
overridevirtual

Definition at line 171 of file RootTruthParticleCnvTool.cxx.

171 { abort(); }

◆ release()

unsigned long RootTruthParticleCnvTool::release ( )
overridevirtual

Definition at line 132 of file RootTruthParticleCnvTool.cxx.

132 { abort(); }

◆ restart()

StatusCode RootTruthParticleCnvTool::restart ( )
overridevirtual

Definition at line 175 of file RootTruthParticleCnvTool.cxx.

175 { abort(); }

◆ setProperty() [1/2]

StatusCode RootTruthParticleCnvTool::setProperty ( const std::string &  name,
const Gaudi::Details::PropertyBase &  p 
)
overridevirtual

Definition at line 145 of file RootTruthParticleCnvTool.cxx.

145 { abort(); }

◆ setProperty() [2/2]

StatusCode RootTruthParticleCnvTool::setProperty ( const std::string &  s)
overridevirtual

Definition at line 143 of file RootTruthParticleCnvTool.cxx.

143  {
144  abort(); }

◆ setPropertyRepr()

StatusCode RootTruthParticleCnvTool::setPropertyRepr ( const std::string &  n,
const std::string &  r 
)
overridevirtual

Definition at line 146 of file RootTruthParticleCnvTool.cxx.

146 { abort(); }

◆ start()

StatusCode RootTruthParticleCnvTool::start ( )
overridevirtual

Definition at line 173 of file RootTruthParticleCnvTool.cxx.

173 { abort(); }

◆ stop()

StatusCode RootTruthParticleCnvTool::stop ( )
overridevirtual

Definition at line 177 of file RootTruthParticleCnvTool.cxx.

177 { abort(); }

◆ sysFinalize()

StatusCode RootTruthParticleCnvTool::sysFinalize ( )
overridevirtual

Definition at line 180 of file RootTruthParticleCnvTool.cxx.

180 { abort(); }

◆ sysInitialize()

StatusCode RootTruthParticleCnvTool::sysInitialize ( )
overridevirtual

Definition at line 170 of file RootTruthParticleCnvTool.cxx.

170 { abort(); }

◆ sysReinitialize()

StatusCode RootTruthParticleCnvTool::sysReinitialize ( )
overridevirtual

Definition at line 172 of file RootTruthParticleCnvTool.cxx.

172 { abort(); }

◆ sysRestart()

StatusCode RootTruthParticleCnvTool::sysRestart ( )
overridevirtual

Definition at line 176 of file RootTruthParticleCnvTool.cxx.

176 { abort(); }

◆ sysStart()

StatusCode RootTruthParticleCnvTool::sysStart ( )
overridevirtual

Definition at line 174 of file RootTruthParticleCnvTool.cxx.

174 { abort(); }

◆ sysStop()

StatusCode RootTruthParticleCnvTool::sysStop ( )
overridevirtual

Definition at line 178 of file RootTruthParticleCnvTool.cxx.

178 { abort(); }

◆ terminate()

StatusCode RootTruthParticleCnvTool::terminate ( )
overridevirtual

Definition at line 181 of file RootTruthParticleCnvTool.cxx.

181 { abort(); }

◆ type()

const std::string & RootTruthParticleCnvTool::type ( ) const
overridevirtual

Definition at line 166 of file RootTruthParticleCnvTool.cxx.

166 { abort(); }

The documentation for this class was generated from the following files:
ITruthParticleCnvTool::convert
virtual StatusCode convert(const McEventCollection *mcEvts, const unsigned int genEvtIndex, TruthParticleContainer *mcParts, const ITruthParticleVisitor *visitor=0) const =0
Convert a McEventCollection into an TruthParticleContainer.
ParticleImpl::pdgId
virtual int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
Definition: ParticleImpl.h:738
TruthEtIsolationsContainer
Definition: TruthEtIsolationsContainer.h:26
TruthParticle
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:58
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
TruthParticle::genParticle
HepMC::ConstGenParticlePtr genParticle() const
Retrieve the GenParticle this TruthParticle has been made from (if any)
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:279
TruthParticle::setGenEventIndex
void setGenEventIndex(size_t index)
set the GenEvent index
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:338
PowhegPy8EG_H2a.pdgId
dictionary pdgId
Definition: PowhegPy8EG_H2a.py:128
ITruthParticleVisitor
Definition: ITruthParticleVisitor.h:30
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
TruthParticleContainer::Map_t
std::unordered_map< long, const TruthParticle * > Map_t
barcode to TruthParticle dictionary
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:59
charge
double charge(const T &p)
Definition: AtlasPID.h:494
RootTruthParticleCnvTool::chargeFromPdgId
double chargeFromPdgId(int pdgId) const
Helper method to get the charge of a particle given its PDG Id.
Definition: RootTruthParticleCnvTool.cxx:120
ITruthParticleVisitor::visit
virtual void visit(TruthParticle *truthParticle) const =0
The method to visit a TruthParticle to apply further modifications to the instance at hand.
L1Topo::Error
Error
The different types of error that can be flagged in the L1TopoRDO.
Definition: Error.h:16
TruthParticle::setCharge
void setCharge(const ChargeType charge)
Set the charge of this TruthParticle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:327