ATLAS Offline Software
Loading...
Searching...
No Matches
TruthParticleContainerCnv.cxx
Go to the documentation of this file.
1
2
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"
19
20// McParticleKernel includes
22
23
24// McParticleEventTPCnv includes
27
28// McParticleEventAthenaPool includes
30
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
47 TruthParticleContainer_PERS *pers = cnv.createPersistent(trans, log);
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}
#define endmsg
TruthParticleContainer_p6 TruthParticleContainer_PERS
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
virtual TRANS * createTransient(const PERS *persObj, MsgStream &log)
Create transient representation of a persistent object.
Compatibility for old converter classes that don't get passed the key.
ToolHandle< ITruthParticleCnvTool > m_cnvTool
Handle to the McEventCollection -> TruthParticleContainer converter tool.
TruthParticleContainerCnv(ISvcLocator *svcloc)
Create the converter from the service locator.
virtual TruthParticleContainer * createTransient()
Build the transient representation from a persistent one.
virtual TruthParticleContainer_PERS * createPersistent(TruthParticleContainer *transCont)
Build the persistent representation from the transient one.