ATLAS Offline Software
LArHVLineIDDetDescrCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  LAr DetDescrCnv package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 
12 
15 #include "GaudiKernel/MsgStream.h"
16 #include "StoreGate/StoreGateSvc.h"
17 
20 
21 
22 long int
24 {
25  return (storageType());
26 }
27 
30 {
31  // First call parent init
33  MsgStream log(msgSvc(), "LArHVLineIDDetDescrCnv");
34  log << MSG::DEBUG << "in initialize" << endmsg;
35 
36  if (sc.isFailure()) {
37  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
38  return sc;
39  }
40 
41  return StatusCode::SUCCESS;
42 }
43 
44 //--------------------------------------------------------------------
45 
48 {
49  MsgStream log(msgSvc(), "LArHVLineIDDetDescrCnv");
50  log << MSG::DEBUG << "in finalize" << endmsg;
51 
52  return StatusCode::SUCCESS;
53 }
54 
55 //--------------------------------------------------------------------
56 
58 LArHVLineIDDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
59 {
60  //StatusCode sc = StatusCode::SUCCESS;
61  MsgStream log(msgSvc(), "LArHVLineIDDetDescrCnv");
62  log << MSG::INFO << "in createObj: creating a LArHVLineID helper object in the detector store" << endmsg;
63 
64  // Create a new LArHVLineID
65 
66  DetDescrAddress* ddAddr;
67  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
68  if(!ddAddr) {
69  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
70  return StatusCode::FAILURE;
71  }
72 
73  // Get the StoreGate key of this container.
74  std::string helperKey = *( ddAddr->par() );
75  if ("" == helperKey) {
76  log << MSG::DEBUG << "No Helper key " << endmsg;
77  }
78  else {
79  log << MSG::DEBUG << "Helper key is " << helperKey << endmsg;
80  }
81 
82 
83  // get DetectorStore service
85  StatusCode status = serviceLocator()->service("DetectorStore", detStore);
86  if (status.isFailure()) {
87  log << MSG::FATAL << "DetectorStore service not found !" << endmsg;
88  return StatusCode::FAILURE;
89  } else {}
90 
91  // Get the dictionary manager from the detector store
92  //const DataHandle<IdDictManager> idDictMgr;
93  const IdDictManager* idDictMgr;
94  status = detStore->retrieve(idDictMgr, "IdDict");
95  if (status.isFailure()) {
96  log << MSG::FATAL << "Could not get IdDictManager !" << endmsg;
97  return StatusCode::FAILURE;
98  }
99  else {
100  log << MSG::DEBUG << " Found the IdDictManager. " << endmsg;
101  }
102 
103 
104  // create the helper
105  LArHVLineID* hvline_id = new LArHVLineID;
106  // pass a pointer to IMessageSvc to the helper
107  hvline_id->setMessageSvc(msgSvc());
108 
109  if (idDictMgr->initializeHelper(*hvline_id)) {
110  log << MSG::ERROR << "Unable to initialize LArHVLineID" << endmsg;
111  return StatusCode::FAILURE;
112  }
113  else {
114  log << MSG::DEBUG << " Initialized LArHVLineID. " << endmsg;
115  }
116 
117  // Pass a pointer to the container to the Persistency service by reference.
118  pObj = SG::asStorable(hvline_id);
119  return StatusCode::SUCCESS;
120 
121 }
122 
123 //--------------------------------------------------------------------
124 
125 long
127 {
128  return DetDescr_StorageType;
129 }
130 
131 //--------------------------------------------------------------------
132 const CLID&
135 }
136 
137 //--------------------------------------------------------------------
139  :
141 {}
142 
143 
144 
AtlasDetectorID::setMessageSvc
virtual void setMessageSvc(IMessageSvc *msgSvc) override
Definition: AtlasDetectorID.cxx:748
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
DetDescr_StorageType
const long DetDescr_StorageType
Definition: DetDescrCnvSvc.cxx:20
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
LArHVLineIDDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: LArHVLineIDDetDescrCnv.cxx:47
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArHVLineIDDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: LArHVLineIDDetDescrCnv.cxx:58
DetDescrAddress.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IdDictManager.h
LArHVLineID.h
LArHVLineIDDetDescrCnv::LArHVLineIDDetDescrCnv
LArHVLineIDDetDescrCnv(ISvcLocator *svcloc)
Definition: LArHVLineIDDetDescrCnv.cxx:138
LArHVLineIDDetDescrCnv::storageType
static long storageType()
Definition: LArHVLineIDDetDescrCnv.cxx:126
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArHVLineIDDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: LArHVLineIDDetDescrCnv.cxx:29
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
DetDescrConverter
Definition: DetDescrConverter.h:32
LArHVLineIDDetDescrCnv::classID
static const CLID & classID()
Definition: LArHVLineIDDetDescrCnv.cxx:133
DetDescrAddress
Definition: DetDescrAddress.h:32
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
IdDictManager::initializeHelper
int initializeHelper(IdHelper &helper) const
Return value: 0 OK, >0 error.
Definition: IdDictManager.cxx:44
LArHVLineIDDetDescrCnv.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdDictManager
IdDictManager is the interface to identifier dictionaries.
Definition: IdDictManager.h:36
LArHVLineIDDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: LArHVLineIDDetDescrCnv.cxx:23
DetDescrConverter.h
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
merge.status
status
Definition: merge.py:17
StoreGateSvc.h
LArHVLineID
Helper for the Liquid Argon Calorimeter High-Voltage identifiers.
Definition: LArHVLineID.h:48