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>
14
15
17 const std::string &name,
18 const IInterface *parent)
19 : GeoModelXmlTool(type, name, parent)
20{
21}
22
23
25{
26 // retrieve the common stuff
28
29 const HGTD_ID *idHelper{};
30 ATH_CHECK(detStore()->retrieve(idHelper, "HGTD_ID"));
31
32 GeoModelExperiment *theExpt{};
33 ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
34
35 m_commonItems = std::make_unique<InDetDD::SiCommonItems>(idHelper);
36
37 //
38 // Check the availability
39 //
40 std::string node{"InnerDetector"};
41 std::string table{"HGTDXDD"};
42
43 GeoModelIO::ReadGeoModel* sqlreader = getSqliteReader();
44
45 if(!sqlreader){
46 if (!isAvailable(node, table)) {
47 ATH_MSG_ERROR("No HGTD geometry found. HGTD can not be built.");
48 return StatusCode::FAILURE;
49 }
50 }
51 //
52 // Create the detector manager
53 //
54 // The * converts a ConstPVLink to a ref to a GeoVPhysVol
55 // The & takes the address of the GeoVPhysVol
56 GeoPhysVol *world = &*theExpt->getPhysVol();
57 auto *manager = new HGTD_DetectorManager(&*detStore());
58
59 // --------------------------------------------------
60 // Alignment folder setup
61 // --------------------------------------------------
62 if (m_alignable) {
63 ATH_MSG_DEBUG("HGTD alignment enabled (GeoModel level only)");
64 }
65 else {
66 ATH_MSG_DEBUG("HGTD alignment DISABLED");
67 }
68
69 HGTD_GmxInterface gmxInterface(manager, m_commonItems.get());
70
71 // Load the geometry, create the volume,
72 // node,table are the location in the DB to look for the clob
73 // empty strings are the (optional) containing detector and envelope names
74 // allowed to pass a null sqlreader ptr - it will be used to steer the source of the geometry
75 const GeoVPhysVol* topVolume = createTopVolume(world, gmxInterface, node, table,"","",sqlreader);
76 // if we are using SQLite inputs,
77 if(sqlreader){
78 bool useNewIdentifierScheme = idHelper->get_useNewIdentifierScheme();
79 if (useNewIdentifierScheme){
80 ATH_MSG_DEBUG("Building HGTD Readout Geometry from SQLite using "<<m_geoDbTagSvc->getParamSvcName());
81 gmxInterface.buildReadoutGeometryFromSqlite(m_sqliteReadSvc.operator->(),sqlreader);
82 } else {
83 ATH_MSG_FATAL("SQLite workflow is unsupported for old HGTD identifier scheme!");
84 return StatusCode::FAILURE;
85 }
86 }
87
88 if (topVolume) { //see that a valid pointer is returned
89 manager->addTreeTop(topVolume);
90 } else {
91 ATH_MSG_FATAL("Could not find the Top Volume!!!");
92 return StatusCode::FAILURE;
93 }
94
95 // set the manager
97
98 // getName here will return whatever is passed as name to DetectorFactory - make this more explicit?
99 ATH_CHECK(detStore()->record(m_detManager, m_detManager->getName()));
100 theExpt->addManager(m_detManager);
101
102 return StatusCode::SUCCESS;
103}
104
105
107{
108 // Release manager from the detector store
109 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits< HGTD_DetectorManager >::ID(), m_detManager->getName());
110 if (proxy) {
111 proxy->reset();
112 m_detManager = nullptr;
113 }
114
115 return StatusCode::SUCCESS;
116}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_FATAL(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
Gaudi::Property< bool > m_alignable
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:518
Definition node.h:24