ATLAS Offline Software
TruthParticleContainerCnv.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // TruthParticleContainerCnv.cxx
8 // Implementation file for class TruthParticleContainerCnv
9 // Author: S.Binet<binet@cern.ch>
11 
12 // STL includes
13 
14 // Framework includes
15 #include "GaudiKernel/MsgStream.h"
16 #include "GaudiKernel/IToolSvc.h"
17 #include "GaudiKernel/IAlgTool.h"
18 #include "StoreGate/StoreGateSvc.h"
19 
20 // McParticleKernel includes
22 
23 
24 // McParticleEventTPCnv includes
27 
28 // McParticleEventAthenaPool includes
30 
33  TruthParticleContainer_PERS>(svcLocator)
34 {
35  if ( m_cnvTool.retrieve().isFailure() ) {
36  throw std::runtime_error("Could not fetch TruthParticleCnvTool !!");
37  }
38 }
39 
40 
43 {
44  MsgStream log( msgSvc(), "TruthParticleContainerCnv" );
45 
48 
49  log << MSG::DEBUG << "::createPersistent [Success]" << endmsg;
50  return pers;
51 }
52 
54 {
55  MsgStream msg( msgSvc(), "TruthParticleContainerCnv" );
56 
57  TruthParticleContainer *trans = 0;
58 
59  static const pool::Guid p5_guid("2D25E3D9-950B-49E0-A51F-2B6EC93D1A23");
60  static const pool::Guid p6_guid("97AC2CEE-7E8A-4E2E-B6B5-FD8545D77FC4");
61 
62  if ( compareClassGuid(p6_guid) ) {
63 
64  std::unique_ptr<TruthParticleContainer_p6> pers( poolReadObject<TruthParticleContainer_p6>() );
66  trans = cnv.createTransient( pers.get(), msg );
67 
68  } else if ( compareClassGuid(p5_guid) ) {
69 
70  std::unique_ptr<TruthParticleContainer_p5> pers( poolReadObject<TruthParticleContainer_p5>() );
72  trans = cnv.createTransient( pers.get(), msg );
73 
74  } else {
75  throw std::runtime_error("Unsupported persistent version of TruthParticleContainer");
76  }
77 
78  return trans;
79 }
ITruthParticleCnvTool.h
TruthParticleContainerCnv::createTransient
virtual TruthParticleContainer * createTransient()
Build the transient representation from a persistent one.
Definition: TruthParticleContainerCnv.cxx:53
TruthParticleContainerCnv::m_cnvTool
ToolHandle< ITruthParticleCnvTool > m_cnvTool
Handle to the McEventCollection -> TruthParticleContainer converter tool.
Definition: TruthParticleContainerCnv.h:72
TPPolyCnvBase::createTransient
virtual TRANS * createTransient(const PERS *persObj, MsgStream &log)
Create transient representation of a persistent object.
TruthParticleContainerCnv.h
TruthParticleContainer_p6
Definition: TruthParticleContainer_p6.h:27
TruthParticleContainer
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
TruthParticleContainerCnv_p5
Definition: TruthParticleContainerCnv_p5.h:41
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
TruthParticleContainerCnv_p6
Definition: TruthParticleContainerCnv_p6.h:41
TruthParticleContainerCnv::createPersistent
virtual TruthParticleContainer_PERS * createPersistent(TruthParticleContainer *transCont)
Build the persistent representation from the transient one.
Definition: TruthParticleContainerCnv.cxx:42
TruthParticleContainerCnv_p6.h
TruthParticleContainerCnv_p5.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
T_AthenaPoolCustCnv< TruthParticleContainer, TruthParticleContainer_PERS >::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
StoreGateSvc.h
TruthParticleContainerCnv::TruthParticleContainerCnv
TruthParticleContainerCnv(ISvcLocator *svcloc)
Create the converter from the service locator.
Definition: TruthParticleContainerCnv.cxx:31