ATLAS Offline Software
Loading...
Searching...
No Matches
SCTGeometryManagerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 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 }
698
699 // for the stave alignment frame rotation we use the one of the iEta=1
700 // non-stereo side (which is the module local frame)
701 if(iEta==1 && !element->isStereo())
702 rotation = element->moduleTransform().rotation();
703 }
704 }
705
706 // we set the alignment frame to be the CoG of the stave
707 // with rotation being the one of the iEta=1 module set above
708 Amg::Translation3D translation(mod->centerOfGravity());
709 Amg::Transform3D localToGlobal = translation * rotation;
710
711
712 ATH_MSG_DEBUG("Prepared local to global transform :");
713 ATH_MSG_DEBUG(" - translation: "<<localToGlobal.translation().x()<<" "<<localToGlobal.translation().y()<<" "<<localToGlobal.translation().z());
714 ATH_MSG_DEBUG(" - rotation:");
715 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(0,0)<<" "<<localToGlobal.rotation()(0,1)<<" "<<localToGlobal.rotation()(0,2));
716 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(1,0)<<" "<<localToGlobal.rotation()(1,1)<<" "<<localToGlobal.rotation()(1,2));
717 ATH_MSG_DEBUG(" "<<localToGlobal.rotation()(2,0)<<" "<<localToGlobal.rotation()(2,1)<<" "<<localToGlobal.rotation()(2,2));
718
719 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
720
721 m_alignModuleListPtr->push_back(mod);
722 }
723 }
724 }
725
726 //_______________________________________________________________________
728 {
729 // ========================================
730 // END CAPS
731 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L2: 2 x 9 disks");
732
733 // ========================================
734 // get all modules for Level 2 alignment of the Endcaps
735 // Level 2 is 2 x 9 SCT Endcap disks
736
737 const Amg::Transform3D transform = Amg::Transform3D::Identity();
738
739 unsigned int maxHash = m_idHelper->wafer_hash_max();
740 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
741
743 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
745
746 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
747 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
748 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
749 if (!m_detManager->numerology().useDisk(iWheel))
750 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
751
752 Trk::AlignModule * mod = new Trk::AlignModule(this);
753 mod->setIdHash(getNextIDHash());
754 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
755
756 std::stringstream name;
757 if(iEndcapIndex == 0)
758 name <<"SCT/EndcapA/Disk_" << iWheel;
759 else
760 name <<"SCT/EndcapC/Disk_" << iWheel;
761 mod->setName(name.str());
762
763 if(!m_alignEndcaps || !moduleSelected(mod)) {
764 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
765 delete mod;
766 continue;
767 }
768
769 ATH_MSG_DEBUG("Building module "<<mod->name());
770
771 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
772 ATH_MSG_DEBUG("iEta "<<iEta);
773 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
774 ATH_MSG_DEBUG("iPhi "<<iPhi);
775 for(int is=0; is<2; is++) { // module side
776
777 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
778 if (element) {
779 // get element location for debugging
780 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
781 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
782 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
783
784 // add element to the AlignModule
785 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
786 // and fill the corresponding map
787 (*sctIdHashMap)[element->identifyHash()] = mod;
788 }
789 }
790 }
791 }
792
793 // for endcap we move the CoG
794 Amg::Translation3D translation(mod->centerOfGravity());
795 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
796 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
797 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
798
799 m_alignModuleListPtr->push_back(mod);
800 }
801 }
802 }
803
804 //_______________________________________________________________________
806 {
807 // ========================================
808 // END CAPS
809 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L25: 2 x 22 rings");
810
811 if(!m_alignEndcaps) {
812 ATH_MSG_DEBUG("Not aligning endcaps");
813 return;
814 }
815
816 // ========================================
817 // get all modules for Level 2 alignment of the Endcaps
818 // 2 x 22 SCT Endcap rings
819
820 const Amg::Transform3D transform = Amg::Transform3D::Identity();
821
822 unsigned int maxHash = m_idHelper->wafer_hash_max();
823 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
824
826 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
828
829 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
830 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
831 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
832 if (!m_detManager->numerology().useDisk(iWheel))
833 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
834 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
835 ATH_MSG_DEBUG("iEta "<<iEta);
836
837 Trk::AlignModule * mod = new Trk::AlignModule(this);
838 mod->setIdHash(getNextIDHash());
839 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,iEta,0,0));
840
841 std::stringstream name;
842 if(iEndcapIndex == 0)
843 name <<"SCT/EndcapA/Disk_"<<iWheel<<"/Ring_"<<iEta;
844 else
845 name <<"SCT/EndcapC/Disk_"<<iWheel<<"/Ring_"<<iEta;
846 mod->setName(name.str());
847
848 if(!moduleSelected(mod)) {
849 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
850 delete mod;
851 continue;
852 }
853
854 ATH_MSG_DEBUG("Building module "<<mod->name());
855
856 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
857 ATH_MSG_DEBUG("iPhi "<<iPhi);
858 for(int is=0; is<2; is++) { // module side
859
860 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
861 if (element) {
862 // get element location for debugging
863 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
864 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
865 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
866
867 // add element to the AlignModule
868 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
869 // and fill the corresponding map
870 (*sctIdHashMap)[element->identifyHash()] = mod;
871 }
872 }
873 }
874
875 // for endcap we move the CoG
876
877
878
879 Amg::Translation3D translation(mod->centerOfGravity());
880 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
881 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
882 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
883
884 m_alignModuleListPtr->push_back(mod);
885 }
886 }
887 }
888 }
889
890 //_______________________________________________________________________
892 {
893 ATH_MSG_INFO("Preparing the old SCT Barrel geometry for L2: 4 barrel layers + 2 x 9 endcap disks");
894
895 const Amg::Transform3D transform = Amg::Transform3D::Identity();
896
897 unsigned int maxHash = m_idHelper->wafer_hash_max();
898 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
899
901 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
903
904 // first endcaap C
905 int iEndcapIndex = 1;
906 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
907 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
908 if (!m_detManager->numerology().useDisk(iWheel))
909 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
910
911 Trk::AlignModule * mod = new Trk::AlignModule(this);
912 mod->setIdHash(getNextIDHash());
913 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
914
915 std::stringstream name;
916 name <<"SCT/EndcapC/Disk_" << iWheel;
917 mod->setName(name.str());
918
919 if(!m_alignEndcaps || !moduleSelected(mod)) {
920 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
921 delete mod;
922 continue;
923 }
924
925 ATH_MSG_DEBUG("Building module "<<mod->name());
926
927 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
928 ATH_MSG_DEBUG("iEta "<<iEta);
929 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
930 ATH_MSG_DEBUG("iPhi "<<iPhi);
931 for(int is=0; is<2; is++) { // module side
932 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
933 if (element) {
934 // get element location for debugging
935 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
936 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
937 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
938
939 // add element to the AlignModule
940 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
941 // and fill the corresponding map
942 (*sctIdHashMap)[element->identifyHash()] = mod;
943 }
944 }
945 }
946 }
947
948 // for endcap we move the CoG
949 Amg::Translation3D translation(mod->centerOfGravity());
950 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
951 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
952 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
953
954 m_alignModuleListPtr->push_back(mod);
955 }
956
957 // now barrel
958 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
959 if (!m_detManager->numerology().useLayer(iLayer))
960 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
961
962 // create the AlignModule
963 Trk::AlignModule * mod = new Trk::AlignModule(this);
964 mod->setIdHash(getNextIDHash());
965 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, 0, 0, 0));
966
967 std::stringstream name;
968 name <<"SCT/Barrel/Layer_"<<iLayer;
969 mod->setName(name.str());
970
971 if(!m_alignBarrel || !moduleSelected(mod)) {
972 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
973 delete mod;
974 continue;
975 }
976
977 ATH_MSG_DEBUG("Building module "<<mod->name());
978
979 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
980 ATH_MSG_DEBUG("iPhi "<<iPhi);
981 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
982 ATH_MSG_DEBUG("iEta "<<iEta);
983 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
984 // iEta=0 is not defined for the SCT
985 continue;
986 for (int is = 0; is < 2; is++) { // module side
987
988 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
989 if (element) {
990 // get element location for debugging
991 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
992 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
993 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
994
995 // add element to the AlignModule
996 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
997 // and fill the corresponding map
998 (*sctIdHashMap)[element->identifyHash()] = mod;
999 }
1000 }
1001 }
1002 }
1003
1004 m_alignModuleListPtr->push_back(mod);
1005 }
1006
1007 // and endcaap A
1008 iEndcapIndex = 0;
1009 iSide = m_detManager->numerology().endcapId(iEndcapIndex);
1010 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
1011 if (!m_detManager->numerology().useDisk(iWheel))
1012 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
1013
1014 Trk::AlignModule * mod = new Trk::AlignModule(this);
1015 mod->setIdHash(getNextIDHash());
1016 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,0,0,0));
1017
1018 std::stringstream name;
1019 name <<"SCT/EndcapA/Disk_" << iWheel;
1020 mod->setName(name.str());
1021
1022 if(!m_alignEndcaps || !moduleSelected(mod)) {
1023 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1024 delete mod;
1025 continue;
1026 }
1027
1028 ATH_MSG_DEBUG("Building module "<<mod->name());
1029
1030 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
1031 ATH_MSG_DEBUG("iEta "<<iEta);
1032 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
1033 ATH_MSG_DEBUG("iPhi "<<iPhi);
1034 for(int is=0; is<2; is++) { // module side
1035 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
1036 if (element) {
1037 // get element location for debugging
1038 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1039 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1040 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1041
1042 // add element to the AlignModule
1043 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1044 // and fill the corresponding map
1045 (*sctIdHashMap)[element->identifyHash()] = mod;
1046 }
1047 }
1048 }
1049 }
1050
1051 // for endcap we move the CoG
1052 Amg::Translation3D translation(mod->centerOfGravity());
1053 ATH_MSG_DEBUG("Endcap:" << iSide << " , disk: " << iWheel << " , CoG (" << translation.x() << " , " << translation.y() << " , " << translation.z() << " ) " );
1054
1055 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
1056
1057 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
1058
1059 m_alignModuleListPtr->push_back(mod);
1060 }
1061 }
1062
1063 //_______________________________________________________________________
1065 {
1066 // ========================================
1067 // BARREL
1068 ATH_MSG_INFO("Preparing the SCT Barrel geometry for L3: module (bi-wafer) level");
1069
1070 // =========================================
1071 // get all modules for SCT Barrel Level 3 alignment
1072 // 2112 modules
1073
1074 unsigned int maxHash = m_idHelper->wafer_hash_max();
1075 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
1076
1078 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
1080
1081 for (int iLayer = 0; iLayer < m_detManager->numerology().numLayers(); iLayer++) {
1082 if (!m_detManager->numerology().useLayer(iLayer))
1083 ATH_MSG_INFO(" Layer "<<iLayer<<" not present");
1084 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForLayer(iLayer); iPhi++) {
1085 ATH_MSG_DEBUG("iPhi "<<iPhi);
1086 for (int iEta = m_detManager->numerology().beginEtaModuleForLayer(iLayer); iEta < m_detManager->numerology().endEtaModuleForLayer(iLayer); iEta++) {
1087 ATH_MSG_DEBUG("iEta "<<iEta);
1088 if (!iEta && m_detManager->numerology().skipEtaZeroForLayer(iLayer))
1089 // iEta=0 is not defined for the SCT
1090 continue;
1091
1092 // create the AlignModule
1093 Trk::AlignModule * mod = new Trk::AlignModule(this);
1094 mod->setIdHash(getNextIDHash());
1095 mod->setIdentifier(m_idHelper->wafer_id(0, iLayer, iPhi, iEta, 0));
1096
1097 std::stringstream name;
1098 name <<"SCT/Barrel/Layer_"<<iLayer<<"/Phi_"<<iPhi<<"/Eta_"<<iEta;
1099 mod->setName(name.str());
1100
1101 if(!m_alignBarrel || !moduleSelected(mod)) {
1102 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1103 delete mod;
1104 continue;
1105 }
1106
1107 ATH_MSG_DEBUG("Building module "<<mod->name());
1108
1109 for(int is=0;is<2;is++) { // module side
1110
1111 const SiDetectorElement * element = m_detManager->getDetectorElement(0, iLayer, iPhi, iEta, is);
1112
1113 if (element) {
1114 // get element location for debugging
1115 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1116 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1117 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1118
1119 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1120 // should this be identity? if yes, it means that the
1121 // db frame constants are in the global frame. Or not?
1122 const Amg::Transform3D transform = Amg::Transform3D::Identity();
1123 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1124
1125 // add element to the AlignModule
1126 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1127 // and fill the corresponding map
1128 (*sctIdHashMap)[element->identifyHash()] = mod;
1129
1130 // the local frame for the SCT barrel modules is always that
1131 // of the Rphi element, NOT stereo !
1132 // in any case the correct frame can be obtained using moduleTransform() call
1133 // regardless of the side, but we only need it once so we retrieve it
1134 // for the non-stereo side
1135 if(!element->isStereo())
1136 mod->setGlobalFrameToAlignFrameTransform(element->moduleTransform().inverse());
1137 }
1138 }
1139
1140 m_alignModuleListPtr->push_back(mod);
1141 }
1142 }
1143
1144 }
1145 }
1146
1147 //_______________________________________________________________________
1149 {
1150 // ========================================
1151 // ENDCAPs
1152 ATH_MSG_INFO("Preparing the SCT Endcap geometry for L3: module (bi-wafer) level");
1153
1154 // =========================================
1155 // get all modules for SCT Endcap Level 3 alignment
1156 // 2 * 988
1157
1158 unsigned int maxHash = m_idHelper->wafer_hash_max();
1159 ATH_MSG_DEBUG("maxHash for the SCT "<<maxHash);
1160
1162 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(maxHash),nullptr);
1164
1165 for (int iEndcapIndex = 0; iEndcapIndex < m_detManager->numerology().numEndcaps(); iEndcapIndex++) {
1166 int iSide = m_detManager->numerology().endcapId(iEndcapIndex);
1167 for (int iWheel = 0; iWheel < m_detManager->numerology().numDisks(); iWheel++) {
1168 if (!m_detManager->numerology().useDisk(iWheel))
1169 ATH_MSG_INFO(" Disk "<<iWheel<<" not present");
1170 for (int iEta = 0; iEta < m_detManager->numerology().numRingsForDisk(iWheel); iEta++) {
1171 ATH_MSG_DEBUG("iEta "<<iEta);
1172 for (int iPhi = 0; iPhi < m_detManager->numerology().numPhiModulesForDiskRing(iWheel,iEta); iPhi++) {
1173 ATH_MSG_DEBUG("iPhi "<<iPhi);
1174
1175 Trk::AlignModule * mod = new Trk::AlignModule(this);
1176 mod->setIdHash(getNextIDHash());
1177 mod->setIdentifier(m_idHelper->wafer_id(iSide,iWheel,iPhi,iEta,0));
1178
1179 std::stringstream name;
1180 if(iEndcapIndex == 0)
1181 name<<"SCT/EndcapA";
1182 else
1183 name<<"SCT/EndcapC";
1184 name<<"/Disk_"<<iWheel<<"/Phi_"<<iPhi<<"/Eta_"<<iEta;
1185 mod->setName(name.str());
1186
1187 if(!m_alignEndcaps || !moduleSelected(mod)) {
1188 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1189 delete mod;
1190 continue;
1191 }
1192
1193 ATH_MSG_DEBUG("Building module "<<mod->name());
1194
1195 for(int is=0; is<2; is++) { // module side
1196
1197 const SiDetectorElement * element = m_detManager->getDetectorElement(iSide, iWheel, iPhi, iEta, is);
1198 if (element) {
1199 // get element location for debugging
1200 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
1201 // ATH_MSG_DEBUG(" SCTDetectorElement id: " << id << " with center = " << center);
1202 // ATH_MSG_DEBUG(" Is Barrel: "<< m_idHelper->is_barrel(id));
1203
1204 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1205 // should this be identity? if yes, it means that the
1206 // db frame constants are in the global frame. Or not?
1207 const Amg::Transform3D transform = Amg::Transform3D::Identity();
1208 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1209
1210 // add element to the AlignModule
1211 mod->addDetElement(Trk::AlignModule::SCT,element,transform);
1212 // and fill the corresponding map
1213 (*sctIdHashMap)[element->identifyHash()] = mod;
1214
1215 // the local frame for the SCT endcap modules is always that
1216 // of the Rphi element, NOT stereo !
1217 // in any case the correct frame can be obtained using moduleTransform() call
1218 // regardless of the side, but we only need it once so we retrieve it
1219 // for the non-stereo side
1220 if(!element->isStereo())
1221 mod->setGlobalFrameToAlignFrameTransform(element->moduleTransform().inverse());
1222 }
1223 }
1224
1225 m_alignModuleListPtr->push_back(mod);
1226 }
1227 }
1228 }
1229 }
1230
1231 }
1232
1233 //________________________________________________________________________
1235 {
1236 // prepare all parameters
1238 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransX));
1239 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransY));
1240 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransZ));
1241 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotX));
1242 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotY));
1243 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotZ));
1244
1245 // set sigmas
1246 setSigmas(module,fullModPars);
1247
1248 // select active parameters based on jobOption properties
1250 for(unsigned int ipar=0;ipar<fullModPars->size();++ipar) {
1251
1252 Identifier AlimodID = module->identify();
1253 Identifier modID = ((module->detElementCollection(Trk::AlignModule::SCT))->at(0))->identify();
1254
1255 if(m_idHelper->is_barrel(modID)) {
1256 ATH_MSG_DEBUG("SCT barrel module with id "<<AlimodID);
1257 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignBarrelX)
1258 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignBarrelY)
1259 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignBarrelZ)
1260 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignBarrelRotX)
1261 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignBarrelRotY)
1262 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignBarrelRotZ) ) {
1263 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1264 activeModPars->push_back(fullModPars->at(ipar));
1265 }
1266 else
1267 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1268 }
1269 else {
1270 ATH_MSG_DEBUG("SCT endcap module with id "<<AlimodID);
1271 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignEndcapX)
1272 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignEndcapY)
1273 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignEndcapZ)
1274 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignEndcapRotX)
1275 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignEndcapRotY)
1276 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignEndcapRotZ) ) {
1277 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1278 activeModPars->push_back(fullModPars->at(ipar));
1279 }
1280 else
1281 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1282 }
1283 }
1284
1285 // now add parameters to the list
1286 allFullModPars->push_back(fullModPars);
1287 allActiveModPars->push_back(activeModPars);
1288 }
1289
1290 //________________________________________________________________________
1292 {
1293 for(unsigned int ipar=0;ipar<modPars->size();++ipar) {
1294 // barrel
1295 if(m_idHelper->is_barrel(module->identify()))
1296 switch(modPars->at(ipar)->paramType()) {
1298 modPars->at(ipar)->setSigma(m_sigmaBarrelX);
1299 modPars->at(ipar)->setSoftCut(m_softcutBarrelX);
1300 break;
1302 modPars->at(ipar)->setSigma(m_sigmaBarrelY);
1303 modPars->at(ipar)->setSoftCut(m_softcutBarrelY);
1304 break;
1306 modPars->at(ipar)->setSigma(m_sigmaBarrelZ);
1307 modPars->at(ipar)->setSoftCut(m_softcutBarrelZ);
1308 break;
1310 modPars->at(ipar)->setSigma(m_sigmaBarrelRotX);
1311 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotX);
1312 break;
1314 modPars->at(ipar)->setSigma(m_sigmaBarrelRotY);
1315 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotY);
1316 break;
1318 modPars->at(ipar)->setSigma(m_sigmaBarrelRotZ);
1319 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotZ);
1320 break;
1321 default:
1322 break;
1323 }
1324 // end-caps
1325 else
1326 switch(modPars->at(ipar)->paramType()) {
1328 modPars->at(ipar)->setSigma(m_sigmaEndcapX);
1329 modPars->at(ipar)->setSoftCut(m_softcutEndcapX);
1330 break;
1332 modPars->at(ipar)->setSigma(m_sigmaEndcapY);
1333 modPars->at(ipar)->setSoftCut(m_softcutEndcapY);
1334 break;
1336 modPars->at(ipar)->setSigma(m_sigmaEndcapZ);
1337 modPars->at(ipar)->setSoftCut(m_softcutEndcapZ);
1338 break;
1340 modPars->at(ipar)->setSigma(m_sigmaEndcapRotX);
1341 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotX);
1342 break;
1344 modPars->at(ipar)->setSigma(m_sigmaEndcapRotY);
1345 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotY);
1346 break;
1348 modPars->at(ipar)->setSigma(m_sigmaEndcapRotZ);
1349 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotZ);
1350 break;
1351 default:
1352 break;
1353 }
1354 }
1355 }
1356
1357 //________________________________________________________________________
1358 bool SCTGeometryManagerTool::moduleSelected(unsigned long long id)
1359 {
1361 return true;
1362
1363 int nsel = m_moduleSelection.size();
1364 for(int i=0;i<nsel;++i)
1365 if(m_moduleSelection.at(i) == id)
1366 return true;
1367
1368 return false;
1369 }
1370
1371 //________________________________________________________________________
1373 {
1374 return moduleSelected(mod->identify().get_compact());
1375 }
1376
1377 //________________________________________________________________________
1379 {
1380 ATH_MSG_INFO("---------------------------------------------------");
1381 ATH_MSG_INFO("Summary of the alignment geometry");
1382 ATH_MSG_INFO("Number of alignable objects: "<< m_alignModuleList.size());
1383 for(unsigned int i=0;i<m_alignModuleList.size();i++) {
1384 const Trk::AlignModule* module = m_alignModuleList.at(i);
1385 ATH_MSG_INFO(i<<". "<< module->name());
1386 ATH_MSG_INFO(" - identifier: "<<module->identify());
1387 ATH_MSG_INFO(" - has "<<module->detElementCollection(Trk::AlignModule::SCT)->size()<<" SCT modules");
1388
1389 Amg::Transform3D localtoglobal = (module->globalFrameToAlignFrame()).inverse();
1390 ATH_MSG_DEBUG(" - local to global : "<<std::setprecision(12)<<localtoglobal.translation()<<" "<<localtoglobal.rotation());
1391
1392 DataVector<Trk::AlignPar> * pars = m_alignModuleTool->getAlignPars(module);
1393 int npars = pars->size();
1394 ATH_MSG_DEBUG(" - number of active transform parameters: "<<npars);
1395 for(int j=0;j<npars;j++)
1396 ATH_MSG_DEBUG(" * par "<<j<<" \'"<<(*pars)[j]->dumpType()<<"\' : sigma = "<<(*pars)[j]->sigma()<<" , softCut = "<<(*pars)[j]->softCut());
1397 }
1398 ATH_MSG_INFO("---------------------------------------------------");
1399 }
1400
1401} // 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