ATLAS Offline Software
BeamPipeDetectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "BeamPipeDetectorTool.h"
9 
12 #include "GaudiKernel/IService.h"
13 #include "GaudiKernel/ISvcLocator.h"
14 #include "GaudiKernel/MsgStream.h"
15 
16 #include "StoreGate/StoreGateSvc.h"
17 
20 #include "SGTools/DataProxy.h"
21 
22 #include "GeoModelKernel/GeoVolumeCursor.h"
23 
25  const std::string& name,
26  const IInterface* parent ):
28  m_manager(0),
29  m_mode("BeamPipe")
30 {
31  declareProperty("BeamPipeMode", m_mode); //m_mode="BeamPipe" by default, setting m_mode="AssemblyBeamPipe" will trigger optimised implementation using assembly volume
32 }
33 
35 {
36 }
37 
38 
40 {
41  MsgStream log(msgSvc(), name());
42 
43  log << MSG::INFO << "Building Beam Pipe" << endmsg;
44 
45  IGeoDbTagSvc *geoDbTag;
46  StatusCode sc = service ("GeoDbTagSvc",geoDbTag);
47  if (sc.isFailure()) {
48  log << MSG::FATAL << "Could not locate GeoDbTagSvc" << endmsg;
49  return StatusCode::FAILURE;
50  }
51 
52 
53  std::string atlasVersion = geoDbTag->atlasVersion();
54  if(atlasVersion == "AUTO")
55  atlasVersion = "ATLAS-00";
56  std::string versionNode = "ATLAS";
57 
58  GeoModelExperiment * theExpt;
59  if (StatusCode::SUCCESS != detStore()->retrieve( theExpt, "ATLAS" )) {
60  log << MSG::ERROR
61  << "Could not find GeoModelExperiment ATLAS"
62  << endmsg;
63  return (StatusCode::FAILURE);
64  }
65 
66  if ( 0 == m_detector )
67  {
68  GeoPhysVol *world=&*theExpt->getPhysVol();
69 
70 
71  ServiceHandle<IRDBAccessSvc> accessSvc(geoDbTag->getParamSvcName(),name());
72  ATH_CHECK( accessSvc.retrieve());
73 
74 
75  GeoModelIO::ReadGeoModel* sqliteReader = geoDbTag->getSqliteReader();
76  if (sqliteReader) {
77  BeamPipeDetectorFactory_Lite theBeamPipeFactory;
78  theBeamPipeFactory.create(world);
79  m_manager = theBeamPipeFactory.getDetectorManager();
80 
81  }
82  else {
83 
84 
85  // Check we have the beampipe and print its version
86  // Print the version tag:
87  std::string beampipeVersionTag;
88  beampipeVersionTag = accessSvc->getChildTag("BeamPipe", atlasVersion,versionNode);
89  log << MSG::DEBUG << "Beampipe Version: " << beampipeVersionTag << endmsg;
90 
91  if (beampipeVersionTag.empty()) {
92  log << MSG::INFO << "No BeamPipe Version. Beam pipe will not be built." << endmsg;
93  }
94  else {
95  BeamPipeDetectorFactory theBeamPipeFactory(detStore().operator->(),accessSvc.operator->());
96  theBeamPipeFactory.setTagNode(atlasVersion,versionNode,m_mode);
97  theBeamPipeFactory.create(world);
98 
99  m_manager = theBeamPipeFactory.getDetectorManager();
100  }
101  }
102 
103  if (m_manager) {
104  theExpt->addManager(m_manager);
105  sc = detStore()->record(m_manager,m_manager->getName());
106  if (sc.isFailure()) {
107  log << MSG::ERROR << "Could not register BeamPipe detector manager" << endmsg;
108  return (StatusCode::FAILURE);
109  }
110  return StatusCode::SUCCESS;
111  }
112  }
113  return StatusCode::FAILURE;
114 }
115 
117 {
119  if(proxy) {
120  proxy->reset();
121  m_manager = 0;
122  }
123  return StatusCode::SUCCESS;
124 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
BeamPipeDetectorFactory_Lite::getDetectorManager
virtual const BeamPipeDetectorManager * getDetectorManager() const override
Definition: BeamPipeDetectorFactory_Lite.cxx:28
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
BeamPipeDetectorTool::create
virtual StatusCode create() override final
Definition: BeamPipeDetectorTool.cxx:39
GeoModelExperiment
Definition: GeoModelExperiment.h:32
BeamPipeDetectorTool::~BeamPipeDetectorTool
virtual ~BeamPipeDetectorTool() override final
Definition: BeamPipeDetectorTool.cxx:34
BeamPipeDetectorTool::BeamPipeDetectorTool
BeamPipeDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: BeamPipeDetectorTool.cxx:24
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
GeoModelExperiment.h
BeamPipeDetectorManager.h
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
BeamPipeDetectorFactory_Lite.h
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
BeamPipeDetectorTool::clear
virtual StatusCode clear() override final
Definition: BeamPipeDetectorTool.cxx:116
BeamPipeDetectorFactory.h
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
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
BeamPipeDetectorFactory::setTagNode
void setTagNode(std::string tag, std::string node, std::string mode)
Definition: BeamPipeDetectorFactory.cxx:311
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoModelTool
Definition: GeoModelTool.h:17
BeamPipeDetectorFactory
Definition: BeamPipeDetectorFactory.h:19
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IGeoDbTagSvc
Definition: IGeoDbTagSvc.h:26
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
IGeoDbTagSvc::getParamSvcName
virtual const std::string & getParamSvcName() const =0
BeamPipeDetectorFactory_Lite::create
virtual void create(GeoPhysVol *world) override
Definition: BeamPipeDetectorFactory_Lite.cxx:18
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
BeamPipeDetectorTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IGeoDbTagSvc::atlasVersion
virtual const std::string & atlasVersion() const =0
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
BeamPipeDetectorFactory_Lite
Definition: BeamPipeDetectorFactory_Lite.h:14
BeamPipeDetectorTool::m_mode
std::string m_mode
Definition: BeamPipeDetectorTool.h:25
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
BeamPipeDetectorTool::m_manager
const BeamPipeDetectorManager * m_manager
Definition: BeamPipeDetectorTool.h:24
SG::DataProxy
Definition: DataProxy.h:44
StoreGateSvc.h
IGeoDbTagSvc.h
IGeoDbTagSvc::getSqliteReader
virtual GeoModelIO::ReadGeoModel * getSqliteReader()=0
ServiceHandle< IRDBAccessSvc >
DataProxy.h