ATLAS Offline Software
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)
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
100  if (proxy) {
101  proxy->reset();
102  m_detManager = nullptr;
103  }
104 
105  return StatusCode::SUCCESS;
106 }
107 
108 
109 StatusCode 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 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
GeoModelXmlTool::createBaseTool
StatusCode createBaseTool()
Definition: GeoModelXmlTool.cxx:26
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GeoModelExperiment
Definition: GeoModelExperiment.h:32
HGTD_GMX_DetectorTool::m_commonItems
std::unique_ptr< InDetDD::SiCommonItems > m_commonItems
Definition: HGTD_GMX_DetectorTool.h:35
GeoModelXmlTool::isAvailable
bool isAvailable(const std::string &versionNode, const std::string &tableNode) const
Definition: GeoModelXmlTool.cxx:78
IOVSVC_CALLBACK_ARGS_P
#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
IGeoModelTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS)=0
HGTD_DetectorManager.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
GeoModelExperiment.h
GeoModelXmlTool::createTopVolume
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
Definition: GeoModelXmlTool.cxx:35
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
GeoModelXmlTool::getSqliteReader
GeoModelIO::ReadGeoModel * getSqliteReader() const
Definition: GeoModelXmlTool.cxx:174
GeoModelTool::manager
virtual GeoVDetectorManager * manager()
The Detector Node corresponding to this tool.
Definition: GeoModelTool.cxx:21
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AlignableTransformContainer.h
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HGTD_GMX_DetectorTool::HGTD_GMX_DetectorTool
HGTD_GMX_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HGTD_GMX_DetectorTool.cxx:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
HGTD_ID
Definition: HGTD_ID.h:47
HGTD_GMX_DetectorTool::clear
virtual StatusCode clear() override final
Definition: HGTD_GMX_DetectorTool.cxx:96
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
python.ext.table_printer.table
list table
Definition: table_printer.py:81
DataHandle
an iterator over instances of a given type in StoreGateSvc. It d-casts and caches locally the pointed...
Definition: DataHandle.h:42
HGTD_GMX_DetectorTool::create
virtual StatusCode create() override final
Definition: HGTD_GMX_DetectorTool.cxx:24
HGTD_GmxInterface
Definition: HGTD_GmxInterface.h:29
IGeoModelTool
Definition: IGeoModelTool.h:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
GeoModelXmlTool
Definition: GeoModelXmlTool.h:21
GeoModelXmlTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: GeoModelXmlTool.h:45
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GeoModelXmlTool::m_sqliteReadSvc
ServiceHandle< IRDBAccessSvc > m_sqliteReadSvc
Definition: GeoModelXmlTool.h:44
HGTD_DetectorManager
Definition: HGTD_DetectorManager.h:33
HGTD_GMX_DetectorTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS_P(I, keys)) override final
Definition: HGTD_GMX_DetectorTool.cxx:134
HGTD_GMX_DetectorTool.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
I
#define I(x, y, z)
Definition: MD5.cxx:116
SG::DataProxy
Definition: DataProxy.h:44
HGTD_GmxInterface.h
HGTD_GMX_DetectorTool::m_detManager
const HGTD_DetectorManager * m_detManager
Definition: HGTD_GMX_DetectorTool.h:34
node
Definition: memory_hooks-stdcmalloc.h:74
ATLAS_NOT_THREAD_SAFE
StatusCode HGTD_GMX_DetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: HGTD_GMX_DetectorTool.cxx:109
DataProxy.h
HGTD_GmxInterface::buildReadoutGeometryFromSqlite
void buildReadoutGeometryFromSqlite(IRDBAccessSvc *rdbAccessSvc, GeoModelIO::ReadGeoModel *sqlreader)
Definition: HGTD_GmxInterface.cxx:197