ATLAS Offline Software
CaloIdMgrDetDescrCnv.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  Calo Det Descr converter package
7  -----------------------------------------
8  ***************************************************************************/
9 
10 //<doc><file> $Id: CaloIdMgrDetDescrCnv.cxx,v 1.7 2009-02-10 14:09:21 fledroit Exp $
11 //<version> $Name: not supported by cvs2svn $
12 
13 
16 
17 
18 // infrastructure includes
21 #include "GaudiKernel/MsgStream.h"
22 #include "StoreGate/StoreGateSvc.h"
24 
25 // Identifier includes
34 #include "CaloIdentifier/TileID.h"
40 
41 
42 long int
44 {
45  return (storageType());
46 }
47 
50 {
51  // First call parent init
53  MsgStream log(msgSvc(), "CaloIdMgrDetDescrCnv");
54  log << MSG::DEBUG << "in initialize" << endmsg;
55 
56  if (sc.isFailure()) {
57  log << MSG::ERROR << "DetDescrConverter::initialize failed" << endmsg;
58  return sc;
59  }
60 
61  return StatusCode::SUCCESS;
62 }
63 
64 //--------------------------------------------------------------------
65 
68 {
69  MsgStream log(msgSvc(), "CaloIdMgrDetDescrCnv");
70  log << MSG::DEBUG << "in finalize" << endmsg;
71 
72  return StatusCode::SUCCESS;
73 }
74 
75 //--------------------------------------------------------------------
76 
77 
78 namespace {
79 
80 
81 template <class T>
82 StatusCode set_helper (StoreGateSvc* detStore,
83  const char* sgkey,
85  MsgStream& log)
86 {
87  const T* id = 0;
88  CHECK_WITH_CONTEXT( detStore->retrieve (id, sgkey), "CaloIdMgrDetDescrCnv" );
89  mgr->set_helper (id);
90  log << MSG::DEBUG << "Found Calo ID helper " << sgkey << endmsg;
91  return StatusCode::SUCCESS;
92 }
93 
94 
95 } // anonymous namespace
96 
98 CaloIdMgrDetDescrCnv::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
99 {
100  MsgStream log(msgSvc(), "CaloIdMgrDetDescrCnv");
101  log << MSG::INFO
102  << "in createObj: creating a CaloDescrManager object in the detector store"
103  << endmsg;
104 
105  // Create a new CaloIdManager
106 
107  DetDescrAddress* ddAddr;
108  ddAddr = dynamic_cast<DetDescrAddress*> (pAddr);
109  if(!ddAddr) {
110  log << MSG::FATAL << "Could not cast to DetDescrAddress." << endmsg;
111  return StatusCode::FAILURE;
112  }
113 
114  // Get the StoreGate key of this container.
115  std::string mgrKey = *( ddAddr->par() );
116  if ("" == mgrKey) {
117  log << MSG::DEBUG << "No Manager key " << endmsg;
118  }
119  else {
120  log << MSG::DEBUG << "Manager key is " << mgrKey << endmsg;
121  }
122 
123  // Create the manager
124  CaloIdManager* caloIdMgr = new CaloIdManager();
125 
126  // Pass a pointer to the container to the Persistency service by reference.
127  pObj = SG::asStorable(caloIdMgr);
128 
129  // get DetectorStore service
130  StoreGateSvc * detStore = 0;
131  CHECK( serviceLocator()->service("DetectorStore", detStore) );
132 
133  // Initialize manager with all helpers.
134 #define SET_HELPER(H) CHECK( set_helper<H> (detStore, #H, caloIdMgr, log) )
135 
137 
138  bool is_test_beam = false;
139  std::vector<std::string> file_names =
140  caloIdMgr->getCaloCell_ID()->file_names();
141  for (size_t i = 0; i < file_names.size(); i++) {
142  if (file_names[i].find ("_H8_") != std::string::npos) {
143  is_test_beam =true;
144  break;
145  }
146  }
147 
154  SET_HELPER (TileID);
156 
157  if (!is_test_beam) {
163  }
164 
165 #undef SET_HELPER
166 
167 
168  log << MSG::INFO << " Finished " << endmsg;
169 
170  // Initialize the calo mgr
171  // We protect here in case this has been initialized elsewhere
172  if (!caloIdMgr->isInitialized()) {
173 
174  log << MSG::INFO << "Initializing CaloIdMgr from values in CaloIdMgrDetDescrCnv "
175  << endmsg;
176 
177  // Initialize the manager ...
178 
179  // in this one, only strictly calo work is done
180  caloIdMgr->initialize();
181 
182  }
183 
184 
185  return StatusCode::SUCCESS;
186 
187 }
188 
189 //--------------------------------------------------------------------
190 
191 long
193 {
194  return DetDescr_StorageType;
195 }
196 
197 //--------------------------------------------------------------------
198 const CLID&
201 }
202 
203 //--------------------------------------------------------------------
205  :
207 {}
AtlasDetectorID::file_names
std::vector< std::string > file_names(void) const
File names for subdet dictionaries.
Definition: AtlasDetectorID.cxx:716
common.sgkey
def sgkey(tool)
Definition: common.py:1028
CaloIdMgrDetDescrCnv::classID
static const CLID & classID()
class ID (used by CnvFactory)
Definition: CaloIdMgrDetDescrCnv.cxx:199
CaloIdMgrDetDescrCnv.h
CHECK_WITH_CONTEXT
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:396
LArEM_ID.h
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
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TTOnlineID
Helper class for Calo TT online identifiers.
Definition: TTOnlineID.h:37
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArFCAL_SuperCell_ID
Helper class for LArFCAL offline identifiers for supercells.
Definition: LArFCAL_SuperCell_ID.h:48
LArFCAL_SuperCell_ID.h
DetDescrAddress.h
LArHEC_ID
Helper class for LArHEC offline identifiers.
Definition: LArHEC_ID.h:85
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
Tile_SuperCell_ID
Helper class for Tile offline identifiers for supercells.
Definition: Tile_SuperCell_ID.h:64
CaloIdMgrDetDescrCnv::repSvcType
virtual long int repSvcType() const
Definition: CaloIdMgrDetDescrCnv.cxx:43
LArHEC_ID.h
LArEM_SuperCell_ID.h
Helper class for LArEM offline identifiers for supercells.
TileID.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
LArHEC_SuperCell_ID.h
Helper class for LArHEC offline identifiers for supercells.
CaloIdMgrDetDescrCnv::CaloIdMgrDetDescrCnv
CaloIdMgrDetDescrCnv(ISvcLocator *svcloc)
Definition: CaloIdMgrDetDescrCnv.cxx:204
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
CaloIdManager::initialize
void initialize(void)
Definition: CaloIdManager.cxx:146
LArEM_SuperCell_ID
Helper class for LArEM offline identifiers for supercells.
Definition: LArEM_SuperCell_ID.h:122
DetDescrConverter
Definition: DetDescrConverter.h:32
DetDescrAddress
Definition: DetDescrAddress.h:32
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
CaloIdMgrDetDescrCnv::initialize
virtual StatusCode initialize()
Definition: CaloIdMgrDetDescrCnv.cxx:49
CaloCell_SuperCell_ID
Helper class for offline supercell identifiers.
Definition: CaloCell_SuperCell_ID.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
TileID
Helper class for TileCal offline identifiers.
Definition: TileID.h:68
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
CaloCell_SuperCell_ID.h
Helper class for offline supercell identifiers.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
CaloIdMgrDetDescrCnv::storageType
static long storageType()
Storage type (used by CnvFactory)
Definition: CaloIdMgrDetDescrCnv.cxx:192
TTOnlineID.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
CaloDM_ID.h
CaloIdMgrDetDescrCnv::finalize
virtual StatusCode finalize()
Definition: CaloIdMgrDetDescrCnv.cxx:67
CaloIdManager::isInitialized
bool isInitialized(void) const
Definition: CaloIdManager.cxx:152
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloIdMgrDetDescrCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Definition: CaloIdMgrDetDescrCnv.cxx:98
CaloLVL1_ID
Helper class for offline TT identifiers.
Definition: CaloLVL1_ID.h:66
CaloIdManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
Definition: CaloIdManager.cxx:63
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SET_HELPER
#define SET_HELPER(H)
LArFCAL_ID.h
CaloLVL1_ID.h
LArMiniFCAL_ID
Helper class for LArMiniFCAL offline identifiers.
Definition: LArMiniFCAL_ID.h:57
DetDescrConverter.h
LArMiniFCAL_ID.h
CaloDM_ID
Helper class for Calo Dead Material offline identifiers.
Definition: CaloDM_ID.h:102
DEBUG
#define DEBUG
Definition: page_access.h:11
LArHEC_SuperCell_ID
Helper class for LArHEC offline identifiers for supercells.
Definition: LArHEC_SuperCell_ID.h:59
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Tile_SuperCell_ID.h
Helper class for Tile offline identifiers for supercells.
CaloIdManager.h
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
StoreGateSvc.h
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35