ATLAS Offline Software
Loading...
Searching...
No Matches
BeamPipeDetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12#include "GaudiKernel/IService.h"
13#include "GaudiKernel/ISvcLocator.h"
14
16
19#include "SGTools/DataProxy.h"
20
21#include "GeoModelKernel/GeoVolumeCursor.h"
22
24 const std::string& name,
25 const IInterface* parent ):
26 GeoModelTool(type,name,parent)
27{
28}
29
31
32
34{
35 ATH_MSG_INFO("Building Beam Pipe");
36
37 SmartIF<IGeoDbTagSvc> geoDbTag{Gaudi::svcLocator()->service("GeoDbTagSvc")};
38 ATH_CHECK(geoDbTag.isValid());
39
40 std::string atlasVersion = geoDbTag->atlasVersion();
41 std::string versionNode = "ATLAS";
42
43 GeoModelExperiment* theExpt{nullptr};
44 ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
45
46 GeoPhysVol* world=theExpt->getPhysVol();
47
48 ServiceHandle<IRDBAccessSvc> accessSvc(geoDbTag->getParamSvcName(),name());
49 ATH_CHECK(accessSvc.retrieve());
50
51 GeoModelIO::ReadGeoModel* sqliteReader = geoDbTag->getSqliteReader();
52 if (sqliteReader) {
53 BeamPipeDetectorFactory_Lite theBeamPipeFactory;
54 theBeamPipeFactory.create(world);
55 m_manager = theBeamPipeFactory.getDetectorManager();
56 }
57 else {
58 // Check we have the beampipe and print its version
59 // Print the version tag:
60 std::string beampipeVersionTag;
61 beampipeVersionTag = accessSvc->getChildTag("BeamPipe", atlasVersion,versionNode);
62 ATH_MSG_DEBUG("Beampipe Version: " << beampipeVersionTag);
63
64 if (beampipeVersionTag.empty()) {
65 ATH_MSG_INFO("No BeamPipe Version. Beam pipe will not be built.");
66 }
67 else {
68 BeamPipeDetectorFactory theBeamPipeFactory(detStore().operator->(),accessSvc.operator->());
69 theBeamPipeFactory.setTagNode(atlasVersion,versionNode,m_mode);
70 theBeamPipeFactory.create(world);
71
72 m_manager = theBeamPipeFactory.getDetectorManager();
73 }
74 }
75
76 if (m_manager) {
77 theExpt->addManager(m_manager);
78 ATH_CHECK(detStore()->record(m_manager,m_manager->getName()));
79 return StatusCode::SUCCESS;
80 }
81
82 return StatusCode::FAILURE;
83}
84
86{
87 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<BeamPipeDetectorManager>::ID(),m_manager->getName());
88 if(proxy) {
89 proxy->reset();
90 m_manager = nullptr;
91 }
92 return StatusCode::SUCCESS;
93}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Definition of the abstract IRDBAccessSvc interface.
virtual const BeamPipeDetectorManager * getDetectorManager() const override
virtual void create(GeoPhysVol *world) override
virtual void create(GeoPhysVol *world) override
void setTagNode(std::string tag, std::string node, std::string mode)
virtual const BeamPipeDetectorManager * getDetectorManager() const override
virtual StatusCode create() override final
virtual ~BeamPipeDetectorTool() override final
virtual StatusCode clear() override final
BeamPipeDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
const BeamPipeDetectorManager * m_manager
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)