ATLAS Offline Software
Loading...
Searching...
No Matches
TRTGeometryManagerTool.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
12
14
18
19
21
22
23#include <iostream>
24#include <memory>
25
26using namespace InDetDD;
27
28namespace InDet {
29
30//________________________________________________________________________
32{
33 ATH_MSG_DEBUG("deleting alignModuleList");
34 for (int i=0;i<(int)m_alignModuleList.size();i++)
35 delete m_alignModuleList[i];
36 m_alignModuleList.clear();
37
38 ATH_MSG_DEBUG("deleting fullAlignParList");
39 delete m_fullAlignParList;
40 ATH_MSG_DEBUG("deleting alignParList");
41 delete m_alignParList;
42}
43
44//________________________________________________________________________
46{
47 ATH_MSG_DEBUG("initialize() of TRTGeometryManagerTool");
48
49 // alignment levels are members of the IGeometryManagerTool base class
50 m_alignLevel = m_alignLevelProp;
51 m_alignLevelBarrel = m_alignLevelBarrelProp;
52 m_alignLevelEndcaps = m_alignLevelEndcapsProp;
53
54 // retrieve AlignModuleTool
55 if ( m_alignModuleTool.retrieve().isFailure() ) {
56 msg(MSG::FATAL)<<"Could not get " << m_alignModuleTool << endmsg;
57 return StatusCode::FAILURE;
58 }
59 else
60 ATH_MSG_INFO("Retrieved " << m_alignModuleTool);
61
62 // retrieve TRT ID helper
63 if ( detStore()->retrieve(m_idHelper, "TRT_ID").isFailure() ) {
64 msg(MSG::FATAL) << " Cannot retrieve TRT ID Helper " << endmsg;
65 return StatusCode::FAILURE;
66 }
67 else
68 ATH_MSG_INFO("retrieved TRT ID Helper");
69
70 // retrieve TRT detector manager
71 if ( detStore()->retrieve(m_trtDetManager).isFailure() ) {
72 msg(MSG::FATAL) << " Cannot retrieve TRT Detector Manager " << endmsg;
73 return StatusCode::FAILURE;
74 }
75 else
76 ATH_MSG_INFO("retrieved TRT Detector Manager");
77
78 // dump module selection
79 if(m_doModuleSelection && msgLvl(MSG::INFO)) {
80 msg(MSG::INFO)<<"Creating geometry for selected "<<m_moduleSelection.value().size()<<" modules:"<<endmsg;
81 for(unsigned int i=0;i<m_moduleSelection.value().size();i++)
82 msg(MSG::INFO)<<" "<<i<<". "<<m_moduleSelection.value().at(i)<<endmsg;
83 }
84
85 // check the allowed geometry levels
86 if(!checkAlignLevel())
87 return StatusCode::FAILURE;
88
89 return StatusCode::SUCCESS;
90}
91
92//________________________________________________________________________
94{
95 ATH_MSG_DEBUG("finalize() of TRTGeometryManagerTool");
96
97 return StatusCode::SUCCESS;
98}
99
100//________________________________________________________________________
102{
103 m_alignLevelBarrel = m_alignLevelEndcaps = -1;
104 m_alignLevel = level;
105}
106
107//________________________________________________________________________
109{
110 if(m_alignLevel == 0) {
111 ATH_MSG_INFO("Alignment level for TRT is "<<m_alignLevel);
112 return true;
113 }
114
115 if(m_alignLevelBarrel == -1) {
116 if(m_alignLevel == 200)
117 m_alignLevelBarrel = 2;
118 else
119 m_alignLevelBarrel = m_alignLevel;
120 }
121
122 if(m_alignLevelEndcaps == -1)
123 m_alignLevelEndcaps = m_alignLevel;
124
126
127 // if the alignment level for barrel and EC is set correctly
128 // reset the global alignment level
129 if(ok)
130 m_alignLevel = -1;
131
132 return ok;
133}
134
135//________________________________________________________________________
137{
138 if(!m_alignBarrel)
139 return true;
140
141 // check whether geometry level is allowed
142 switch(m_alignLevelBarrel) {
143 case 1: case 2: case 3:
144 ATH_MSG_INFO("Alignment level for TRT Barrel is "<<m_alignLevelBarrel);
145 return true;
146 default:
147 msg(MSG::FATAL)<<"Alignment level "<<m_alignLevelBarrel<<" does not exist for TRT Barrel"<<endmsg;
148 return false;
149 }
150}
151
152//________________________________________________________________________
154{
155 if(!m_alignEndcaps)
156 return true;
157
158 // check whether geometry level is allowed
159 switch(m_alignLevelEndcaps) {
160 case 1: case 2: case 200: case 3:
161 ATH_MSG_INFO("Alignment level for TRT Endcaps is "<<m_alignLevelEndcaps);
162 return true;
163 default:
164 msg(MSG::FATAL)<<"Alignment level "<<m_alignLevelEndcaps<<" does not exist for TRT Endcaps"<<endmsg;
165 return false;
166 }
167}
168
169//________________________________________________________________________
171{
172 ATH_MSG_DEBUG("in ReadGeometry() solveLevel="<<solveLevel);
173
174 // set pointers
175 m_idHashToAlignModuleMapsPtr = &m_idHashToAlignModuleMaps;
176 m_alignModuleListPtr = &m_alignModuleList;
177
178 // build alignment geometry
180
181 // now set the alignment parameters
182 // first prepare the parameter lists
185 // loop over modules
186 std::vector<Trk::AlignModule *>::const_iterator imod = m_alignModuleList.begin();
187 std::vector<Trk::AlignModule *>::const_iterator imod_end = m_alignModuleList.end();
188 for( ; imod!=imod_end; ++imod)
190
191 // set alignModuleList and hash table in the alignModuleTool
193 ATH_MSG_DEBUG(" geometry set in m_alignModuleTool");
194
195 // set alignPar lists in the alignModuleTool
196 ATH_MSG_DEBUG(" alignParList = "<<m_alignParList);
197 ATH_MSG_DEBUG(" fullAlignParList = "<<m_fullAlignParList);
199 ATH_MSG_DEBUG(" AlignParLists set in m_alignModuleTool");
200
201 // dump summary about the geometry setup
202 if (m_dumpGeometry)
203 dumpGeometry();
204
205 int nDoF= m_alignModuleTool->nAlignParameters();
206 ATH_MSG_INFO("Total number of degrees of freedom: "<<nDoF);
207
208 return nDoF;
209}
210
211//_______________________________________________________________________
213{
214 ATH_MSG_INFO("Preparing the TRT geometry");
215
216 if(m_alignLevel == 0)
217 buildL0();
218 else {
219
220 if(m_alignBarrel)
221 switch(m_alignLevelBarrel) {
222 case 1:
224 break;
225 case 2:
227 break;
228 case 3:
230 m_alignModuleTool->setSubDetElement(Trk::AlignModule::TRT,true);
231 break;
232 default:
233 break;
234 }
235
237 switch(m_alignLevelEndcaps) {
238 case 1:
240 break;
241 case 2:
243 break;
244 case 200:
246 break;
247 case 3:
249 m_alignModuleTool->setSubDetElement(Trk::AlignModule::TRT,true);
250 break;
251 default:
252 break;
253 }
254 }
255}
256
257//_______________________________________________________________________
259{
260 ATH_MSG_INFO("Preparing the TRT geometry for L0: whole TRT");
261
262 // ========================================
263 // get all modules for Level 0 alignment
264 // Level 0 is the whole TRT, i.e., 1 AlignModule in total
265
266 // define modules
267 // we'll stick with the base AlignModule here since we don't want to
268 // do shifting for the moment but we might need to extend AlignModule
269 // in the future
270
271 // for L1 alignment the alignment frame is equal to the global frame
272 // and since the TRT detector element positions are also stored in
273 // the global frame in DB, transform is identity
274 Amg::Transform3D transform = Amg::Transform3D::Identity();
275
276 // use the 'real' identifier of the TRT barrel for TRT L0 module
277 Trk::AlignModule * trt = new Trk::AlignModule(this);
278 trt->setIdHash(getNextIDHash());
279 trt->setName("TRT");
280 trt->setIdentifier(m_idHelper->barrel_ec_id(-1));
281
282 if(!moduleSelected(trt)) {
283 ATH_MSG_DEBUG("Module "<<trt->name()<<" NOT selected");
284 delete trt;
285 return;
286 }
287
288 // get maximum number of elements from the helper
289 unsigned int trtmaxHash = m_idHelper->straw_layer_hash_max();
290 ATH_MSG_DEBUG("maxHash for the TRT "<<trtmaxHash);
291
292 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
293 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)(trtmaxHash),nullptr);
294 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
295
296 // ================================================================
297 // loop over TRT elements and add them to respective alignModules
298 // ================================================================
299 for (unsigned int index = 0; index < trtmaxHash; index++) {
300 IdentifierHash idHash = index;
301 Identifier id = m_idHelper->layer_id(idHash);
302
303 // get the element via hash
304 const TRT_BaseElement * element = m_trtDetManager->getElement(idHash);
305 if (element) {
306 // get element location for debugging
307// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
308// ATH_MSG_DEBUG(" TRTDetectorElement id: " << id << " with center = " << center);
309
310 // add element to respective AlignModule
311
312 // add to the Inner Detector structure
313 if(msgLvl(MSG::DEBUG)) {
314 if (m_idHelper->is_barrel(id))
315 msg(MSG::DEBUG)<<"... TRT barrel element"<<endmsg;
316 else
317 msg(MSG::DEBUG)<<"... TRT endcap element"<<endmsg;
318 }
319 trt->addDetElement(Trk::AlignModule::TRT,element,transform);
320
321 // and fill the corresponding map
322 (*trtIdHashMap)[idHash] = trt;
323 }
324 else
325 ATH_MSG_DEBUG("No TRTDetectorElement with id: "<<id);
326 }
327
328 // add created module to the geometry
329 m_alignModuleListPtr->push_back(trt);
330
331 ATH_MSG_DEBUG("TRT L0 module successfully added to the list");
332}
333
334//_______________________________________________________________________
336{
337 // ===========================
338 // BARREL
339 // ===========================
340 ATH_MSG_INFO("Preparing the TRT Barrelgeometry for L1: whole barrel");
341
342 // ========================================
343 // get all modules for barrel Level 1 alignment
344 // Level 1 is barrel as a single AlignModule
345
346 // define modules
347 // we'll stick with the base AlignModule here since we don't want to
348 // do shifting for the moment but we might need to extend AlignModule
349 // in the future
350
351 // get maximum number of elements from the helper
352 unsigned int maxHash = 0;
353 if(m_alignLevelEndcaps==3)
354 maxHash = m_idHelper->straw_hash_max();
355 else
356 maxHash = m_idHelper->straw_layer_hash_max();
357 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
358
359 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
360 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
361 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
362
363 // for L1 alignment the alignment frame is equal to the global frame
364 // and since the TRT detector element positions are also stored in
365 // the global frame in DB, transform is identity
366 Amg::Transform3D transform = Amg::Transform3D::Identity();
367
368 // BARREL
369 // use the 'real' identifier of the TRT barrel that can be
370 // used by idHelper->barrel_ec()
371 // TRT barrel has two sides so both -1 and +1 are ok
372 // but -1 is used in the DB so we use it here as well
373 Trk::AlignModule * trtBarrel = new Trk::AlignModule(this);
374 trtBarrel->setIdHash(getNextIDHash());
375 trtBarrel->setName("TRT Barrel");
376 trtBarrel->setIdentifier(m_idHelper->barrel_ec_id(-1));
377
378 if(!moduleSelected(trtBarrel)) {
379 ATH_MSG_DEBUG("Module "<<trtBarrel->name()<<" NOT selected");
380 delete trtBarrel;
381 }
382 else {
383 // loop over detector elements in the barrel and add them to respective alignModules
384 for (unsigned int iLayer = 0; iLayer < m_trtDetManager->getNumerology()->getNBarrelRings(); iLayer++) // barrel layers
385 for (unsigned int iPhiModule = 0; iPhiModule < m_trtDetManager->getNumerology()->getNBarrelPhi(); iPhiModule++) // modules in phi
386 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNBarrelLayers(iLayer); iStrawLayer++) // straw layers inside one phi module
387 for (int iSide = 0; iSide < 2; iSide++) { // side of the straw
388 const TRT_BarrelElement * element = m_trtDetManager->getBarrelElement(iSide, iLayer, iPhiModule, iStrawLayer);
389 if (element) {
390 // get element location for debugging
391// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
392// ATH_MSG_DEBUG(" TRTDetectorElement id: " << element->identify() << " with center = " << center);
393
394 // add to the barrel
395 trtBarrel->addDetElement(Trk::AlignModule::TRT,element,transform);
396 // and fill the corresponding map
397 (*trtIdHashMap)[element->identifyHash()] = trtBarrel;
398 }
399 else
400 ATH_MSG_DEBUG("No TRT_BarrelElement with side-layer-phi-strawLayer:" <<iSide<<"-"<<iLayer<<"-"<<iPhiModule<<"-"<<iStrawLayer);
401 }
402
403 // add
404 m_alignModuleListPtr->push_back(trtBarrel);
405 }
406}
407
408
409//_______________________________________________________________________
411{
412 // ===========================
413 // ENDCAPs
414 // ===========================
415 ATH_MSG_INFO("Preparing the TRT Endcap geometry for L1: 2 endcaps");
416
417 // ========================================
418 // get all modules for Endcap Level 1 alignment
419 // Level 1 is endcap AlignModules
420
421 // define modules
422 // we'll stick with the base AlignModule here since we don't want to
423 // do shifting for the moment but we might need to extend AlignModule
424 // in the future
425
426 // get maximum number of elements from the helper
427 unsigned int maxHash = 0;
428 if(m_alignLevelBarrel==3)
429 maxHash = m_idHelper->straw_hash_max();
430 else
431 maxHash = m_idHelper->straw_layer_hash_max();
432 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
433
434 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
435 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
436 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
437
438 // for L1 alignment the alignment frame is equal to the global frame
439 // and since the TRT detector element positions are also stored in
440 // the global frame in DB, transform is identity
441 Amg::Transform3D transform = Amg::Transform3D::Identity();
442
443 // ENDCAPs
444 // identifiers for endcaps are set in analogy to barrel
445 // above to -2 and +2 so they can be used by
446 // idHelper->barrel_ec()
447 Trk::AlignModule * trtEndCap[2];
448 for (int iSide=0;iSide<2;iSide++) {
449 trtEndCap[iSide] = new Trk::AlignModule(this);
450 trtEndCap[iSide] -> setIdHash(getNextIDHash());
451
452 if(iSide)
453 trtEndCap[iSide]->setName("TRT EndCap C");
454 else
455 trtEndCap[iSide]->setName("TRT EndCap A");
456
457 int idSide = iSide ? 2 : -2;
458 trtEndCap[iSide]->setIdentifier(m_idHelper->barrel_ec_id(idSide));
459
460 if( !moduleSelected(trtEndCap[iSide]) || (m_endcap!=idSide && m_endcap!=0 ) ) {
461 ATH_MSG_DEBUG("Module "<<trtEndCap[iSide]->name()<<" NOT selected");
462 delete trtEndCap[iSide];
463 }
464 else {
465 for (unsigned int iWheel = 0; iWheel < m_trtDetManager->getNumerology()->getNEndcapWheels(); iWheel++)
466 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNEndcapLayers(iWheel); iStrawLayer++)
467 for(unsigned int iPhi = 0; iPhi < m_trtDetManager->getNumerology()->getNEndcapPhi(); iPhi++) {
468 const TRT_EndcapElement * element = m_trtDetManager->getEndcapElement(iSide, iWheel, iStrawLayer, iPhi);
469 if (element) {
470 // get element location for debugging
471// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
472// ATH_MSG_DEBUG(" TRTDetectorElement id: " << id << " with center = " << center);
473
474 // add element to respective AlignModule
475 trtEndCap[iSide]->addDetElement(Trk::AlignModule::TRT,element,transform);
476 // and fill the corresponding map
477 (*trtIdHashMap)[element->identifyHash()] = trtEndCap[iSide];
478 }
479 else
480 ATH_MSG_DEBUG("No TRT_EndcapElement with side-wheel-strawLayer-phi:" <<iSide<<"-"<<iWheel<<"-"<<iStrawLayer<<"-"<<iPhi);
481 }
482
483 // for endcap we move the CoG
484 Amg::Translation3D translation(trtEndCap[iSide]->centerOfGravity());
485 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
486 trtEndCap[iSide]->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
487
488 // add
489 m_alignModuleListPtr->push_back(trtEndCap[iSide]);
490 }
491 }
492}
493
494
495//_______________________________________________________________________
497{
498 // ===========================
499 // BARREL
500 // ===========================
501 ATH_MSG_INFO("Preparing the TRT Barrel geometry for L2: 3 layers with 32 modules each (96 modules)");
502
503 // ========================================
504 // get all modules for TRT Barrel Level 2 alignment
505 // Level 2 in the barrel is 3 layers with 32 phi modules each
506 // i.e. 96 AlignModules in total
507
508 // define modules
509 // we'll stick with the base AlignModule here since we don't want to
510 // do shifting for the moment but we might need to extend AlignModule
511 // in the future
512
513 // TRT detector element positions are stored in the DB in global frame
514 // so the DB frame to global frame transform is identity
515 Amg::Transform3D transform = Amg::Transform3D::Identity();
516
517 // get maximum number of elements from the helper
518 unsigned int maxHash = 0;
519 if(m_alignLevelEndcaps==3)
520 maxHash = m_idHelper->straw_hash_max();
521 else
522 maxHash = m_idHelper->straw_layer_hash_max();
523 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
524
525 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
526 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
527 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
528
529 // for the alignment frame we would like to use something like
530 // the 'center-of-gravity' (cog) of the module and the rotation
531 // of the strawlayer planes. the main problem here is that the
532 // planes are not entirely parallel. for the definition of the
533 // alignment of the module this is all irrelevant, but we would
534 // like to give the twist some meaning, like 'the rotation
535 // around the most central straw': since strawlayer planes are
536 // even and straws as well, there is no such thing as a really
537 // central straw. we'll do something that brings us as close as
538 // possible: for the central plane take strawlayer that is at
539 // (N+1)/2, where N is the maximum strawlayer. (strawlayers
540 // start counting at 0). The reason to pick the outer of the two
541 // central strawlayers is that there are more straws per layer
542 // in the outer layers and that the outer layers are also
543 // further apart, so this is closer to the 'real' cog.
544
545 for (unsigned int iPhiModule = 0; iPhiModule < m_trtDetManager->getNumerology()->getNBarrelPhi(); iPhiModule++) { // modules in phi
546 for (unsigned int iLayer = 0; iLayer < m_trtDetManager->getNumerology()->getNBarrelRings(); iLayer++) {// barrel layers
547 // create the AlignModule
548 Trk::AlignModule * mod = new Trk::AlignModule(this);
549 mod->setIdHash(getNextIDHash());
550 mod->setIdentifier(m_idHelper->module_id(-1, iPhiModule, iLayer));
551
552 std::stringstream name;
553 name<<"TRT/Barrel/Module_-1_"<<iPhiModule<<"_"<<iLayer;
554 mod->setName(name.str());
555
556 if(!moduleSelected(mod) || !moduleSelectedBarrel(iLayer,iPhiModule)) {
557 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
558 delete mod;
559 continue;
560 }
561
562 ATH_MSG_DEBUG("Building module "<<mod->name());
563
564 // create the collection of central layers for cog and transform calculation
565 std::vector<const Trk::TrkDetElementBase *> centralLayers;
566
567 int maxstrawlayer = m_trtDetManager->getNumerology()->getNBarrelLayers(iLayer);
568 ATH_MSG_DEBUG("maxstrawlayer "<<maxstrawlayer);
569 for (int iStrawLayer = 0; iStrawLayer < maxstrawlayer; iStrawLayer++) { // straw layers inside one phi module
570 ATH_MSG_DEBUG("iStrawLayer "<<iStrawLayer);
571 for (int iSide = 0; iSide < 2; iSide++) { // side of the straw
572 ATH_MSG_DEBUG("iSide "<<iSide);
573 const TRT_BarrelElement * element = m_trtDetManager->getBarrelElement(iSide, iLayer, iPhiModule, iStrawLayer);
574 if (element) {
575 // get element location for debugging
576// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
577// ATH_MSG_DEBUG(" TRTDetectorElement id: " << element->identify() << " with center = " << center);
578
579 // update maximum straw layer
580 maxstrawlayer = std::max(maxstrawlayer,m_idHelper->straw_layer(element->identify()));
581
582 // add element to respective AlignModule
583 mod->addDetElement(Trk::AlignModule::TRT,element,transform);
584
585 // and fill the corresponding map
586 (*trtIdHashMap)[element->identifyHash()] = mod;
587
588 // add central layers to centralLayers collection
589 // maxstrawlayer is probably odd (if there is an even number
590 // of strawlayers), but I could be wrong, so let's make this always work:
591 // if maxstrawlayer==23, we want to pick strawlayer 12
592 // if maxstrawlayer==24, we still want to pick strawlayer 12
593 if( iStrawLayer == maxstrawlayer/2 ) {
594 //Amg::Vector3D center = element->transform() * Amg::Vector3D(0,0,0);
595 centralLayers.push_back(element);
596 }
597 }
598 else
599 ATH_MSG_DEBUG("No TRT_BarrelElement with side-layer-phi-strawLayer:" <<iSide<<"-"<<iLayer<<"-"<<iPhiModule<<"-"<<iStrawLayer);
600 }
601 }
602
603 // This is how the frames line up for a bec=-1 module at global
604 // position (0,R,-360):
605 //
606 // global straw det-element
607 // x +x -x
608 // y +y +z
609 // z +z +y
610 //
611 // For other bec=-1 modules you just need to rotate around
612 // global y. For bec=+1 modules it looks like this:
613 //
614 // global straw det-element
615 // x -x -x
616 // y +y +z
617 // z -z +y
618 // So that just involves one rotation around local-y for the strawreference frame.
619 //
620 std::vector<std::vector<const Trk::TrkDetElementBase *> *> centralLayersVec;
621 centralLayersVec.push_back(&centralLayers);
622
623 Amg::Translation3D translation(Trk::AlignModule::centerOfGravity(centralLayersVec));
624 // for the rotation, we choose the element on the '-1' side.
625 Amg::RotationMatrix3D rotation = ( m_idHelper->barrel_ec(centralLayers.front()->identify()) == -1 ) ?
626 centralLayers.front()->transform().rotation() : centralLayers.back()->transform().rotation();
627 Amg::Transform3D localToGlobal = translation * rotation;
628
629
630
631 ATH_MSG_DEBUG("centerOfGravity "<< mod->centerOfGravity(centralLayersVec));
632 ATH_MSG_DEBUG("Prepared local to global transform : "<<std::setprecision(12)<<localToGlobal.translation()<<" "<<localToGlobal.rotation());
633
634 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
635
636 // add AlignModule to the geometry
637 m_alignModuleListPtr->push_back(mod);
638 }
639 }
640
641 }
642
643
644//_______________________________________________________________________
646{
647 // ===========================
648 // ENDCAPs
649 // ===========================
650 ATH_MSG_INFO("Preparing the TRT Endcap geometry for L2: 2 x 40 rings");
651
652 // ========================================
653 // get all modules for TRT Endcap Level 2 alignment
654 // Level 2 in the endcaps is 40 rings per endcap
655 // i.e. 40 AlignModules in total
656
657 // define modules
658 // we'll stick with the base AlignModule here since we don't want to
659 // do shifting for the moment but we might need to extend AlignModule
660 // in the future
661
662 // TRT detector element positions are stored in the DB in global frame
663 // so the DB frame to global frame transform is identity
664 Amg::Transform3D transform = Amg::Transform3D::Identity();
665
666 // get maximum number of elements from the helper
667 unsigned int maxHash = 0;
668 if(m_alignLevelBarrel==3)
669 maxHash = m_idHelper->straw_hash_max();
670 else
671 maxHash = m_idHelper->straw_layer_hash_max();
672 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
673
674 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
675 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
676 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
677
678 for (int iSide = 0; iSide < 2; iSide++) {
679 int idSide = iSide ? 2 : -2;
680 ATH_MSG_DEBUG("Side : "<<iSide<<" , idSide : "<<idSide);
681 if( m_endcap!=idSide && m_endcap!=0 ) {
682 ATH_MSG_DEBUG("Endcap "<<idSide<<" NOT aligned");
683 continue;
684 }
685
686 int iRing(-1);
687 std::unique_ptr<Trk::AlignModule> mod;
688 for (unsigned int iWheel = 0; iWheel < m_trtDetManager->getNumerology()->getNEndcapWheels(); iWheel++) {
689 ATH_MSG_DEBUG("Wheel : "<<iWheel);
690 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNEndcapLayers(iWheel); iStrawLayer++) {
691 ATH_MSG_DEBUG("StrawLayer : "<<iStrawLayer);
692
693 if(iStrawLayer%4==0) {
694 if(iRing >= 0 && mod) {
695 // before creating module for new ring we set the alignment
696 // frame for the previous one and add it to the list of modules
697 ATH_MSG_DEBUG("Setting frame for ring : "<<iRing);
698
699 // for endcap we move the CoG with no additional rotation
700 Amg::Translation3D translation(mod->centerOfGravity());
701
702 Amg::Transform3D localToGlobal = translation * Amg::RotationMatrix3D::Identity();
703
704 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
705
706 // add AlignModule to the geometry
707 m_alignModuleListPtr->push_back(mod.release());
708 }
709
710 // new ring
711 iRing++;
712
713 ATH_MSG_DEBUG("Ring : "<<iRing);
714 // create the AlignModule
715 mod= std::make_unique<Trk::AlignModule>(this);
716 mod->setIdHash(getNextIDHash());
717 // Identifier for a ring is the Identifier for the first Straw layer in that ring
718 // one ring has 4 straw layers
719 int strawLayerForRing = (iStrawLayer/4) * 4;
720 mod->setIdentifier(m_idHelper->layer_id((iSide ? 2:-2),0,iWheel,strawLayerForRing));
721
722 std::stringstream name;
723 name<<"TRT/Endcap/Module_"<<(iSide ? 2:-2)<<"_"<<iRing;
724 mod->setName(name.str());
725
726 if(!moduleSelected(mod.get())) {
727 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
728 mod.reset();
729 continue;
730 }
731
732 ATH_MSG_DEBUG("Building module "<<mod->name());
733 }
734 if (!mod) continue;
735 for(unsigned int iPhi = 0; iPhi < m_trtDetManager->getNumerology()->getNEndcapPhi(); iPhi++) {
736 const TRT_EndcapElement * element = m_trtDetManager->getEndcapElement(iSide, iWheel, iStrawLayer, iPhi);
737 if (element) {
738 // get element location for debugging
739// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
740// ATH_MSG_DEBUG(" TRTDetectorElement id: " << id << " with center = " << center);
741
742 // add element to respective AlignModule
743 mod->addDetElement(Trk::AlignModule::TRT,element,transform);
744
745 // and fill the corresponding map
746 //coverity[WRAPPER_ESCAPE]
747 (*trtIdHashMap)[element->identifyHash()] = mod.get();
748 }
749 else
750 ATH_MSG_DEBUG("No TRT_EndcapElement with side-wheel-strawLayer-phi:" <<iSide<<"-"<<iWheel<<"-"<<iStrawLayer<<"-"<<iPhi);
751 }
752 }
753 }
754
755 if (mod) {
756 // for the last ring we have to explicitly set the alignment
757 // frame add it to the list of modules here, at the end of
758 // loop over wheels
759 ATH_MSG_DEBUG("Setting frame for ring : "<<iRing);
760
761 // for endcap we move the CoG with no additional rotation
762 Amg::Translation3D translation(mod->centerOfGravity());
763 Amg::Transform3D localToGlobal = translation * Amg::RotationMatrix3D::Identity();
764
765 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
766
767 // add AlignModule to the geometry
768 m_alignModuleListPtr->push_back(mod.release());
769 }
770 }
771}
772
773
774//_______________________________________________________________________
776{
777 // !!!! WARNING !!!!
778 // !!!! This method sets up the TRT Endcap level 2 geometry which
779 // !!!! is now obsolete. The method buildL2Endcap() should be used
780 // !!!! instead !!!
781
782 // ===========================
783 // ENDCAPs
784 // ===========================
785 ATH_MSG_INFO("Preparing the _OLD_ TRT Endcap geometry for L2: 2 x 14 wheels");
786
787 // ========================================
788 // get all modules for TRT Endcap Level 2 alignment
789 // Level 2 in the endcaps is 14 wheels per endcap
790 // i.e. 28 AlignModules in total
791
792 // define modules
793 // we'll stick with the base AlignModule here since we don't want to
794 // do shifting for the moment but we might need to extend AlignModule
795 // in the future
796
797 // TRT detector element positions are stored in the DB in global frame
798 // so the DB frame to global frame transform is identity
799 Amg::Transform3D transform = Amg::Transform3D::Identity();
800
801 // get maximum number of elements from the helper
802 unsigned int maxHash = 0;
803 if(m_alignLevelBarrel==3)
804 maxHash = m_idHelper->straw_hash_max();
805 else
806 maxHash = m_idHelper->straw_layer_hash_max();
807 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
808
809 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
810 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
811 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
812
813 for (int iSide = 0; iSide < 2; iSide++) {
814 int idSide = iSide ? 2 : -2;
815 ATH_MSG_DEBUG("Side : "<<iSide<<" , idSide : "<<idSide);
816 if( m_endcap!=idSide && m_endcap!=0 ) {
817 ATH_MSG_DEBUG("Endcap "<<idSide<<" NOT aligned");
818 continue;
819 }
820
821 for (unsigned int iWheel = 0; iWheel < m_trtDetManager->getNumerology()->getNEndcapWheels(); iWheel++) {
822 // create the AlignModule
823 Trk::AlignModule * mod = new Trk::AlignModule(this);
824 mod->setIdHash(getNextIDHash());
825 mod->setIdentifier(m_idHelper->module_id(idSide,0,iWheel));
826
827 std::stringstream name;
828 name<<"TRT/Endcap/Module_"<<idSide<<"_"<<iWheel;
829 mod->setName(name.str());
830
831 if(!moduleSelected(mod)) {
832 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
833 delete mod;
834 continue;
835 }
836
837 ATH_MSG_DEBUG("Building module "<<mod->name());
838
839 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNEndcapLayers(iWheel); iStrawLayer++) {
840 for(unsigned int iPhi = 0; iPhi < m_trtDetManager->getNumerology()->getNEndcapPhi(); iPhi++) {
841 const TRT_EndcapElement * element = m_trtDetManager->getEndcapElement(iSide, iWheel, iStrawLayer, iPhi);
842 if (element) {
843 // get element location for debugging
844// HepGeom::Point3D<double> center = element->transform() * HepGeom::Point3D<double>();
845// ATH_MSG_DEBUG(" TRTDetectorElement id: " << id << " with center = " << center);
846
847 // add element to respective AlignModule
848 mod->addDetElement(Trk::AlignModule::TRT,element,transform);
849
850 // and fill the corresponding map
851 (*trtIdHashMap)[element->identifyHash()] = mod;
852 }
853 else
854 ATH_MSG_DEBUG("No TRT_EndcapElement with side-wheel-strawLayer-phi:" <<iSide<<"-"<<iWheel<<"-"<<iStrawLayer<<"-"<<iPhi);
855 }
856 }
857
858 // for endcap we move the CoG with no additional rotation
859 Amg::Translation3D translation(mod->centerOfGravity());
860 Amg::Transform3D localtoglobal = translation * Amg::RotationMatrix3D::Identity();
861
862 mod->setGlobalFrameToAlignFrameTransform(localtoglobal.inverse());
863
864 // add AlignModule to the geometry
865 m_alignModuleListPtr->push_back(mod);
866 }
867 }
868
869 }
870
871
872//_______________________________________________________________________
874{
875 // ===========================
876 // BARREL Level 3
877 // ===========================
878 ATH_MSG_INFO("Preparing the TRT Barrel geometry for L3");
879
880 // ========================================
881 // get all modules for TRT Barrel Level 3 alignment
882 // Level 3 is one AlignModule per straw
883
884 // define modules
885 // we'll stick with the base AlignModule here since we don't want to
886 // do shifting for the moment but we might need to extend AlignModule
887 // in the future
888
889 // TRT detector element positions are stored in the DB in global frame
890 // so the DB frame to global frame transform is identity
891 Amg::Transform3D transform = Amg::Transform3D::Identity();
892
893 // get maximum number of elements from the helper
894 unsigned int maxHash = m_idHelper->straw_hash_max();
895 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
896
897 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
898 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
899 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
900
901 for (unsigned int iPhiModule = 0; iPhiModule < m_trtDetManager->getNumerology()->getNBarrelPhi(); iPhiModule++) { // modules in phi
902 ATH_MSG_DEBUG("iPhiModule "<<iPhiModule);
903 for (unsigned int iLayer = 0; iLayer < m_trtDetManager->getNumerology()->getNBarrelRings(); iLayer++) {// barrel layers
904 ATH_MSG_DEBUG("iLayer "<<iLayer);
905
906 if(!moduleSelectedBarrel(iLayer,iPhiModule)) {
907 ATH_MSG_INFO("Skipping barrel layer "<<iLayer<<" phi sector "<<iPhiModule);
908 continue;
909 }
910
911 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNBarrelLayers(iLayer); iStrawLayer++) { // straw layers inside one phi module
912 ATH_MSG_DEBUG("iStrawLayer "<<iStrawLayer);
913 for (int iSide = 0; iSide < 2; iSide++) { // side of the straw
914 ATH_MSG_DEBUG("iSide "<<iSide);
915 int idSide = iSide ? 1 : -1;
916
917 const TRT_BarrelElement * element = m_trtDetManager->getBarrelElement(iSide, iLayer, iPhiModule, iStrawLayer);
918 if(element) {
919 for (unsigned int iStraw = 0; iStraw< element->nStraws(); iStraw++)
920 {
921 ATH_MSG_DEBUG("iStraw "<<iStraw);
922
923 // create the AlignModule
924 Trk::AlignModule * mod = new Trk::AlignModule(this);
925 mod->setIdHash(getNextIDHash());
926 Identifier moduleId = m_idHelper->straw_id(idSide,iPhiModule,iLayer,iStrawLayer,iStraw);
927 mod->setIdentifier(moduleId);
928
929 std::stringstream name;
930 name<<"TRT/Barrel/Straw_"<<idSide<<"_"<<iPhiModule<<"_"<<iLayer<<"_"<<iStrawLayer<<"_"<<iStraw;
931 mod->setName(name.str());
932
933 if(!moduleSelected(mod)) {
934 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
935 delete mod;
936 mod=nullptr;
937 continue;
938 }
939
940 ATH_MSG_DEBUG("Building module "<<mod->name());
941
942 // add element to respective AlignModule
943 mod->addDetElement(Trk::AlignModule::TRT, element, transform, moduleId);
944
945 // and fill the corresponding map
946 (*trtIdHashMap)[m_idHelper->straw_hash(moduleId)] = mod;
947
948 // set the align frame transform
949 Amg::Transform3D localToGlobal = element->strawTransform(iStraw);
950 Amg::RotationMatrix3D lgrot = localToGlobal.rotation();
951 ATH_MSG_DEBUG("Prepared local to global transform : "<<std::setprecision(12)
952 <<localToGlobal.translation()<<" "<<localToGlobal.rotation());
953 ATH_MSG_DEBUG(" rotation = (" << lgrot(2,1) << "," << lgrot(0,2) << "," << lgrot(1,0) << ")");
954
955 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
956
957 Amg::Transform3D aatr = element->transform();
958 Amg::RotationMatrix3D aarot = aatr.rotation();
959
960 ATH_MSG_DEBUG("Straw layer transform : "<<std::setprecision(12)
961 <<aatr.translation()<<" "<<aatr.rotation());
962 ATH_MSG_DEBUG(" rotation = (" << aarot(2,1) << "," << aarot(0,2) << "," << aarot(1,0) << ")");
963
964 // add AlignModule to the geometry
965 m_alignModuleListPtr->push_back(mod);
966 }
967 }
968 else
969 ATH_MSG_DEBUG("No TRT_BarrelElement with side-layer-phi-strawLayer:" <<iSide<<"-"<<iLayer<<"-"<<iPhiModule<<"-"<<iStrawLayer);
970 }
971 }
972 }
973 }
974
975 }
976
977//_______________________________________________________________________
979{
980 // ===========================
981 // ENDCAP Level 3
982 // ===========================
983 ATH_MSG_INFO("Preparing the TRT Endcap geometry for L3");
984
985 // ========================================
986 // get all modules for TRT Endcap Level 3 alignment
987 // Level 3 is one AlignModule per straw
988
989 // define modules
990 // we'll stick with the base AlignModule here since we don't want to
991 // do shifting for the moment but we might need to extend AlignModule
992 // in the future
993
994 // TRT detector element positions are stored in the DB in the local frame
995 // so the DB frame to local frame transform is identity
996 Amg::Transform3D transform = Amg::Transform3D::Identity();
997
998 // get maximum number of elements from the helper
999 unsigned int maxHash = m_idHelper->straw_hash_max();
1000 ATH_MSG_DEBUG("maxHash for the TRT "<<maxHash);
1001
1002 if(!m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT))
1003 m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT) = new Trk::AlignModuleList((size_t)maxHash,nullptr);
1004 Trk::AlignModuleList * trtIdHashMap = m_idHashToAlignModuleMapsPtr->at(Trk::AlignModule::TRT);
1005
1006
1007 for (int iSide = 0; iSide < 2; iSide++) { // endcap
1008 int idSide = iSide ? 2 : -2;
1009 ATH_MSG_DEBUG("Side : "<<iSide<<" , idSide : "<<idSide);
1010 if( m_endcap!=idSide && m_endcap!=0 ) {
1011 ATH_MSG_DEBUG("Endcap "<<idSide<<" NOT aligned");
1012 continue;
1013 }
1014
1015 // wheels in Z
1016 for (unsigned int iWheel = 0; iWheel < m_trtDetManager->getNumerology()->getNEndcapWheels(); iWheel++) {
1017 ATH_MSG_DEBUG("iWheel "<<iWheel);
1018
1019 // sectors in Phi
1020 for (unsigned int iPhiModule = 0; iPhiModule < m_trtDetManager->getNumerology()->getNEndcapPhi(); iPhiModule++) {
1021
1022 ATH_MSG_DEBUG("iPhiModule "<<iPhiModule);
1023
1024 if(!moduleSelectedEndcap(iWheel,iPhiModule)) {
1025 ATH_MSG_INFO("Skipping endcap wheel "<<iWheel<<" phi sector "<<iPhiModule);
1026 continue;
1027 }
1028
1029 // endcap straw layers in z (with in a wheel)
1030 for (unsigned int iStrawLayer = 0; iStrawLayer < m_trtDetManager->getNumerology()->getNEndcapLayers(iWheel); iStrawLayer++) {
1031
1032 const TRT_EndcapElement * element = m_trtDetManager->getEndcapElement(iSide, iWheel, iStrawLayer, iPhiModule);
1033
1034 if(element) {
1035 for (unsigned int iStraw = 0; iStraw< element->nStraws(); iStraw++) {
1036 ATH_MSG_DEBUG("iStraw "<<iStraw);
1037
1038 // create the AlignModule
1039 Trk::AlignModule * mod = new Trk::AlignModule(this);
1040 mod->setIdHash(getNextIDHash());
1041 Identifier moduleId = m_idHelper->straw_id(idSide,iPhiModule,iWheel,iStrawLayer,iStraw);
1042 mod->setIdentifier(moduleId);
1043
1044 std::stringstream name;
1045 name<<"TRT/Endcap/Straw_"<<idSide<<"_"<<iPhiModule<<"_"<<iWheel<<"_"<<iStrawLayer<<"_"<<iStraw;
1046 mod->setName(name.str());
1047
1048 if(!moduleSelected(mod)) {
1049 ATH_MSG_DEBUG("Module "<<mod->name()<<" NOT selected");
1050 delete mod;
1051 mod=nullptr;
1052 continue;
1053 }
1054
1055 ATH_MSG_DEBUG("Building module "<<mod->name());
1056
1057 // add element to respective AlignModule
1058 mod->addDetElement(Trk::AlignModule::TRT, element, transform, moduleId);
1059
1060 // and fill the corresponding map
1061 (*trtIdHashMap)[m_idHelper->straw_hash(moduleId)] = mod;
1062
1063 // set the align frame transform
1064 Amg::Transform3D localToGlobal = element->strawTransform(iStraw);
1065 Amg::RotationMatrix3D lgrot = localToGlobal.rotation();
1066
1067 ATH_MSG_DEBUG("Prepared local to global transform : "<<std::setprecision(12)
1068 <<localToGlobal.translation()<<" "<<localToGlobal.rotation());
1069
1070 ATH_MSG_DEBUG(" rotation = (" << lgrot(2,1) << "," << lgrot(0,2) << "," << lgrot(1,0) << ")");
1071
1072 mod->setGlobalFrameToAlignFrameTransform(localToGlobal.inverse());
1073
1074 Amg::Transform3D aatr = element->transform();
1075 Amg::RotationMatrix3D aarot = aatr.rotation();
1076
1077 ATH_MSG_DEBUG("Straw layer transform : "<<std::setprecision(12)
1078 <<aatr.translation()<<" "<<aatr.rotation());
1079 ATH_MSG_DEBUG(" rotation = (" << aarot(2,1) << "," << aarot(0,2) << "," << aarot(1,0) << ")");
1080
1081 // add AlignModule to the geometry
1082 m_alignModuleListPtr->push_back(mod);
1083 }// Straws
1084 }// if the EndcapElement Exists
1085 else
1086 ATH_MSG_DEBUG("No TRT_EndcapElement with endcap-wheel-strawLayer-phi:" <<iSide<<"-"<<iWheel<<"-"<<iStrawLayer<<"-"<<iPhiModule);
1087 }// StrawLayer
1088 }// PhiModule
1089 }// Wheel
1090 }// Endcap
1091
1092 }
1093
1094//________________________________________________________________________
1096{
1097 // prepare all parameters
1099 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransX));
1100 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransY));
1101 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::TransZ));
1102 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotX));
1103 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotY));
1104 fullModPars->push_back(new Trk::AlignPar(module,Trk::AlignModule::RotZ));
1105
1106 // set sigmas
1107 setSigmas(module,fullModPars);
1108
1109 // select active parameters based on jobOption properties
1111 for(unsigned int ipar=0;ipar<fullModPars->size();++ipar) {
1112
1113 Identifier modID = module->identify();
1114
1115 if(m_idHelper->is_barrel(modID)) {
1116 ATH_MSG_DEBUG("Barrel module with id "<<modID);
1117 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignBarrelX)
1118 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignBarrelY)
1119 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignBarrelZ)
1120 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignBarrelRotX)
1121 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignBarrelRotY)
1122 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignBarrelRotZ) ) {
1123 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1124 activeModPars->push_back(fullModPars->at(ipar));
1125 }
1126 else
1127 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1128 }
1129 else {
1130 ATH_MSG_DEBUG("Endcap module with id "<<modID);
1131 if( (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransX && m_alignEndcapX)
1132 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransY && m_alignEndcapY)
1133 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::TransZ && m_alignEndcapZ)
1134 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotX && m_alignEndcapRotX)
1135 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotY && m_alignEndcapRotY)
1136 || (fullModPars->at(ipar)->paramType() == Trk::AlignModule::RotZ && m_alignEndcapRotZ) ) {
1137 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is now active");
1138 activeModPars->push_back(fullModPars->at(ipar));
1139 }
1140 else
1141 ATH_MSG_DEBUG("parameter type "<<fullModPars->at(ipar)->paramType()<<" is NOT active");
1142 }
1143 }
1144
1145 // add to parameter lists
1146 allFullModPars->push_back(fullModPars);
1147 allActiveModPars->push_back(activeModPars);
1148}
1149
1150
1151//________________________________________________________________________
1153{
1154 for(unsigned int ipar=0;ipar<modPars->size();++ipar) {
1155 // barrel
1156 if(m_idHelper->is_barrel(module->identify()))
1157 switch(modPars->at(ipar)->paramType()) {
1159 modPars->at(ipar)->setSigma(m_sigmaBarrelX);
1160 modPars->at(ipar)->setSoftCut(m_softcutBarrelX);
1161 break;
1163 modPars->at(ipar)->setSigma(m_sigmaBarrelY);
1164 modPars->at(ipar)->setSoftCut(m_softcutBarrelY);
1165 break;
1167 modPars->at(ipar)->setSigma(m_sigmaBarrelZ);
1168 modPars->at(ipar)->setSoftCut(m_softcutBarrelZ);
1169 break;
1171 modPars->at(ipar)->setSigma(m_sigmaBarrelRotX);
1172 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotX);
1173 break;
1175 modPars->at(ipar)->setSigma(m_sigmaBarrelRotY);
1176 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotY);
1177 break;
1179 modPars->at(ipar)->setSigma(m_sigmaBarrelRotZ);
1180 modPars->at(ipar)->setSoftCut(m_softcutBarrelRotZ);
1181 break;
1182 default:
1183 break;
1184 }
1185 // end-caps
1186 else
1187 switch(modPars->at(ipar)->paramType()) {
1189 modPars->at(ipar)->setSigma(m_sigmaEndcapX);
1190 modPars->at(ipar)->setSoftCut(m_softcutEndcapX);
1191 break;
1193 modPars->at(ipar)->setSigma(m_sigmaEndcapY);
1194 modPars->at(ipar)->setSoftCut(m_softcutEndcapY);
1195 break;
1197 modPars->at(ipar)->setSigma(m_sigmaEndcapZ);
1198 modPars->at(ipar)->setSoftCut(m_softcutEndcapZ);
1199 break;
1201 modPars->at(ipar)->setSigma(m_sigmaEndcapRotX);
1202 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotX);
1203 break;
1205 modPars->at(ipar)->setSigma(m_sigmaEndcapRotY);
1206 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotY);
1207 break;
1209 modPars->at(ipar)->setSigma(m_sigmaEndcapRotZ);
1210 modPars->at(ipar)->setSoftCut(m_softcutEndcapRotZ);
1211 break;
1212 default:
1213 break;
1214 }
1215 }
1216}
1217
1218
1219//________________________________________________________________________
1221{
1223 return true;
1224
1225 int nsel = m_moduleSelection.value().size();
1226 for(int i=0;i<nsel;++i)
1227 if(m_moduleSelection.value().at(i) == id)
1228 return true;
1229
1230 return false;
1231}
1232
1233
1234//________________________________________________________________________
1236{
1237 return moduleSelected(mod->identify().get_compact());
1238}
1239
1240
1241//________________________________________________________________________
1242bool TRTGeometryManagerTool::moduleSelectedBarrel(unsigned int ilayer, unsigned int iphi)
1243{
1244 bool select = true;
1245 if(!m_barrelLayers.value().empty()) {
1246 select = false;
1247 for(unsigned int i=0;i<m_barrelLayers.value().size();i++) {
1248 if(m_barrelLayers.value()[i] == (int)ilayer) {
1249 select = true;
1250 break;
1251 }
1252 }
1253 }
1254
1255 if(!select)
1256 return false;
1257
1258 if(!m_barrelPhiSectors.value().empty()) {
1259 select = false;
1260 for(unsigned int i=0;i<m_barrelPhiSectors.value().size();i++) {
1261 if(m_barrelPhiSectors.value()[i] == (int)iphi) {
1262 select = true;
1263 break;
1264 }
1265 }
1266 }
1267
1268 return select;
1269}
1270
1271//________________________________________________________________________
1272bool TRTGeometryManagerTool::moduleSelectedEndcap(unsigned int iwheel, unsigned int iphi)
1273{
1274 bool select = true;
1275 if(!m_endcapWheels.value().empty()) {
1276 select = false;
1277 for(unsigned int i=0;i<m_endcapWheels.value().size();++i) {
1278 if(m_endcapWheels.value()[i] == (int)iwheel) {
1279 select = true;
1280 break;
1281 }
1282 }
1283 }
1284
1285 if(!select)
1286 return false;
1287
1288 if(!m_endcapPhiSectors.value().empty()) {
1289 select = false;
1290 for(unsigned int i=0;i<m_endcapPhiSectors.value().size();i++) {
1291 if(m_endcapPhiSectors.value()[i] == (int)iphi) {
1292 select = true;
1293 break;
1294 }
1295 }
1296 }
1297
1298 return select;
1299}
1300
1301
1302//________________________________________________________________________
1304{
1305 ATH_MSG_INFO("---------------------------------------------------");
1306 ATH_MSG_INFO("Summary of the alignment geometry");
1307 ATH_MSG_INFO("Number of alignable objects: "<<m_alignModuleList.size());
1308 ATH_MSG_INFO("Total number of aligment DoFs: "<<m_alignModuleTool->nAlignParameters());
1309
1310 for(unsigned int i=0;i<m_alignModuleList.size();i++) {
1311 const Trk::AlignModule * module = m_alignModuleList.at(i);
1312 //ATH_MSG_DEBUG(i<<". "<< module->name());
1313 //ATH_MSG_DEBUG(" - identifier: "<<module->identify());
1314 //ATH_MSG_DEBUG(" - has "<<module->detElementCollection(Trk::AlignModule::TRT)->size()<<" TRT modules");
1315
1316 Amg::Transform3D localtoglobal = (module->globalFrameToAlignFrame()).inverse();
1317 ATH_MSG_DEBUG(" - local to global : "<<std::setprecision(12)<<localtoglobal.translation()<<" "<<localtoglobal.rotation());
1318
1319 DataVector<Trk::AlignPar> * pars = m_alignModuleTool->getAlignPars(module);
1320 int npars = pars->size();
1321 ATH_MSG_DEBUG(" - number of active transform parameters: "<<npars);
1322 for(int j=0;j<npars;j++)
1323 ATH_MSG_DEBUG(" * par "<<j<<" \'"<<(*pars)[j]->dumpType()<<"\' : sigma = "<<(*pars)[j]->sigma()<<" , softCut = "<<(*pars)[j]->softCut());
1324 }
1325 ATH_MSG_INFO("---------------------------------------------------");
1326}
1327
1328} // end namespace
1329
#define endmsg
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
An STL vector of pointers that by default owns its pointed-to elements.
size_t size() const
Number of registered mappings.
This is an Identifier helper class for the TRT subdetector.
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.
Extended TRT_BaseElement to describe a TRT readout element, this is a planar layer with n ( order of ...
Virtual base class of TRT readout elements.
virtual IdentifierHash identifyHash() const override final
identifier hash
unsigned int nStraws() const
Number of straws in the element.
virtual Identifier identify() const override final
identifier of this detector element:
virtual const Amg::Transform3D & transform() const override final
Element Surface: Get Transform of element in Tracking frame: Amg.
const Amg::Transform3D & strawTransform(unsigned int straw) const
Straw transform - fast access in array, in Tracking frame: Amg.
Extended class of a TRT_BaseElement to describe a readout elment in the endcap.
Gaudi::Property< bool > m_alignEndcaps
Gaudi::Property< bool > m_dumpGeometry
Gaudi::Property< double > m_sigmaBarrelY
Gaudi::Property< bool > m_doModuleSelection
Gaudi::Property< double > m_softcutBarrelY
void buildL2Endcaps()
builds geometry for L2 TRT Endcapalignment Creates 80 modules - 40 rings per endcap
bool moduleSelected(Trk::AlignModule *mod)
check wheather module is selected for module pointer
Gaudi::Property< double > m_softcutBarrelZ
Gaudi::Property< bool > m_alignEndcapZ
Gaudi::Property< double > m_sigmaEndcapY
Gaudi::Property< double > m_softcutEndcapRotX
Gaudi::Property< bool > m_alignBarrel
Gaudi::Property< double > m_sigmaBarrelX
void setSigmas(Trk::AlignModule *mod, DataVector< Trk::AlignPar > *modPars)
sets sigmas for modules
void buildL2EndcapsOLD()
builds geometry for L2 TRT Endcapalignment Creates 28 modules - 14 wheels per endcap
PublicToolHandle< Trk::IAlignModuleTool > m_alignModuleTool
pointer to AlignModuleTool
bool checkAlignLevelEndcaps()
check whether the Endcap alignment level is correct
std::vector< Trk::AlignModuleList * > m_idHashToAlignModuleMaps
Gaudi::Property< double > m_softcutEndcapZ
Gaudi::Property< bool > m_alignBarrelY
Gaudi::Property< bool > m_alignBarrelZ
void dumpGeometry()
print basic geometry info to screen
Gaudi::Property< bool > m_alignEndcapRotY
void buildL0()
builds geometry for L1 TRT alignment Creates 1 module - the whole TRT
Gaudi::Property< double > m_sigmaBarrelRotX
Gaudi::Property< std::vector< int > > m_endcapWheels
list of endcap wheels to align (if empty, align everything)
Gaudi::Property< bool > m_alignEndcapRotZ
Gaudi::Property< int > m_alignLevelProp
property, copied to m_alignLevel in initialize()
Gaudi::Property< std::vector< int > > m_barrelLayers
list of barrel layers to align (if empty, align everything)
Gaudi::Property< int > m_alignLevelEndcapsProp
property, copied to m_alignLevelEndcaps in initialize()
Gaudi::Property< double > m_softcutEndcapRotZ
const InDetDD::TRT_DetectorManager * m_trtDetManager
pointer to TRT detector manager
Gaudi::Property< bool > m_alignBarrelRotY
Gaudi::Property< double > m_sigmaEndcapX
bool moduleSelectedEndcap(unsigned int iwheel, unsigned int iphi)
check wheather we are aligning the different endcaps and sectors
Gaudi::Property< std::vector< int > > m_endcapPhiSectors
list of endcap phi sectors to align (if empty, align everything)
Gaudi::Property< double > m_sigmaEndcapRotY
Gaudi::Property< bool > m_alignEndcapY
Gaudi::Property< double > m_sigmaBarrelZ
void buildGeometry()
builds geometry for TRT alignment
DataVector< DataVector< Trk::AlignPar > > * m_fullAlignParList
Gaudi::Property< double > m_softcutBarrelRotY
void buildL3Barrel()
builds geometry for L3 TRT Barrel alignment Creates many modules - one module per straw
Gaudi::Property< bool > m_alignEndcapX
Gaudi::Property< bool > m_alignBarrelRotZ
Gaudi::Property< double > m_sigmaEndcapRotZ
Gaudi::Property< double > m_sigmaEndcapRotX
Gaudi::Property< bool > m_alignBarrelX
bool moduleSelectedBarrel(unsigned int iLayer, unsigned int iPhi)
check wheather barrel module is selected by layer and phi
Gaudi::Property< double > m_softcutEndcapY
Gaudi::Property< std::vector< int > > m_barrelPhiSectors
list of barrel phi sectors to align (if empty, align everything)
void buildL1Endcaps()
builds geometry for L1 TRT Endcap alignment Creates 2 modules, one for each endcap
Gaudi::Property< double > m_sigmaBarrelRotY
Gaudi::Property< bool > m_alignEndcapRotX
Gaudi::Property< double > m_sigmaEndcapZ
Gaudi::Property< double > m_sigmaBarrelRotZ
void buildL1Barrel()
builds geometry for L1 TRT Barrel alignment Creates single module for barrel
Gaudi::Property< double > m_softcutBarrelRotZ
Gaudi::Property< double > m_softcutEndcapX
void buildL3Endcap()
builds geometry for L3 TRT Endcap alignment Creates many modules - one module per straw
Gaudi::Property< double > m_softcutBarrelX
void buildL2Barrel()
builds geometry for L2 TRT Barrel alignment Creates 96 modules - 3 layers with 32 modules per layer
Gaudi::Property< int > m_endcap
endcap_id of the endcap to align (-2 or 2 for endcap A or C, 0 for both)
Gaudi::Property< std::vector< unsigned long long > > m_moduleSelection
int ReadGeometry(int solveLevel)
read the geometry Method is called from the main AlignAlg to build the geometry based on the requeste...
DataVector< DataVector< Trk::AlignPar > > * m_alignParList
Gaudi::Property< double > m_softcutBarrelRotX
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()
Gaudi::Property< double > m_softcutEndcapRotY
Gaudi::Property< int > m_alignLevelBarrelProp
property, copied to m_alignLevelBarrel in initialize()
bool checkAlignLevel()
check whether the alignment level is correct
Gaudi::Property< bool > m_alignBarrelRotX
bool checkAlignLevelBarrel()
check whether the Barrel alignment level is correct
static Amg::Vector3D centerOfGravity(const std::vector< DetElementCollection * > &)
Calculates center of gravity (average center of associated det-elements).
void setIdHash(IdentifierHash id)
Definition AlignModule.h:94
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...
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
std::vector< AlignModule * > AlignModuleList
Definition index.py:1
MsgStream & msg
Definition testRead.cxx:32