ATLAS Offline Software
MuonContainerCnv.cxx
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // MuonContainerCnv.cxx
8 // Implementation file for class MuonContainerCnv
9 // Author: Ketevi A. Assamagan <ketevi@bnl.gov>
11 
12 // STL includes
13 
14 // Framework includes
15 #include "GaudiKernel/MsgStream.h"
16 
17 // RecAthenaPool includes
18 #include "MuonContainerCnv.h"
20 
24 
28 
30 // Protected methods:
32 
34 {
35 
36  MsgStream log(msgSvc(), "MuonContainerCnv");
38  if (!sc.isSuccess()) {
39  log << MSG::ERROR << "Can not initialize Converter base class." << endmsg;
40  return(sc);
41  }
42 
43  // retrieve the storegate service
44  if ( !m_storeGate.retrieve().isSuccess() ) {
45  log << MSG::ERROR
46  << "Unable to retrieve pointer to StoreGateSvc"
47  << endmsg;
48  return StatusCode::FAILURE;
49  }
50 
55 
56  return StatusCode::SUCCESS;
57 }
58 
61 {
62  MsgStream msg( msgSvc(), "MuonContainerCnv" );
63 
65  MuonContainer_PERS *persObj = cnv.createPersistent( transCont, msg );
66 
67  msg << MSG::DEBUG << "::createPersistent [Success]" << endmsg;
68  return persObj;
69 }
70 
72 {
73  MsgStream msg( msgSvc(), "MuonContainerConverter" );
74 
75  Analysis::MuonContainer *transObj = 0;
76 
77  static const pool::Guid tr_guid("E5B86159-2270-4770-A412-078D09F12215");
78  static const pool::Guid p1_guid("2B37C58D-4FBF-46F3-AB5C-B1408DBB99BE");
79  static const pool::Guid p2_guid("AB37C580-4FBF-51F3-F85D-014F8DBBE9BC");
80  static const pool::Guid p3_guid("FB88C580-EFBF-5CDE-EEED-AABF8DBCE9EE");
81  static const pool::Guid p4_guid("01887544-EFBF-E099-1116-0051F2678B09");
82  static const pool::Guid p5_guid("45887564-EABA-EBC9-DE1A-2459F21780CC");
83  static const pool::Guid p6_guid("56E6FC8D-E6B3-4FFB-83A2-A9AEF6E35FF3");
84 
85  if ( compareClassGuid(p6_guid) ) {
86 
87  std::unique_ptr<MuonContainer_p6> persObj(poolReadObject<MuonContainer_p6>());
88  transObj = m_cnv_p6.createTransient( persObj.get(), msg );
89 
90  } else if ( compareClassGuid(p5_guid) ) {
91 
92  std::unique_ptr<MuonContainer_p5> persObj(poolReadObject<MuonContainer_p5>());
93  transObj = m_cnv_p5.createTransient( persObj.get(), msg );
94 
95  } else if ( compareClassGuid(p4_guid) ) {
96 
97  std::unique_ptr<MuonContainer_p4> persObj(poolReadObject<MuonContainer_p4>());
98  transObj = m_cnv_p4.createTransient( persObj.get(), msg );
99 
100  } else if ( compareClassGuid(p3_guid) ) {
101 
102  std::unique_ptr<MuonContainer_p3> persObj(poolReadObject<MuonContainer_p3>());
103  transObj = m_cnv_p3.createTransient( persObj.get(), msg );
104 
105  } else if ( compareClassGuid(p2_guid) ) {
106 
109  if ( m_storeGate->record( cont, m_muonCaloEnergyContainerName ).isFailure() ) {
110  msg << MSG::WARNING << "Not able to recod MuonCaloEnergyContainer in StoreGate " << endmsg;
111  }
112  }
113 
114  std::unique_ptr<MuonContainer_p2> persObj( poolReadObject<MuonContainer_p2>() );
115  transObj = m_cnv_p2.createTransient( persObj.get(), msg );
116 
117  } else if ( compareClassGuid(p1_guid) ) {
118 
121  if ( m_storeGate->record( cont, m_muonCaloEnergyContainerName ).isFailure() ) {
122  msg << MSG::WARNING << "Not able to recod MuonCaloEnergyContainer in StoreGate " << endmsg;
123  }
124  }
125 
126  // using unique_ptr ensures deletion of the persistent object
127  std::unique_ptr<MuonContainer_p1> persObj( poolReadObject<MuonContainer_p1>() );
128  transObj = m_cnv_p1.createTransient( persObj.get(), msg );
129 
130  } else if ( compareClassGuid(tr_guid) ) {
131 
132  // regular object from before the T/P separation
133  return poolReadObject<Analysis::MuonContainer>();
134 
135  } else {
136  throw std::runtime_error("Unsupported persistent version of MuonContainer");
137  }
138 
139  return transObj;
140 }
MuonContainerCnv::createTransient
virtual Analysis::MuonContainer * createTransient()
Build the transient representation from a persistent one.
Definition: MuonContainerCnv.cxx:71
MuonContainerCnv_p1::setEventStore
void setEventStore(const StoreGateSvc_t storeGate)
Definition: MuonContainerCnv_p1.h:48
MuonCaloEnergyContainer
Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old Athena::TPCnvVers::Current MuonCaloEnergyContainer
Definition: RecTPCnv.cxx:126
TPCnvVectorConst
Definition: TPConverter.h:1271
TPPolyCnvBase::createTransient
virtual TRANS * createTransient(const PERS *persObj, MsgStream &log)
Create transient representation of a persistent object.
MuonCaloEnergyContainer.h
MuonContainerCnv_p1::setKey
void setKey(const std::string &key)
Definition: MuonContainerCnv_p1.h:47
MuonContainerCnv::m_cnv_p4
MuonContainerCnv_p4 m_cnv_p4
Definition: MuonContainerCnv.h:83
MuonContainer_p6
Definition: MuonContainer_p6.h:23
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
MuonContainerCnv::m_cnv_p2
MuonContainerCnv_p2 m_cnv_p2
Definition: MuonContainerCnv.h:81
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
MuonContainerCnv::m_muonCaloEnergyContainerName
std::string m_muonCaloEnergyContainerName
Definition: MuonContainerCnv.h:78
MuonContainerCnv::createPersistent
virtual MuonContainer_PERS * createPersistent(Analysis::MuonContainer *transCont)
Build the persistent representation from the transient one.
Definition: MuonContainerCnv.cxx:60
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonCaloEnergyContainer
Data object for a StoreGate container holding a vector of CaloEnergy, the detailed energy loss descri...
Definition: MuonCaloEnergyContainer.h:19
Analysis::MuonContainer
definition of StoreGate container holding a vector of Analysis::Muon
Definition: Reconstruction/MuonIdentification/muonEvent/muonEvent/MuonContainer.h:38
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
MuonContainerCnv.h
MuonContainerCnv::m_cnv_p5
MuonContainerCnv_p5 m_cnv_p5
Definition: MuonContainerCnv.h:84
MuonContainerCnv::m_cnv_p1
MuonContainerCnv_p1 m_cnv_p1
Definition: MuonContainerCnv.h:80
MuonContainerCnv::initialize
virtual StatusCode initialize()
initialize() - need to access Storegate
Definition: MuonContainerCnv.cxx:33
MuonContainerCnv::m_storeGate
StoreGateSvc_t m_storeGate
Definition: MuonContainerCnv.h:77
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
T_AthenaPoolCustCnv< Analysis::MuonContainer, MuonContainer_PERS >::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
T_AthenaPoolCustCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
MuonContainerCnv_p2::setEventStore
void setEventStore(const StoreGateSvc_t storeGate)
Definition: MuonContainerCnv_p2.h:47
MuonContainerCnv::m_cnv_p3
MuonContainerCnv_p3 m_cnv_p3
Definition: MuonContainerCnv.h:82
MuonContainerCnv_p2::setKey
void setKey(const std::string &key)
Definition: MuonContainerCnv_p2.h:46
MuonContainerCnv::m_cnv_p6
MuonContainerCnv_p6 m_cnv_p6
Definition: MuonContainerCnv.h:85