ATLAS Offline Software
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>
13 #include <InDetIdentifier/PLR_ID.h>
14 #include <SGTools/DataProxy.h>
15 
16 
18  const std::string &name,
19  const IInterface *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
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();
58  manager->addFolder(m_alignmentFolderName);
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 
102 StatusCode 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 
130 {
131  //
132  // The call-back routine, which just calls the real call-back routine from the manager.
133  //
134  if (!m_detManager) {
135  ATH_MSG_WARNING("Manager does not exist");
136  return StatusCode::FAILURE;
137  }
138  if (m_alignable) {
139  return m_detManager->align(I, keys);
140  } else {
141  ATH_MSG_DEBUG("Alignment disabled. No alignments applied");
142  return StatusCode::SUCCESS;
143  }
144 }
145 
146 
148 {
150 
151  ATH_MSG_INFO("\n\nPLR Numerology:\n===============\n\nNumber of parts is " << m_moduleTree.nParts());
152 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
GeoModelExperiment::getPhysVol
GeoPhysVol * getPhysVol()
Destructor.
Definition: GeoModelExperiment.cxx:21
GeoModelXmlTool::createBaseTool
StatusCode createBaseTool()
Definition: GeoModelXmlTool.cxx:26
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
PLRDetectorTool::m_moduleTree
WaferTree m_moduleTree
Definition: PLRDetectorTool.h:38
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PLRDetectorTool::PLRDetectorTool
PLRDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PLRDetectorTool.cxx:17
PLR_ID.h
This is an Identifier helper class for the PLR subdetector. This class inherits from PicelID.
GeoModelExperiment
Definition: GeoModelExperiment.h:32
PLR_ID
This is an Identifier helper class for the PLR subdetector. This class inherits from PixelID.
Definition: PLR_ID.h:24
GeoModelXmlTool::isAvailable
bool isAvailable(const std::string &versionNode, const std::string &tableNode) const
Definition: GeoModelXmlTool.cxx:78
IOVSVC_CALLBACK_ARGS_P
#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
IGeoModelTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS)=0
PLRDetectorTool::create
virtual StatusCode create() override final
Definition: PLRDetectorTool.cxx:25
PLRDetectorTool::align
virtual StatusCode align(IOVSVC_CALLBACK_ARGS_P(I, keys)) override final
Definition: PLRDetectorTool.cxx:129
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
PLRDetectorTool::m_detManager
const InDetDD::PixelDetectorManager * m_detManager
Definition: PLRDetectorTool.h:36
GeoModelExperiment.h
GeoModelXmlTool::createTopVolume
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
Definition: GeoModelXmlTool.cxx:35
GeoModelXmlTool::m_detectorName
Gaudi::Property< std::string > m_detectorName
Definition: GeoModelXmlTool.h:42
PixelDetectorManager.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PLRDetectorTool.h
GeoModelXmlTool::getSqliteReader
GeoModelIO::ReadGeoModel * getSqliteReader() const
Definition: GeoModelXmlTool.cxx:174
GeoModelTool::manager
virtual GeoVDetectorManager * manager()
The Detector Node corresponding to this tool.
Definition: GeoModelTool.cxx:21
ATLAS_NOT_THREAD_SAFE
StatusCode PLRDetectorTool::registerCallback ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
Definition: PLRDetectorTool.cxx:102
PLRDetectorTool::m_alignable
Gaudi::Property< bool > m_alignable
Definition: PLRDetectorTool.h:40
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AlignableTransformContainer.h
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
PLRDetectorTool::doNumerology
void doNumerology()
Definition: PLRDetectorTool.cxx:147
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PLRDetectorTool::m_envelopeVolumeName
Gaudi::Property< std::string > m_envelopeVolumeName
Definition: PLRDetectorTool.h:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PLRDetectorTool::m_containingDetectorName
Gaudi::Property< std::string > m_containingDetectorName
Definition: PLRDetectorTool.h:46
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDetDD::InDetDetectorManager::align
StatusCode align(IOVSVC_CALLBACK_ARGS) const
python.ext.table_printer.table
list table
Definition: table_printer.py:81
PLRDetectorTool::clear
virtual StatusCode clear() override final
Definition: PLRDetectorTool.cxx:90
InDetDD::SiNumerology
Definition: SiNumerology.h:27
DataHandle
an iterator over instances of a given type in StoreGateSvc. It d-casts and caches locally the pointed...
Definition: DataHandle.h:42
InDetDD::PLRGmxInterface
Definition: PLRGmxInterface.h:25
PLRGmxInterface.h
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
IGeoModelTool
Definition: IGeoModelTool.h:12
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
GeoModelXmlTool
Definition: GeoModelXmlTool.h:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PLRDetectorTool::m_alignmentFolderName
Gaudi::Property< std::string > m_alignmentFolderName
Definition: PLRDetectorTool.h:42
InDetDD::SiDetectorManager
Definition: SiDetectorManager.h:60
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
BarrelEndcap::nParts
int nParts() const
Definition: WaferTree.h:69
I
#define I(x, y, z)
Definition: MD5.cxx:116
SG::DataProxy
Definition: DataProxy.h:44
node
Definition: memory_hooks-stdcmalloc.h:74
PLRDetectorTool::m_commonItems
std::unique_ptr< InDetDD::SiCommonItems > m_commonItems
Definition: PLRDetectorTool.h:37
DataProxy.h