ATLAS Offline Software
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...
 
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 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
 

Detailed Description

Definition at line 13 of file RootTruthParticleCnvTool.h.

Member Function Documentation

◆ 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 156 of file RootTruthParticleCnvTool.cxx.

156 { abort(); }

◆ convert()

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

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 }

◆ execute() [1/2]

StatusCode RootTruthParticleCnvTool::execute ( ) const
overridevirtual

A hook for Athena algorithms.

Definition at line 23 of file RootTruthParticleCnvTool.cxx.

23 { abort(); }

◆ execute() [2/2]

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

Definition at line 24 of file RootTruthParticleCnvTool.cxx.

24 { abort(); }

◆ finalize()

StatusCode RootTruthParticleCnvTool::finalize ( )
overridevirtual

Definition at line 167 of file RootTruthParticleCnvTool.cxx.

167 { abort(); }

◆ FSMState()

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

Definition at line 170 of file RootTruthParticleCnvTool.cxx.

170  {
171  abort(); }

◆ getProperties()

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

Definition at line 142 of file RootTruthParticleCnvTool.cxx.

142 { abort(); }

◆ getProperty() [1/3]

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

Definition at line 135 of file RootTruthParticleCnvTool.cxx.

135 { abort(); }

◆ getProperty() [2/3]

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

Definition at line 138 of file RootTruthParticleCnvTool.cxx.

139  {
140  abort(); }

◆ getProperty() [3/3]

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

Definition at line 137 of file RootTruthParticleCnvTool.cxx.

137 { abort(); }

◆ hasProperty()

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

Definition at line 143 of file RootTruthParticleCnvTool.cxx.

143  {
144  abort(); }

◆ initialize()

StatusCode RootTruthParticleCnvTool::initialize ( )
overridevirtual

Definition at line 157 of file RootTruthParticleCnvTool.cxx.

157 { abort(); }

◆ name()

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

Definition at line 181 of file RootTruthParticleCnvTool.cxx.

181 {abort();}

◆ parent()

const IInterface * RootTruthParticleCnvTool::parent ( ) const
overridevirtual

Definition at line 155 of file RootTruthParticleCnvTool.cxx.

155 { abort(); }

◆ reinitialize()

StatusCode RootTruthParticleCnvTool::reinitialize ( )
overridevirtual

Definition at line 159 of file RootTruthParticleCnvTool.cxx.

159 { abort(); }

◆ restart()

StatusCode RootTruthParticleCnvTool::restart ( )
overridevirtual

Definition at line 163 of file RootTruthParticleCnvTool.cxx.

163 { abort(); }

◆ setProperty() [1/2]

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

Definition at line 133 of file RootTruthParticleCnvTool.cxx.

133 { abort(); }

◆ setProperty() [2/2]

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

Definition at line 131 of file RootTruthParticleCnvTool.cxx.

131  {
132  abort(); }

◆ setPropertyRepr()

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

Definition at line 134 of file RootTruthParticleCnvTool.cxx.

134 { abort(); }

◆ start()

StatusCode RootTruthParticleCnvTool::start ( )
overridevirtual

Definition at line 161 of file RootTruthParticleCnvTool.cxx.

161 { abort(); }

◆ stop()

StatusCode RootTruthParticleCnvTool::stop ( )
overridevirtual

Definition at line 165 of file RootTruthParticleCnvTool.cxx.

165 { abort(); }

◆ sysFinalize()

StatusCode RootTruthParticleCnvTool::sysFinalize ( )
overridevirtual

Definition at line 168 of file RootTruthParticleCnvTool.cxx.

168 { abort(); }

◆ sysInitialize()

StatusCode RootTruthParticleCnvTool::sysInitialize ( )
overridevirtual

Definition at line 158 of file RootTruthParticleCnvTool.cxx.

158 { abort(); }

◆ sysReinitialize()

StatusCode RootTruthParticleCnvTool::sysReinitialize ( )
overridevirtual

Definition at line 160 of file RootTruthParticleCnvTool.cxx.

160 { abort(); }

◆ sysRestart()

StatusCode RootTruthParticleCnvTool::sysRestart ( )
overridevirtual

Definition at line 164 of file RootTruthParticleCnvTool.cxx.

164 { abort(); }

◆ sysStart()

StatusCode RootTruthParticleCnvTool::sysStart ( )
overridevirtual

Definition at line 162 of file RootTruthParticleCnvTool.cxx.

162 { abort(); }

◆ sysStop()

StatusCode RootTruthParticleCnvTool::sysStop ( )
overridevirtual

Definition at line 166 of file RootTruthParticleCnvTool.cxx.

166 { abort(); }

◆ terminate()

StatusCode RootTruthParticleCnvTool::terminate ( )
overridevirtual

Definition at line 169 of file RootTruthParticleCnvTool.cxx.

169 { abort(); }

◆ type()

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

Definition at line 154 of file RootTruthParticleCnvTool.cxx.

154 { abort(); }

The documentation for this class was generated from the following files:
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
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:538
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