ATLAS Offline Software
ZDC_DetTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ZDC_DetTool.h"
6 #include "ZDC_DetFactory.h"
7 #include "ZDC_DetManager.h"
9 #include "GaudiKernel/IService.h"
10 #include "GaudiKernel/ISvcLocator.h"
12 #include "StoreGate/StoreGateSvc.h"
14 
15 ZDC_DetTool::ZDC_DetTool(const std::string& type, const std::string& name, const IInterface* parent)
17 {
18 
19  if (msgLevel(MSG::DEBUG))
20  msg(MSG::DEBUG) << "INSIDE CONSTRUCTOR OF DETTOOL" << endmsg
21  << "INSIDE CONSTRUCTOR OF DETTOOL string& type " << type << endmsg
22  << "INSIDE CONSTRUCTOR OF DETTOOL std::string& name " << name << endmsg;
23 }
24 
26 {
27  // This will need to be modified once we register the Toy DetectorNode in the Transient Detector Store
28 
29  if (nullptr != m_detector) {
30 
31  delete m_detector;
32  m_detector = nullptr;
33  }
34 }
35 
37 {
38 
39  // Locate the top level experiment node
40  GeoModelExperiment* theExpt = nullptr;
41 
42  ATH_CHECK( detStore()->retrieve(theExpt, "ATLAS") );
43 
44  ZDC_DetFactory theZDCFactory(detStore().operator->());
45 
46  ServiceHandle<IGeoDbTagSvc> geoDbTag("GeoDbTagSvc", name());
47  ATH_CHECK( geoDbTag.retrieve() );
48 
49  GeoModel::GeoConfig geoConfig = geoDbTag->geoConfig();
50 
51  //Set the geometry configuration
52  if(geoConfig==GeoModel::GEO_RUN2){
53  ATH_MSG_INFO("Initializing ZDC geometry for PbPb2015");
54  theZDCFactory.initializePbPb2015();
55  }else if(geoConfig==GeoModel::GEO_RUN3){
56  ATH_MSG_INFO("Initializing ZDC geometry for PbPb2023");
57  theZDCFactory.initializePbPb2023();
58  }else if(geoConfig==GeoModel::GEO_RUN4){
59  ATH_MSG_ERROR("No ZDC geometry defined for RUN4");
60  }
61 
62  if (nullptr == m_detector) { // Create the ZDCDetectorNode instance
63 
64  try {
65  // This strange way of casting is to avoid an utterly brain damaged compiler warning.
66  GeoPhysVol* world = &*theExpt->getPhysVol();
67  theZDCFactory.create(world);
68  }
69  catch (const std::bad_alloc&) {
70 
71  ATH_MSG_FATAL("Could not create new ZDC DetectorNode!");
72  return StatusCode::FAILURE;
73  }
74 
75  // Register the ZDC DetectorNode instance with the Transient Detector Store
76  theExpt->addManager(theZDCFactory.getDetectorManager());
77  ATH_CHECK( detStore()->record(theZDCFactory.getDetectorManager(),theZDCFactory.getDetectorManager()->getName()) );
78  }
79 
80  return StatusCode::SUCCESS;
81 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ZDC_DetTool::create
virtual StatusCode create() override final
Definition: ZDC_DetTool.cxx:36
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ZDC_DetTool.h
GeoModel::GeoConfig
GeoConfig
Definition: IGeoDbTagSvc.h:17
ZDC_DetManager.h
GeoModelExperiment
Definition: GeoModelExperiment.h:32
ZDC_DetFactory.h
GeoModelExperiment.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ZDC_DetTool::~ZDC_DetTool
virtual ~ZDC_DetTool() override final
Definition: ZDC_DetTool.cxx:25
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
ZDC_DetTool::ZDC_DetTool
ZDC_DetTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ZDC_DetTool.cxx:15
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoModel::GEO_RUN4
@ GEO_RUN4
Definition: IGeoDbTagSvc.h:21
GeoModelTool
Definition: GeoModelTool.h:17
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
GeoModel::GEO_RUN3
@ GEO_RUN3
Definition: IGeoDbTagSvc.h:20
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
GeoModelTool::m_detector
GeoVDetectorManager * m_detector
Definition: GeoModelTool.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
GeoModel::GEO_RUN2
@ GEO_RUN2
Definition: IGeoDbTagSvc.h:19
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
ZDC_DetFactory
Definition: ZDC_DetFactory.h:24
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
IGeoDbTagSvc.h
ServiceHandle< IGeoDbTagSvc >