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