ATLAS Offline Software
Loading...
Searching...
No Matches
SiGeometryManagerTool.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
10
14
16
20
22#include <ostream>
23
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_pixelDetManager(nullptr)
35 , m_sctDetManager(nullptr)
36 , m_pixHelper()
37 , m_sctHelper()
38 , m_idHelper()
40 , m_sctGeoManager("")
41 , m_alignModuleTool("Trk::AlignModuleTool/AlignModuleTool")
42 , m_idHashToAlignModuleMaps(Trk::AlignModule::NDetectorTypes,(Trk::AlignModuleList*)nullptr)
43 , m_alignParList(nullptr)
44 , m_fullAlignParList(nullptr)
45 {
46 declareInterface<IGeometryManagerTool>(this);
47 declareProperty("AlignModuleTool", m_alignModuleTool);
48
49 declareProperty("PixelGeometryManager", m_pixelGeoManager);
50 declareProperty("SCTGeometryManager", m_sctGeoManager);
51
52 // Silicon joboptions
53 declareProperty("AlignPixel", m_alignPixel = true);
54 declareProperty("AlignSCT", m_alignSCT = true);
55
56 declareProperty("AlignX", m_alignX = true);
57 declareProperty("AlignY", m_alignY = true);
58 declareProperty("AlignZ", m_alignZ = true);
59 declareProperty("AlignRotX", m_alignRotX = true);
60 declareProperty("AlignRotY", m_alignRotY = true);
61 declareProperty("AlignRotZ", m_alignRotZ = true);
62
63 declareProperty("SetSigmaX", m_sigmaX = 1.);
64 declareProperty("SetSigmaY", m_sigmaY = 1.);
65 declareProperty("SetSigmaZ", m_sigmaZ = 1.);
66 declareProperty("SetSigmaRotX", m_sigmaRotX = 0.001);
67 declareProperty("SetSigmaRotY", m_sigmaRotY = 0.001);
68 declareProperty("SetSigmaRotZ", m_sigmaRotZ = 0.001);
69
70 // defines alignment level
71 declareProperty("AlignmentLevel", m_alignLevel = -1);
72
73 declareProperty("doModuleSelection", m_doModuleSelection = false);
74 declareProperty("ModuleSelection", m_moduleSelection);
75
76 declareProperty("DumpGeometry", m_dumpGeometry = true);
77 declareProperty("ActualGeometry", m_actualGeom = false);
78
79 m_hashCounter = 0;
80 m_logStream = nullptr;
81 }
82
83 //________________________________________________________________________
85 {
86 ATH_MSG_DEBUG("deleting alignModuleList");
87 for (const auto & i:m_alignModuleList) delete i;
88 m_alignModuleList.clear();
89
90 ATH_MSG_DEBUG("deleting fullAlignParList");
91 delete m_fullAlignParList;
92 ATH_MSG_DEBUG("deleting alignParList");
93 delete m_alignParList;
94 }
95
96 //________________________________________________________________________
98 {
99 ATH_MSG_DEBUG("initialize() of SiGeometryManagerTool");
100
101 // retrieve AlignModuleTool
102 ATH_CHECK( m_alignModuleTool.retrieve() );
103
104 // retrieve Pixel helper
105 ATH_CHECK( detStore()->retrieve(m_pixHelper) );
106
107 // retrieve SCT helper
108 ATH_CHECK( detStore()->retrieve(m_sctHelper));
109
110 // retrieve silicon helper
111 ATH_CHECK( detStore()->retrieve(m_idHelper) );
112
113 // retrieve SCT detector manager
115
116 // retrieve PIX detector manager
118
119 // dump module selection
120 if(m_doModuleSelection && msgLvl(MSG::INFO)) {
121 int idx{};
122 ATH_MSG_INFO("Creating geometry for selected "<<m_moduleSelection.size()<<" modules:");
123 for(const auto & mod:m_moduleSelection)
124 ATH_MSG_INFO(" "<<idx++<<". "<<mod);
125 }
126
127 // retrieve PixelGeometryManagerTool
128 if ( !m_pixelGeoManager.empty() ) {
129 ATH_CHECK( m_pixelGeoManager.retrieve() );
130 }
131
132 // retrieve SCTGeometryManagerTool
133 if ( !m_sctGeoManager.empty() ) {
134 ATH_CHECK( m_sctGeoManager.retrieve() );
135 }
136
137 if(!m_alignPixel && !m_alignSCT) {
138 ATH_MSG_FATAL("Alignment of both Pixel and SCT turned off. Aborting.");
139 return StatusCode::FAILURE;
140 }
141
142 // check allowed alignment level
143 if(!checkAlignLevel()) {
144 ATH_MSG_FATAL("Wrong alignment level.");
145 return StatusCode::FAILURE;
146 }
147
148 return StatusCode::SUCCESS;
149 }
150
151 //________________________________________________________________________
153 {
154 ATH_MSG_DEBUG("finalize() of SiGeometryManagerTool");
155
156 return StatusCode::SUCCESS;
157 }
158
159 //________________________________________________________________________
161 {
162 switch(m_alignLevel) {
163
164 case 0:
165 // for L0 we don't need the other two managers so everything is ok
166 ATH_MSG_INFO("Setting up level 0 alignment of the Silicon");
167 break;
168
169 case 1: case 2: case 3:
170 // for levels 1,2,3 we need the managers and we have to
171 // set the levels in them
172 if( (m_pixelGeoManager.empty() && m_alignPixel) || (m_sctGeoManager.empty() && m_alignSCT) ) {
173 ATH_MSG_ERROR("PixelGeometryManagerTool and/or SCTGeometryManagerTool not available");
174 ATH_MSG_ERROR("Can't set alignment geometry.");
175 return false;
176 }
177
178 ATH_MSG_INFO("Setting up level "<<m_alignLevel<<" alignment of the Silicon");
179 m_pixelGeoManager->setAlignLevel(m_alignLevel);
180 m_sctGeoManager->setAlignLevel(m_alignLevel);
181
182 // we also check that the managers support the levels
183 if( (m_alignPixel && !m_pixelGeoManager->checkAlignLevel()) || (m_alignSCT && !m_sctGeoManager->checkAlignLevel()) )
184 return false;
185 break;
186
187 case -1:
188 // if level is not set here (i.e. it is equal to -1) we need the Pixel and SCT
189 // managers but we trust their setup, we don't need to check it
190 if( (m_pixelGeoManager.empty() && m_alignPixel) || (m_sctGeoManager.empty() && m_alignSCT) ) {
191 ATH_MSG_ERROR("PixelGeometryManagerTool and/or SCTGeometryManagerTool not available");
192 ATH_MSG_ERROR("Can't set alignment geometry.");
193 return false;
194 }
195 break;
196
197 default:
198 ATH_MSG_ERROR("Unknown alignment level "<<m_alignLevel<<". Can't set alignment geometry.");
199 return false;
200
201 }
202
203 return true;
204 }
205
206 //________________________________________________________________________
208 {
209 m_logStream = os;
210 if (!m_pixelGeoManager.empty())
211 m_pixelGeoManager->setLogStream(m_logStream);
212 if (!m_sctGeoManager.empty())
213 m_sctGeoManager->setLogStream(m_logStream);
214 }
215
216 //________________________________________________________________________
218 {
219 ATH_MSG_DEBUG("in ReadGeometry() solveLevel="<<solveLevel);
220
221 // set pointers
224
225 // build alignment geometry
227
228 // now set the alignment parameters
229 // first prepare the parameter lists
232 // loop over modules
233 ATH_MSG_DEBUG("Adding module parameters to modules");
234 std::vector<Trk::AlignModule *>::const_iterator imod = m_alignModuleList.begin();
235 std::vector<Trk::AlignModule *>::const_iterator imod_end = m_alignModuleList.end();
236 for( ; imod!=imod_end ; ++imod) {
237 ATH_MSG_DEBUG("Module "<<(*imod)->name());
239 }
240
241 // set alignModuleList and hash table in the alignModuleTool
243 ATH_MSG_DEBUG(" geometry set in m_alignModuleTool");
244
245 // set alignPar lists in the alignModuleTool
246 ATH_MSG_DEBUG(" alignParList = "<<m_alignParList);
247 ATH_MSG_DEBUG(" fullAlignParList = "<<m_fullAlignParList);
249 ATH_MSG_DEBUG(" AlignParLists set in m_alignModuleTool");
250
251 // dump summary about the geometry setup
252 if (m_dumpGeometry)
253 dumpGeometry();
254
255 int nDoF= m_alignModuleTool->nAlignParameters();
256 ATH_MSG_INFO("Total number of degrees of freedom: "<<nDoF);
257
258 return nDoF;
259 }
260
261 //_______________________________________________________________________
263 {
264 ATH_MSG_INFO("Preparing the Silicon geometry");
265
266 int idHash = 0;
267
268 if(m_alignLevel==0)
269 buildL0();
270
271 else {
272
273 // PIXEL
274 if(m_alignPixel) {
275 m_pixelGeoManager->setFirstIDHash(idHash);
278
279 m_pixelGeoManager->buildGeometry();
280
281 idHash=m_pixelGeoManager->getNextIDHash();
282 }
283
284 // SCT
285 if(m_alignSCT) {
286 m_sctGeoManager->setFirstIDHash(idHash);
289
290 m_sctGeoManager->buildGeometry();
291 }
292 }
293
294 }
295
296 //_______________________________________________________________________
298 {
299 ATH_MSG_INFO("Preparing the Silicon geometry for L0");
300 // ========================================
301 // Level 0 is just one module containing
302 // the whole Silicon detector (Pixel+SCT)
303
304 Trk::AlignModule * silicon = new Trk::AlignModule(this);
305 silicon->setIdHash(getNextIDHash());
306 silicon->setName("Silicon");
307
308 // use the identifier of the Pixel for the whole Silicon at L0
309 silicon->setIdentifier(m_pixHelper->wafer_id(0,0,0,0));
310
311 // check if we're aligning Silicon
312 if(!moduleSelected(silicon)) {
313 ATH_MSG_DEBUG("Module "<<silicon->name()<<" NOT selected");
314 delete silicon;
315 return;
316 }
317
318 ATH_MSG_DEBUG("Created module "<<silicon->name()<<" idHash: "<<silicon->identifyHash()<<" identifier: "<<silicon->identify());
319
320 // for L0 alignment the alignment frame is equal to the global frame
321 // and since the PIXEL and SCT detector element positions are also stored
322 // in the global frame in DB, transform is identity
323 const Amg::Transform3D transform = Amg::Transform3D::Identity();
324
325 // PIXEL
326 // get maximum number of elements from the helper
327 unsigned int pixelmaxHash = m_pixHelper->wafer_hash_max();
328 ATH_MSG_DEBUG("maxHash for the Pixel: "<<pixelmaxHash);
329
331 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::Pixel) = new Trk::AlignModuleList((size_t)(pixelmaxHash),nullptr);
333
334 // ==================================================================
335 // loop over Pixel elements and add them to respective alignModules
336 // ==================================================================
337 for (unsigned int index = 0; index < pixelmaxHash; index++) {
338 IdentifierHash idHash = index;
339 Identifier id = m_pixHelper->wafer_id(idHash);
340
341 ATH_MSG_DEBUG(" Pixel DetectorElement idhash: "<<index);
342 ATH_MSG_DEBUG(" DetectorElement id: "<<id);
343
344 // get the element via hash
345 const SiDetectorElement * element2 = m_pixelDetManager->getDetectorElement(id);
346 if (element2) {
347 const Trk::TrkDetElementBase * element = static_cast<const Trk::TrkDetElementBase*> (element2);
348
349 // get element location for debugging
350 // HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
351 // ATH_MSG_DEBUG(" DetectorElement idhash: " << index);
352 // ATH_MSG_DEBUG(" DetectorElement id: " << id << " with center = " << center);
353 // ATH_MSG_DEBUG(" Is Barrel: "<< m_pixHelper->is_barrel(id));
354
355 // add element to respective AlignModule
356
357 // add to the pixel structure
358 if(msgLvl(MSG::DEBUG)) {
359 if (m_pixHelper->is_barrel(id))
360 msg(MSG::DEBUG)<<"... Pixel barrel element"<<endmsg;
361 else
362 msg(MSG::DEBUG)<<"... Pixel endcap element"<<endmsg;
363 }
364 silicon->addDetElement(Trk::AlignModule::Pixel,element,transform);
365
366 // and fill the corresponding map
367 (*pixelIdHashMap)[idHash] = silicon;
368 }
369 else
370 ATH_MSG_DEBUG("No Pixel detector with id: "<<id);
371 }
372
373 // SCT
374 // get maximum number of elements from the helper
375 unsigned int sctmaxHash = m_sctHelper->wafer_hash_max();
376 ATH_MSG_DEBUG("maxHash for the SCT: "<<sctmaxHash);
377
379 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::SCT) = new Trk::AlignModuleList((size_t)(sctmaxHash),nullptr);
381
382 // ================================================================
383 // loop over SCT elements and add them to respective alignModules
384 // ================================================================
385 for (unsigned int index = 0; index < sctmaxHash; index++) {
386 IdentifierHash idHash = index;
387 Identifier id = m_sctHelper->wafer_id(idHash);
388
389 ATH_MSG_DEBUG(" SCT DetectorElement idhash: "<<index);
390 ATH_MSG_DEBUG(" DetectorElement id: "<<id);
391
392 // get the element via hash
393 const SiDetectorElement * element2 = m_sctDetManager->getDetectorElement(id);
394 if (element2) {
395 const Trk::TrkDetElementBase * element = static_cast<const Trk::TrkDetElementBase*> (element2);
396
397 // add element to respective AlignModule
398
399 // add to the sct barrel structure
400 if(msgLvl(MSG::DEBUG)) {
401 if (m_sctHelper->is_barrel(id))
402 msg(MSG::DEBUG)<<"... SCT barrel element"<<endmsg;
403 else
404 msg(MSG::DEBUG)<<"... SCT endcap element"<<endmsg;
405 }
406 silicon->addDetElement(Trk::AlignModule::SCT,element,transform);
407
408 // and fill the corresponding map
409 (*sctIdHashMap)[idHash] = silicon;
410 }
411 else
412 ATH_MSG_DEBUG("No SCT detector with id: "<<id);
413 }
414
415 // add created module to the geometry
416 m_alignModuleListPtr->push_back(silicon);
417
418 ATH_MSG_DEBUG("Silicon L0 module successfully added to the list");
419 }
420
421 //________________________________________________________________________
423 {
424 // for standalone Pixel and SCT modules call the respective methods
426 m_pixelGeoManager->addModuleParameters(module,allFullModPars,allActiveModPars);
427 return;
428 }
429 else if(isOneDetOnly(module,Trk::AlignModule::SCT)) {
430 m_sctGeoManager->addModuleParameters(module,allFullModPars,allActiveModPars);
431 return;
432 }
433
434 // for combined modules do the work here
435
436 // prepare all parameters
438 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransX));
439 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransY));
440 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransZ));
441 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotX));
442 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotY));
443 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotZ));
444
445 // set sigmas
446 setSigmas(module,fullModPars);
447
448 // select active parameters based on jobOption properties
450 for(unsigned int ipar=0;ipar<fullModPars->size();++ipar) {
451
452 Identifier AlimodID = module->identify();
453
454 ATH_MSG_DEBUG("Silicon module with id "<<AlimodID);
455 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignX)
456 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignY)
457 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignZ)
458 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignRotX)
459 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignRotY)
460 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignRotZ) ) {
461 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
462 activeModPars->push_back(fullModPars->at(ipar));
463 }
464 else
465 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
466 }
467
468 // now add parameters to the list
469 allFullModPars->push_back(fullModPars);
470 allActiveModPars->push_back(activeModPars);
471 }
472
473 //________________________________________________________________________
474 bool SiGeometryManagerTool::moduleSelected(unsigned long long id)
475 {
477 return true;
478
479 int nsel = m_moduleSelection.size();
480 for(int i=0;i<nsel;++i)
481 if(m_moduleSelection.at(i) == id)
482 return true;
483
484 return false;
485 }
486
487 //________________________________________________________________________
489 {
490 ATH_MSG_DEBUG("Setting sigmas for module: "<<module->name());
491 for(unsigned int ipar=0;ipar<modPars->size();++ipar)
492 switch(modPars->at(ipar)->paramType()) {
494 modPars->at(ipar)->setSigma(m_sigmaX);
495 break;
497 modPars->at(ipar)->setSigma(m_sigmaY);
498 break;
500 modPars->at(ipar)->setSigma(m_sigmaZ);
501 break;
503 modPars->at(ipar)->setSigma(m_sigmaRotX);
504 break;
506 modPars->at(ipar)->setSigma(m_sigmaRotY);
507 break;
509 modPars->at(ipar)->setSigma(m_sigmaRotZ);
510 break;
511 default:
512 break;
513 }
514 }
515
516 //________________________________________________________________________
518 {
519 return moduleSelected(mod->identify().get_compact());
520 }
521
522 //________________________________________________________________________
524 {
525
526 ATH_MSG_INFO("---------------------------------------------------");
527 ATH_MSG_INFO("Try to write an Si geom root file:");
528 TGeoManager* gm=new TGeoManager("Silicon","Silicon");
529 TGeoMaterial* mat=new TGeoMaterial("Vacuum",0,0,0);
530 TGeoMedium* med=new TGeoMedium("Vacuum",1,mat);
531 TGeoVolume* top = gm->MakeBox("Silicon",med,2000.,2000.,10000.);
532 gm->SetTopVolume(top);
533 static constexpr std::size_t nElements{60'000};
534 //avoid large stack use; simple arrays would use 2.4Mb stack total
535 std::vector<TGeoVolume*> Si_cog(nElements);
536 std::vector<TGeoVolume*> Si(nElements);
537 int Si_count=0;
538 std::vector<TGeoTranslation*> tr(nElements);
539 std::vector<TGeoRotation* > ro(nElements);
540 std::vector<TGeoCombiTrans*> mx(nElements);
541
542 TGeoTranslation* nulltrans=new TGeoTranslation(0.0,0.0,0.0);
543 TGeoRotation* nullrota=new TGeoRotation();
544 nullrota->SetAngles(0.0,0.0,0.0); // Euler angles
545 TGeoRotation* fliprota=new TGeoRotation();
546 fliprota->SetAngles(0.0,-90.0,0.0); // Euler angles (rotation around X)
547 TGeoCombiTrans* donothing=new TGeoCombiTrans(*nulltrans,*nullrota);
548 TGeoCombiTrans* swapaxes=new TGeoCombiTrans(*nulltrans,*fliprota);
549
550 Amg::Vector3D ea;
552
553 // First prepare the higher level (L1, L2) structures:
554 TGeoVolume* L0_A = gm->MakeTube("L0_A",med,0.0,1100.0,5000.0);
555 L0_A->SetVisibility(kFALSE);
556 top->AddNodeOverlap(L0_A,Si_count,donothing);
557 Si_count++;
558 TGeoVolume* L1_IBL_A = gm->MakeTube("L1_IBL_A",med,20.0,40.0,700.0);
559 L1_IBL_A->SetVisibility(kFALSE);
560 L0_A->AddNodeOverlap(L1_IBL_A,Si_count,donothing);
561 Si_count++;
562 TGeoVolume* L1_DBM_A = gm->MakeTube("L1_DBM_A",med,20.0,40.0,1000.0);
563 L1_DBM_A->SetVisibility(kFALSE);
564 L0_A->AddNodeOverlap(L1_DBM_A,Si_count,donothing);
565 Si_count++;
566 TGeoVolume* L1_PIX_A = gm->MakeTube("L1_PIX_A",med,40.0,150.0,700.0);
567 L1_PIX_A->SetVisibility(kFALSE);
568 L0_A->AddNodeOverlap(L1_PIX_A,Si_count,donothing);
569 Si_count++;
570 TGeoVolume* L1_SCTA_A = gm->MakeTube("L1_SCTA_A",med,250.0,550.0,3000.0);
571 L1_SCTA_A->SetVisibility(kFALSE);
572 L0_A->AddNodeOverlap(L1_SCTA_A,Si_count,donothing);
573 Si_count++;
574 TGeoVolume* L1_SCTB_A = gm->MakeTube("L1_SCTB_A",med,250.0,550.0,3000.0);
575 L1_SCTB_A->SetVisibility(kFALSE);
576 L0_A->AddNodeOverlap(L1_SCTB_A,Si_count,donothing);
577 Si_count++;
578 TGeoVolume* L1_SCTC_A = gm->MakeTube("L1_SCTC_A",med,250.0,550.0,3000.0);
579 L1_SCTC_A->SetVisibility(kFALSE);
580 L0_A->AddNodeOverlap(L1_SCTC_A,Si_count,donothing);
581 Si_count++;
582
583
584
585 ATH_MSG_INFO("---------------------------------------------------");
586 ATH_MSG_INFO("Summary of the alignment geometry");
587 ATH_MSG_INFO("Number of alignable objects: "<< m_alignModuleList.size());
588 for(unsigned int i=0;i<m_alignModuleList.size();i++) {
589 const Trk::AlignModule* module = m_alignModuleList.at(i);
590 ATH_MSG_INFO(i<<". "<< module->name());
591 ATH_MSG_INFO(" - identifier: "<<module->identify());
592 ATH_MSG_INFO(" - identifierHash: "<<module->identifyHash());
593
594 unsigned int npix(0);
595 unsigned int nsct(0);
596 unsigned int nSi(0);
597 bool isPix(false);
598 bool isSCT(false);
599 if(module->detElementCollection(Trk::AlignModule::Pixel)) {
600 npix = module->detElementCollection(Trk::AlignModule::Pixel)->size();
601 nSi = npix; isPix = true;
602 ATH_MSG_INFO(" - has "<<npix<<" Pixel modules");
603 }
604 if(module->detElementCollection(Trk::AlignModule::SCT)) {
605 nsct = module->detElementCollection(Trk::AlignModule::SCT)->size();
606 nSi = nsct; isSCT = true;
607 ATH_MSG_INFO(" - has "<<nsct<<" SCT modules");
608 }
609 if(!isPix && !isSCT) ATH_MSG_INFO(" UNKNOWN module found: "<<module->identify());
610
611 // Loop over all detector elements of this align module:
612 for(unsigned int j=0;j<nSi;j++) {
613 const SiDetectorElement * element=nullptr;
614 if(isPix) element = dynamic_cast<const SiDetectorElement*>(module->detElementCollection(Trk::AlignModule::Pixel)->at(j));
615 if(isSCT) element = dynamic_cast<const SiDetectorElement*>(module->detElementCollection(Trk::AlignModule::SCT)->at(j));
616 if (not element){
617 ATH_MSG_WARNING("Dynamic cast to SiDetectorElement from pixel or SCT module failed");
618 return;
619 }
620 const Identifier element_id = element->identify();
621 int det;
622 int bec;
623 int layer;
624 int ring;
625 int sector;
626 int side;
627 // in the future, the InDetAlignDBTool::idToDetSet should be directly used !
628 bool resok=false;
629 if (m_pixHelper->is_pixel(element_id)) {
630 det=1;
631 bec=m_pixHelper->barrel_ec(element_id);
632 layer=m_pixHelper->layer_disk(element_id);
633 ring=m_pixHelper->eta_module(element_id);
634 sector=m_pixHelper->phi_module(element_id);
635 side=0;
636 resok=true;
637 } else if (m_sctHelper->is_sct(element_id)) {
638 det=2;
639 bec=m_sctHelper->barrel_ec(element_id);
640 layer=m_sctHelper->layer_disk(element_id);
641 ring=m_sctHelper->eta_module(element_id);
642 sector=m_sctHelper->phi_module(element_id);
643 side=m_sctHelper->side(element_id);
644 resok=true;
645 }
646 if(!resok) ATH_MSG_INFO(" UNRESOLVED module found: "<<element_id);
647
648 if(resok && !(element->isStereo())) { // take only phi SCT modules and Pixels
649 // extract the transformation parameters from Eigen:
650 if( m_actualGeom ) {
651 xyz = element->transform().translation(); // translation (actual)
652 ea = element->transform().rotation().eulerAngles(2, 0, 2); // Euler angles (actual)
653 } else {
654 xyz = element->defTransform().translation(); // translation (nominal)
655 ea = element->defTransform().rotation().eulerAngles(2, 0, 2); // Euler angles (nominal)
656 }
657
658 ATH_MSG_INFO(">>> Element ident,det,bec,layer,ring,sector,side: "<<element_id<<", "<<det<<", "<<bec<<", "<<layer<<", "<<ring<<", "<<sector<<", "<<side);
659 ATH_MSG_INFO(">>> Element length/width/thickness: "<<element->length()<<", "<<element->width()<<", "<<element->thickness());
660 if(element->isSCT() && element->isEndcap())
661 ATH_MSG_INFO(">>> SCT Endcap wedge, min/max "<<element->minWidth()<<" / "<<element->maxWidth());
662 ATH_MSG_INFO(">>> Center position: "<<element->center());
663 ATH_MSG_INFO(">>> Default transformation: ");
664 ATH_MSG_INFO(">>> translation: "<<xyz);
665 ATH_MSG_INFO(">>> Euler angles: Phi="<<57.2957*ea[0]<<" Theta="<<57.2957*ea[1]<<" Psi="<<57.2957*ea[2]);
666
667
668 ATH_MSG_INFO("Adding a volume to the Silicon geometry:");
669 TString nname = "Si_COG_";
670 TString mname = "Si_MOD_";
671 TString undsc = "_";
672
673 std::string det_str = std::to_string(det);
674 std::string bec_str = std::to_string( bec);
675 std::string layer_str = std::to_string( layer);
676 std::string ring_str = std::to_string( ring);
677 std::string sector_str = std::to_string( sector);
678 const auto suffix = TString(det_str)+undsc+TString(bec_str)+undsc+TString(layer_str)+undsc+TString(ring_str)+undsc+TString(sector_str);
679 nname += suffix;
680 mname += suffix;
681
682 Si_cog[Si_count] = gm->MakeSphere(nname,med,0.0,element->length(),0.0,180.0,0.0,360.0); // invisible container
683 Si_cog[Si_count]->SetVisibility(kFALSE);
684 // create a wedge for SCT Endcap, otherwise a box:
685 if(element->isSCT() && element->isEndcap()) {
686 Si[Si_count] = gm->MakeTrd1(mname,med,0.5*element->minWidth(),0.5*element->maxWidth(),0.5*element->thickness(),0.5*element->length()); // this is a wedge!
687 } else {
688 Si[Si_count] = gm->MakeBox(mname,med,0.5*element->width(),0.5*element->thickness(),0.5*element->length()); // creator takes the half-lengths!
689 }
690 tr[Si_count] = new TGeoTranslation();
691 tr[Si_count]->SetTranslation(xyz[0],xyz[1],xyz[2]);
692 ro[Si_count] = new TGeoRotation();
693 ro[Si_count]->SetAngles(57.2957*ea[0],57.2957*ea[1],57.2957*ea[2]);
694 mx[Si_count] = new TGeoCombiTrans(*tr[Si_count],*ro[Si_count]);
695
696 TGeoVolume* parrent_elem = nullptr;
697 switch(det)
698 {
699 case 1:
700 if(bec==0 && layer==0) parrent_elem = L1_IBL_A;
701 else if(abs(bec)==4) parrent_elem = L1_DBM_A;
702 else parrent_elem = L1_PIX_A;
703 break;
704 case 2:
705 switch(bec)
706 {
707 case -2:
708 parrent_elem = L1_SCTC_A;
709 break;
710 case 0:
711 parrent_elem = L1_SCTB_A;
712 break;
713 case 2:
714 parrent_elem = L1_SCTA_A;
715 break;
716 default:
717 break;
718 }
719 break;
720 default:
721 break;
722 }
723 if(parrent_elem) {
724 // parrent_elem->AddNode(Si_cog[Si_count],Si_count,mx[Si_count]);
725 // top->AddNode(Si_cog[Si_count],Si_count,mx[Si_count]);
726 top->AddNode(Si_cog[Si_count],0,mx[Si_count]);
727 // Si_cog[Si_count]->AddNode(Si[Si_count],Si_count,gGeoIdentity);
728 // Si_cog[Si_count]->AddNode(Si[Si_count],side,swapaxes);
729 Si_cog[Si_count]->AddNode(Si[Si_count],0,swapaxes);
730 Si_count++;
731 }
732 }
733 }
734
735
736 if(npix && nsct)
737 ATH_MSG_INFO(" - has "<<npix+nsct<<" Silicon modules in total");
738
739 Amg::Transform3D localtoglobal = (module->globalFrameToAlignFrame()).inverse();
740 ATH_MSG_DEBUG(" - local to global : "<<std::setprecision(12)<<localtoglobal.translation()<<" "<<localtoglobal.rotation());
741
742 DataVector<Trk::AlignPar> * pars = m_alignModuleTool->getAlignPars(module);
743 int npars = pars->size();
744 ATH_MSG_DEBUG(" - number of active transform parameters: "<<npars);
745 for(int j=0;j<npars;j++)
746 ATH_MSG_DEBUG(" * par "<<j<<": sigma = "<<(*pars)[j]->sigma());
747
748 }
749
750
751 // close geometry end write the geometry root file:
752 gm->CloseGeometry();
753 gm->Export("Silicon.root","Silicon","v");
754
755 }
756
757 //________________________________________________________________________
759 {
760 ATH_MSG_DEBUG("in isOneDetOnly for detector type "<<dettype);
761 const Trk::AlignModule::DetElementCollection * coll = mod->detElementCollection(dettype);
762 if(!coll || coll->empty())
763 return false;
764
765 int nelem(0);
766 for(int i=1;i<Trk::AlignModule::NDetectorTypes;i++) {
767 if(i==dettype)
768 continue;
769 coll = mod->detElementCollection((Trk::AlignModule::DetectorType)i);
770 if(coll)
771 nelem += coll->size();
772 }
773
774 if(nelem)
775 return false;
776
777 ATH_MSG_DEBUG("module IS of type "<<dettype);
778 return true;
779 }
780
781
782} // end namespace
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(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 Pixel subdetector.
This is an Identifier helper class for the SCT subdetector.
if(pathvar)
This is an Identifier helper class for both the Pixel and SCT subdetectors.
@ top
#define xyz
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).
double length() const
Length in eta direction (z - barrel, r - endcap).
double width() const
Methods from design (inline).
double maxWidth() const
Max width.
virtual const Amg::Vector3D & center() const override final
Center in global coordinates.
virtual Identifier identify() const override final
identifier of this detector element (inline)
double minWidth() const
Min width.
const InDetDD::PixelDetectorManager * m_pixelDetManager
pointer to PIX detector manager
DataVector< DataVector< Trk::AlignPar > > * m_alignParList
ToolHandle< Trk::IGeometryManagerTool > m_pixelGeoManager
pointer to Pixel geometry manager
void buildGeometry()
builds geometry for Silicon alignment
void setSigmas(Trk::AlignModule *mod, DataVector< Trk::AlignPar > *modPars)
sets sigmas for modules
ToolHandle< Trk::IAlignModuleTool > m_alignModuleTool
pointer to AlignModuleTool
Gaudi::Property< std::string > m_pixelDetManagerName
bool moduleSelected(Trk::AlignModule *mod)
check wheather module is selected for module pointer
int ReadGeometry(int solveLevel)
read the geometry Method is called from the main AlignAlg to build the geometry based on the requeste...
void buildL0()
creates L0 AlignModules for Silicon
const SCT_ID * m_sctHelper
pointer to SCT detector manager
const SiliconID * m_idHelper
pointer to Silicon detector manager
ToolHandle< Trk::IGeometryManagerTool > m_sctGeoManager
pointer to SCT geometry manager
DataVector< DataVector< Trk::AlignPar > > * m_fullAlignParList
std::vector< unsigned long long > m_moduleSelection
void setLogStream(std::ostream *os)
sets the output stream for the logfile
void dumpGeometry()
print basic geometry info to screen
const InDetDD::SCT_DetectorManager * m_sctDetManager
pointer to SCT detector manager
bool isOneDetOnly(const Trk::AlignModule *mod, Trk::AlignModule::DetectorType dettype) const
check whether the module is of a single detector type
bool checkAlignLevel()
check whether the alignment level is correct
const PixelID * m_pixHelper
pointer to PIX detector manager
std::vector< Trk::AlignModuleList * > m_idHashToAlignModuleMaps
Gaudi::Property< std::string > m_stripDetManagerName
SiGeometryManagerTool(const std::string &type, const std::string &name, const IInterface *parent)
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 setIdHash(IdentifierHash id)
Definition AlignModule.h:93
std::vector< const TrkDetElementBase * > DetElementCollection
typedefs to contain detector element pointers and transforms
Definition AlignModule.h:60
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_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
std::vector< Trk::AlignModuleList * > * m_idHashToAlignModuleMapsPtr
pointer to vector of hashMaps to which the elements are added
This is the base class for all tracking detector elements with read-out relevant information.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
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