ATLAS Offline Software
Loading...
Searching...
No Matches
src/PixelDetectorTool.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
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
36PixelDetectorTool::PixelDetectorTool( const std::string& type, const std::string& name, const IInterface* parent )
37 : GeoModelTool( type, name, parent )
38{
39 declareProperty("Services",m_services);
40 declareProperty("ServicesOnLadder",m_servicesOnLadder);
41 declareProperty("Alignable", m_alignable);
42 declareProperty("TweakIBLDist", m_tweakIBLDist);
43 declareProperty("DC1Geometry",m_dc1Geometry);
44 declareProperty("InitialLayout",m_initialLayout);
45 declareProperty("DevVersion", m_devVersion);
46 declareProperty("OverrideVersionName", m_overrideVersionName);
47 declareProperty("useDynamicAlignFolders", m_useDynamicAlignFolders);
48}
49
54
55
57{
58 if (!m_bcmTool.empty()) {
59 ATH_CHECK( m_bcmTool.retrieve() );
60 }
61 if (!m_blmTool.empty()) {
62 ATH_CHECK( m_blmTool.retrieve() );
63 }
64 return StatusCode::SUCCESS;
65}
66
71{
72 if (m_devVersion) ATH_MSG_WARNING("You are using a development version. There are no guarantees of stability");
73
74 // Get the detector configuration.
75 ServiceHandle<IGeoDbTagSvc> geoDbTagSvc("GeoDbTagSvc",name());
76 ATH_CHECK(geoDbTagSvc.retrieve());
77
78 ServiceHandle<IRDBAccessSvc> rdbAccessSvc(geoDbTagSvc->getParamSvcName(),name());
79 ATH_CHECK(rdbAccessSvc.retrieve());
80
81
82 GeoModelExperiment* theExpt = nullptr;
83 ATH_CHECK(detStore()->retrieve(theExpt,"ATLAS"));
84
85 GeoPhysVol *world=theExpt->getPhysVol();
86 GeoModelIO::ReadGeoModel* sqliteReader = geoDbTagSvc->getSqliteReader();
87
88 std::string detectorKey{""};
89 std::string detectorNode{""};
90 if(!sqliteReader) {
91 DecodeVersionKey decodeVersion(geoDbTagSvc.operator->(), "Pixel");
92 detectorKey = decodeVersion.tag();
93 detectorNode = decodeVersion.node();
94 if(decodeVersion.custom()) {
95 ATH_MSG_WARNING("PixelDetectorTool: Detector Information coming from a custom configuration!!" );
96 }
97 }
98
99 IRDBRecordset_ptr switchSet = rdbAccessSvc->getRecordsetPtr("PixelSwitches", detectorKey, detectorNode);
100 const IRDBRecord *switchTable = (*switchSet)[0];
101
102 std::string versionName;
103 std::string descrName="noDescr";
104
105 m_dc1Geometry = switchTable->getInt("DC1GEOMETRY");
106 m_initialLayout = switchTable->getInt("INITIALLAYOUT");
107 if (!switchTable->isFieldNull("VERSIONNAME")) {
108 versionName = switchTable->getString("VERSIONNAME");
109 }
110 if (!switchTable->isFieldNull("DESCRIPTION")) {
111 descrName = switchTable->getString("DESCRIPTION");
112 }
113 m_buildDBM = switchTable->getInt("BUILDDBM");
114
115 // Initialize switches
116 PixelSwitches switches;
117
118 switches.setServices(m_services);
120 switches.setAlignable(m_alignable);
122 switches.setDBM(m_buildDBM); //DBM flag
124
125 //JBdV
127 switches.setServices(m_services); //Overwrite there for the time being.
128
129 const PixelID * idHelper = nullptr;
130 ATH_CHECK(detStore()->retrieve(idHelper, "PixelID"));
131
132 // Retrieve the Geometry DB Interface
133 ATH_CHECK(m_geometryDBSvc.retrieve());
134
135 // Pass athena services to factory, etc
137 m_athenaComps->setDetStore(detStore().operator->());
138 m_athenaComps->setGeoDbTagSvc(&*geoDbTagSvc);
139 m_athenaComps->setRDBAccessSvc(&*rdbAccessSvc);
140 m_athenaComps->setGeometryDBSvc(&*m_geometryDBSvc);
141 m_athenaComps->setIdHelper(idHelper);
142
143 // BCM Tool.
144 if (!m_bcmTool.empty()) {
145 if (!m_bcmTool.retrieve().isFailure()) {
146 ATH_MSG_INFO("BCM_GeoModel tool retrieved: " << m_bcmTool );
147 } else {
148 ATH_MSG_INFO("Could not retrieve " << m_bcmTool << " - BCM will not be built" );
149 }
150 m_athenaComps->setBCM(&*m_bcmTool);
151 }
152 else {
153 ATH_MSG_INFO("BCM not requested." );
154 }
155
156 // BLM Tool.
157 if (!m_blmTool.empty()) {
158 if (!m_blmTool.retrieve().isFailure()) {
159 ATH_MSG_INFO("BLM_GeoModel tool retrieved: " << m_blmTool );
160 }
161 else {
162 ATH_MSG_INFO("Could not retrieve " << m_blmTool << " - BLM will not be built" );
163 }
164 m_athenaComps->setBLM(&*m_blmTool);
165 }
166 else {
167 ATH_MSG_INFO("BLM not requested." );
168 }
169
170 // Service builder tool
171 if (!m_serviceBuilderTool.empty()) {
172 if (!m_serviceBuilderTool.retrieve().isFailure()) {
173 ATH_MSG_INFO("Service builder tool retrieved: " << m_serviceBuilderTool );
174 m_athenaComps->setServiceBuilderTool(&*m_serviceBuilderTool);
175 }
176 else {
177 ATH_MSG_ERROR("Could not retrieve " << m_serviceBuilderTool << ", some services will not be built." );
178 }
179 }
180 else {
181 if (versionName == "SLHC") { // TODO
182 ATH_MSG_ERROR("Service builder tool not specified. Some services will not be built" );
183 }
184 else {
185 ATH_MSG_INFO("Service builder tool not specified." );
186 }
187 }
188
189 if(sqliteReader) {
190 // ---------------------- Build from SQLite file --------------------------
191 ATH_MSG_INFO("Building the geometry from the SQLite file");
192
193 ATH_MSG_DEBUG("Creating the Pixel ");
194 ATH_MSG_DEBUG("Pixel Geometry Options:");
195 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false"));
196 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
197 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
198 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
199 ATH_MSG_DEBUG(" VersioName = " << versionName );
200
201 if (versionName == "IBL") switches.setIBL();
202
203 PixelDetectorFactoryLite thePixelFactory(sqliteReader,m_athenaComps,switches);
204 thePixelFactory.create(world);
205 m_manager=thePixelFactory.getDetectorManager();
206 }
207 else {
208 // ---------------------- Build from GeometryDB --------------------------
209 ATH_MSG_INFO("Building Pixel Detector with Version Tag: " << detectorKey
210 << " at Node: " << detectorNode);
211
212 ATH_MSG_INFO("Building the geometry in the standard way");
213
214 // Print the version tag:
215 std::string pixelVersionTag = rdbAccessSvc->getChildTag("Pixel", detectorKey, detectorNode);
216 ATH_MSG_INFO("Pixel Version: " << pixelVersionTag );
217
218 // Check if version is empty. If so, then the Pixel cannot be built. This may or may not be intentional.
219 // We just issue an INFO message.
220 if (pixelVersionTag.empty()) {
221 ATH_MSG_INFO("No Pixel Version. Pixel Detector will not be built." );
222 return StatusCode::SUCCESS;
223 }
224
225 // Unless we are using custom pixel, the switch positions are going to
226 // come from the database:
227
228 ATH_MSG_DEBUG("PixelDetectorTool: Detector Information coming from the database and job options IGNORED." );
229 ATH_MSG_DEBUG("Keys for Pixel Switches are " << detectorKey << " " << detectorNode );
230
231 if (versionName.empty()) {
232 if (m_dc1Geometry) {
233 versionName = "DC1";
234 }
235 else {
236 versionName = "DC2";
237 }
238 }
239
240 if (!m_overrideVersionName.empty()) {
241 versionName = m_overrideVersionName;
242 ATH_MSG_INFO("Overriding version name: " << versionName );
243 }
244
245 ATH_MSG_DEBUG("Creating the Pixel " );
246 ATH_MSG_DEBUG("Pixel Geometry Options:" );
247 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false") );
248 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
249 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
250 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
251 ATH_MSG_DEBUG(" VersioName = " << versionName );
252
253 if (m_IBLParameterSvc.retrieve().isFailure()) {
254 ATH_MSG_WARNING( "Could not retrieve IBLParameterSvc");
255 }
256 else {
257 m_IBLParameterSvc->setBoolParameters(m_alignable,"alignable");
258 }
259
260 if (versionName == "IBL") switches.setIBL();
261
262 if (!m_devVersion) {
263
264 if(versionName == "DC1" || versionName == "DC2") {
265 // DC1/DC2 version
266 PixelDetectorFactoryDC2 thePixel(m_athenaComps, switches);
267 thePixel.create(world);
268 m_manager = thePixel.getDetectorManager();
269 }
270 else if (versionName == "SR1") {
271 // SR1. Same a DC3 but only 1 part (barrel, ec A or ec C) built
272 PixelDetectorFactorySR1 thePixel(m_athenaComps, switches);
273 thePixel.create(world);
274 m_manager = thePixel.getDetectorManager();
275 }
276 else {
277 // DC3, SLHC, IBL
278 PixelDetectorFactory thePixel(m_athenaComps, switches);
279 if(descrName.compare("TrackingGeometry")!=0) {
280 thePixel.create(world);
281 }
282 else {
283 ATH_MSG_INFO("Pixel - TrackingGeometry tag - no geometry built" );
284 }
285 m_manager = thePixel.getDetectorManager();
286 }
287
288 }
289 else {
290 // DEVELOPMENT VERSIONS
291 PixelDetectorFactory thePixel(m_athenaComps, switches);
292 thePixel.create(world);
293 m_manager = thePixel.getDetectorManager();
294 }
295 }
296
297 // Register the manager to the Det Store
298 ATH_CHECK(detStore()->record(m_manager, m_manager->getName()));
299 // Add the manager to the experiment
300 theExpt->addManager(m_manager);
301
302 // Symlink the manager
303 const SiDetectorManager * siDetManager = m_manager;
304 ATH_CHECK(detStore()->symLink(m_manager, siDetManager));
305
306 return StatusCode::SUCCESS;
307}
308
310{
311 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<InDetDD::PixelDetectorManager>::ID(),m_manager->getName());
312 if(proxy) {
313 proxy->reset();
314 m_manager = nullptr;
315 }
316 return StatusCode::SUCCESS;
317}
318
319StatusCode
320PixelDetectorTool::align ATLAS_NOT_THREAD_SAFE(IOVSVC_CALLBACK_ARGS_P(I,keys))
321//Not thread safe as the call m_manager->align will invalidateAllElements it holds
322{
323 if (!m_manager) {
324 ATH_MSG_WARNING("Manager does not exist" );
325 return StatusCode::FAILURE;
326 }
327 if (m_alignable) {
328 return const_cast<InDetDD::PixelDetectorManager*>(m_manager)->align(I,keys);
329 } else{
330 ATH_MSG_DEBUG("Alignment disabled. No alignments applied" );
331 return StatusCode::SUCCESS;
332 }
333}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
#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
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 I(x, y, z)
Definition MD5.cxx:116
Define macros for attributes used to control the static checker.
#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...
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: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 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
ToolHandle< IGeoSubDetTool > m_bcmTool
ToolHandle< IGeoSubDetTool > m_blmTool
const InDetDD::PixelDetectorManager * m_manager
virtual StatusCode initialize() override final
std::string m_overrideVersionName
virtual ~PixelDetectorTool() override final
ServiceHandle< IGeometryDBSvc > m_geometryDBSvc
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
PixelDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
PublicToolHandle< IInDetServMatBuilderTool > m_serviceBuilderTool
Class to hold various Athena components.
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
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)