ATLAS Offline Software
SegmentCollectionCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------------
6 //
7 // file: SegmentCollectionCnv.cxx
8 // author: Andreas Wildauer
9 // author: Edward Moyse
10 //
11 //-----------------------------------------------------------------------------
12 
13 #include "SegmentCollectionCnv.h"
14 #include "GaudiKernel/IToolSvc.h"
15 
16 
17 //-----------------------------------------------------------------------------
18 // Constructor
19 //-----------------------------------------------------------------------------
22  m_msgSvc( msgSvc() ),
23  m_log( m_msgSvc, "SegmentCollectionCnv" )
24 {
25 }
26 
27 //-----------------------------------------------------------------------------
28 // Initializer
29 //-----------------------------------------------------------------------------
31 {
32  if( m_oldExtCnvInitialized ) return;
33 
34  //-------------------------------------------------------------------------
35  // Set up the message stream
36  //-------------------------------------------------------------------------
37  m_log.setLevel( m_msgSvc->outputLevel() );
38  m_log << MSG::INFO << "SegmentCollectionCnv::initialize()" << endmsg;
39 
40  bool doInDet(true);
41  bool doMuon(true);
42 
43  IConverter *converter = m_athenaPoolCnvSvc->converter( CLID(17001567) );
44  m_log << MSG::DEBUG << "SegmentCollectionCnv: InDetTrack converter=" << converter << endmsg;
45  if(converter != nullptr) registerExtendingCnv( converter );
46  else doInDet=false;
47 
48  converter = m_athenaPoolCnvSvc->converter( CLID(239128586) );
49  m_log << MSG::DEBUG << "SegmentCollectionCnv: MuonMeasurements converter=" << converter << endmsg;
50  if(converter !=nullptr ) registerExtendingCnv( converter );
51  else doMuon=false;
52 
53  //-------------------------------------------------------------------------
54  // We cannot proceed if none of the tools is present
55  //-------------------------------------------------------------------------
56  if( !doInDet && !doMuon ) {
57  m_log << MSG::FATAL << "Failed to load Extending T/P converters!" << endmsg;
58  }
60 }
61 
62 
65 {
66  std::string logname = "SegmentCollectionCnv";
67  if (const DataObject* dObj = getDataObject()) {
68  logname += dObj->name();
69  }
70 
71  MsgStream log (m_msgSvc, logname );
72  return m_TPConverterForPER.createPersistent( transCont, log );
73 }
74 
75 
76 //-----------------------------------------------------------------------------
77 // Create transient collection
78 //-----------------------------------------------------------------------------
80 {
81  m_log.setLevel( m_msgSvc->outputLevel() );
82  static const pool::Guid tlp4_guid( "27FB33E0-3284-11E8-9390-0800271C02BC" );
83  static const pool::Guid tlp3_guid( "1AA73E8A-AF6D-11E3-A8C8-6C3BE51AB9F1" );
84  static const pool::Guid tlp2_guid( "61A4056D-4FDF-4798-93D7-1BAC351FE32E" );
85  static const pool::Guid tlp1_guid( "03A83988-8E38-45E9-95A5-9CB17B98074C" );
86  static const pool::Guid p0_guid( "AAE2BF35-4971-4368-B0B1-BE209CC81538" );
87 
88  Trk::SegmentCollection *p_collection = nullptr;
89 
90  if( compareClassGuid( tlp4_guid ) ) {
91  poolReadObject< SegmentCollection_PERS >( m_TPConverterForPER );
92  p_collection = m_TPConverterForPER.createTransient( m_log );
93  } else if( compareClassGuid( tlp3_guid ) ) {
95  poolReadObject< Trk::SegmentCollection_tlp3 >( m_TPConverter_tlp3 );
96  p_collection = m_TPConverter_tlp3.createTransient( m_log );
97  } else if( compareClassGuid( tlp2_guid ) ) {
99  poolReadObject< Trk::SegmentCollection_tlp2 >( m_TPConverter_tlp2 );
100  p_collection = m_TPConverter_tlp2.createTransient( m_log );
101  } else if( compareClassGuid( tlp1_guid ) ) {
103  poolReadObject< Trk::SegmentCollection_tlp1 >( m_TPConverter_tlp1 );
104  p_collection = m_TPConverter_tlp1.createTransient( m_log );
105  }
106  else if( compareClassGuid( p0_guid ) ) {
107  p_collection = poolReadObject< Trk::SegmentCollection >();
108  }
109  else
110  throw std::runtime_error( "Unsupported persistent version of Trk::SegmentCollection (unknown GUID)" );
111 
112  return p_collection;
113 }
SegmentCollectionCnv::SegmentCollectionCnv
SegmentCollectionCnv(ISvcLocator *svcloc)
Definition: SegmentCollectionCnv.cxx:20
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
AthenaPoolConverter::m_athenaPoolCnvSvc
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
Definition: AthenaPoolConverter.h:111
python.ZdcRecConfig.doMuon
doMuon
Definition: ZdcRecConfig.py:331
SegmentCollectionCnv::m_TPConverter_tlp3
SegmentCollectionCnv_tlp3 m_TPConverter_tlp3
Definition: SegmentCollectionCnv.h:62
SegmentCollectionCnv::createTransient
virtual Trk::SegmentCollection * createTransient() override
Definition: SegmentCollectionCnv.cxx:79
SegmentCollectionCnv::m_TPConverter_tlp1
SegmentCollectionCnv_tlp1 m_TPConverter_tlp1
Definition: SegmentCollectionCnv.h:60
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
TopLevelTPConverter::createTransient
TRANS * createTransient(MsgStream &log)
Create transient representation of the persistent object known to this converter.
Definition: TopLevelTPConverter.h:62
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
Trk::SegmentCollection_tlp4
Definition: SegmentCollection_tlp4.h:47
SegmentCollectionCnv::createPersistent
virtual SegmentCollection_PERS * createPersistent(Trk::SegmentCollection *transCont) override
Definition: SegmentCollectionCnv.cxx:64
DataVector< Trk::Segment >
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AthenaPoolCnvTPExtension::registerExtendingCnv
virtual bool registerExtendingCnv(AthenaConverterTLPExtension *cnv)
Register extending converter (that is, another converter that will extent this converter) and all his...
Definition: AthenaPoolCnvTPExtension.h:19
SegmentCollectionCnv::m_TPConverterForPER
SegmentCollectionCNV_PERS m_TPConverterForPER
Definition: SegmentCollectionCnv.h:63
SegmentCollectionCnv::initializeOldExtConverters
void initializeOldExtConverters()
setup old extended converters when reading old data
Definition: SegmentCollectionCnv.cxx:30
DEBUG
#define DEBUG
Definition: page_access.h:11
SegmentCollectionCnv::m_msgSvc
IMessageSvc * m_msgSvc
Definition: SegmentCollectionCnv.h:56
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AthenaPoolConverter::getDataObject
virtual const DataObject * getDataObject() const
Definition: AthenaPoolConverter.cxx:269
SegmentCollectionCnv_tlp4::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of transObj.
Definition: SegmentCollectionCnv_tlp4.cxx:71
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
SegmentCollectionCnv::m_log
MsgStream m_log
Definition: SegmentCollectionCnv.h:57
SegmentCollectionCnv.h
MakeSliceSet.logname
logname
Definition: MakeSliceSet.py:34
SegmentCollectionCnv::m_TPConverter_tlp2
SegmentCollectionCnv_tlp2 m_TPConverter_tlp2
Definition: SegmentCollectionCnv.h:61
SegmentCollectionCnv::m_oldExtCnvInitialized
bool m_oldExtCnvInitialized
Definition: SegmentCollectionCnv.h:58