ATLAS Offline Software
ml/src/PixelDetectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
10 
12 #include <GeoModelKernel/GeoPhysVol.h>
15 #include <SGTools/DataProxy.h>
16 #include <StoreGate/StoreGateSvc.h>
17 
18 
19 namespace ITk
20 {
21 
23  const std::string &name,
24  const IInterface *parent)
26 {
27 }
28 
29 
31 {
32  // retrieve the common stuff
34 
35  GeoModelExperiment *theExpt = nullptr;
36  ATH_CHECK(detStore()->retrieve(theExpt, "ATLAS"));
37  const PixelID *idHelper = nullptr;
38  ATH_CHECK(detStore()->retrieve(idHelper, "PixelID"));
39 
40  m_commonItems = std::make_unique<InDetDD::SiCommonItems>(idHelper);
41 
42  GeoModelIO::ReadGeoModel* sqlreader = getSqliteReader();
43 
44  // If we are not taking the geo from sqlite, check the availability of tables
45  // (or that we have a local geometry)
46  std::string node{"Pixel"};
47  std::string table{"PIXXDD"};
48 
49  if(!sqlreader){
50  if (!isAvailable(node, table)) {
51  ATH_MSG_INFO("Trying new " << m_detectorName.value() << " database location.");
52  node = "InnerDetector";
53  table = "PixelXDD";
54  if (!isAvailable(node, table)) {
55  ATH_MSG_ERROR("No ITk Pixel geometry found. ITk Pixel can not be built.");
56  return StatusCode::FAILURE;
57  }
58  }
59  }
60  //
61  // Create the detector manager
62  //
63  // The * converts a ConstPVLink to a ref to a GeoVPhysVol
64  // The & takes the address of the GeoVPhysVol
65  GeoPhysVol *world = &*theExpt->getPhysVol();
66  auto *manager = new InDetDD::PixelDetectorManager(&*detStore(), m_detectorName, "PixelID");
67  const std::string topFolder(m_alignmentFolderName);
68  manager->addFolder(topFolder);
69  if (m_alignable) {
71  manager->addAlignFolderType(alignFolderType);
72  manager->addChannel(topFolder +"/ID", 2, InDetDD::global);
73  manager->addChannel(topFolder +"/PIX", 1, InDetDD::global);
74  manager->addChannel(topFolder +"/PIXB1", 0, InDetDD::local);
75  manager->addChannel(topFolder +"/PIXB2", 0, InDetDD::local);
76  manager->addChannel(topFolder +"/PIXB3", 0, InDetDD::local);
77  manager->addChannel(topFolder +"/PIXB4", 0, InDetDD::local);
78  manager->addChannel(topFolder +"/PIXB5", 0, InDetDD::local);
79  manager->addChannel(topFolder +"/PIXEA1", 0, InDetDD::local);
80  manager->addChannel(topFolder +"/PIXEA2", 0, InDetDD::local);
81  manager->addChannel(topFolder +"/PIXEA3", 0, InDetDD::local);
82  manager->addChannel(topFolder +"/PIXEA4", 0, InDetDD::local);
83  manager->addChannel(topFolder +"/PIXEA5", 0, InDetDD::local);
84  manager->addChannel(topFolder +"/PIXEA6", 0, InDetDD::local);
85  manager->addChannel(topFolder +"/PIXEA7", 0, InDetDD::local);
86  manager->addChannel(topFolder +"/PIXEA8", 0, InDetDD::local);
87  manager->addChannel(topFolder +"/PIXEA9", 0, InDetDD::local);
88  manager->addChannel(topFolder +"/PIXEC1", 0, InDetDD::local);
89  manager->addChannel(topFolder +"/PIXEC2", 0, InDetDD::local);
90  manager->addChannel(topFolder +"/PIXEC3", 0, InDetDD::local);
91  manager->addChannel(topFolder +"/PIXEC4", 0, InDetDD::local);
92  manager->addChannel(topFolder +"/PIXEC5", 0, InDetDD::local);
93  manager->addChannel(topFolder +"/PIXEC6", 0, InDetDD::local);
94  manager->addChannel(topFolder +"/PIXEC7", 0, InDetDD::local);
95  manager->addChannel(topFolder +"/PIXEC8", 0, InDetDD::local);
96  manager->addChannel(topFolder +"/PIXEC9", 0, InDetDD::local);
97  }
99 
100  // Load the geometry, create the volume,
101  // node,table are the location in the DB to look for the clob
102  // empty strings are the (optional) containing detector and envelope names
103  // allowed to pass a null sqlreader ptr - it will be used to steer the source of the geometry
104  const GeoVPhysVol* topVolume = createTopVolume(world, gmxInterface, node, table,"","",sqlreader);
105  if(sqlreader){
106  ATH_MSG_INFO("Building Pixel Readout Geometry from SQLite using "<<m_geoDbTagSvc->getParamSvcName());
107  gmxInterface.buildReadoutGeometryFromSqlite(m_sqliteReadSvc.operator->(),sqlreader);
108  }
109  if (topVolume) { //see that a valid pointer is returned
110  manager->addTreeTop(topVolume);
112  manager->initNeighbours();
113  } else {
114  ATH_MSG_FATAL("Could not find the Top Volume!!!");
115  return StatusCode::FAILURE;
116  }
117 
118  // set the manager
120 
121  ATH_CHECK(detStore()->record(m_detManager, m_detManager->getName()));
122  theExpt->addManager(m_detManager);
123 
124  // Create a symLink to the SiDetectorManager base class so it can be accessed as either SiDetectorManager or
125  // PixelDetectorManager
126  const InDetDD::SiDetectorManager *siDetManager = m_detManager;
127  ATH_CHECK(detStore()->symLink(m_detManager, siDetManager));
128 
129  return StatusCode::SUCCESS;
130 }
131 
132 
134 {
136  if (proxy) {
137  proxy->reset();
138  m_detManager = nullptr;
139  }
140  return StatusCode::SUCCESS;
141 }
142 
144 {
145  ATH_MSG_INFO( "\n\nPixel Numerology:\n===============\n\nNumber of parts is " << m_moduleTree.nParts() );
147 
148  bool barrelDone = false;
149  for (int b = -1; b <= 1; ++b) {
150  if (m_moduleTree.count(b)) {
151  msg(MSG::INFO) << " Found barrel with index " << b << std::endl;
152  n.addBarrel(b);
153  if (!barrelDone) {
154  n.setNumLayers(m_moduleTree[b].nLayers());
155  msg(MSG::INFO) << " Number of barrel layers = " << n.numLayers() << std::endl;
156  for (LayerDisk::iterator l = m_moduleTree[b].begin(); l != m_moduleTree[b].end(); ++l) {
157  n.setNumEtaModulesForLayer(l->first, l->second.nEtaModules());
158  // All staves within a layer are assumed identical, so we can just look at the first eta
159  n.setNumPhiModulesForLayer(l->first, l->second.begin()->second.nPhiModules());
160  msg(MSG::INFO) << " layer = " << l->first << " has " << n.numEtaModulesForLayer(l->first) <<
161  " etaModules each with " << n.numPhiModulesForLayer(l->first) << " phi modules" << std::endl;
162  }
163  barrelDone = true;
164  }
165  }
166 
167  }
168 
169  bool endcapDone = false;
170  for (int ec = -2; ec <= 2; ec += 4) {
171  if (m_moduleTree.count(ec)) {
172  msg(MSG::INFO) << " Found endcap with index " << ec << std::endl;
173  n.addEndcap(ec);
174  if (!endcapDone) {
175  n.setNumDiskLayers(m_moduleTree[ec].nLayers());
176  msg(MSG::INFO) << " Number of endcap layers = " << n.numDiskLayers() << std::endl;
177  for (LayerDisk::iterator l = m_moduleTree[ec].begin(); l != m_moduleTree[ec].end(); ++l) {
178  n.setNumDisksForLayer(l->first, l->second.nEtaModules());
179  msg(MSG::INFO) << " Layer " << l->first << " has " << n.numDisksForLayer(l->first) << " disks" << std::endl;
180  for (EtaModule::iterator eta = l->second.begin(); eta != l->second.end(); ++eta) {
181  n.setNumPhiModulesForLayerDisk(l->first, eta->first, eta->second.nPhiModules());
182  msg(MSG::DEBUG) << " Disk " << eta->first << " has " <<
183  n.numPhiModulesForLayerDisk(l->first, eta->first) << " phi modules" << std::endl;
184  }
185  }
186  endcapDone = true;
187  }
188  }
189  }
190 
191  msg(MSG::INFO) << endmsg;
192 
193  int totalWafers = 0;
194  for (BarrelEndcap::iterator bec = m_moduleTree.begin(); bec != m_moduleTree.end(); ++bec) {
195  for (LayerDisk::iterator ld = bec->second.begin(); ld != bec->second.end(); ++ld) {
196  for (EtaModule::iterator eta = ld->second.begin(); eta != ld->second.end(); ++eta) {
197  for (PhiModule::iterator phi = eta->second.begin(); phi != eta->second.end(); ++phi) {
198  for (Side::iterator side =phi->second.begin(); side != phi->second.end(); ++side) {
199  totalWafers++;
200  }
201  }
202  }
203  }
204  }
205  ATH_MSG_INFO("Total number of wafers added is " << totalWafers);
206  const PixelID *pixelIdHelper = dynamic_cast<const PixelID *> (m_commonItems->getIdHelper());
207  ATH_MSG_INFO("Total number of wafer identifiers is " << pixelIdHelper->wafer_hash_max());
208 
209  // Used in digitization to create one vector big enough to hold all pixels
210  n.setMaxNumEtaCells(1);
211  for (int d = 0; d < manager->numDesigns(); ++d) {
212  n.setMaxNumPhiCells(manager->getPixelDesign(d)->rows());
213  n.setMaxNumEtaCells(manager->getPixelDesign(d)->columns());
214  }
215  ATH_MSG_INFO("Max. eta cells is " << n.maxNumEtaCells());
216  ATH_MSG_INFO("Max. phi cells is " << n.maxNumPhiCells());
217 
218  manager->numerology() = n;
219 
220  ATH_MSG_INFO("End of numerology\n");
221 }
222 
223 } // namespace ITk
224 
ITk::PixelDetectorTool::clear
virtual StatusCode clear() override final
Definition: ml/src/PixelDetectorTool.cxx:133
ITk::PixelDetectorTool::PixelDetectorTool
PixelDetectorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ml/src/PixelDetectorTool.cxx:22
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
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
InDetDD::ITk::PixelGmxInterface
Definition: PixelGmxInterface.h:31
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
hist_file_dump.d
d
Definition: hist_file_dump.py:137
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
GeoModelExperiment
Definition: GeoModelExperiment.h:32
PixelGmxInterface.h
GeoModelXmlTool::isAvailable
bool isAvailable(const std::string &versionNode, const std::string &tableNode) const
Definition: GeoModelXmlTool.cxx:78
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
InDetDD::static_run1
@ static_run1
Definition: InDetDD_Defs.h:19
InDetDD::global
@ global
Definition: InDetDD_Defs.h:16
TRT::Hit::side
@ side
Definition: HitInfo.h:83
ITk::PixelDetectorTool::doNumerology
void doNumerology(InDetDD::PixelDetectorManager *manager)
Definition: ml/src/PixelDetectorTool.cxx:143
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
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
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AlignableTransformContainer.h
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
InDetDD::ITk::PixelGmxInterface::buildReadoutGeometryFromSqlite
void buildReadoutGeometryFromSqlite(IRDBAccessSvc *rdbAccessSvc, GeoModelIO::ReadGeoModel *sqlreader)
Definition: PixelGmxInterface.cxx:448
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITk::PixelDetectorTool::m_detManager
const InDetDD::PixelDetectorManager * m_detManager
Definition: ml/PixelGeoModelXml/PixelDetectorTool.h:38
InDetDD::local
@ local
Definition: InDetDD_Defs.h:16
ITk::PixelDetectorTool::m_commonItems
std::unique_ptr< InDetDD::SiCommonItems > m_commonItems
Definition: ml/PixelGeoModelXml/PixelDetectorTool.h:39
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
ITk
Definition: ITkPixelOfflineCalibCondAlg.cxx:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
ITk::PixelDetectorTool::m_alignmentFolderName
Gaudi::Property< std::string > m_alignmentFolderName
Definition: ml/PixelGeoModelXml/PixelDetectorTool.h:44
python.ext.table_printer.table
list table
Definition: table_printer.py:81
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
InDetDD::SiNumerology
Definition: SiNumerology.h:27
DecodeVersionKey.h
GeoModelExperiment::addManager
void addManager(const GeoVDetectorManager *)
Definition: GeoModelExperiment.cxx:40
ITk::PixelDetectorTool::m_alignable
Gaudi::Property< bool > m_alignable
Definition: ml/PixelGeoModelXml/PixelDetectorTool.h:42
GeoModelXmlTool
Definition: GeoModelXmlTool.h:21
PixelModuleDesign.h
GeoModelXmlTool::m_geoDbTagSvc
ServiceHandle< IGeoDbTagSvc > m_geoDbTagSvc
Definition: GeoModelXmlTool.h:45
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ITk::PixelDetectorTool::create
virtual StatusCode create() override final
Definition: ml/src/PixelDetectorTool.cxx:30
GeoModelXmlTool::m_sqliteReadSvc
ServiceHandle< IRDBAccessSvc > m_sqliteReadSvc
Definition: GeoModelXmlTool.h:44
DEBUG
#define DEBUG
Definition: page_access.h:11
InDetDD::SiDetectorManager
Definition: SiDetectorManager.h:60
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
PixelDetectorTool.h
BarrelEndcap::nParts
int nParts() const
Definition: WaferTree.h:69
PixelID
Definition: PixelID.h:67
SG::DataProxy
Definition: DataProxy.h:45
StoreGateSvc.h
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
InDetDD::AlignFolderType
AlignFolderType
Definition: InDetDD_Defs.h:19
geometry_dat_to_json.ld
ld
Definition: geometry_dat_to_json.py:32
node
Definition: memory_hooks-stdcmalloc.h:74
ITk::PixelDetectorTool::m_moduleTree
WaferTree m_moduleTree
Definition: ml/PixelGeoModelXml/PixelDetectorTool.h:40
DataProxy.h