ATLAS Offline Software
SCT_DetectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SCT_DetectorTool.h"
6 
7 #include "SCT_DetectorFactory.h"
9 #include "SCT_DataBase.h"
10 #include "SCT_Options.h"
11 
13 
18 
21 
23  const std::string& name,
24  const IInterface* parent)
26 {
27 }
28 
29 // Create the Geometry via the factory corresponding to this tool
30 
33 {
34 
35  // Get the detector configuration.
36  ATH_CHECK(m_geoDbTagSvc.retrieve());
37 
38  ServiceHandle<IRDBAccessSvc> accessSvc(m_geoDbTagSvc->getParamSvcName(),name());
39  ATH_CHECK(accessSvc.retrieve());
40 
41  // Print the SCT version tag:
42  std::string detectorTag{""};
43  std::string detectorNode{""};
44  GeoModelIO::ReadGeoModel* sqliteReader = m_geoDbTagSvc->getSqliteReader();
45 
46  if(!sqliteReader) {
47  DecodeVersionKey versionKey{m_geoDbTagSvc.get(), "SCT"};
48  ATH_MSG_INFO("Building SCT with Version Tag: " << versionKey.tag() << " at Node: " << versionKey.node());
49 
50  detectorTag = versionKey.tag();
51  detectorNode = versionKey.node();
52 
53  std::string sctVersionTag{accessSvc->getChildTag("SCT", detectorTag, detectorNode)};
54 
55  ATH_MSG_INFO("SCT Version: " << sctVersionTag);
56  if (sctVersionTag.empty()) {
57  ATH_MSG_INFO("No SCT Version. SCT will not be built.");
58  return StatusCode::SUCCESS;
59  }
60  else {
61  ATH_MSG_DEBUG("Keys for SCT Switches are " << detectorTag << " " << detectorNode);
62  }
63  }
64  std::string versionName;
65  IRDBRecordset_ptr switchSet{accessSvc->getRecordsetPtr("SctSwitches", detectorTag, detectorNode)};
66  const IRDBRecord* switches{(*switchSet)[0]};
67  if (not switches->isFieldNull("COSMICLAYOUT")) {
68  m_cosmic = switches->getInt("COSMICLAYOUT");
69  }
70  if (not switches->isFieldNull("VERSIONNAME")) {
71  versionName = switches->getString("VERSIONNAME");
72  }
73 
74  if (versionName.empty() && m_cosmic) {
75  versionName = "SR1";
76  }
77 
78  ATH_MSG_DEBUG("Creating the SCT");
79  ATH_MSG_DEBUG("SCT Geometry Options: ");
80  ATH_MSG_DEBUG(" Alignable: " << (m_alignable.value() ? "true" : "false"));
81  ATH_MSG_DEBUG(" CosmicLayout: " << (m_cosmic ? "true" : "false"));
82  ATH_MSG_DEBUG(" VersionName: " << versionName);
83 
85  options.setAlignable(m_alignable.value());
86  options.setDynamicAlignFolders(m_useDynamicAlignFolders.value());
87 
88  // Locate the top level experiment node
89  GeoModelExperiment* theExpt{nullptr};
90  ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
91 
92  // Retrieve the Geometry DB Interface
93  ATH_CHECK(m_geometryDBSvc.retrieve());
94 
95  // Pass athena services to factory, etc
96  m_athenaComps.setDetStore(detStore().operator->());
99  m_athenaComps.setRDBAccessSvc(&*accessSvc);
100  const SCT_ID* idHelper{nullptr};
101  ATH_CHECK(detStore()->retrieve(idHelper, "SCT_ID"));
102  m_athenaComps.setIdHelper(idHelper);
103 
104  GeoPhysVol* world{theExpt->getPhysVol()};
105 
106  // If we are using the SQLite reader, then we are not building the raw geometry but
107  // just locating it and attaching to readout geometry and various other actions
108  // taken in this factory.
109  if (sqliteReader) {
110  ATH_MSG_INFO("Building the geometry from the SQLite file");
111  SCT_DetectorFactoryLite theSCT{sqliteReader, &m_athenaComps, options};
112  theSCT.create(world);
113  m_manager = theSCT.getDetectorManager();
114  }
115  else {
117  theSCT.create(world);
118  m_manager = theSCT.getDetectorManager();
119  }
120 
121  if (m_manager==nullptr) {
122  ATH_MSG_FATAL("SCT_DetectorManager not created");
123  return StatusCode::FAILURE;
124  }
125 
126  ATH_MSG_DEBUG("Registering SCT_DetectorManager. ");
127  ATH_CHECK(detStore()->record(m_manager, m_manager->getName()));
128  theExpt->addManager(m_manager);
129 
130  // Create a symLink to the SiDetectorManager base class
131  const SiDetectorManager* siDetManager{m_manager};
132  ATH_CHECK(detStore()->symLink(m_manager, siDetManager));
133 
134  return StatusCode::SUCCESS;
135 }
136 
139 {
141  if (proxy) {
142  proxy->reset();
143  m_manager = nullptr;
144  }
145  return StatusCode::SUCCESS;
146 }
147 
150 //Not thread safe as the call m_manager->align will invalidateAllElements it holds
151 {
152  if (m_manager==nullptr) {
153  ATH_MSG_FATAL("Manager does not exist");
154  return StatusCode::FAILURE;
155  }
156  if (m_alignable.value()) {
157  return const_cast<InDetDD::SCT_DetectorManager*>(m_manager)->align(I, keys);
158  } else {
159  ATH_MSG_DEBUG("Alignment disabled. No alignments applied");
160  return StatusCode::SUCCESS;
161  }
162 }
SCT_DetectorFactory
Definition: SCT_DetectorFactory.h:23
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_DetectorTool::m_useDynamicAlignFolders
BooleanProperty m_useDynamicAlignFolders
Definition: SCT_DetectorTool.h:38
SCT_DetectorTool::m_athenaComps
SCT_GeoModelAthenaComps m_athenaComps
Definition: SCT_DetectorTool.h:43
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_DetectorTool::create
virtual StatusCode create() override final
Definition: SCT_DetectorTool.cxx:32
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:407
SCT_DetectorTool.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_DetectorFactoryLite
Definition: SCT_DetectorFactoryLite.h:34
SCT_DataBase.h
SCT_DetectorTool::m_cosmic
bool m_cosmic
Definition: SCT_DetectorTool.h:39
SCT_Options.h
GeoModelExperiment
Definition: GeoModelExperiment.h:32
SCT_GeoModelAthenaComps::setIdHelper
void setIdHelper(const SCT_ID *idHelper)
Definition: SCT_GeoModelAthenaComps.cxx:13
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
SCT_DetectorTool::SCT_DetectorTool
SCT_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCT_DetectorTool.cxx:22
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
InDetDD::AthenaComps::setGeoDbTagSvc
void setGeoDbTagSvc(IGeoDbTagSvc *)
Definition: InDetDDAthenaComps.cxx:22
InDetDD::AthenaComps::setDetStore
void setDetStore(StoreGateSvc *)
Definition: InDetDDAthenaComps.cxx:17
SCT_Options
Definition: SCT_Options.h:12
GeoModelExperiment.h
SCT_DetectorFactory.h
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
DecodeVersionKey
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
Definition: DecodeVersionKey.h:18
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
SCT_DetectorFactoryLite.h
SCT_DetectorTool::clear
virtual StatusCode clear() override final
Definition: SCT_DetectorTool.cxx:138
test_pyathena.parent
parent
Definition: test_pyathena.py:15
GeoModelTool
Definition: GeoModelTool.h:16
InDetDD::AthenaComps::setRDBAccessSvc
void setRDBAccessSvc(IRDBAccessSvc *)
Definition: InDetDDAthenaComps.cxx:27
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:378
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DecodeVersionKey.h
ATLAS_NOT_THREAD_SAFE
StatusCode SCT_DetectorTool::align ATLAS_NOT_THREAD_SAFE(IOVSVC_CALLBACK_ARGS_P(I, keys))
Definition: SCT_DetectorTool.cxx:149
SCT_DetectorTool::m_geometryDBSvc
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc
Definition: SCT_DetectorTool.h:46
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
SCT_ID
Definition: SCT_ID.h:68
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
InDetDD::AthenaComps::setGeometryDBSvc
void setGeometryDBSvc(IGeometryDBSvc *)
Definition: InDetDDAthenaComps.cxx:32
InDetDD::SiDetectorManager
Definition: SiDetectorManager.h:60
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
I
#define I(x, y, z)
Definition: MD5.cxx:116
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
SCT_DetectorManager.h
SG::DataProxy
Definition: DataProxy.h:45
SCT_DetectorTool::m_manager
const InDetDD::SCT_DetectorManager * m_manager
Definition: SCT_DetectorTool.h:41
SCT_DetectorTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: SCT_DetectorTool.h:45
SCT_DetectorTool::m_alignable
BooleanProperty m_alignable
Definition: SCT_DetectorTool.h:37
ServiceHandle< IRDBAccessSvc >