ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD_GMX_DetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include "HGTD_GmxInterface.h"
7
9
11#include <GeoModelKernel/GeoPhysVol.h>
13#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 HGTD_GmxInterface gmxInterface(manager, m_commonItems.get());
60
61 // Load the geometry, create the volume,
62 // node,table are the location in the DB to look for the clob
63 // empty strings are the (optional) containing detector and envelope names
64 // allowed to pass a null sqlreader ptr - it will be used to steer the source of the geometry
65 const GeoVPhysVol* topVolume = createTopVolume(world, gmxInterface, node, table,"","",sqlreader);
66 // if we are using SQLite inputs,
67 if(sqlreader){
68 bool useNewIdentifierScheme = idHelper->get_useNewIdentifierScheme();
69 if (useNewIdentifierScheme){
70 ATH_MSG_INFO("Building HGTD Readout Geometry from SQLite using "<<m_geoDbTagSvc->getParamSvcName());
71 gmxInterface.buildReadoutGeometryFromSqlite(m_sqliteReadSvc.operator->(),sqlreader);
72 } else {
73 ATH_MSG_FATAL("SQLite workflow is unsupported for old HGTD identifier scheme!");
74 return StatusCode::FAILURE;
75 }
76 }
77
78 if (topVolume) { //see that a valid pointer is returned
79 manager->addTreeTop(topVolume);
80 } else {
81 ATH_MSG_FATAL("Could not find the Top Volume!!!");
82 return StatusCode::FAILURE;
83 }
84
85 // set the manager
87
88 // getName here will return whatever is passed as name to DetectorFactory - make this more explicit?
89 ATH_CHECK(detStore()->record(m_detManager, m_detManager->getName()));
90 theExpt->addManager(m_detManager);
91
92 return StatusCode::SUCCESS;
93}
94
95
97{
98 // Release manager from the detector store
99 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits< HGTD_DetectorManager >::ID(), m_detManager->getName());
100 if (proxy) {
101 proxy->reset();
102 m_detManager = nullptr;
103 }
104
105 return StatusCode::SUCCESS;
106}
107
108
109StatusCode HGTD_GMX_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE () // Thread unsafe detStore()->regFcn (callback) is used.
110{
111 // Register call-back for software alignment
112 if (m_alignable) {
113 if (detStore()->contains<AlignableTransformContainer>(m_alignmentFolderName)) {
114 ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_alignmentFolderName);
116 StatusCode sc = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool *>(this), atc, m_alignmentFolderName);
117 if (sc.isFailure()) {
118 ATH_MSG_ERROR("Could not register callback on AlignableTransformContainer with folder "
119 << m_alignmentFolderName);
120 return StatusCode::FAILURE;
121 }
122 } else {
123 ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder "
124 << m_alignmentFolderName << ", Alignment disabled!");
125 }
126 } else {
127 ATH_MSG_INFO("Alignment disabled. No callback registered");
128 // We return failure otherwise it will try and register a GeoModelSvc callback associated with this callback.
129 }
130 return StatusCode::SUCCESS;
131}
132
133
134StatusCode HGTD_GMX_DetectorTool::align(IOVSVC_CALLBACK_ARGS_P( I, keys ))
135{
136 // The call-back routine, which just calls the real call-back routine from the manager.
137 if (!m_detManager) {
138 ATH_MSG_WARNING( "Manager does not exist for " << I <<" "<< keys );
139 return StatusCode::FAILURE;
140 }
141
142 ATH_MSG_INFO( "No align method yet implemented for HGTD_DetectorManager. Nothing to do." );
143
144 return StatusCode::SUCCESS;
145}
#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)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
StatusCode HGTD_GMX_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
#define IOVSVC_CALLBACK_ARGS_P(I, K)
short hand for IOVSvc call back argument list, to be used when access to formal arguments is needed,...
Definition IOVSvcDefs.h:42
static Double_t sc
#define I(x, y, z)
Definition MD5.cxx:116
an iterator over instances of a given type in StoreGateSvc.
Definition DataHandle.h:43
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
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114