ATLAS Offline Software
ZDC_DetTool.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 #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  if (msgLevel(MSG::DEBUG)) msg(MSG::DEBUG) << " Building ZDC geometry " << endmsg;
39 
40  // Locate the top level experiment node
41  GeoModelExperiment* theExpt = nullptr;
42 
43  if (StatusCode::SUCCESS != detStore()->retrieve(theExpt, "ATLAS")) {
44 
45  if (msgLevel(MSG::ERROR)) msg(MSG::ERROR) << " Could not find GeoModelExperiment ATLAS " << endmsg;
46  return (StatusCode::FAILURE);
47  }
48 
49 
50  ZDC_DetFactory theZDCFactory(detStore().operator->());
51 
52  IGeoDbTagSvc *geoDbTag;
53  StatusCode sc = service ("GeoDbTagSvc",geoDbTag);
54  if (sc.isFailure()) {
55  msg(MSG::FATAL) << "Could not locate GeoDbTagSvc" << endmsg;
56  return StatusCode::FAILURE;
57  }
58 
59  GeoModel::GeoConfig geoConfig = geoDbTag->geoConfig();
60 
61  //Set the geometry configuration
62  if(geoConfig==GeoModel::GEO_RUN2){
63  msg(MSG::INFO) << "Initializing ZDC geometry for PbPb2015" << endmsg;
64  theZDCFactory.initializePbPb2015();
65  }else if(geoConfig==GeoModel::GEO_RUN3){
66  msg(MSG::INFO) << "Initializing ZDC geometry for PbPb2023" << endmsg;
67  theZDCFactory.initializePbPb2023();
68  }else if(geoConfig==GeoModel::GEO_RUN4){
69  msg(MSG::ERROR) << "No ZDC geometry defined for RUN4" << endmsg;
70  }
71 
72  if (nullptr == m_detector) { // Create the ZDCDetectorNode instance
73 
74  try {
75  // This strange way of casting is to avoid an utterly brain damaged compiler warning.
76  GeoPhysVol* world = &*theExpt->getPhysVol();
77  theZDCFactory.create(world);
78  }
79  catch (const std::bad_alloc&) {
80 
81  if (msgLevel(MSG::FATAL)) msg(MSG::FATAL) << "Could not create new ZDC DetectorNode!" << endmsg;
82  return StatusCode::FAILURE;
83  }
84 
85  // Register the ZDC DetectorNode instance with the Transient Detector Store
86  theExpt->addManager(theZDCFactory.getDetectorManager());
87  if(detStore()->record(theZDCFactory.getDetectorManager(),theZDCFactory.getDetectorManager()->getName())==StatusCode::SUCCESS){
88  return StatusCode::SUCCESS;}
89  else{
90  msg(MSG::FATAL) << "Could not register ZDC detector manager" << endmsg;}
91 
92  }
93 
94  return StatusCode::FAILURE;
95 }
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
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
ZDC_DetTool.h
GeoModel::GeoConfig
GeoConfig
Definition: IGeoDbTagSvc.h:17
ZDC_DetManager.h
GeoModelExperiment
Definition: GeoModelExperiment.h:32
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ZDC_DetFactory.h
GeoModelExperiment.h
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
IGeoDbTagSvc
Definition: IGeoDbTagSvc.h:26
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:195
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