ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
TruthHelper::GenAccessIO Class Reference

#include <GenAccessIO.h>

Collaboration diagram for TruthHelper::GenAccessIO:

Public Member Functions

 GenAccessIO ()
 
StatusCode getMC (MCParticleCollection &mcParticles, const bool ifgen=false, const std::string &key="GEN_EVENT") const
 
StatusCode getDH (const McEventCollection *&dh) const
 
StatusCode getDH (const McEventCollection *&dh, const std::string &key) const
 
StatusCode store (McEventCollection *storee, const std::string &key) const
 
 GenAccessIO ()
 
StatusCode getMC (MCParticleCollection &mcParticles, const bool ifgen=false, const std::string &key="GEN_EVENT") const
 
StatusCode getDH (const McEventCollection *&dh) const
 
StatusCode getDH (const McEventCollection *&dh, const std::string &key) const
 
StatusCode store (McEventCollection *storee, const std::string &key) const
 

Private Attributes

StoreGateSvcm_sgSvc
 

Detailed Description

Definition at line 24 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

Constructor & Destructor Documentation

◆ GenAccessIO() [1/2]

TruthHelper::GenAccessIO::GenAccessIO ( )
inline

Definition at line 27 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

27  : m_sgSvc(0) {
28  if (Gaudi::svcLocator()->service("StoreGateSvc", m_sgSvc).isFailure()) {
29  throw StatusCode::FAILURE;
30  }
31  }

◆ GenAccessIO() [2/2]

TruthHelper::GenAccessIO::GenAccessIO ( )
inline

Definition at line 27 of file PhysicsAnalysis/TruthParticleID/McParticleTools/src/GenAccessIO.h.

27  : m_sgSvc(0) {
28  if (Gaudi::svcLocator()->service("StoreGateSvc", m_sgSvc).isFailure()) {
29  throw StatusCode::FAILURE;
30  }
31  }

Member Function Documentation

◆ getDH() [1/4]

StatusCode TruthHelper::GenAccessIO::getDH ( const McEventCollection *&  dh) const
inline

Definition at line 73 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

73  {
74  return m_sgSvc->retrieve(dh);
75  }

◆ getDH() [2/4]

StatusCode TruthHelper::GenAccessIO::getDH ( const McEventCollection *&  dh) const
inline

Definition at line 73 of file PhysicsAnalysis/TruthParticleID/McParticleTools/src/GenAccessIO.h.

73  {
74  return m_sgSvc->retrieve(dh);
75  }

◆ getDH() [3/4]

StatusCode TruthHelper::GenAccessIO::getDH ( const McEventCollection *&  dh,
const std::string &  key 
) const
inline

Definition at line 76 of file PhysicsAnalysis/TruthParticleID/McParticleTools/src/GenAccessIO.h.

76  {
77  return m_sgSvc->retrieve(dh, key);
78  }

◆ getDH() [4/4]

StatusCode TruthHelper::GenAccessIO::getDH ( const McEventCollection *&  dh,
const std::string &  key 
) const
inline

Definition at line 76 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

76  {
77  return m_sgSvc->retrieve(dh, key);
78  }

◆ getMC() [1/2]

StatusCode TruthHelper::GenAccessIO::getMC ( MCParticleCollection mcParticles,
const bool  ifgen = false,
const std::string &  key = "GEN_EVENT" 
) const
inline

Definition at line 32 of file PhysicsAnalysis/TruthParticleID/McParticleTools/src/GenAccessIO.h.

32  {
33  MsgStream log(Athena::getMessageSvc(), "GenAccessIO");
34 
35  // Retrieve iterators for McEventCollections objects
38  if ( (m_sgSvc->retrieve(firstMEC, lastMEC)).isFailure() ) {
39  log << MSG::ERROR << "Could not retrieve iterators for McEventCollections" << endmsg;
40  }
41  const McEventCollection& mcColl = *firstMEC;
42  int icount = 0;
43  for ( ; firstMEC!= lastMEC; ++firstMEC) icount++;
44  log << MSG::DEBUG << "Number of McEventCollections= "<< icount << endmsg;
45 
46  // If there is more than one then do the retrieve with the key
47  if (icount > 1) {
48  log << MSG::DEBUG << "Key = " << key << endmsg;
49  const McEventCollection* mcCollptr = nullptr;
50  return this->getDH(mcCollptr, key);
51  }
52 
53  if (icount > 0) {
54  // Iterate over all McEvent records
56  for (itr = mcColl.begin(); itr!=mcColl.end(); ++itr) {
57  // Access the HepMC record which is wrapped within McEvent
58  const HepMC::GenEvent* genEvt = (*itr);
59  if (genEvt == 0) return StatusCode::FAILURE;
60  if (ifgen) {
61  for (auto it: *genEvt) {
62  if (!HepMC::is_simulation_particle(it)) mcParticles.push_back(it);
63  }
64  } else {
65  for (auto it: *genEvt) {
66  mcParticles.push_back(it);
67  }
68  }
69  }
70  }
71  return StatusCode::SUCCESS;
72  }

◆ getMC() [2/2]

StatusCode TruthHelper::GenAccessIO::getMC ( MCParticleCollection mcParticles,
const bool  ifgen = false,
const std::string &  key = "GEN_EVENT" 
) const
inline

Definition at line 32 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

32  {
33  MsgStream log(Athena::getMessageSvc(), "GenAccessIO");
34 
35  // Retrieve iterators for McEventCollections objects
38  if ( (m_sgSvc->retrieve(firstMEC, lastMEC)).isFailure() ) {
39  log << MSG::ERROR << "Could not retrieve iterators for McEventCollections" << endmsg;
40  }
41  const McEventCollection& mcColl = *firstMEC;
42  int icount = 0;
43  for ( ; firstMEC!= lastMEC; ++firstMEC) icount++;
44  log << MSG::DEBUG << "Number of McEventCollections= "<< icount << endmsg;
45 
46  // If there is more than one then do the retrieve with the key
47  if (icount > 1) {
48  log << MSG::DEBUG << "Key = " << key << endmsg;
49  const McEventCollection* mcCollptr = nullptr;
50  return this->getDH(mcCollptr, key);
51  }
52 
53  if (icount > 0) {
54  // Iterate over all McEvent records
56  for (itr = mcColl.begin(); itr!=mcColl.end(); ++itr) {
57  // Access the HepMC record which is wrapped within McEvent
58  const HepMC::GenEvent* genEvt = (*itr);
59  if (genEvt == 0) return StatusCode::FAILURE;
60  if (ifgen) {
61  for (auto it: *genEvt) {
62  if (!HepMC::is_simulation_particle(it)) mcParticles.push_back(it);
63  }
64  } else {
65  for (auto it: *genEvt) {
66  mcParticles.push_back(it);
67  }
68  }
69  }
70  }
71  return StatusCode::SUCCESS;
72  }

◆ store() [1/2]

StatusCode TruthHelper::GenAccessIO::store ( McEventCollection storee,
const std::string &  key 
) const
inline

Definition at line 79 of file PhysicsAnalysis/TruthParticleID/McParticleTools/src/GenAccessIO.h.

79  {
80  return m_sgSvc->record(storee, key);
81  }

◆ store() [2/2]

StatusCode TruthHelper::GenAccessIO::store ( McEventCollection storee,
const std::string &  key 
) const
inline

Definition at line 79 of file Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h.

79  {
80  return m_sgSvc->record(storee, key);
81  }

Member Data Documentation

◆ m_sgSvc

StoreGateSvc * TruthHelper::GenAccessIO::m_sgSvc
private

The documentation for this class was generated from the following file:
StoreGateSvc::record
StatusCode record(T *p2BRegistered, const TKEY &key)
Record an object with a key.
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
skel.it
it
Definition: skel.GENtoEVGEN.py:423
TruthHelper::GenAccessIO::m_sgSvc
StoreGateSvc * m_sgSvc
Definition: Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h:83
PyPoolBrowser.dh
dh
Definition: PyPoolBrowser.py:102
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
HepMC::is_simulation_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...
Definition: MagicNumbers.h:299
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TruthHelper::GenAccessIO::getDH
StatusCode getDH(const McEventCollection *&dh) const
Definition: Generators/FlowAfterburner/FlowAfterburner/GenAccessIO.h:73
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
SG::ConstIterator
Definition: SGIterator.h:163
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37