ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_GMX_DetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "HGTD_GmxInterface.h"
7
9
10#include <GeoModelKernel/GeoPhysVol.h>
12#include <SGTools/DataProxy.h>
13
14
16 const std::string &name,
17 const IInterface *parent)
18 : GeoModelXmlTool(type, name, parent)
19{
20}
21
22
24{
25 // retrieve the common stuff
27
28 const HGTD_ID *idHelper{};
29 ATH_CHECK(detStore()->retrieve(idHelper, "HGTD_ID"));
30
31 GeoModelExperiment *theExpt{};
32 ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
33
34 m_commonItems = std::make_unique<InDetDD::SiCommonItems>(idHelper);
35
36 //
37 // Check the availability
38 //
39 std::string node{"InnerDetector"};
40 std::string table{"HGTDXDD"};
41
42 GeoModelIO::ReadGeoModel* sqlreader = getSqliteReader();
43
44 if(!sqlreader){
45 if (!isAvailable(node, table)) {
46 ATH_MSG_ERROR("No HGTD geometry found. HGTD can not be built.");
47 return StatusCode::FAILURE;
48 }
49 }
50 //
51 // Create the detector manager
52 //
53 // The * converts a ConstPVLink to a ref to a GeoVPhysVol
54 // The & takes the address of the GeoVPhysVol
55 GeoPhysVol *world = &*theExpt->getPhysVol();
56 auto *manager = new HGTD_DetectorManager(&*detStore());
57
58 HGTD_GmxInterface gmxInterface(manager, m_commonItems.get());
59
60 // Load the geometry, create the volume,
61 // node,table are the location in the DB to look for the clob
62 // empty strings are the (optional) containing detector and envelope names
63 // allowed to pass a null sqlreader ptr - it will be used to steer the source of the geometry
64 const GeoVPhysVol* topVolume = createTopVolume(world, gmxInterface, node, table,"","",sqlreader);
65 // if we are using SQLite inputs,
66 if(sqlreader){
67 bool useNewIdentifierScheme = idHelper->get_useNewIdentifierScheme();
68 if (useNewIdentifierScheme){
69 ATH_MSG_INFO("Building HGTD Readout Geometry from SQLite using "<<m_geoDbTagSvc->getParamSvcName());
70 gmxInterface.buildReadoutGeometryFromSqlite(m_sqliteReadSvc.operator->(),sqlreader);
71 } else {
72 ATH_MSG_FATAL("SQLite workflow is unsupported for old HGTD identifier scheme!");
73 return StatusCode::FAILURE;
74 }
75 }
76
77 if (topVolume) { //see that a valid pointer is returned
78 manager->addTreeTop(topVolume);
79 } else {
80 ATH_MSG_FATAL("Could not find the Top Volume!!!");
81 return StatusCode::FAILURE;
82 }
83
84 // set the manager
86
87 // getName here will return whatever is passed as name to DetectorFactory - make this more explicit?
88 ATH_CHECK(detStore()->record(m_detManager, m_detManager->getName()));
89 theExpt->addManager(m_detManager);
90
91 return StatusCode::SUCCESS;
92}
93
94
96{
97 // Release manager from the detector store
98 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits< HGTD_DetectorManager >::ID(), m_detManager->getName());
99 if (proxy) {
100 proxy->reset();
101 m_detManager = nullptr;
102 }
103
104 return StatusCode::SUCCESS;
105}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
virtual GeoVDetectorManager * manager()
ServiceHandle< IRDBAccessSvc > m_sqliteReadSvc
StatusCode createBaseTool()
bool isAvailable(const std::string &versionNode, const std::string &tableNode) const
GeoModelXmlTool(const std::string &type, const std::string &name, const IInterface *parent)
const GeoVPhysVol * createTopVolume(GeoPhysVol *worldVol, GmxInterface &interface, const std::string &versionNode, const std::string &tableNode, const std::string &containingDetector="", const std::string &envelopeName="", const GeoModelIO::ReadGeoModel *sqlreader=nullptr) const
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
GeoModelIO::ReadGeoModel * getSqliteReader() const
The Detector manager has methods to retrieve the Identifier helper and methods to retrieve the detect...
std::unique_ptr< InDetDD::SiCommonItems > m_commonItems
const HGTD_DetectorManager * m_detManager
virtual StatusCode clear() override final
virtual StatusCode create() override final
HGTD_GMX_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
void buildReadoutGeometryFromSqlite(IRDBAccessSvc *rdbAccessSvc, GeoModelIO::ReadGeoModel *sqlreader)
This is an Identifier helper class for the HGTD subdetector.
Definition HGTD_ID.h:47
bool get_useNewIdentifierScheme() const
Definition HGTD_ID.cxx:516
Definition node.h:24