ATLAS Offline Software
Loading...
Searching...
No Matches
SCTGeometryManagerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
11
13
17
18
19
21
22
23#include <iostream>
24
25using namespace InDetDD;
26
27namespace InDet {
28
29 //________________________________________________________________________
31 const std::string& name,
32 const IInterface * parent)
33 : AthAlgTool(type,name,parent)
34 , m_detManager(nullptr)
35 , m_idHelper()
36 , m_alignModuleTool("Trk::AlignModuleTool/AlignModuleTool")
37 , m_idHashToAlignModuleMaps(Trk::AlignModule::NDetectorTypes,(Trk::AlignModuleList*)nullptr)
38 , m_alignParList(nullptr)
39 , m_fullAlignParList(nullptr)
40 {
41 declareInterface<IGeometryManagerTool>(this);
42 declareProperty("AlignModuleTool", m_alignModuleTool);
43
44 // Pixel joboptions
45 declareProperty("AlignBarrel", m_alignBarrel = true);
46 declareProperty("AlignEndcaps", m_alignEndcaps = true);
47
48 declareProperty("AlignBarrelX", m_alignBarrelX = true);
49 declareProperty("AlignBarrelY", m_alignBarrelY = true);
50 declareProperty("AlignBarrelZ", m_alignBarrelZ = true);
51 declareProperty("AlignBarrelRotX", m_alignBarrelRotX = true);
52 declareProperty("AlignBarrelRotY", m_alignBarrelRotY = true);
53 declareProperty("AlignBarrelRotZ", m_alignBarrelRotZ = true);
54
55 declareProperty("AlignEndcapX", m_alignEndcapX = true);
56 declareProperty("AlignEndcapY", m_alignEndcapY = true);
57 declareProperty("AlignEndcapZ", m_alignEndcapZ = true);
58 declareProperty("AlignEndcapRotX", m_alignEndcapRotX = true);
59 declareProperty("AlignEndcapRotY", m_alignEndcapRotY = true);
60 declareProperty("AlignEndcapRotZ", m_alignEndcapRotZ = true);
61
62 declareProperty("SetSigmaBarrelX", m_sigmaBarrelX = 1.);
63 declareProperty("SetSigmaBarrelY", m_sigmaBarrelY = 1.);
64 declareProperty("SetSigmaBarrelZ", m_sigmaBarrelZ = 1.);
65 declareProperty("SetSigmaBarrelRotX", m_sigmaBarrelRotX = 0.001);
66 declareProperty("SetSigmaBarrelRotY", m_sigmaBarrelRotY = 0.001);
67 declareProperty("SetSigmaBarrelRotZ", m_sigmaBarrelRotZ = 0.001);
68
69 declareProperty("SetSigmaEndcapX", m_sigmaEndcapX = 1.);
70 declareProperty("SetSigmaEndcapY", m_sigmaEndcapY = 1.);
71 declareProperty("SetSigmaEndcapZ", m_sigmaEndcapZ = 1.);
72 declareProperty("SetSigmaEndcapRotX", m_sigmaEndcapRotX = 0.001);
73 declareProperty("SetSigmaEndcapRotY", m_sigmaEndcapRotY = 0.001);
74 declareProperty("SetSigmaEndcapRotZ", m_sigmaEndcapRotZ = 0.001);
75
76 declareProperty("SetSoftCutBarrelX", m_softcutBarrelX = 1.);
77 declareProperty("SetSoftCutBarrelY", m_softcutBarrelY = 1.);
78 declareProperty("SetSoftCutBarrelZ", m_softcutBarrelZ = 1.);
79 declareProperty("SetSoftCutBarrelRotX", m_softcutBarrelRotX = 1.);
80 declareProperty("SetSoftCutBarrelRotY", m_softcutBarrelRotY = 1.);
81 declareProperty("SetSoftCutBarrelRotZ", m_softcutBarrelRotZ = 1.);
82
83 declareProperty("SetSoftCutEndcapX", m_softcutEndcapX = 1.);
84 declareProperty("SetSoftCutEndcapY", m_softcutEndcapY = 1.);
85 declareProperty("SetSoftCutEndcapZ", m_softcutEndcapZ = 1.);
86 declareProperty("SetSoftCutEndcapRotX", m_softcutEndcapRotX = 1.);
87 declareProperty("SetSoftCutEndcapRotY", m_softcutEndcapRotY = 1.);
88 declareProperty("SetSoftCutEndcapRotZ", m_softcutEndcapRotZ = 1.);
89
90 // defines alignment level
91 declareProperty("AlignmentLevel", m_alignLevel = 1);
92 declareProperty("AlignmentLevelBarrel", m_alignLevelBarrel = -1);
93 declareProperty("AlignmentLevelEndcaps", m_alignLevelEndcaps = -1);
94
95 declareProperty("doModuleSelection", m_doModuleSelection = false);
96 declareProperty("ModuleSelection", m_moduleSelection);
97
98 declareProperty("UseOldL2", m_useOldL2 = false);
99 declareProperty("DumpGeometry", m_dumpGeometry = true);
100
101 m_hashCounter = 0;
102 m_logStream = nullptr;
103 }
104
105 //________________________________________________________________________
107 {
108 ATH_MSG_DEBUG("deleting alignModuleList");
109 for (int i=0;i<(int)m_alignModuleList.size();i++)
110 delete m_alignModuleList[i];
111 m_alignModuleList.clear();
112
113 ATH_MSG_DEBUG("deleting fullAlignParList");
114 delete m_fullAlignParList;
115 ATH_MSG_DEBUG("deleting alignParList");
116 delete m_alignParList;
117 }
118
119 //________________________________________________________________________
121 {
122 ATH_MSG_DEBUG("initialize() of SCTGeometryManagerTool");
123
124 // retrieve AlignModuleTool
125 if ( m_alignModuleTool.retrieve().isFailure() ) {
126 msg(MSG::FATAL)<<"Could not get " << m_alignModuleTool << endmsg;
127 return StatusCode::FAILURE;
128 }
129 else
130 ATH_MSG_INFO("Retrieved " << m_alignModuleTool);
131
132 // retrieve SCT helper
133 if ( detStore()->retrieve(m_idHelper).isFailure() ) {
134 msg(MSG::FATAL) << " Cannot retrieve SCT Helper " << endmsg;
135 return StatusCode::FAILURE;
136 }
137 else
138 ATH_MSG_INFO("retrieved Silicon SCT Helper");
139
140 // retrieve SCT detector manager
141 if ( detStore()->retrieve(m_detManager,m_stripDetManagerName).isFailure() ) {
142 msg(MSG::FATAL) << " Cannot retrieve SCT Detector Manager " << endmsg;
143 return StatusCode::FAILURE;
144 }
145 else
146 ATH_MSG_INFO("retrieved SCT Detector Manager");
147
148 // dump module selection
149 if(m_doModuleSelection && msgLvl(MSG::INFO)) {
150 msg(MSG::INFO)<<"Creating geometry for selected "<<m_moduleSelection.size()<<" modules:"<<endmsg;
151 for(unsigned int i=0;i<m_moduleSelection.size();i++)
152 msg(MSG::INFO)<<" "<<i<<". "<<m_moduleSelection.at(i)<<endmsg;
153 }
154
155 // check the allowed geometry levels
156 if(!checkAlignLevel())
157 return StatusCode::FAILURE;
158
159 return StatusCode::SUCCESS;
160 }
161
162 //________________________________________________________________________
164 {
165 ATH_MSG_DEBUG("finalize() of SCTGeometryManagerTool");
166
167 return StatusCode::SUCCESS;
168 }
169
170 //________________________________________________________________________
176
177 //________________________________________________________________________
179 {
180 if(m_alignLevel == 0) {
181 ATH_MSG_INFO("Alignment level for SCT is "<<m_alignLevel);
182 return true;
183 }
184
185 if(m_alignLevel == 2 && m_useOldL2) {
186 ATH_MSG_INFO("Setting up OLD L2 alignment level for SCT");
189 return true;
190 }
191
192 if(m_alignLevelBarrel == -1)
194
195 if(m_alignLevelEndcaps == -1)
197
199
200 // if the alignment level for barrel and EC is set correctly
201 // reset the global alignment level
202 if(ok)
203 m_alignLevel = -1;
204
205 return ok;
206 }
207
208 //________________________________________________________________________
210 {
211 if(!m_alignBarrel)
212 return true;
213
214 // check whether geometry level is allowed
215 switch(m_alignLevelBarrel) {
216 case 1: case 2: case 27: case 3:
217 ATH_MSG_INFO("Alignment level for SCT Barrel is "<<m_alignLevelBarrel);
218 return true;
219 default:
220 msg(MSG::FATAL)<<"Alignment level "<<m_alignLevelBarrel<<" does not exist for SCT Barrel"<<endmsg;
221 return false;
222 }
223 }
224
225 //________________________________________________________________________
227 {
228 if(!m_alignEndcaps)
229 return true;
230
231 // check whether geometry level is allowed
232 switch(m_alignLevelEndcaps) {
233 case 1: case 2: case 25: case 3:
234 ATH_MSG_INFO("Alignment level for SCT Endcaps is "<<m_alignLevelBarrel);
235 return true;
236 default:
237 msg(MSG::FATAL)<<"Alignment level "<<m_alignLevelEndcaps<<" does not exist for SCT Endcaps"<<endmsg;
238 return false;
239 }
240 }
241
242 //________________________________________________________________________
244 {
245 ATH_MSG_DEBUG("in ReadGeometry() solveLevel="<<solveLevel);
246
247 // set pointers
250
251 // build alignment geometry
253
254 // now set the alignment parameters
255 // first prepare the parameter lists
258 // loop over modules
259 ATH_MSG_DEBUG("Adding module parameters to modules");
260 std::vector<Trk::AlignModule *>::const_iterator imod = m_alignModuleList.begin();
261 std::vector<Trk::AlignModule *>::const_iterator imod_end = m_alignModuleList.end();
262 for( ; imod!=imod_end ; ++imod)
264
265 // set alignModuleList and hash table in the alignModuleTool
267 ATH_MSG_DEBUG(" geometry set in m_alignModuleTool");
268
269 // set alignPar lists in the alignModuleTool
270 ATH_MSG_DEBUG(" alignParList = "<<m_alignParList);
271 ATH_MSG_DEBUG(" fullAlignParList = "<<m_fullAlignParList);
273 ATH_MSG_DEBUG(" AlignParLists set in m_alignModuleTool");
274
275 // dump summary about the geometry setup
276 if (m_dumpGeometry)
277 dumpGeometry();
278
279 int nDoF= m_alignModuleTool->nAlignParameters();
280 ATH_MSG_INFO("Total number of degrees of freedom: "<<nDoF);
281
282 return nDoF;
283 }
284
285 //_______________________________________________________________________
287 {
288 ATH_MSG_INFO("Preparing the SCT geometry");
289
290 if(m_alignLevel == 0)
291 buildL0();
292 else if (m_alignLevel == 2 && m_useOldL2)
293 buildL2Old();
294 else {
295
296 if(m_alignBarrel)
297 switch(m_alignLevelBarrel) {
298 case 1:
300 break;
301 case 2:
303 break;
304 case 27:
306 break;
307 case 3:
309 break;
310 default:
311 break;
312 }
313
315 switch(m_alignLevelEndcaps) {
316 case 1:
318 break;
319 case 2:
321 break;
322 case 25:
324 break;
325 case 3:
327 break;
328 default:
329 break;
330 }
331
332 }
333 }
334
335 //_______________________________________________________________________
337 {
338 ATH_MSG_INFO("Preparing the SCT geometry for L0: the whole SCT");
339 // ===================================================
340 // Level 0 is just one module containing the whole SCT
341
342 Trk::AlignModule * sct = new Trk::AlignModule(this);
343 sct->setIdHash(getNextIDHash());
344 sct->setName("SCT");
345
346 // use the identifier of the SCT barrel for the whole SCT at L0
347 sct->setIdentifier(m_idHelper->wafer_id(0,0,0,0,0));
348
349 ATH_MSG_DEBUG("Created module "<<sct->name()<<" idHash: "<<sct->identifyHash()<<" identifier: "<<sct->identify());
350
351 // for L0 alignment the alignment frame is equal to the global frame
352 // and since the SCT detector element positions are also stored
353 // in the global frame in DB, transform is identity
354 const Amg::Transform3D transform = Amg::Transform3D::Identity();
355
356 // get maximum number of elements from the helper
357 unsigned int sctmaxHash = m_idHelper->wafer_hash_max();
358 ATH_MSG_DEBUG("maxHash for the SCT: "<<sctmaxHash);
359
361 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(sctmaxHash),nullptr);
363
364 // ================================================================
365 // loop over SCT elements and add them to respective alignModules
366 // ================================================================
367 for (unsigned int index = 0; index < sctmaxHash; index++) {
368 IdentifierHash idHash = index;
369 Identifier id = m_idHelper->wafer_id(idHash);
370
371 ATH_MSG_DEBUG(" SCT DetectorElement idhash: "<<index);
372 ATH_MSG_DEBUG(" DetectorElement id: "<<id);
373
374 // get the element via hash
375 const SiDetectorElement * element = m_detManager->getDetectorElement(id);
376 if (element) {
377 // add element to respective AlignModule
378 // add to the sct barrel structure
379 if(msgLvl(MSG::DEBUG)) {
380 if (m_idHelper->is_barrel(id))
381 msg(MSG::DEBUG)<<"... SCT barrel element"<<endmsg;
382 else
383 msg(MSG::DEBUG)<<"... SCT endcap element"<<endmsg;
384 }
385 sct->addDetElement(Trk::AlignModule::SCT,element,transform);
386
387 // and fill the corresponding map
388 (*sctIdHashMap)[idHash] = sct;
389 }
390 else
391 ATH_MSG_DEBUG("No SCT detector with id: "<<id);
392 }
393
394 // add created module to the geometry
395 m_alignModuleListPtr->push_back(sct);
396
397 ATH_MSG_DEBUG("SCT L0 module successfully added to the geometry");
398 }
399
400 //_______________________________________________________________________
402 {
403 // ===========================
404 // BARREL
405 // ===========================
406 ATH_MSG_INFO("Preparing the SCT Barrel geometry for L1: barrel + 2 endcaps");
407
408 // ========================================
409 // Level 1 is whole SCT barrel
410
411 // get maximum number of elements from the helper
412 unsigned int maxHash = m_idHelper->wafer_hash_max();
413 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
414
416 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
418
419 // use the 'real' identifier of the Pixel
420 // build barrel module
421 Trk::AlignModule * mod = new Trk::AlignModule(this);
422 mod->setIdHash(getNextIDHash());
423 mod->setName("SCT Barrel");
424 mod->setIdentifier(m_idHelper->wafer_id(0,0,0,0,0));
425
426 // check if selected
427 if(!m_alignBarrel || !moduleSelected(mod)) {
428 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
429 delete mod;
430 return;
431 }
432
433 // fill module with detector elements
434 ATH_MSG_DEBUG("Building module "<<mod->name());
435
436 const Amg::Transform3D transform = Amg::Transform3D::Identity();
437
438 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
439 if (!m_detManager->numerology().useLayer(iLayer))
440 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
441
442 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
443 ATH_MSG_DEBUG("iPhi "<<iPhi);
444 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
445 ATH_MSG_DEBUG("iEta "<<iEta);
446
447 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
448 // iEta=0 is not defined for the SCT
449 continue;
450
451 for (int is = 0; is < 2; is++) { // module side
452 const SiDetectorElement* element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
453
454 if (element) {
455 // get element location for debugging
456 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
457 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
458 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
459
460 // add element to the AlignModule
461 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
462 // and fill the corresponding map
463 (*sctIdHashMap)[element->identifyHash()] = mod;
464 }
465 }
466 }
467 }
468 }
469
470 m_alignModuleListPtr->push_back(mod);
471
472 ATH_MSG_DEBUG("SCT Barrel successfully added to the geometry");
473 }
474
475 //_______________________________________________________________________
477 {
478 // ===========================
479 // ENDCAPs
480 // ===========================
481 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L1: 2 endcaps");
482
483 // ========================================
484 // Level 1 is 2 SCT endcaps
485
486 // get maximum number of elements from the helper
487 unsigned int maxHash = m_idHelper->wafer_hash_max();
488 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
489
491 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
493
494 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
495 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
496
497 Trk::AlignModule * mod = new Trk::AlignModule(this);
498 mod->setIdHash(getNextIDHash());
499 mod->setIdentifier(m_idHelper->wafer_id(iSide,0,0,0,0));
500 if(iEndcapIndex == 0)
501 mod->setName("SCT EndCap A");
502 else
503 mod->setName("SCT EndCap C");
504
505 if(!m_alignEndcaps || !moduleSelected(mod)) {
506 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
507 delete mod;
508 continue;
509 }
510
511 ATH_MSG_DEBUG("Building module "<<mod->name());
512
513 const Amg::Transform3D transform = Amg::Transform3D::Identity();
514
515 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
516 if (!m_detManager->numerology().useDisk(iWheel))
517 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
518
519 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
520 ATH_MSG_DEBUG("iEta "<<iEta);
521 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
522 ATH_MSG_DEBUG("iPhi "<<iPhi);
523 for(int is=0; is<2; is++) { // module side
524
525 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
526 if (element) {
527 // get element location for debugging
528 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
529 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
530 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
531
532 // add element to the AlignModule
533 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
534 // and fill the corresponding map
535 (*sctIdHashMap)[element->identifyHash()] = mod;
536 }
537 }
538 }
539 }
540 }
541
542 // for endcap we move the CoG
543 Amg::Translation3D translation(mod->centerOfGravity());
544 ATH_MSG_DEBUG("Endcap:" << iSide << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
545 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
546
547 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
548
549 m_alignModuleListPtr->push_back(mod);
550 }
551
552 ATH_MSG_DEBUG("SCT End-caps successfully added to the geometry");
553 }
554
555 //_______________________________________________________________________
557 {
558 // ========================================
559 // BARREL
560 ATH_MSG_INFO("Preparing the SCT Barrel geometry for L2: 4 layers");
561
562 // ========================================
563 // get all modules for Level 2 alignment of the Barrel
564 // Level 2 is 4 SCT barrel layers
565
566 const Amg::Transform3D transform = Amg::Transform3D::Identity();
567
568 unsigned int maxHash = m_idHelper->wafer_hash_max();
569 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
570
572 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
574
575 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
576 if (!m_detManager->numerology().useLayer(iLayer))
577 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
578
579 // create the AlignModule
580 Trk::AlignModule * mod = new Trk::AlignModule(this);
581 mod->setIdHash(getNextIDHash());
582 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, 0, 0, 0));
583
584 std::stringstream name;
585 name <<"SCT/Barrel/Layer_"<<iLayer;
586 mod->setName(name.str());
587
588 if(!m_alignBarrel || !moduleSelected(mod)) {
589 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
590 delete mod;
591 continue;
592 }
593
594 ATH_MSG_DEBUG("Building module "<<mod->name());
595
596 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
597 ATH_MSG_DEBUG("iPhi "<<iPhi);
598 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
599 ATH_MSG_DEBUG("iEta "<<iEta);
600 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
601 // iEta=0 is not defined for the SCT
602 continue;
603 for (int is = 0; is < 2; is++) { // module side
604
605 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
606 if (element) {
607 // get element location for debugging
608 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
609 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
610 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
611
612 // add element to the AlignModule
613 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
614 // and fill the corresponding map
615 (*sctIdHashMap)[element->identifyHash()] = mod;
616 }
617 }
618 }
619 }
620
621 m_alignModuleListPtr->push_back(mod);
622 }
623 }
624
625 //_______________________________________________________________________
627 {
628 // ========================================
629 // BARREL
630 ATH_MSG_INFO("Preparing the SCT Barrel geometry for L27: 176 staves (ladders)");
631
632 if(!m_alignBarrel) {
633 ATH_MSG_DEBUG("Not aligning barrel");
634 return;
635 }
636
637 // ========================================
638 // get all modules for Level 27 alignment of the Barrel
639 // 176 staves (ladders)
640
641 const Amg::Transform3D transform = Amg::Transform3D::Identity();
642
643 unsigned int maxHash = m_idHelper->wafer_hash_max();
644 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
645
647 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
649
650 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
651 if (!m_detManager->numerology().useLayer(iLayer))
652 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
653 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
654 ATH_MSG_DEBUG("iPhi "<<iPhi);
655
656 // create the AlignModule
657 Trk::AlignModule * mod = new Trk::AlignModule(this);
658 mod->setIdHash(getNextIDHash());
659
660 // even though there is no iEta=0 module for SCT barrel, the
661 // Identifier is still valid so we use it for the stave
662 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, iPhi, 0, 0));
663
664 std::stringstream name;
665 name <<"SCT/Barrel/Layer_"<<iLayer<<"/PhiStave_"<<iPhi;
666 mod->setName(name.str());
667
668 if(!moduleSelected(mod)) {
669 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
670 delete mod;
671 continue;
672 }
673
674 ATH_MSG_DEBUG("Building module "<<mod->name());
675
676 // rotation of the stave alignment frame
677 Amg::RotationMatrix3D rotation; rotation.setIdentity();
678
679 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
680 ATH_MSG_DEBUG("iEta "<<iEta);
681 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
682 // iEta=0 is not defined for the SCT
683 continue;
684 for (int is = 0; is < 2; is++) { // module side
685
686 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
687 if (element) {
688 // get element location for debugging
689 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
690 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
691 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
692
693 // add element to the AlignModule
694 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
695 // and fill the corresponding map
696 (*sctIdHashMap)[element->identifyHash()] = mod;
697 // for the stave alignment frame rotation we use the one of the iEta=1
698 // non-stereo side (which is the module local frame)
699 if(iEta==1 && !element->isStereo())
700 rotation = element->moduleTransform().rotation();
701 }
702 }
703 }
704
705 // we set the alignment frame to be the CoG of the stave
706 // with rotation being the one of the iEta=1 module set above
707 Amg::Translation3D translation(mod->centerOfGravity());
708 Amg::Transform3D localToGlobal = translation * rotation;
709
710
711 ATH_MSG_DEBUG("Prepared local to global transform :");
712 ATH_MSG_DEBUG(" - translation: "<<localToGlobal.translation().x()<<" "<<localToGlobal.translation().y()<<" "<<localToGlobal.translation().z());
713 ATH_MSG_DEBUG(" - rotation:");
714 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(0,0)<<" "<<localToGlobal.rotation()(0,1)<<" "<<localToGlobal.rotation()(0,2));
715 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(1,0)<<" "<<localToGlobal.rotation()(1,1)<<" "<<localToGlobal.rotation()(1,2));
716 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(2,0)<<" "<<localToGlobal.rotation()(2,1)<<" "<<localToGlobal.rotation()(2,2));
717
718 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
719
720 m_alignModuleListPtr->push_back(mod);
721 }
722 }
723 }
724
725 //_______________________________________________________________________
727 {
728 // ========================================
729 // END CAPS
730 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L2: 2 x 9 disks");
731
732 // ========================================
733 // get all modules for Level 2 alignment of the Endcaps
734 // Level 2 is 2 x 9 SCT Endcap disks
735
736 const Amg::Transform3D transform = Amg::Transform3D::Identity();
737
738 unsigned int maxHash = m_idHelper->wafer_hash_max();
739 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
740
742 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
744
745 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
746 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
747 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
748 if (!m_detManager->numerology().useDisk(iWheel))
749 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
750
751 Trk::AlignModule * mod = new Trk::AlignModule(this);
752 mod->setIdHash(getNextIDHash());
753 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
754
755 std::stringstream name;
756 if(iEndcapIndex == 0)
757 name <<"SCT/EndcapA/Disk_" << iWheel;
758 else
759 name <<"SCT/EndcapC/Disk_" << iWheel;
760 mod->setName(name.str());
761
762 if(!m_alignEndcaps || !moduleSelected(mod)) {
763 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
764 delete mod;
765 continue;
766 }
767
768 ATH_MSG_DEBUG("Building module "<<mod->name());
769
770 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
771 ATH_MSG_DEBUG("iEta "<<iEta);
772 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
773 ATH_MSG_DEBUG("iPhi "<<iPhi);
774 for(int is=0; is<2; is++) { // module side
775
776 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
777 if (element) {
778 // get element location for debugging
779 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
780 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
781 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
782
783 // add element to the AlignModule
784 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
785 // and fill the corresponding map
786 (*sctIdHashMap)[element->identifyHash()] = mod;
787 }
788 }
789 }
790 }
791
792 // for endcap we move the CoG
793 Amg::Translation3D translation(mod->centerOfGravity());
794 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
795 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
796 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
797
798 m_alignModuleListPtr->push_back(mod);
799 }
800 }
801 }
802
803 //_______________________________________________________________________
805 {
806 // ========================================
807 // END CAPS
808 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L25: 2 x 22 rings");
809
810 if(!m_alignEndcaps) {
811 ATH_MSG_DEBUG("Not aligning endcaps");
812 return;
813 }
814
815 // ========================================
816 // get all modules for Level 2 alignment of the Endcaps
817 // 2 x 22 SCT Endcap rings
818
819 const Amg::Transform3D transform = Amg::Transform3D::Identity();
820
821 unsigned int maxHash = m_idHelper->wafer_hash_max();
822 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
823
825 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
827
828 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
829 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
830 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
831 if (!m_detManager->numerology().useDisk(iWheel))
832 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
833 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
834 ATH_MSG_DEBUG("iEta "<<iEta);
835
836 Trk::AlignModule * mod = new Trk::AlignModule(this);
837 mod->setIdHash(getNextIDHash());
838 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,iEta,0,0));
839
840 std::stringstream name;
841 if(iEndcapIndex == 0)
842 name <<"SCT/EndcapA/Disk_"<<iWheel<<"/Ring_"<<iEta;
843 else
844 name <<"SCT/EndcapC/Disk_"<<iWheel<<"/Ring_"<<iEta;
845 mod->setName(name.str());
846
847 if(!moduleSelected(mod)) {
848 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
849 delete mod;
850 continue;
851 }
852
853 ATH_MSG_DEBUG("Building module "<<mod->name());
854
855 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
856 ATH_MSG_DEBUG("iPhi "<<iPhi);
857 for(int is=0; is<2; is++) { // module side
858
859 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
860 if (element) {
861 // get element location for debugging
862 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
863 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
864 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
865
866 // add element to the AlignModule
867 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
868 // and fill the corresponding map
869 (*sctIdHashMap)[element->identifyHash()] = mod;
870 }
871 }
872 }
873
874 // for endcap we move the CoG
875
876
877
878 Amg::Translation3D translation(mod->centerOfGravity());
879 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
880 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
881 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
882
883 m_alignModuleListPtr->push_back(mod);
884 }
885 }
886 }
887 }
888
889 //_______________________________________________________________________
891 {
892 ATH_MSG_INFO("Preparing the old SCT Barrel geometry for L2: 4 barrel layers + 2 x 9 endcap disks");
893
894 const Amg::Transform3D transform = Amg::Transform3D::Identity();
895
896 unsigned int maxHash = m_idHelper->wafer_hash_max();
897 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
898
900 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
902
903 // first endcaap C
904 int iEndcapIndex = 1;
905 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
906 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
907 if (!m_detManager->numerology().useDisk(iWheel))
908 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
909
910 Trk::AlignModule * mod = new Trk::AlignModule(this);
911 mod->setIdHash(getNextIDHash());
912 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
913
914 std::stringstream name;
915 name <<"SCT/EndcapC/Disk_" << iWheel;
916 mod->setName(name.str());
917
918 if(!m_alignEndcaps || !moduleSelected(mod)) {
919 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
920 delete mod;
921 continue;
922 }
923
924 ATH_MSG_DEBUG("Building module "<<mod->name());
925
926 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
927 ATH_MSG_DEBUG("iEta "<<iEta);
928 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
929 ATH_MSG_DEBUG("iPhi "<<iPhi);
930 for(int is=0; is<2; is++) { // module side
931 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
932 if (element) {
933 // get element location for debugging
934 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
935 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
936 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
937
938 // add element to the AlignModule
939 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
940 // and fill the corresponding map
941 (*sctIdHashMap)[element->identifyHash()] = mod;
942 }
943 }
944 }
945 }
946
947 // for endcap we move the CoG
948 Amg::Translation3D translation(mod->centerOfGravity());
949 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
950 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
951 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
952
953 m_alignModuleListPtr->push_back(mod);
954 }
955
956 // now barrel
957 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
958 if (!m_detManager->numerology().useLayer(iLayer))
959 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
960
961 // create the AlignModule
962 Trk::AlignModule * mod = new Trk::AlignModule(this);
963 mod->setIdHash(getNextIDHash());
964 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, 0, 0, 0));
965
966 std::stringstream name;
967 name <<"SCT/Barrel/Layer_"<<iLayer;
968 mod->setName(name.str());
969
970 if(!m_alignBarrel || !moduleSelected(mod)) {
971 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
972 delete mod;
973 continue;
974 }
975
976 ATH_MSG_DEBUG("Building module "<<mod->name());
977
978 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
979 ATH_MSG_DEBUG("iPhi "<<iPhi);
980 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
981 ATH_MSG_DEBUG("iEta "<<iEta);
982 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
983 // iEta=0 is not defined for the SCT
984 continue;
985 for (int is = 0; is < 2; is++) { // module side
986
987 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
988 if (element) {
989 // get element location for debugging
990 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
991 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
992 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
993
994 // add element to the AlignModule
995 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
996 // and fill the corresponding map
997 (*sctIdHashMap)[element->identifyHash()] = mod;
998 }
999 }
1000 }
1001 }
1002
1003 m_alignModuleListPtr->push_back(mod);
1004 }
1005
1006 // and endcaap A
1007 iEndcapIndex = 0;
1008 iSide = m_detManager->numerology().endcapId(iEndcapIndex);
1009 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
1010 if (!m_detManager->numerology().useDisk(iWheel))
1011 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
1012
1013 Trk::AlignModule * mod = new Trk::AlignModule(this);
1014 mod->setIdHash(getNextIDHash());
1015 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
1016
1017 std::stringstream name;
1018 name <<"SCT/EndcapA/Disk_" << iWheel;
1019 mod->setName(name.str());
1020
1021 if(!m_alignEndcaps || !moduleSelected(mod)) {
1022 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1023 delete mod;
1024 continue;
1025 }
1026
1027 ATH_MSG_DEBUG("Building module "<<mod->name());
1028
1029 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
1030 ATH_MSG_DEBUG("iEta "<<iEta);
1031 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
1032 ATH_MSG_DEBUG("iPhi "<<iPhi);
1033 for(int is=0; is<2; is++) { // module side
1034 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
1035 if (element) {
1036 // get element location for debugging
1037 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1038 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1039 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1040
1041 // add element to the AlignModule
1042 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1043 // and fill the corresponding map
1044 (*sctIdHashMap)[element->identifyHash()] = mod;
1045 }
1046 }
1047 }
1048 }
1049
1050 // for endcap we move the CoG
1051 Amg::Translation3D translation(mod->centerOfGravity());
1052 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
1053
1054 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
1055
1056 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
1057
1058 m_alignModuleListPtr->push_back(mod);
1059 }
1060 }
1061
1062 //_______________________________________________________________________
1064 {
1065 // ========================================
1066 // BARREL
1067 ATH_MSG_INFO("Preparing the SCT Barrel geometry for L3: module (bi-wafer) level");
1068
1069 // =========================================
1070 // get all modules for SCT Barrel Level 3 alignment
1071 // 2112 modules
1072
1073 unsigned int maxHash = m_idHelper->wafer_hash_max();
1074 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
1075
1077 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
1079
1080 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
1081 if (!m_detManager->numerology().useLayer(iLayer))
1082 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
1083 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
1084 ATH_MSG_DEBUG("iPhi "<<iPhi);
1085 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
1086 ATH_MSG_DEBUG("iEta "<<iEta);
1087 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
1088 // iEta=0 is not defined for the SCT
1089 continue;
1090
1091 // create the AlignModule
1092 Trk::AlignModule * mod = new Trk::AlignModule(this);
1093 mod->setIdHash(getNextIDHash());
1094 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, iPhi, iEta, 0));
1095
1096 std::stringstream name;
1097 name <<"SCT/Barrel/Layer_"<<iLayer<<"/Phi_"<<iPhi<<"/Eta_"<<iEta;
1098 mod->setName(name.str());
1099
1100 if(!m_alignBarrel || !moduleSelected(mod)) {
1101 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1102 delete mod;
1103 continue;
1104 }
1105
1106 ATH_MSG_DEBUG("Building module "<<mod->name());
1107
1108 for(int is=0;is<2;is++) { // module side
1109
1110 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
1111
1112 if (element) {
1113 // get element location for debugging
1114 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1115 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1116 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1117
1118 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1119 // should this be identity? if yes, it means that the
1120 // db frame constants are in the global frame. Or not?
1121 const Amg::Transform3D transform = Amg::Transform3D::Identity();
1122 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1123
1124 // add element to the AlignModule
1125 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1126 // and fill the corresponding map
1127 (*sctIdHashMap)[element->identifyHash()] = mod;
1128
1129 // the local frame for the SCT barrel modules is always that
1130 // of the Rphi element, NOT stereo !
1131 // in any case the correct frame can be obtained using moduleTransform() call
1132 // regardless of the side, but we only need it once so we retrieve it
1133 // for the non-stereo side
1134 if(!element->isStereo())
1135 mod->setGlobalFrameToAlignFrameTransform(element->moduleTransform().inverse());
1136 }
1137 }
1138
1139 m_alignModuleListPtr->push_back(mod);
1140 }
1141 }
1142
1143 }
1144 }
1145
1146 //_______________________________________________________________________
1148 {
1149 // ========================================
1150 // ENDCAPs
1151 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L3: module (bi-wafer) level");
1152
1153 // =========================================
1154 // get all modules for SCT Endcap Level 3 alignment
1155 // 2 * 988
1156
1157 unsigned int maxHash = m_idHelper->wafer_hash_max();
1158 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
1159
1161 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
1163
1164 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
1165 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
1166 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
1167 if (!m_detManager->numerology().useDisk(iWheel))
1168 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
1169 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
1170 ATH_MSG_DEBUG("iEta "<<iEta);
1171 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
1172 ATH_MSG_DEBUG("iPhi "<<iPhi);
1173
1174 Trk::AlignModule * mod = new Trk::AlignModule(this);
1175 mod->setIdHash(getNextIDHash());
1176 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,iPhi,iEta,0));
1177
1178 std::stringstream name;
1179 if(iEndcapIndex == 0)
1180 name<<"SCT/EndcapA";
1181 else
1182 name<<"SCT/EndcapC";
1183 name<<"/Disk_"<<iWheel<<"/Phi_"<<iPhi<<"/Eta_"<<iEta;
1184 mod->setName(name.str());
1185
1186 if(!m_alignEndcaps || !moduleSelected(mod)) {
1187 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1188 delete mod;
1189 continue;
1190 }
1191
1192 ATH_MSG_DEBUG("Building module "<<mod->name());
1193
1194 for(int is=0; is<2; is++) { // module side
1195
1196 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
1197 if (element) {
1198 // get element location for debugging
1199 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1200 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1201 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1202
1203 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1204 // should this be identity? if yes, it means that the
1205 // db frame constants are in the global frame. Or not?
1206 const Amg::Transform3D transform = Amg::Transform3D::Identity();
1207 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1208
1209 // add element to the AlignModule
1210 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1211 // and fill the corresponding map
1212 (*sctIdHashMap)[element->identifyHash()] = mod;
1213
1214 // the local frame for the SCT endcap modules is always that
1215 // of the Rphi element, NOT stereo !
1216 // in any case the correct frame can be obtained using moduleTransform() call
1217 // regardless of the side, but we only need it once so we retrieve it
1218 // for the non-stereo side
1219 if(!element->isStereo())
1220 mod->setGlobalFrameToAlignFrameTransform(element->moduleTransform().inverse());
1221 }
1222 }
1223
1224 m_alignModuleListPtr->push_back(mod);
1225 }
1226 }
1227 }
1228 }
1229
1230 }
1231
1232 //________________________________________________________________________
1234 {
1235 // prepare all parameters
1237 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransX));
1238 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransY));
1239 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransZ));
1240 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotX));
1241 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotY));
1242 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotZ));
1243
1244 // set sigmas
1245 setSigmas(module,fullModPars);
1246
1247 // select active parameters based on jobOption properties
1249 for(unsigned int ipar=0;ipar<fullModPars->size();++ipar) {
1250
1251 Identifier AlimodID = module->identify();
1252 Identifier modID = ((module->detElementCollection(Trk::AlignModule::SCT))->at(0))->identify();
1253
1254 if(m_idHelper->is_barrel(modID)) {
1255 ATH_MSG_DEBUG("SCT barrel module with id "<<AlimodID);
1256 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignBarrelX)
1257 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignBarrelY)
1258 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignBarrelZ)
1259 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignBarrelRotX)
1260 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignBarrelRotY)
1261 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignBarrelRotZ) ) {
1262 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1263 activeModPars->push_back(fullModPars->at(ipar));
1264 }
1265 else
1266 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1267 }
1268 else {
1269 ATH_MSG_DEBUG("SCT endcap module with id "<<AlimodID);
1270 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignEndcapX)
1271 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignEndcapY)
1272 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignEndcapZ)
1273 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignEndcapRotX)
1274 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignEndcapRotY)
1275 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignEndcapRotZ) ) {
1276 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1277 activeModPars->push_back(fullModPars->at(ipar));
1278 }
1279 else
1280 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1281 }
1282 }
1283
1284 // now add parameters to the list
1285 allFullModPars->push_back(fullModPars);
1286 allActiveModPars->push_back(activeModPars);
1287 }
1288
1289 //________________________________________________________________________
1291 {
1292 for(unsigned int ipar=0;ipar<modPars->size();++ipar) {
1293 // barrel
1294 if(m_idHelper->is_barrel(module->identify()))
1295 switch(modPars->at(ipar)->paramType()) {
1297 modPars->at(ipar)->setSigma(m_sigmaBarrelX);
1298 modPars->at(ipar)->setSoftCut(m_softcutBarrelX);
1299 break;
1301 modPars->at(ipar)->setSigma(m_sigmaBarrelY);
1302 modPars->at(ipar)->setSoftCut(m_softcutBarrelY);
1303 break;
1305 modPars->at(ipar)->setSigma(m_sigmaBarrelZ);
1306 modPars->at(ipar)->setSoftCut(m_softcutBarrelZ);
1307 break;
1309 modPars->at(ipar)->setSigma(m_sigmaBarrelRotX);
1310 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotX);
1311 break;
1313 modPars->at(ipar)->setSigma(m_sigmaBarrelRotY);
1314 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotY);
1315 break;
1317 modPars->at(ipar)->setSigma(m_sigmaBarrelRotZ);
1318 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotZ);
1319 break;
1320 default:
1321 break;
1322 }
1323 // end-caps
1324 else
1325 switch(modPars->at(ipar)->paramType()) {
1327 modPars->at(ipar)->setSigma(m_sigmaEndcapX);
1328 modPars->at(ipar)->setSoftCut(m_softcutEndcapX);
1329 break;
1331 modPars->at(ipar)->setSigma(m_sigmaEndcapY);
1332 modPars->at(ipar)->setSoftCut(m_softcutEndcapY);
1333 break;
1335 modPars->at(ipar)->setSigma(m_sigmaEndcapZ);
1336 modPars->at(ipar)->setSoftCut(m_softcutEndcapZ);
1337 break;
1339 modPars->at(ipar)->setSigma(m_sigmaEndcapRotX);
1340 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotX);
1341 break;
1343 modPars->at(ipar)->setSigma(m_sigmaEndcapRotY);
1344 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotY);
1345 break;
1347 modPars->at(ipar)->setSigma(m_sigmaEndcapRotZ);
1348 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotZ);
1349 break;
1350 default:
1351 break;
1352 }
1353 }
1354 }
1355
1356 //________________________________________________________________________
1357 bool SCTGeometryManagerTool::moduleSelected(unsigned long long id)
1358 {
1360 return true;
1361
1362 int nsel = m_moduleSelection.size();
1363 for(int i=0;i<nsel;++i)
1364 if(m_moduleSelection.at(i) == id)
1365 return true;
1366
1367 return false;
1368 }
1369
1370 //________________________________________________________________________
1372 {
1373 return moduleSelected(mod->identify().get_compact());
1374 }
1375
1376 //________________________________________________________________________
1378 {
1379 ATH_MSG_INFO("---------------------------------------------------");
1380 ATH_MSG_INFO("Summary of the alignment geometry");
1381 ATH_MSG_INFO("Number of alignable objects: "<< m_alignModuleList.size());
1382 for(unsigned int i=0;i<m_alignModuleList.size();i++) {
1383 const Trk::AlignModule* module = m_alignModuleList.at(i);
1384 ATH_MSG_INFO(i<<". "<< module->name());
1385 ATH_MSG_INFO(" - identifier: "<<module->identify());
1386 ATH_MSG_INFO(" - has "<<module->detElementCollection(Trk::AlignModule::SCT)->size()<<" SCT modules");
1387
1388 Amg::Transform3D localtoglobal = (module->globalFrameToAlignFrame()).inverse();
1389 ATH_MSG_DEBUG(" - local to global : "<<std::setprecision(12)<<localtoglobal.translation()<<" "<<localtoglobal.rotation());
1390
1391 DataVector<Trk::AlignPar> * pars = m_alignModuleTool->getAlignPars(module);
1392 int npars = pars->size();
1393 ATH_MSG_DEBUG(" - number of active transform parameters: "<<npars);
1394 for(int j=0;j<npars;j++)
1395 ATH_MSG_DEBUG(" * par "<<j<<" \'"<<(*pars)[j]->dumpType()<<"\' : sigma = "<<(*pars)[j]->sigma()<<" , softCut = "<<(*pars)[j]->softCut());
1396 }
1397 ATH_MSG_INFO("---------------------------------------------------");
1398 }
1399
1400} // end namespace
#define endmsg
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
An STL vector of pointers that by default owns its pointed-to elements.
This is an Identifier helper class for the SCT subdetector.
AlignModule is a grouping of TrkDetElementBase objects, grouped according to the type of alignment,...
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Derived DataVector<T>.
Definition DataVector.h:795
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
Class to hold geometrical description of a silicon detector element.
bool isStereo() const
Check if it is the stereo side (useful for SCT).
const Amg::Transform3D & moduleTransform() const
Module to global frame transform.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
std::vector< Trk::AlignModuleList * > m_idHashToAlignModuleMaps
int ReadGeometry(int solveLevel)
read the geometry Method is called from the main AlignAlg to build the geometry based on the requeste...
void buildL2Endcaps()
creates L2 AlignModules for SCT endcaps
void setSigmas(Trk::AlignModule *mod, DataVector< Trk::AlignPar > *modPars)
sets sigmas for modules
void buildL3Barrel()
creates L3 AlignModules for SCT barrel
void setAlignLevel(int level)
set alignment level
std::vector< unsigned long long > m_moduleSelection
SCTGeometryManagerTool(const std::string &type, const std::string &name, const IInterface *parent)
void buildL3Endcaps()
creates L3 AlignModules for SCT endcaps
bool checkAlignLevelEndcaps()
check whether the Endcap alignment level is correct
void buildL1Barrel()
creates L1 AlignModules for SCT barrel
const InDetDD::SCT_DetectorManager * m_detManager
pointer to SCT detector manager
void buildL25Endcaps()
creates L25 AlignModules for SCT endcaps
DataVector< DataVector< Trk::AlignPar > > * m_fullAlignParList
bool checkAlignLevelBarrel()
check whether the Barrel alignment level is correct
void buildL2Old()
creates L2 AlignModules for the full Pixel in the ordering equal to the old code
void buildL27Barrel()
creates L27 AlignModules for SCT barrel
const SCT_ID * m_idHelper
pointer to SCT detector manager
void buildL0()
creates L0 AlignModules for SCT
void addModuleParameters(Trk::AlignModule *module, DataVector< DataVector< Trk::AlignPar > > *allFullModPars, DataVector< DataVector< Trk::AlignPar > > *allActiveModPars)
adds alignment parameters for the module checks for active parameters and calls setSigmas()
void buildL2Barrel()
creates L2 AlignModules for SCT barrel
DataVector< DataVector< Trk::AlignPar > > * m_alignParList
bool moduleSelected(Trk::AlignModule *mod)
check wheather module is selected for module pointer
ToolHandle< Trk::IAlignModuleTool > m_alignModuleTool
pointer to AlignModuleTool
void buildGeometry()
builds geometry for SCT alignment
bool checkAlignLevel()
check whether the alignment level is correct
Gaudi::Property< std::string > m_stripDetManagerName
void dumpGeometry()
print basic geometry info to screen
void buildL1Endcaps()
creates L1 AlignModules for SCT endcaps
void setIdHash(IdentifierHash id)
Definition AlignModule.h:93
Identifier identify() const
Definition AlignModule.h:97
void setIdentifier(Identifier identifier)
Set and return identifier of module.
Definition AlignModule.h:96
const std::string & name() const
Definition AlignModule.h:89
void setName(const std::string &name)
Set and return name of align module (i.e.
Definition AlignModule.h:88
void addDetElement(AlignModule::DetectorType detType, const TrkDetElementBase *det, const Amg::Transform3D &transform, Identifier id=Identifier())
used to add a detector element to the align module with a align frame to detector element local frame...
IdentifierHash identifyHash() const
Set and return index of module, used by alignment classes to keep track of order of align module.
Definition AlignModule.h:92
std::ostream * m_logStream
logfile output stream
int m_alignLevelBarrel
alignment level
int m_hashCounter
variable for setting the idHash of the AlignModules
virtual int getNextIDHash()
get next free IDHash usable for new AlignModule
Trk::AlignModuleList * m_alignModuleListPtr
pointer to module list to which the modules are added
int m_alignLevelEndcaps
alignment level
std::vector< Trk::AlignModuleList * > * m_idHashToAlignModuleMapsPtr
pointer to vector of hashMaps to which the elements are added
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Affine3d Transform3D
Eigen::Translation< double, 3 > Translation3D
Message Stream Member.
Primary Vertex Finder.
@ OWN_ELEMENTS
this data object owns its elements
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Ensure that the ATLAS eigen extensions are properly loaded.
std::vector< AlignModule * > AlignModuleList
Definition index.py:1