ATLAS Offline Software
SCT_ClusterContainerCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "MsgUtil.h"
8 
10 #include "StoreGate/StoreGateSvc.h"
11 
12 #include <iostream>
13 #include <memory>
14 
16  : SCT_ClusterContainerCnvBase(svcloc, "SCT_ClusterContainerCnv"),
17  m_converter_p0(),
18  m_storeGate(nullptr)
19  {}
20 
21 
23  ATH_MSG_INFO("SCT_ClusterContainerCnv::initialize()");
24 
26  if (sc.isFailure()) {
27  ATH_MSG_FATAL("Cannot initialize cnv base !");
28  return StatusCode::FAILURE;
29  }
30 
31  // get StoreGate service. This is needed only for clients
32  // that register collections directly to the SG instead of adding
33  // them to the container.
34  sc = service("StoreGateSvc", m_storeGate);
35  if (sc.isFailure()) {
36  ATH_MSG_FATAL("StoreGate service not found !");
37  return StatusCode::FAILURE;
38  }
39 
40  // get DetectorStore service
41  StoreGateSvc* detStore(nullptr);
42  if (service("DetectorStore", detStore).isFailure()) {
43  ATH_MSG_FATAL("DetectorStore service not found !");
44  return StatusCode::FAILURE;
45  } else {
46  ATH_MSG_DEBUG("Found DetectorStore.");
47  }
48 
49  // Get the SCT helper from the detector store
50  const SCT_ID* idhelper(nullptr);
51  if (detStore->retrieve(idhelper, "SCT_ID").isFailure()) {
52  ATH_MSG_FATAL("Could not get SCT_ID helper !");
53  return StatusCode::FAILURE;
54  } else {
55  ATH_MSG_DEBUG("Found the SCT_ID helper.");
56  }
57 
58  if (m_converter_p0.initialize(msg()).isFailure())
59  {
60  ATH_MSG_FATAL("Could not initialize converter!");
61  return StatusCode::FAILURE;
62  }
63 
64  ATH_MSG_DEBUG("Converter initialized");
65 
66  return StatusCode::SUCCESS;
67 }
68 
69 
71  // MsgStream log(msgSvc(), "SCT_ClusterContainerCnv" );
72  static const pool::Guid p0_guid("A180F372-0D52-49C3-8AA0-0939CB0B8179"); // before t/p split
73  static const pool::Guid p1_guid("657F6546-F5CD-4166-9567-16AD9C96D286"); // with SCT_Cluster_tlp1
74  static const pool::Guid p2_guid("ECE7D831-0F31-4E6F-A6BE-2ADDE90083BA"); // with SCT_Cluster_p2
75  static const pool::Guid p3_guid("623F5836-369F-4A94-9DD4-DAD728E93C13"); // with SCT_Cluster_p3
76 
77  //ATH_MSG_DEBUG("createTransient(): main converter");
78  InDet::SCT_ClusterContainer* p_collection(nullptr);
79  if ( compareClassGuid(p3_guid) ) {
80  //ATH_MSG_DEBUG("createTransient(): T/P version 3 detected");
81  std::unique_ptr< SCT_ClusterContainer_PERS > p_coll( poolReadObject< SCT_ClusterContainer_PERS >() );
82  p_collection = m_TPConverter_p3.createTransient( p_coll.get(), msg() );
83 
84  } else if ( compareClassGuid(p1_guid) ) {
85  //ATH_MSG_DEBUG("createTransient(): T/P version 1 detected");
86  std::unique_ptr< InDet::SCT_ClusterContainer_tlp1 > p_coll( poolReadObject< InDet::SCT_ClusterContainer_tlp1 >() );
87  p_collection = m_TPConverter.createTransient( p_coll.get(), msg() );
88 
89  } else if ( compareClassGuid(p2_guid) ) {
90  //ATH_MSG_DEBUG("createTransient(): T/P version 2 detected");
91  std::unique_ptr< InDet::SCT_ClusterContainer_p2 > p_coll( poolReadObject< InDet::SCT_ClusterContainer_p2 >() );
92  p_collection = m_TPConverter_p2.createTransient( p_coll.get(), msg() );
93 
94  } else if ( compareClassGuid(p0_guid) ) {
95  //ATH_MSG_DEBUG("createTransient(): Old input file");
96  std::unique_ptr< SCT_ClusterContainer_p0 > col_vect( poolReadObject< SCT_ClusterContainer_p0 >() );
97  p_collection = m_converter_p0.createTransient( col_vect.get(), msg() );
98 
99  } else {
100  throw std::runtime_error("Unsupported persistent version of SCT_ClusterContainer");
101 
102  }
103  return p_collection;
104 }
105 
106 
109  return sctdc_p;
110 }
SCT_ClusterContainerCnv_p0::initialize
StatusCode initialize(MsgStream &log)
Definition: SCT_ClusterContainerCnv_p0.cxx:35
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SCT_ClusterContainerCnv::createTransient
virtual InDet::SCT_ClusterContainer * createTransient()
Definition: SCT_ClusterContainerCnv.cxx:70
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_ClusterContainerCnv::createPersistent
virtual SCT_ClusterContainer_PERS * createPersistent(InDet::SCT_ClusterContainer *transCont)
Definition: SCT_ClusterContainerCnv.cxx:107
SCT_ClusterContainerCnv::m_TPConverter_p3
SCT_ClusterContainerCnv_p3 m_TPConverter_p3
Definition: SCT_ClusterContainerCnv.h:39
InDet::SCT_ClusterContainer
Trk::PrepRawDataContainer< SCT_ClusterCollection > SCT_ClusterContainer
Definition: SCT_ClusterContainer.h:27
SCT_ClusterContainerCnv.h
TPAbstractPolyCnvBase::createPersistent
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SCT_ClusterContainerCnv::m_converter_p0
SCT_ClusterContainerCnv_p0 m_converter_p0
Definition: SCT_ClusterContainerCnv.h:37
SCT_ClusterContainerCnv::SCT_ClusterContainerCnv
SCT_ClusterContainerCnv(ISvcLocator *svcloc)
Definition: SCT_ClusterContainerCnv.cxx:15
pool::Guid
::Guid Guid
Definition: T_AthenaPoolCustCnv.h:19
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
TopLevelTPConverter::createTransient
TRANS * createTransient(MsgStream &log)
Create transient representation of the persistent object known to this converter.
Definition: TopLevelTPConverter.h:62
SCT_ClusterContainerCnv::initialize
virtual StatusCode initialize()
Gaudi Service Interface method implementations:
Definition: SCT_ClusterContainerCnv.cxx:22
T_AthenaPoolCustomCnv
Compatibility for old converter classes that don't get passed the key.
Definition: T_AthenaPoolCustomCnv.h:132
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SCT_ClusterContainerCnv_p0::createTransient
virtual InDet::SCT_ClusterContainer * createTransient(const SCT_ClusterContainer_p0 *, MsgStream &) override
Definition: SCT_ClusterContainerCnv_p0.h:34
SCT_ClusterContainerCnv::m_TPConverter
SCT_ClusterContainerCnv_tlp1 m_TPConverter
Definition: SCT_ClusterContainerCnv.h:38
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
SCT_ClusterContainerCnv::m_storeGate
StoreGateSvc * m_storeGate
Definition: SCT_ClusterContainerCnv.h:43
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
SCT_ClusterContainerCnv_p2::createTransient
virtual InDet::SCT_ClusterContainer * createTransient(const InDet::SCT_ClusterContainer_p2 *persObj, MsgStream &log)
Definition: SCT_ClusterContainerCnv_p2.cxx:195
SCT_ID
Definition: SCT_ID.h:68
InDet::SCT_ClusterContainer_p3
Definition: SCT_ClusterContainer_p3.h:23
T_AthenaPoolCustCnv::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:
SCT_ClusterContainerCnv::m_TPConverter_p2
SCT_ClusterContainerCnv_p2 m_TPConverter_p2
Definition: SCT_ClusterContainerCnv.h:40
SCT_ClusterContainerCnv_p3::createTransient
virtual InDet::SCT_ClusterContainer * createTransient(const InDet::SCT_ClusterContainer_p3 *persObj, MsgStream &log)
Definition: SCT_ClusterContainerCnv_p3.cxx:199
StoreGateSvc.h
MsgUtil.h