ATLAS Offline Software
Loading...
Searching...
No Matches
PixelDetectorFactoryLite.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-203 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "PixelSwitches.h"
8
9// Envelope, as a starting point of the geometry
10#include "GeoPixelEnvelope.h"
11
12// GeoModel includes
13#include "GeoModelKernel/GeoNameTag.h"
14#include "GeoModelKernel/GeoPhysVol.h"
15#include "GeoModelKernel/GeoAlignableTransform.h"
16#include "GeoModelRead/ReadGeoModel.h"
17#include "GaudiKernel/SystemOfUnits.h"
18
19// InDetReadoutGeometry
24
25#include "DBPixelGeoManager.h"
27
29
31
32
35
36PixelDetectorFactoryLite::PixelDetectorFactoryLite(GeoModelIO::ReadGeoModel *sqliteReader
37 , PixelGeoModelAthenaComps * athenaComps
38 , const PixelSwitches & switches)
39 : InDetDD::DetectorFactoryBase(athenaComps)
40 , m_sqliteReader (sqliteReader)
41{
42 // Create the detector manager
44
45 // Create the geometry manager.
46 m_geometryManager = std::make_unique<DBPixelGeoManager>(athenaComps);
47
48 // Pass the switches
49 m_geometryManager->SetServices(switches.services());
50 m_geometryManager->SetServicesOnLadder(switches.servicesOnLadder());
51 m_geometryManager->SetDC1Geometry(switches.dc1Geometry());
52 m_geometryManager->SetAlignable(switches.alignable());
53 m_geometryManager->SetInitialLayout(switches.initialLayout());
54 m_geometryManager->SetIBL(switches.ibl());
55
56 // get switch for DBM
57 m_geometryManager->SetDBMFlag(switches.dbm());
58 msg(MSG::INFO) << "DBM switch = SetDBMFlag: "<< m_geometryManager->dbm() << endmsg;
59
60 // Create SiCommonItems ans store it in geometry manager.
61 // These are items that are shared by all elements
62 std::unique_ptr<SiCommonItems> commonItems{std::make_unique<SiCommonItems>(athenaComps->getIdHelper())};
63 m_geometryManager->setCommonItems(commonItems.get());
64
65 // Add SiCommonItems to PixelDetectorManager to hold and delete it.
66 m_detectorManager->setCommonItems(std::move(commonItems));
67
68 // Determine if initial layer and tag from the id dict are consistent
69 bool initialLayoutIdDict = (m_detectorManager->tag() == "initial_layout");
70 if (m_geometryManager->InitialLayout() != initialLayoutIdDict ) {
71 msg(MSG::WARNING) << "IdDict tag is \"" << m_detectorManager->tag()
72 << "\" which is inconsistent with the layout choosen!" << endmsg;
73 }
74
75 //
76 // Set Version information
77 //
78 std::string versionTag = m_geometryManager->versionTag();
79 std::string versionName = m_geometryManager->versionName();
80 std::string layout = m_geometryManager->versionLayout();
81 std::string description = m_geometryManager->versionDescription() ;
82 int versionMajorNumber = 5;
83 int versionMinorNumber = 1;
84 int versionPatchNumber = 0;
85
86 if (m_geometryManager->InitialLayout()) {
87 layout = "Initial";
88 }
89
90 InDetDD::Version version(versionTag,
91 versionName,
92 layout,
94 versionMajorNumber,
95 versionMinorNumber,
96 versionPatchNumber);
97 m_detectorManager->setVersion(version);
98
100
101 if (sqliteReader) {
102 m_mapFPV = std::shared_ptr<std::map<std::string, GeoFullPhysVol*>> (new std::map<std::string, GeoFullPhysVol*> (m_sqliteReader->getPublishedNodes<std::string, GeoFullPhysVol*>("Pixel")));
103 m_mapAX = std::shared_ptr< std::map<std::string, GeoAlignableTransform*>> (new std::map<std::string, GeoAlignableTransform *> (m_sqliteReader->getPublishedNodes<std::string, GeoAlignableTransform*>("Pixel")));
104 }
105
106}
107
108
109
110//## Other Operations (implementation)
112{
113 msg(MSG::INFO) << "Building Pixel Detector" << endmsg;
114 msg(MSG::INFO) << " " << m_detectorManager->getVersion().fullDescription() << endmsg;
115
116 // Printout the parameters that are different in DC1 and DC2.
117 m_geometryManager->SetCurrentLD(0);
118 m_geometryManager->SetBarrel();
119 msg(MSG::DEBUG) << " B-Layer basic eta pitch: " << m_geometryManager->DesignPitchZ()/Gaudi::Units::micrometer << "um" << endmsg;
120 msg(MSG::DEBUG) << " B-Layer sensor thickness: " << m_geometryManager->PixelBoardThickness()/Gaudi::Units::micrometer << "um" << endmsg;
121
122
123 // The top level volume
124 GeoFullPhysVol *pPixelEnvelopeVol = (*m_mapFPV)["Pixel_Envelope"];
125
126 // Create the Lite Pixel Envelope...
128 pe.Build() ;
129
130 GeoAlignableTransform * transform = (*m_mapAX)["Pixel_Envelope"];
131
132 // Store alignable transform
133 Identifier id = m_geometryManager->getIdHelper()->wafer_id(0,0,0,0);
134 m_detectorManager->addAlignableTransform(2, id, transform, pPixelEnvelopeVol);
135
136 // Add this to the list of top level physical volumes:
137 m_detectorManager->addTreeTop(pPixelEnvelopeVol);
138
139
140 // Initialize the neighbours
141 m_detectorManager->initNeighbours();
142
143 // Set maximum rows/columns in numerology
144 for (int iDesign = 0; iDesign < m_detectorManager->numDesigns(); iDesign++) {
145 m_detectorManager->numerology().setMaxNumPhiCells(m_detectorManager->getPixelDesign(iDesign)->rows());
146 m_detectorManager->numerology().setMaxNumEtaCells(m_detectorManager->getPixelDesign(iDesign)->columns());
147 }
148
149 // Register the callbacks and keys and the level corresponding to the key.
150 if (m_geometryManager->Alignable()) {
151
153 m_detectorManager->addAlignFolderType(InDetDD::static_run1);
154 m_detectorManager->addFolder("/Indet/Align");
155 m_detectorManager->addChannel("/Indet/Align/ID", 2, InDetDD::global);
156 m_detectorManager->addChannel("/Indet/Align/PIX", 1, InDetDD::global);
157 m_detectorManager->addChannel("/Indet/Align/PIXB1", 0, InDetDD::local);
158 m_detectorManager->addChannel("/Indet/Align/PIXB2", 0, InDetDD::local);
159 m_detectorManager->addChannel("/Indet/Align/PIXB3", 0, InDetDD::local);
160 m_detectorManager->addChannel("/Indet/Align/PIXB4", 0, InDetDD::local);
161 m_detectorManager->addChannel("/Indet/Align/PIXEA1", 0, InDetDD::local);
162 m_detectorManager->addChannel("/Indet/Align/PIXEA2", 0, InDetDD::local);
163 m_detectorManager->addChannel("/Indet/Align/PIXEA3", 0, InDetDD::local);
164 m_detectorManager->addChannel("/Indet/Align/PIXEC1", 0, InDetDD::local);
165 m_detectorManager->addChannel("/Indet/Align/PIXEC2", 0, InDetDD::local);
166 m_detectorManager->addChannel("/Indet/Align/PIXEC3", 0, InDetDD::local);
167 }
168
169 else {
171 m_detectorManager->addGlobalFolder("/Indet/AlignL1/ID");
172 m_detectorManager->addGlobalFolder("/Indet/AlignL2/PIX");
173 m_detectorManager->addChannel("/Indet/AlignL1/ID", 2, InDetDD::global);
174 m_detectorManager->addChannel("/Indet/AlignL2/PIX", 1, InDetDD::global);
175 m_detectorManager->addFolder("/Indet/AlignL3");
176 m_detectorManager->addChannel("/Indet/AlignL3/PIXB1", 0, InDetDD::local);
177 m_detectorManager->addChannel("/Indet/AlignL3/PIXB2", 0, InDetDD::local);
178 m_detectorManager->addChannel("/Indet/AlignL3/PIXB3", 0, InDetDD::local);
179 m_detectorManager->addChannel("/Indet/AlignL3/PIXB4", 0, InDetDD::local);
180 m_detectorManager->addChannel("/Indet/AlignL3/PIXEA1", 0, InDetDD::local);
181 m_detectorManager->addChannel("/Indet/AlignL3/PIXEA2", 0, InDetDD::local);
182 m_detectorManager->addChannel("/Indet/AlignL3/PIXEA3", 0, InDetDD::local);
183 m_detectorManager->addChannel("/Indet/AlignL3/PIXEC1", 0, InDetDD::local);
184 m_detectorManager->addChannel("/Indet/AlignL3/PIXEC2", 0, InDetDD::local);
185 m_detectorManager->addChannel("/Indet/AlignL3/PIXEC3", 0, InDetDD::local);
186 }
187
188 // This is the new LB-IOV sensitive IBL bowing DB
189 m_detectorManager->addSpecialFolder("/Indet/IBLDist");
190
191 }
192
193 // Check that there are no missing elements.
194 // Bypass checks for standard ATLAS.
195 if (m_geometryManager->ibl()) {
196 doChecks();
197 }
198}
199
201{
202 const PixelID * idHelper = m_geometryManager->athenaComps()->getIdHelper();
203 const PixelDetectorManager * manager = m_detectorManager;
204
205 msg(MSG::INFO) << "Doing consistency checks." << endmsg;
206
207 unsigned int maxHash = idHelper->wafer_hash_max();
208
209 int count = 0;
210 int missingCount = 0;
212 for (iter = manager->getDetectorElementBegin(); iter != manager->getDetectorElementEnd(); ++iter){
213 count++;
214 const InDetDD::SiDetectorElement * element = *iter;
215 if (!element) {
216 msg(MSG::WARNING) << "MISSING ELEMENT!!!!!!!!!!! - Element # " << count-1 << endmsg;
217 missingCount++;
218 }
219 }
220
221 if (missingCount) {
222 msg(MSG::ERROR) << "There are missing elements in element array." << endmsg;
223 msg(MSG::INFO) << "Number of elements: " << count << endmsg;
224 msg(MSG::INFO) << "Number missing: " << missingCount << endmsg;
225 }
226
227
228 // ***********************************************************************************
229 // Loop over modules
230 // ***********************************************************************************
231
232 // Barrel
233 int barrelCount = 0;
234 int barrelCountError = 0;
235 for (int iBarrelIndex = 0; iBarrelIndex < manager->numerology().numBarrels(); iBarrelIndex++)
236 {
237 int iBarrel = manager->numerology().barrelId(iBarrelIndex);
238 for (int iLayer = 0; iLayer < manager->numerology().numLayers(); iLayer++) {
239
240 // TEMPORARY FIX
241 // Temporary fix for IBL. Numerology class needs to be fixed.
242 m_geometryManager->SetCurrentLD(iLayer);
243 int etaCorrection = 0;
244 if (!m_geometryManager->allowSkipEtaZero() && manager->numerology().skipEtaZeroForLayer(iLayer)) {
245 etaCorrection = 1;
246 }
247 // END TEMPORARY FIX
248
249 if (manager->numerology().useLayer(iLayer)) {
250 for (int iPhi = 0; iPhi < manager->numerology().numPhiModulesForLayer(iLayer); iPhi++)
251 {
252 for (int iEta = manager->numerology().beginEtaModuleForLayer(iLayer);
253 iEta < manager->numerology().endEtaModuleForLayer(iLayer) - etaCorrection;
254 iEta++)
255 {
256 if (!etaCorrection && !iEta && manager->numerology().skipEtaZeroForLayer(iLayer)) continue; // TEMPORARY FIX
257 Identifier id = idHelper->wafer_id(iBarrel,iLayer,iPhi,iEta);
258 const InDetDD::SiDetectorElement * element = manager->getDetectorElement(id);
259 barrelCount++;
260 std::stringstream ostr;
261 ostr << "[2.1 . " << iBarrel << " . " << iLayer << " . " << iPhi << " . " << iEta << " . 0]";
262 if (!element) {
263 barrelCountError++;
264 msg(MSG::WARNING) << " No element found for id: " << ostr.str() << " " << idHelper->show_to_string(id) << endmsg;
265
266 }
267
268 } // iEta
269
270 } //iPhi
271
272 }
273
274 } //iLayer
275
276 } // Barrel
277
278
279 // Endcap
280 int endcapCount = 0;
281 int endcapCountError = 0;
282 for (int iEndcapIndex = 0; iEndcapIndex < manager->numerology().numEndcaps(); iEndcapIndex++) {
283 int iEndcap = manager->numerology().endcapId(iEndcapIndex);
284 for (int iDisk = 0; iDisk < manager->numerology().numDisks(); iDisk++) {
285 if (manager->numerology().useDisk(iDisk)) {
286 for (int iEta = 0; iEta < manager->numerology().numRingsForDisk(iDisk); iEta++) {
287 for (int iPhi = 0; iPhi < manager->numerology().numPhiModulesForDiskRing(iDisk,iEta); iPhi++) {
288 Identifier id = idHelper->wafer_id(iEndcap,iDisk,iPhi,iEta);
289 const InDetDD::SiDetectorElement * element = manager->getDetectorElement(id);
290 endcapCount++;
291 std::stringstream ostr;
292 ostr << "[2.1." << iEndcap << "." << iDisk << "." << iPhi << "." << iEta << ".0]";
293 if (!element) {
294 endcapCountError++;
295 msg(MSG::WARNING) << " No element found for id: " << ostr.str() << " " << idHelper->show_to_string(id) << endmsg;
296 }
297 } // iEta
298 } //iPhi
299 }
300 } //iDisk
301 } // Endcap;
302
303 // Check DBM endcap modules
304 int endcapCountDBM = 0;
305 int endcapCountErrorDBM = 0;
306 if (m_geometryManager->dbm()) {
307 // Endcap
308 for (int iEndcapIndex = 0; iEndcapIndex < manager->numerology().numEndcapsDBM(); iEndcapIndex++) {
309 int iEndcap = manager->numerology().endcapIdDBM(iEndcapIndex);
310 for (int iDisk = 0; iDisk < manager->numerology().numDisksDBM(); iDisk++) {
311 if (manager->numerology().useDiskDBM(iDisk)) {
312 for (int iEta = 0; iEta < manager->numerology().numRingsForDiskDBM(iDisk); iEta++) {
313 for (int iPhi = 0; iPhi < manager->numerology().numPhiModulesForDiskRingDBM(iDisk,iEta); iPhi++) {
314 Identifier id = idHelper->wafer_id(iEndcap,iDisk,iPhi,iEta);
315 const InDetDD::SiDetectorElement * element = manager->getDetectorElement(id);
316 endcapCountDBM++;
317 std::stringstream ostr;
318 ostr << "[2.1." << iEndcap << "." << iDisk << "." << iPhi << "." << iEta << ".0]";
319 if (!element) {
320 endcapCountErrorDBM++;
321 msg(MSG::WARNING) << " No element found for id (DBM): " << ostr.str() << " " << idHelper->show_to_string(id) << endmsg;
322 }
323 } // iEta
324 } //iPhi
325 }
326 } //iDisk
327 } // Endcap;
328 }
329
330 if (barrelCountError || endcapCountError || endcapCountErrorDBM) {
331 msg(MSG::ERROR) << "There are elements which cannot be found." << endmsg;
332 msg(MSG::INFO) << "Number of barrel elements not found : " << barrelCountError << endmsg;
333 msg(MSG::INFO) << "Number of pixel endcap elements not found : " << endcapCountError << endmsg;
334 msg(MSG::INFO) << "Number of DBM endcap elements not found : " << endcapCountErrorDBM << endmsg;
335 }
336
337 if ( barrelCount+endcapCount+endcapCountDBM != int(maxHash)) {
338 msg(MSG::ERROR) << "Total count does not match maxHash." << endmsg;
339 msg(MSG::INFO) << "Number of barrel elements : " << barrelCount << endmsg;
340 msg(MSG::INFO) << "Number of endcap elements : " << endcapCount << endmsg;
341 msg(MSG::INFO) << "Number of endcap elements (DBM) : " << endcapCountDBM << endmsg;
342 msg(MSG::INFO) << "Total : " << barrelCount+endcapCount+endcapCountDBM << endmsg;
343 msg(MSG::INFO) << "MaxHash : " << maxHash << endmsg;
344 }
345
346 msg(MSG::INFO) << "Number of barrel elements : " << barrelCount << endmsg;
347 msg(MSG::INFO) << "Number of endcap elements : " << endcapCount << endmsg;
348 msg(MSG::INFO) << "Number of endcap elements (DBM) : " << endcapCountDBM << endmsg;
349 msg(MSG::INFO) << "Total : " << barrelCount+endcapCount+endcapCountDBM << endmsg;
350 msg(MSG::INFO) << "MaxHash : " << maxHash << endmsg;
351
352}
#define endmsg
This is an Identifier helper class for the Pixel subdetector.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
DetectorFactoryBase(InDetDD::AthenaComps *athenaComps)
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
Helper class to concentrate common items, such as the pointer to the IdHelper, the lorentzAngle tool ...
Class to hold geometrical description of a silicon detector element.
Class to hold version information consisting of tag, name layout and description as strings,...
Definition Version.h:24
InDetDD::PixelDetectorManager * m_detectorManager
GeoModelIO::ReadGeoModel * m_sqliteReader
std::shared_ptr< std::map< std::string, GeoAlignableTransform * > > m_mapAX
std::shared_ptr< std::map< std::string, GeoFullPhysVol * > > m_mapFPV
std::unique_ptr< PixelGeometryManager > m_geometryManager
virtual void create(GeoPhysVol *world) override
Class to hold various Athena components.
const PixelID * getIdHelper() const
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:360
size_type wafer_hash_max() const
Definition PixelID.cxx:801
bool dynamicAlignFolders() const
bool services() const
bool servicesOnLadder() const
bool initialLayout() const
bool dc1Geometry() const
bool dbm() const
bool ibl() const
bool alignable() const
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Message Stream Member.
@ timedependent_run2
MsgStream & msg
Definition testRead.cxx:32