ATLAS Offline Software
Loading...
Searching...
No Matches
InDetServMatTool.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 "InDetServMatTool.h"
8
16#include "GaudiKernel/ServiceHandle.h"
17#include "GaudiKernel/ToolHandle.h"
18
20#include "SGTools/DataProxy.h"
21
25InDetServMatTool::InDetServMatTool( const std::string& type, const std::string& name, const IInterface* parent )
26 : GeoModelTool( type, name, parent )
27{
28}
29
34{
35
36 //
37 // Locate the top level experiment node
38 //
39 GeoModelExperiment * theExpt{nullptr};
40 ATH_CHECK(detStore()->retrieve(theExpt,"ATLAS"));
41
42 // Get the detector configuration.
43 ATH_CHECK(m_geoDbTagSvc.retrieve());
44
45 ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),name());
46 ATH_CHECK(accessSvc.retrieve());
47
48 GeoPhysVol *world=theExpt->getPhysVol();
49
50 GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
51
52 if (sqliteReader) {
53 InDetServMatFactory_Lite factoryLite;;
54 factoryLite.create(world);
55 m_manager = factoryLite.getDetectorManager();
56 }
57 else {
58 DecodeVersionKey versionKey(m_geoDbTagSvc.get(), "InnerDetector");
59
60 std::string versionTag = accessSvc->getChildTag("InDetServices", versionKey.tag(), versionKey.node());
61 ATH_MSG_DEBUG("versionTag=" << versionTag << " %%%");
62
63 // If versionTag is NULL then don't build.
64 if (versionTag.empty()) {
65 ATH_MSG_INFO("No InDetService Version. InDetService will not be built.");
66 ATH_MSG_DEBUG("InnerDetector Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node());
67 return StatusCode::SUCCESS;
68 }
69
70 ATH_MSG_DEBUG("Keys for InDetServMat Switches are " << versionKey.tag() << " " << versionKey.node());
71
72 std::string versionName{"CSC"};
73 if (!m_overrideVersionName.empty()) {
74 versionName = m_overrideVersionName;
75 ATH_MSG_INFO("Overriding version name: " << versionName);
76 }
77 ATH_MSG_INFO("Building Inner Detector Service Material. Version: " << versionName);
78
79 // Retrieve the Geometry DB Interface
80 ATH_CHECK(m_geometryDBSvc.retrieve());
81
82 // Pass athena services to factory, etc
83 m_athenaComps.setDetStore(detStore().get());
84 m_athenaComps.setGeoDbTagSvc(m_geoDbTagSvc.get());
85 m_athenaComps.setRDBAccessSvc(accessSvc.get());
86 m_athenaComps.setGeometryDBSvc(m_geometryDBSvc.get());
87
88 // Retrieve builder tool (SLHC only)
89 if (versionName == "SLHC") {
90 if (!m_builderTool.empty()) {
91 if(m_builderTool.retrieve().isFailure()) {
92 ATH_MSG_WARNING("Could not retrieve " << m_builderTool << ", some services will not be built.");
93 }
94 else {
95 ATH_MSG_INFO("Service builder tool retrieved: " << m_builderTool);
96 m_athenaComps.setBuilderTool(&*m_builderTool);
97 }
98 }
99 else {
100 // This will become an error once the tool is ready.
101 ATH_MSG_INFO("Service builder tool not specified.");
102 }
103 }
104
105 if (versionName == "CSC") {
106 ATH_MSG_DEBUG("InDetServMat Factory CSC");
108 theIDSM.create(world);
110 } else {
111 // Unrecognized name.
112 ATH_MSG_FATAL("Unrecognized VersionName: " << versionName);
113 return StatusCode::FAILURE;
114 }
115 }
116
117 if (m_manager) {
118 theExpt->addManager(m_manager);
119 ATH_CHECK(detStore()->record (m_manager, m_manager->getName()));
120 }
121 else {
122 ATH_MSG_FATAL("Could not create InDetServMatManager!");
123 return StatusCode::FAILURE;
124 }
125
126 return StatusCode::SUCCESS;
127}
128
130{
131 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<InDetDD::InDetServMatManager>::ID(),m_manager->getName());
132 if(proxy) {
133 proxy->reset();
134 m_manager = nullptr;
135 }
136 return StatusCode::SUCCESS;
137}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(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...
Helpers for checking error return status codes and reporting errors.
Definition of the abstract IRDBAccessSvc interface.
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
virtual const InDetDD::InDetServMatManager * getDetectorManager() const override
virtual void create(GeoPhysVol *world) override
virtual void create(GeoPhysVol *world) override
virtual const InDetDD::InDetServMatManager * getDetectorManager() const override
InDetServMatAthenaComps m_athenaComps
const InDetDD::InDetServMatManager * m_manager
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
virtual StatusCode create() override
Create the Detector Node corresponding to this tool.
StringProperty m_overrideVersionName
ToolHandle< IInDetServMatBuilderTool > m_builderTool
virtual StatusCode clear() override
InDetServMatTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor(s)
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130