ATLAS Offline Software
Loading...
Searching...
No Matches
src/PixelDetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include "PixelDetectorTool.h"
12#include "PixelSwitches.h"
13
19#include "GaudiKernel/ServiceHandle.h"
22#include "GeoModelRead/ReadGeoModel.h"
23
27
29#include "SGTools/DataProxy.h"
30
32
35
40
41
43{
44 if (!m_bcmTool.empty()) {
45 ATH_CHECK( m_bcmTool.retrieve() );
46 }
47 if (!m_blmTool.empty()) {
48 ATH_CHECK( m_blmTool.retrieve() );
49 }
50 return StatusCode::SUCCESS;
51}
52
57{
58 if (m_devVersion) ATH_MSG_WARNING("You are using a development version. There are no guarantees of stability");
59
60 // Get the detector configuration.
61 ServiceHandle<IGeoDbTagSvc> geoDbTagSvc("GeoDbTagSvc",name());
62 ATH_CHECK(geoDbTagSvc.retrieve());
63
64 ServiceHandle<IRDBAccessSvc> rdbAccessSvc(geoDbTagSvc->getParamSvcName(),name());
65 ATH_CHECK(rdbAccessSvc.retrieve());
66
67
68 GeoModelExperiment* theExpt = nullptr;
69 ATH_CHECK(detStore()->retrieve(theExpt,"ATLAS"));
70
71 GeoPhysVol *world=theExpt->getPhysVol();
72 GeoModelIO::ReadGeoModel* sqliteReader = geoDbTagSvc->getSqliteReader();
73
74 std::string detectorKey{""};
75 std::string detectorNode{""};
76 if(!sqliteReader) {
77 DecodeVersionKey decodeVersion(geoDbTagSvc.operator->(), "Pixel");
78 detectorKey = decodeVersion.tag();
79 detectorNode = decodeVersion.node();
80 if(decodeVersion.custom()) {
81 ATH_MSG_WARNING("PixelDetectorTool: Detector Information coming from a custom configuration!!" );
82 }
83 }
84
85 IRDBRecordset_ptr switchSet = rdbAccessSvc->getRecordsetPtr("PixelSwitches", detectorKey, detectorNode);
86 const IRDBRecord *switchTable = (*switchSet)[0];
87
88 std::string versionName;
89 std::string descrName="noDescr";
90
91 m_dc1Geometry = switchTable->getInt("DC1GEOMETRY");
92 m_initialLayout = switchTable->getInt("INITIALLAYOUT");
93 if (!switchTable->isFieldNull("VERSIONNAME")) {
94 versionName = switchTable->getString("VERSIONNAME");
95 }
96 if (!switchTable->isFieldNull("DESCRIPTION")) {
97 descrName = switchTable->getString("DESCRIPTION");
98 }
99 m_buildDBM = switchTable->getInt("BUILDDBM");
100
101 // Initialize switches
102 PixelSwitches switches;
103
104 switches.setServices(m_services);
106 switches.setAlignable(m_alignable);
108 switches.setDBM(m_buildDBM); //DBM flag
110
111 //JBdV
113 switches.setServices(m_services); //Overwrite there for the time being.
114
115 const PixelID * idHelper = nullptr;
116 ATH_CHECK(detStore()->retrieve(idHelper, "PixelID"));
117
118 // Pass athena services to factory, etc
120 m_athenaComps->setDetStore(detStore().operator->());
121 m_athenaComps->setGeoDbTagSvc(&*geoDbTagSvc);
122 m_athenaComps->setRDBAccessSvc(&*rdbAccessSvc);
123 m_athenaComps->setIdHelper(idHelper);
124
125 // BCM Tool.
126 if (!m_bcmTool.empty()) {
127 m_athenaComps->setBCM(m_bcmTool.get());
128 }
129 else {
130 ATH_MSG_INFO("BCM not requested." );
131 }
132
133 // BLM Tool.
134 if (!m_blmTool.empty()) {
135 m_athenaComps->setBLM(m_blmTool.get());
136 }
137 else {
138 ATH_MSG_INFO("BLM not requested." );
139 }
140
141 // Service builder tool
142 if (!m_serviceBuilderTool.empty()) {
143 if (!m_serviceBuilderTool.retrieve().isFailure()) {
144 ATH_MSG_INFO("Service builder tool retrieved: " << m_serviceBuilderTool );
145 m_athenaComps->setServiceBuilderTool(&*m_serviceBuilderTool);
146 }
147 else {
148 ATH_MSG_ERROR("Could not retrieve " << m_serviceBuilderTool << ", some services will not be built." );
149 }
150 }
151 else {
152 if (versionName == "SLHC") { // TODO
153 ATH_MSG_ERROR("Service builder tool not specified. Some services will not be built" );
154 }
155 else {
156 ATH_MSG_INFO("Service builder tool not specified." );
157 }
158 }
159
160 if(sqliteReader) {
161 // ---------------------- Build from SQLite file --------------------------
162 ATH_MSG_INFO("Building the geometry from the SQLite file");
163
164 ATH_MSG_DEBUG("Creating the Pixel ");
165 ATH_MSG_DEBUG("Pixel Geometry Options:");
166 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false"));
167 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
168 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
169 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
170 ATH_MSG_DEBUG(" VersioName = " << versionName );
171
172 if (versionName == "IBL") switches.setIBL();
173
174 PixelDetectorFactoryLite thePixelFactory(sqliteReader,m_athenaComps,switches);
175 thePixelFactory.create(world);
176 m_manager=thePixelFactory.getDetectorManager();
177 }
178 else {
179 // ---------------------- Build from GeometryDB --------------------------
180 ATH_MSG_INFO("Building Pixel Detector with Version Tag: " << detectorKey
181 << " at Node: " << detectorNode);
182
183 ATH_MSG_INFO("Building the geometry in the standard way");
184
185 // Print the version tag:
186 std::string pixelVersionTag = rdbAccessSvc->getChildTag("Pixel", detectorKey, detectorNode);
187 ATH_MSG_INFO("Pixel Version: " << pixelVersionTag );
188
189 // Check if version is empty. If so, then the Pixel cannot be built. This may or may not be intentional.
190 // We just issue an INFO message.
191 if (pixelVersionTag.empty()) {
192 ATH_MSG_INFO("No Pixel Version. Pixel Detector will not be built." );
193 return StatusCode::SUCCESS;
194 }
195
196 // Unless we are using custom pixel, the switch positions are going to
197 // come from the database:
198
199 ATH_MSG_DEBUG("PixelDetectorTool: Detector Information coming from the database and job options IGNORED." );
200 ATH_MSG_DEBUG("Keys for Pixel Switches are " << detectorKey << " " << detectorNode );
201
202 if (versionName.empty()) {
203 if (m_dc1Geometry) {
204 versionName = "DC1";
205 }
206 else {
207 versionName = "DC2";
208 }
209 }
210
211 if (!m_overrideVersionName.empty()) {
212 versionName = m_overrideVersionName;
213 ATH_MSG_INFO("Overriding version name: " << versionName );
214 }
215
216 ATH_MSG_DEBUG("Creating the Pixel " );
217 ATH_MSG_DEBUG("Pixel Geometry Options:" );
218 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false") );
219 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
220 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
221 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
222 ATH_MSG_DEBUG(" VersioName = " << versionName );
223
224 if (m_IBLParameterSvc.retrieve().isFailure()) {
225 ATH_MSG_WARNING( "Could not retrieve IBLParameterSvc");
226 }
227 else {
228 m_IBLParameterSvc->setBoolParameters(m_alignable.value(),"alignable");
229 }
230
231 if (versionName == "IBL") switches.setIBL();
232
233 if (!m_devVersion) {
234
235 if(versionName == "DC1" || versionName == "DC2") {
236 // DC1/DC2 version
237 PixelDetectorFactoryDC2 thePixel(m_athenaComps, switches);
238 thePixel.create(world);
239 m_manager = thePixel.getDetectorManager();
240 }
241 else if (versionName == "SR1") {
242 // SR1. Same a DC3 but only 1 part (barrel, ec A or ec C) built
243 PixelDetectorFactorySR1 thePixel(m_athenaComps, switches);
244 thePixel.create(world);
245 m_manager = thePixel.getDetectorManager();
246 }
247 else {
248 // DC3, SLHC, IBL
249 PixelDetectorFactory thePixel(m_athenaComps, switches);
250 if(descrName.compare("TrackingGeometry")!=0) {
251 thePixel.create(world);
252 }
253 else {
254 ATH_MSG_INFO("Pixel - TrackingGeometry tag - no geometry built" );
255 }
256 m_manager = thePixel.getDetectorManager();
257 }
258
259 }
260 else {
261 // DEVELOPMENT VERSIONS
262 PixelDetectorFactory thePixel(m_athenaComps, switches);
263 thePixel.create(world);
264 m_manager = thePixel.getDetectorManager();
265 }
266 }
267
268 // Register the manager to the Det Store
269 ATH_CHECK(detStore()->record(m_manager, m_manager->getName()));
270 // Add the manager to the experiment
271 theExpt->addManager(m_manager);
272
273 return StatusCode::SUCCESS;
274}
275
277{
278 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<InDetDD::PixelDetectorManager>::ID(),m_manager->getName());
279 if(proxy) {
280 proxy->reset();
281 m_manager = nullptr;
282 }
283 return StatusCode::SUCCESS;
284}
285
286StatusCode
288//Not thread safe as the call m_manager->align will invalidateAllElements it holds
289{
290 if (!m_manager) {
291 ATH_MSG_WARNING("Manager does not exist" );
292 return StatusCode::FAILURE;
293 }
294 if (m_alignable) {
295 return const_cast<InDetDD::PixelDetectorManager*>(m_manager)->align();
296 } else{
297 ATH_MSG_DEBUG("Alignment disabled. No alignments applied" );
298 return StatusCode::SUCCESS;
299 }
300}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
Define macros for attributes used to control the static checker.
This is a helper class to query the version tags from GeoModelSvc and determine the appropriate tag a...
bool custom() const
Return true if CUSTOM is selected.
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:28
virtual bool isFieldNull(std::string_view fieldName) const =0
Check if the field value is NULL.
virtual int getInt(std::string_view fieldName) const =0
Get int field value.
virtual const std::string & getString(std::string_view fieldName) const =0
Get string field value.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
Base class for Pixel and SCT Detector managers.
virtual const InDetDD::PixelDetectorManager * getDetectorManager() const
virtual void create(GeoPhysVol *world)
virtual const InDetDD::PixelDetectorManager * getDetectorManager() const override
virtual void create(GeoPhysVol *world) override
virtual void create(GeoPhysVol *world)
virtual const InDetDD::PixelDetectorManager * getDetectorManager() const
virtual void create(GeoPhysVol *world)
virtual const InDetDD::PixelDetectorManager * getDetectorManager() const
Gaudi::Property< bool > m_useDynamicAlignFolders
Gaudi::Property< bool > m_devVersion
Gaudi::Property< bool > m_services
ToolHandle< IGeoSubDetTool > m_bcmTool
ToolHandle< IGeoSubDetTool > m_blmTool
Gaudi::Property< std::string > m_overrideVersionName
virtual StatusCode align() override
const InDetDD::PixelDetectorManager * m_manager
Gaudi::Property< bool > m_servicesOnLadder
virtual StatusCode initialize() override final
virtual ~PixelDetectorTool() override final
virtual StatusCode create() override final
Create the Detector Node corresponding to this tool.
PixelGeoModelAthenaComps * m_athenaComps
virtual StatusCode clear() override final
ServiceHandle< IIBLParameterSvc > m_IBLParameterSvc
Gaudi::Property< bool > m_dc1Geometry
Gaudi::Property< bool > m_initialLayout
Gaudi::Property< bool > m_alignable
PublicToolHandle< IInDetServMatBuilderTool > m_serviceBuilderTool
Class to hold various Athena components.
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69
void setInitialLayout(bool flag)
void setIBL(bool flag=true)
void setServices(bool flag)
void setServicesOnLadder(bool flag)
void setDC1Geometry(bool flag)
void setDBM(bool flag=false)
void setDynamicAlignFolders(const bool useDynAlignFolders)
void setAlignable(bool flag)