ATLAS Offline Software
TrackCollectionCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------------
6 //
7 // file: TrackCollectionCnv.cxx
8 // author: Lukasz Janyst <ljanyst@cern.ch>
9 //
10 // Ed's converter rewritten and T/P split stuff added
11 //
12 // TODO: MultiComponentTSoS, integrity checking
13 //
14 //-----------------------------------------------------------------------------
15 #include "TrackCollectionCnv.h"
16 
17 #include "GaudiKernel/IToolSvc.h"
18 #include "StoreGate/StoreGateSvc.h"
20 
21 
22 //-----------------------------------------------------------------------------
23 // Constructor
24 //-----------------------------------------------------------------------------
26  TrackCollectionCnvBase(svcloc),
27  m_msgSvc( msgSvc() ),
28  m_log( m_msgSvc, "TrackCollectionCnv" )
29 {
30 }
31 
32 //-----------------------------------------------------------------------------
33 // Initializer
34 //-----------------------------------------------------------------------------
36 {
37  // leaving empty method for future use
39 }
40 
41 
43 {
44  if( m_oldExtCnvInitialized ) return;
45 
46  // m_log.setLevel( m_msgSvc->outputLevel() );
47  m_log << MSG::INFO << "TrackCollectionCnv::initializeOldExtConverters()" << endmsg;
48 
49  bool doInDet(true);
50  bool doMuon(true);
51  bool doCalo(true);
52 
53  IConverter *converter = m_athenaPoolCnvSvc->converter( CLID(17001567) );
54  if(converter != nullptr) registerExtendingCnv( converter );
55  else doInDet=false;
56 
57  converter = m_athenaPoolCnvSvc->converter( CLID(239128586) );
58  if(converter !=nullptr ) registerExtendingCnv( converter );
59  else doMuon=false;
60 
61  converter = m_athenaPoolCnvSvc->converter( CLID(1213853277) );
62  if(converter !=nullptr ) registerExtendingCnv( converter );
63  else doCalo=false;
64 
65  //-------------------------------------------------------------------------
66  // We cannot proceed if none of the tools is present
67  //-------------------------------------------------------------------------
68  if( !doInDet && !doMuon && !doCalo) {
69  m_log << MSG::WARNING << "Could not get any of the extending convertors, and so might have problems later on.";
70  m_log << endmsg;
71  }
73 }
74 
75 
76 
78  const std::string& key)
79 {
80  std::string logname = "TrackCollectionCnv";
81  if (const DataObject* dObj = getDataObject()) {
82  logname += dObj->name();
83  }
84 
85  MsgStream log (m_msgSvc, logname );
86 
87  return m_TPConverter.createPersistentWithKey ( transCont, key, log );
88 }
89 
90 //-----------------------------------------------------------------------------
91 // Create transient collection
92 //-----------------------------------------------------------------------------
94 {
95  m_log.setLevel( m_msgSvc->outputLevel() );
96  static const pool::Guid p7_guid( "D8806153-CA92-4A1A-9859-68E40EB4E336" );
97  static const pool::Guid p6_guid( "3228B252-2C5D-11E8-B170-0800271C02BC" );
98  static const pool::Guid p5_guid( "436E4996-9D6E-11E3-AD2A-6C3BE51AB9F1" );
99  static const pool::Guid p4_guid( "3BEB819F-6ED2-48F6-9F95-E65E1759E781" );
100  static const pool::Guid p3_guid( "A1E9FDCB-2F4A-4AC8-BF4E-2D70B9C70F8A" );
101  static const pool::Guid p2_guid( "2D8B19DC-DB2E-4F56-BB94-D7C4544D501A" );
102  static const pool::Guid p1_guid( "ECB12567-B999-4908-B0C6-C43CF9F9A987" );
103  static const pool::Guid p0_guid( "70ECEBFC-BE00-46C2-8B35-4CC12D18DE39" );
104 
105  TrackCollection *p_collection = nullptr;
106  if( compareClassGuid( p7_guid )){
107  poolReadObject< TrackCollection_PERS >( m_TPConverter );
108  p_collection = m_TPConverter.createTransientWithKey( key, m_log );
109  }
110  else if( compareClassGuid( p6_guid )){
111  poolReadObject< Trk::TrackCollection_tlp6 >( m_TPConverter_tlp6 );
113  }
114  else if( compareClassGuid( p5_guid )){
116  poolReadObject< Trk::TrackCollection_tlp5 >( m_TPConverter_tlp5);
118  }
119  else if( compareClassGuid( p4_guid )){
121  poolReadObject< Trk::TrackCollection_tlp4 >( m_TPConverter_tlp4);
123  }
124  else if( compareClassGuid( p3_guid )){
126  poolReadObject< Trk::TrackCollection_tlp3 >( m_TPConverter_tlp3);
128  }
129  else if( compareClassGuid( p2_guid ) ) {
131  poolReadObject< Trk::TrackCollection_tlp2 >( m_TPConverter_tlp2 );
133  }
134  else if( compareClassGuid( p1_guid ) ) {
136  poolReadObject< Trk::TrackCollection_tlp1 >( m_TPConverter_tlp1 );
138  }
139  else if( compareClassGuid( p0_guid ) ) {
140  p_collection = poolReadObject< TrackCollection >();
141  }
142  else
143  throw std::runtime_error( "Unsupported persistent version of Data Collection" );
144  return p_collection;
145 }
146 
TrackCollectionCnv::m_TPConverter
TrackCollectionCnv_tlp7 m_TPConverter
Definition: TrackCollectionCnv.h:76
TrackCollectionCnv::m_msgSvc
IMessageSvc * m_msgSvc
Definition: TrackCollectionCnv.h:66
python.ZdcRecConfig.doCalo
doCalo
Definition: ZdcRecConfig.py:332
TopLevelTPConverter::createTransientWithKey
TRANS * createTransientWithKey(const std::string &key, MsgStream &log)
Create transient representation of the persistent object known to this converter.
Definition: TopLevelTPConverter.h:78
AthenaPoolConverter::m_athenaPoolCnvSvc
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
Definition: AthenaPoolConverter.h:111
python.ZdcRecConfig.doMuon
doMuon
Definition: ZdcRecConfig.py:331
TrackCollectionCnv::createPersistentWithKey
virtual TrackCollection_PERS * createPersistentWithKey(TrackCollection *transCont, const std::string &key) override
Definition: TrackCollectionCnv.cxx:77
TrackCollectionCnv::initializeOldExtConverters
void initializeOldExtConverters()
setup old extended converters when reading old data
Definition: TrackCollectionCnv.cxx:42
TrackCollectionCnv::createTransientWithKey
virtual TrackCollection * createTransientWithKey(const std::string &key) override
method to be implemented by the developer.
Definition: TrackCollectionCnv.cxx:93
TrackCollectionCnv::m_TPConverter_tlp6
TrackCollectionCnv_tlp6 m_TPConverter_tlp6
Definition: TrackCollectionCnv.h:75
T_AthenaPoolCustomCnvWithKey
This templated class extends T_AthenaPoolCustCnv to provide management of the persistent objects crea...
Definition: T_AthenaPoolCustomCnv.h:35
TrackCollectionCnv::m_TPConverter_tlp4
TrackCollectionCnv_tlp4 m_TPConverter_tlp4
Definition: TrackCollectionCnv.h:73
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
TrackCollectionCnv.h
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
TrackCollectionCnv::m_TPConverter_tlp5
TrackCollectionCnv_tlp5 m_TPConverter_tlp5
Definition: TrackCollectionCnv.h:74
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
TrackCollectionCnv_tlp7::createPersistentWithKey
virtual PERS * createPersistentWithKey(const TRANS *transObj, const std::string &key, MsgStream &log) override
Create persistent representation of transObj.
Definition: TrackCollectionCnv_tlp7.cxx:133
TrackCollectionCnv::m_TPConverter_tlp3
TrackCollectionCnv_tlp3 m_TPConverter_tlp3
Definition: TrackCollectionCnv.h:72
Trk::TrackCollection_tlp7
Definition: TrackCollection_tlp7.h:74
DataVector< Trk::Track >
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TrackCollectionCnv::m_log
MsgStream m_log
Definition: TrackCollectionCnv.h:67
TrackCollectionCnv::TrackCollectionCnv
TrackCollectionCnv(ISvcLocator *svcloc)
Definition: TrackCollectionCnv.cxx:25
TrackCollectionCnv::m_oldExtCnvInitialized
bool m_oldExtCnvInitialized
Definition: TrackCollectionCnv.h:68
TrackCollectionCnv::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition: TrackCollectionCnv.cxx:35
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
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AthenaPoolConverter::getDataObject
virtual const DataObject * getDataObject() const
Definition: AthenaPoolConverter.cxx:269
TrackCollectionCnv::m_TPConverter_tlp1
TrackCollectionCnv_tlp1 m_TPConverter_tlp1
Definition: TrackCollectionCnv.h:70
T_AthenaPoolCustCnv::compareClassGuid
virtual bool compareClassGuid(const Guid &clid) const
Compare POOL class GUID with the one of the object being read.
TrackCollectionCnv::m_TPConverter_tlp2
TrackCollectionCnv_tlp2 m_TPConverter_tlp2
Definition: TrackCollectionCnv.h:71
T_AthenaPoolCustCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
StoreGateSvc.h
MakeSliceSet.logname
logname
Definition: MakeSliceSet.py:34
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37