ATLAS Offline Software
Loading...
Searching...
No Matches
PLRDetectorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PLRDetectorTool.h"
6#include "PLRGmxInterface.h"
7
9
11#include <GeoModelKernel/GeoPhysVol.h>
14#include <SGTools/DataProxy.h>
15
16
18 const std::string &name,
19 const IInterface *parent)
20 : GeoModelXmlTool(type, name, parent)
21{
22}
23
24
26{
27 // retrieve the common stuff
29
30 GeoModelExperiment *theExpt = nullptr;
31 ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
32 const PLR_ID *idHelper = nullptr;
33 ATH_CHECK(detStore()->retrieve(idHelper, "PLR_ID"));
34
35 m_commonItems = std::make_unique<InDetDD::SiCommonItems>(idHelper);
36
37 const GeoModelIO::ReadGeoModel* sqlreader = getSqliteReader();
38
39 std::string node{"InnerDetector"};
40 std::string table{"PLRXDD"};
41
42 //
43 // Check the availability (if not running from SQLite)
44 //
45 if(!sqlreader){
46 if (!isAvailable(node, table)) {
47 ATH_MSG_ERROR("No PLR geometry found. PLR can not be built.");
48 return StatusCode::FAILURE;
49 }
50 }
51 //
52 // Create the detector manager
53 //
54 // The * converts a ConstPVLink to a ref to a GeoVPhysVol
55 // The & takes the address of the GeoVPhysVol
56 GeoPhysVol *world = &*theExpt->getPhysVol();
57 auto *manager = new InDetDD::PixelDetectorManager(&*detStore(), m_detectorName, "PLR_ID");
59 // Load the geometry, create the volume,
60 // node,table are the location in the DB to look for the clob
61 // empty strings are the (optional) containing detector and envelope names
62 // allowed to pass a null sqlreader ptr - it will be used to steer the source of the geometry
64
65 const GeoVPhysVol * topVol = createTopVolume(world, gmxInterface, node, table, m_containingDetectorName, m_envelopeVolumeName,sqlreader);
66 if(topVol){
67 manager->addTreeTop(topVol);
68 manager->initNeighbours();
69 }
70 else{
71 ATH_MSG_FATAL("Could not find the Top Volume!!!");
72 return StatusCode::FAILURE;
73 }
74
75 // set the manager
77
78 ATH_CHECK(detStore()->record(m_detManager, m_detManager->getName()));
79 theExpt->addManager(m_detManager);
80
81 // Create a symLink to the SiDetectorManager base class so it can be accessed as either SiDetectorManager or
82 // PixelDetectorManager
83 const InDetDD::SiDetectorManager *siDetManager = m_detManager;
84 ATH_CHECK(detStore()->symLink(m_detManager, siDetManager));
85
86 return StatusCode::SUCCESS;
87}
88
89
91{
93 if (proxy) {
94 proxy->reset();
95 m_detManager = nullptr;
96 }
97 return StatusCode::SUCCESS;
98
99}
100
101
102StatusCode PLRDetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE ()
103{
104 //
105 // Register call-back for software alignment
106 //
107 if (m_alignable) {
108 if (detStore()->contains<AlignableTransformContainer>(m_alignmentFolderName)) {
109 ATH_MSG_DEBUG("Registering callback on AlignableTransformContainer with folder " << m_alignmentFolderName);
111 StatusCode sc = detStore()->regFcn(&IGeoModelTool::align, dynamic_cast<IGeoModelTool *>(this), atc, m_alignmentFolderName);
112 if (sc.isFailure()) {
113 ATH_MSG_ERROR("Could not register callback on AlignableTransformContainer with folder "
114 << m_alignmentFolderName);
115 return StatusCode::FAILURE;
116 }
117 } else {
118 ATH_MSG_WARNING("Unable to register callback on AlignableTransformContainer with folder "
119 << m_alignmentFolderName << ", Alignment disabled (only if no Run2 scheme is loaded)!");
120 }
121 } else {
122 ATH_MSG_INFO("Alignment disabled. No callback registered");
123 // We return failure otherwise it will try and register a GeoModelSvc callback associated with this callback.
124 }
125 return StatusCode::SUCCESS;
126}
127
128
129StatusCode PLRDetectorTool::align ATLAS_NOT_THREAD_SAFE (IOVSVC_CALLBACK_ARGS_P(I, keys))
130//Not thread safe as the call m_manager->align will invalidateAllElements it holds
131{
132 //
133 // The call-back routine, which just calls the real call-back routine from the manager.
134 //
135 if (!m_detManager) {
136 ATH_MSG_WARNING("Manager does not exist");
137 return StatusCode::FAILURE;
138 }
139 if (m_alignable) {
140 return const_cast<InDetDD::PixelDetectorManager*>(m_detManager)->align(I, keys);
141 } else {
142 ATH_MSG_DEBUG("Alignment disabled. No alignments applied");
143 return StatusCode::SUCCESS;
144 }
145}
146
147
149{
151
152 ATH_MSG_INFO("\n\nPLR Numerology:\n===============\n\nNumber of parts is " << m_moduleTree.nParts());
153}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(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
static Double_t sc
#define I(x, y, z)
Definition MD5.cxx:116
StatusCode PLRDetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
an iterator over instances of a given type in StoreGateSvc.
Definition DataHandle.h:43
GeoPhysVol * getPhysVol()
Destructor.
void addManager(const GeoVDetectorManager *)
virtual GeoVDetectorManager * manager()
StatusCode createBaseTool()
bool isAvailable(const std::string &versionNode, const std::string &tableNode) const
GeoModelXmlTool(const std::string &type, const std::string &name, const IInterface *parent)
const GeoVPhysVol * createTopVolume(GeoPhysVol *worldVol, GmxInterface &interface, const std::string &versionNode, const std::string &tableNode, const std::string &containingDetector="", const std::string &envelopeName="", const GeoModelIO::ReadGeoModel *sqlreader=nullptr) const
Gaudi::Property< std::string > m_detectorName
GeoModelIO::ReadGeoModel * getSqliteReader() const
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
Base class for Pixel and SCT Detector managers.
Class to extract numerology for Pixel and SCT.
std::unique_ptr< InDetDD::SiCommonItems > m_commonItems
PLRDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
WaferTree m_moduleTree
Gaudi::Property< std::string > m_alignmentFolderName
const InDetDD::PixelDetectorManager * m_detManager
Gaudi::Property< std::string > m_containingDetectorName
Gaudi::Property< std::string > m_envelopeVolumeName
virtual StatusCode create() override final
virtual StatusCode clear() override final
This is a Identifier helper class for the PLR subdetector.
Definition PLR_ID.h:22
Definition node.h:24
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114