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
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 // Pass athena services to factory, etc
134 m_athenaComps->setDetStore(detStore().operator->());
135 m_athenaComps->setGeoDbTagSvc(&*geoDbTagSvc);
136 m_athenaComps->setRDBAccessSvc(&*rdbAccessSvc);
137 m_athenaComps->setIdHelper(idHelper);
138
139 // BCM Tool.
140 if (!m_bcmTool.empty()) {
141 m_athenaComps->setBCM(m_bcmTool.get());
142 }
143 else {
144 ATH_MSG_INFO("BCM not requested." );
145 }
146
147 // BLM Tool.
148 if (!m_blmTool.empty()) {
149 m_athenaComps->setBLM(m_blmTool.get());
150 }
151 else {
152 ATH_MSG_INFO("BLM not requested." );
153 }
154
155 // Service builder tool
156 if (!m_serviceBuilderTool.empty()) {
157 if (!m_serviceBuilderTool.retrieve().isFailure()) {
158 ATH_MSG_INFO("Service builder tool retrieved: " << m_serviceBuilderTool );
159 m_athenaComps->setServiceBuilderTool(&*m_serviceBuilderTool);
160 }
161 else {
162 ATH_MSG_ERROR("Could not retrieve " << m_serviceBuilderTool << ", some services will not be built." );
163 }
164 }
165 else {
166 if (versionName == "SLHC") { // TODO
167 ATH_MSG_ERROR("Service builder tool not specified. Some services will not be built" );
168 }
169 else {
170 ATH_MSG_INFO("Service builder tool not specified." );
171 }
172 }
173
174 if(sqliteReader) {
175 // ---------------------- Build from SQLite file --------------------------
176 ATH_MSG_INFO("Building the geometry from the SQLite file");
177
178 ATH_MSG_DEBUG("Creating the Pixel ");
179 ATH_MSG_DEBUG("Pixel Geometry Options:");
180 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false"));
181 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
182 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
183 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
184 ATH_MSG_DEBUG(" VersioName = " << versionName );
185
186 if (versionName == "IBL") switches.setIBL();
187
188 PixelDetectorFactoryLite thePixelFactory(sqliteReader,m_athenaComps,switches);
189 thePixelFactory.create(world);
190 m_manager=thePixelFactory.getDetectorManager();
191 }
192 else {
193 // ---------------------- Build from GeometryDB --------------------------
194 ATH_MSG_INFO("Building Pixel Detector with Version Tag: " << detectorKey
195 << " at Node: " << detectorNode);
196
197 ATH_MSG_INFO("Building the geometry in the standard way");
198
199 // Print the version tag:
200 std::string pixelVersionTag = rdbAccessSvc->getChildTag("Pixel", detectorKey, detectorNode);
201 ATH_MSG_INFO("Pixel Version: " << pixelVersionTag );
202
203 // Check if version is empty. If so, then the Pixel cannot be built. This may or may not be intentional.
204 // We just issue an INFO message.
205 if (pixelVersionTag.empty()) {
206 ATH_MSG_INFO("No Pixel Version. Pixel Detector will not be built." );
207 return StatusCode::SUCCESS;
208 }
209
210 // Unless we are using custom pixel, the switch positions are going to
211 // come from the database:
212
213 ATH_MSG_DEBUG("PixelDetectorTool: Detector Information coming from the database and job options IGNORED." );
214 ATH_MSG_DEBUG("Keys for Pixel Switches are " << detectorKey << " " << detectorNode );
215
216 if (versionName.empty()) {
217 if (m_dc1Geometry) {
218 versionName = "DC1";
219 }
220 else {
221 versionName = "DC2";
222 }
223 }
224
225 if (!m_overrideVersionName.empty()) {
226 versionName = m_overrideVersionName;
227 ATH_MSG_INFO("Overriding version name: " << versionName );
228 }
229
230 ATH_MSG_DEBUG("Creating the Pixel " );
231 ATH_MSG_DEBUG("Pixel Geometry Options:" );
232 ATH_MSG_DEBUG(" Services = " << (m_services ? "true" : "false") );
233 ATH_MSG_DEBUG(" Alignable = " << (m_alignable ? "true" : "false"));
234 ATH_MSG_DEBUG(" DC1Geometry = " << (m_dc1Geometry ? "true" : "false"));
235 ATH_MSG_DEBUG(" InitialLayout = " << (m_initialLayout ? "true" : "false"));
236 ATH_MSG_DEBUG(" VersioName = " << versionName );
237
238 if (m_IBLParameterSvc.retrieve().isFailure()) {
239 ATH_MSG_WARNING( "Could not retrieve IBLParameterSvc");
240 }
241 else {
242 m_IBLParameterSvc->setBoolParameters(m_alignable,"alignable");
243 }
244
245 if (versionName == "IBL") switches.setIBL();
246
247 if (!m_devVersion) {
248
249 if(versionName == "DC1" || versionName == "DC2") {
250 // DC1/DC2 version
251 PixelDetectorFactoryDC2 thePixel(m_athenaComps, switches);
252 thePixel.create(world);
253 m_manager = thePixel.getDetectorManager();
254 }
255 else if (versionName == "SR1") {
256 // SR1. Same a DC3 but only 1 part (barrel, ec A or ec C) built
257 PixelDetectorFactorySR1 thePixel(m_athenaComps, switches);
258 thePixel.create(world);
259 m_manager = thePixel.getDetectorManager();
260 }
261 else {
262 // DC3, SLHC, IBL
263 PixelDetectorFactory thePixel(m_athenaComps, switches);
264 if(descrName.compare("TrackingGeometry")!=0) {
265 thePixel.create(world);
266 }
267 else {
268 ATH_MSG_INFO("Pixel - TrackingGeometry tag - no geometry built" );
269 }
270 m_manager = thePixel.getDetectorManager();
271 }
272
273 }
274 else {
275 // DEVELOPMENT VERSIONS
276 PixelDetectorFactory thePixel(m_athenaComps, switches);
277 thePixel.create(world);
278 m_manager = thePixel.getDetectorManager();
279 }
280 }
281
282 // Register the manager to the Det Store
283 ATH_CHECK(detStore()->record(m_manager, m_manager->getName()));
284 // Add the manager to the experiment
285 theExpt->addManager(m_manager);
286
287 // Symlink the manager
288 const SiDetectorManager * siDetManager = m_manager;
289 ATH_CHECK(detStore()->symLink(m_manager, siDetManager));
290
291 return StatusCode::SUCCESS;
292}
293
295{
296 SG::DataProxy* proxy = detStore()->proxy(ClassID_traits<InDetDD::PixelDetectorManager>::ID(),m_manager->getName());
297 if(proxy) {
298 proxy->reset();
299 m_manager = nullptr;
300 }
301 return StatusCode::SUCCESS;
302}
303
304StatusCode
306//Not thread safe as the call m_manager->align will invalidateAllElements it holds
307{
308 if (!m_manager) {
309 ATH_MSG_WARNING("Manager does not exist" );
310 return StatusCode::FAILURE;
311 }
312 if (m_alignable) {
313 return const_cast<InDetDD::PixelDetectorManager*>(m_manager)->align();
314 } else{
315 ATH_MSG_DEBUG("Alignment disabled. No alignments applied" );
316 return StatusCode::SUCCESS;
317 }
318}
#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...
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: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
virtual StatusCode align() override
const InDetDD::PixelDetectorManager * m_manager
virtual StatusCode initialize() override final
std::string m_overrideVersionName
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
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: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)