ATLAS Offline Software
Loading...
Searching...
No Matches
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
9#include "SCT_DataBase.h"
10#include "SCT_Options.h"
11
13
18
21
23 const std::string& name,
24 const IInterface* parent)
25 : GeoModelTool(type, name, parent)
26{
27}
28
29// Create the Geometry via the factory corresponding to this tool
30
31StatusCode
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
84 SCT_Options options;
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->());
97 m_athenaComps.setGeoDbTagSvc(&*m_geoDbTagSvc);
98 m_athenaComps.setGeometryDBSvc(&*m_geometryDBSvc);
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 {
116 SCT_DetectorFactory theSCT{&m_athenaComps, options};
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
137StatusCode
139{
140 SG::DataProxy* proxy{detStore()->proxy(ClassID_traits<SCT_DetectorManager>::ID(), m_manager->getName())};
141 if (proxy) {
142 proxy->reset();
143 m_manager = nullptr;
144 }
145 return StatusCode::SUCCESS;
146}
147
148StatusCode
149SCT_DetectorTool::align ATLAS_NOT_THREAD_SAFE (IOVSVC_CALLBACK_ARGS_P(I, keys))
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#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
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
#define I(x, y, z)
Definition MD5.cxx:116
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
const std::string & tag() const
Return version tag.
const std::string & node() const
Return the version node.
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
virtual bool isFieldNull(const std::string &fieldName) const =0
Check if the field value is NULL.
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
Base class for Pixel and SCT Detector managers.
virtual void create(GeoPhysVol *world) override
virtual const InDetDD::SCT_DetectorManager * getDetectorManager() const override
virtual void create(GeoPhysVol *world)
virtual const InDetDD::SCT_DetectorManager * getDetectorManager() const
virtual StatusCode create() override final
SCT_DetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
BooleanProperty m_alignable
const InDetDD::SCT_DetectorManager * m_manager
SCT_GeoModelAthenaComps m_athenaComps
virtual StatusCode clear() override final
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc
BooleanProperty m_useDynamicAlignFolders
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68