ATLAS Offline Software
CreateMisalignAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // ================================================
7 // CreateMisalignAlg
8 // ================================================
9 //
10 // CreateMisalignAlg.cxx
11 // Source file for CreateMisalignAlg
12 //
13 // Namespace LocalChi2Align
14 // Header include
15 
16 // Gaudi & StoreGate
17 #include "GaudiKernel/ITHistSvc.h"
18 #include "GaudiKernel/SmartDataPtr.h" //NTupleFilePtr
19 #include "GaudiKernel/RndmGenerators.h"
20 #include "GaudiKernel/IRndmGenSvc.h"
21 
22 // Geometry Stuff
23 #include "Identifier/Identifier.h"
26 #include "InDetIdentifier/SCT_ID.h"
27 #include "InDetIdentifier/TRT_ID.h"
33 
34 // Alignment DB Stuff
37 #include "AthenaKernel/IOVRange.h"
38 #include "CreateMisalignAlg.h"
41 #include <cmath>
42 #include <tuple> //for tuple decomposition and std::ignore
43 #include <sstream>
44 
45 
46 
48 
49 
50 namespace{
51  std::string commonAlignmentOutput(const HepGeom::Transform3D & initialAlignment){
52  std::ostringstream os;
53  os << "\nAlignment x = (" << initialAlignment.getTranslation().x() / CLHEP::micrometer << ") micron\n";
54  os << "Alignment y = (" << initialAlignment.getTranslation().y() / CLHEP::micrometer << ") micron\n";
55  os << "Alignment z = (" << initialAlignment.getTranslation().z() / CLHEP::micrometer << ") micron\n";
56  os << "Alignment x phi = (" << initialAlignment.getRotation().phiX() / CLHEP::deg << ") degree\n";
57  os << "Alignment x Theta = (" << initialAlignment.getRotation().thetaX() / CLHEP::deg << ") degree\n";
58  os << "Alignment y phi = (" << initialAlignment.getRotation().phiY() / CLHEP::deg << ") degree\n";
59  os << "Alignment y Theta = (" << initialAlignment.getRotation().thetaY() / CLHEP::deg << ") degree\n";
60  os << "Alignment z phi = (" << initialAlignment.getRotation().phiZ() / CLHEP::deg << ") degree\n";
61  os << "Alignment z Theta = (" << initialAlignment.getRotation().thetaZ() / CLHEP::deg << ") degree\n";
62  return os.str();
63  }
64 }
65 
66 namespace InDetAlignment
67 {
68 
69  // Constructor
70  CreateMisalignAlg::CreateMisalignAlg(const std::string& name, ISvcLocator* pSvcLocator):
71  AthAlgorithm(name,pSvcLocator),
72  m_idHelper(nullptr),
73  m_pixelIdHelper(nullptr),
74  m_sctIdHelper(nullptr),
75  m_trtIdHelper(nullptr),
76  m_IDAlignDBTool("InDetAlignDBTool",this),
77  m_trtaligndbservice("TRT_AlignDbSvc",name),
78  m_asciiFileNameBase("MisalignmentSet"),
79  m_SQLiteTag("test_tag"),
80  m_firstEvent(true),
81  m_createFreshDB(true),
82  m_MisalignmentMode(0),
83  m_nEvents(0),
84  m_translation(true),
85  m_rotation(true),
86  m_local_translation{0., 0., 0.},
87  m_local_rotation{0., 0., 0.},
88  m_index(""),
89  m_Misalign_maxShift(1*CLHEP::mm),
90  m_Misalign_maxShift_Inner(50*CLHEP::micrometer),
91  m_ScalePixelIBL(1.),
92  m_ScalePixelDBM(1.),
93  m_IBLBowingTshift(0.),
94  m_ScalePixelBarrel(1.),
95  m_ScalePixelEndcap(1.),
96  m_ScaleSCTBarrel(1.),
97  m_ScaleSCTEndcap(1.),
98  m_ScaleTRTBarrel(1.),
99  m_ScaleTRTEndcap(1.),
100  m_VisualizationLookupTree(nullptr),
101  m_AthenaHashedID(-1),
102  m_HumanReadableID(-1),
103  m_doPix(true),
104  m_doStrip(true),
105  m_doTRT(true)
106  {
107  declareProperty("ASCIIFilenameBase" , m_asciiFileNameBase);
108  declareProperty("SQLiteTag" , m_SQLiteTag);
109  declareProperty("MisalignMode" , m_MisalignmentMode);
110  declareProperty("Translation" , m_translation);
111  declareProperty("Rotation" , m_rotation);
112  declareProperty("Local_Translation" , m_local_translation);
113  declareProperty("Local_Rotation" , m_local_rotation);
114  declareProperty("Index" , m_index);
115  declareProperty("MaxShift" , m_Misalign_maxShift);
116  declareProperty("MaxShiftInner" , m_Misalign_maxShift_Inner);
117  declareProperty("CreateFreshDB" , m_createFreshDB);
118  declareProperty("IDAlignDBTool" , m_IDAlignDBTool);
119  declareProperty("TRTAlignDBService" , m_trtaligndbservice);
120  declareProperty("ScalePixelIBL" , m_ScalePixelIBL);
121  declareProperty("ScalePixelDBM" , m_ScalePixelDBM);
122  declareProperty("IBLBowingTshift" , m_IBLBowingTshift);
123  declareProperty("ScalePixelBarrel" , m_ScalePixelBarrel);
124  declareProperty("ScalePixelEndcap" , m_ScalePixelEndcap);
125  declareProperty("ScaleSCTBarrel" , m_ScaleSCTBarrel);
126  declareProperty("ScaleSCTEndcap" , m_ScaleSCTEndcap);
127  declareProperty("ScaleTRTBarrel" , m_ScaleTRTBarrel);
128  declareProperty("ScaleTRTEndcap" , m_ScaleTRTEndcap);
129  }
130 
131  //__________________________________________________________________________
132  // Destructor
134  {
135  ATH_MSG_DEBUG( "CreateMisalignAlg destructor called" );
136  }
137 
138  //__________________________________________________________________________
140  {
141  ATH_MSG_DEBUG("CreateMisalignAlg initialize()");
142  if(m_pixelDetEleCollKey.empty()) {m_doPix=false;ATH_MSG_INFO("Not creating misalignment for Pixel");}
143  if(m_SCTDetEleCollKey.empty()) {m_doStrip=false;ATH_MSG_INFO("Not creating misalignment for Strip/SCT");}
144  if(m_trtDetEleCollKey.empty()) {m_doTRT=false;ATH_MSG_INFO("Not creating misalignment for TRT");}
145 
149 
150  if (m_doPix || m_doStrip) ATH_CHECK(m_IDAlignDBTool.retrieve());
151  if(m_doTRT) ATH_CHECK(m_trtaligndbservice.retrieve());
152  //ID helpers
153  // Pixel
154  if(m_doPix){
155  ATH_CHECK(detStore()->retrieve(m_pixelIdHelper, "PixelID"));
156  }
157  // SCT
158  if(m_doStrip){
159  ATH_CHECK(detStore()->retrieve(m_sctIdHelper, "SCT_ID"));
160  }
161  // TRT
162  if(m_doTRT){
163  ATH_CHECK(detStore()->retrieve(m_trtIdHelper, "TRT_ID"));
164  }
165  ATH_CHECK(detStore()->retrieve(m_idHelper, "AtlasID"));
166 
167  // Retrieve the Histo Service
168  SmartIF<ITHistSvc> hist_svc{Gaudi::svcLocator()->service("THistSvc")};
169  ATH_CHECK(hist_svc.isValid());
170  //Registering TTree for Visualization Lookup
171  m_VisualizationLookupTree = new TTree("IdentifierTree", "Visualization Identifier Lookup Tree");
172  ATH_CHECK(hist_svc->regTree("/IDENTIFIERTREE/IdentifierTree", m_VisualizationLookupTree));
173  m_VisualizationLookupTree->Branch ("AthenaHashedID", &m_AthenaHashedID, "AthenaID/i");
174  m_VisualizationLookupTree->Branch ("HumanReadableID", &m_HumanReadableID, "HumanID/I");
175 
176  // initialize generated Initial Alignment NTuple
177  NTupleFilePtr file1(ntupleSvc(), "/NTUPLES/CREATEMISALIGN");
178 
179  NTuplePtr nt(ntupleSvc(), "/NTUPLES/CREATEMISALIGN/InitialAlignment");
180  if ( !nt ) { // Check if already booked
181  nt = ntupleSvc()->book("/NTUPLES/CREATEMISALIGN/InitialAlignment", CLID_ColumnWiseTuple, "InitialAlignment");
182  if ( nt ) {
183  ATH_MSG_INFO( "InitialAlignment ntuple booked." );
184  ATH_CHECK( nt->addItem("x" ,m_AlignResults_x) );
185  ATH_CHECK( nt->addItem("y" ,m_AlignResults_y) );
186  ATH_CHECK( nt->addItem("z" ,m_AlignResults_z) );
187  ATH_CHECK( nt->addItem("alpha" ,m_AlignResults_alpha) );
188  ATH_CHECK( nt->addItem("beta" ,m_AlignResults_beta) );
189  ATH_CHECK( nt->addItem("gamma" ,m_AlignResults_gamma) );
190  ATH_CHECK( nt->addItem("ID" ,m_AlignResults_Identifier_ID) );
191  ATH_CHECK( nt->addItem("PixelSCT" ,m_AlignResults_Identifier_PixelSCT) );
192  ATH_CHECK( nt->addItem("BarrelEC" ,m_AlignResults_Identifier_BarrelEC) );
193  ATH_CHECK( nt->addItem("LayerDisc" ,m_AlignResults_Identifier_LayerDisc) );
194  ATH_CHECK( nt->addItem("Phi" ,m_AlignResults_Identifier_Phi) );
195  ATH_CHECK( nt->addItem("Eta" ,m_AlignResults_Identifier_Eta) );
196  ATH_CHECK( nt->addItem("center_x" ,m_Initial_center_x ) );
197  ATH_CHECK( nt->addItem("center_y" ,m_Initial_center_y ) );
198  ATH_CHECK( nt->addItem("center_z" ,m_Initial_center_z ) );
199  ATH_CHECK( nt->addItem("misaligned_global_x" ,m_Global_center_x ) );
200  ATH_CHECK( nt->addItem("misaligned_global_y" ,m_Global_center_y ) );
201  ATH_CHECK( nt->addItem("misaligned_global_z" ,m_Global_center_z ) );
202  } else { // did not manage to book the N tuple....
203  msg(MSG::ERROR) << "Failed to book InitialAlignment ntuple." << endmsg;
204  }
205  }
206 
207  if (m_MisalignmentMode) {
208  ATH_MSG_INFO( "Misalignment mode chosen: " << m_MisalignmentMode );
209  if (m_MisalignmentMode == 1) {
210  ATH_MSG_INFO( "MisalignmentX : " << m_Misalign_x / CLHEP::micrometer << " micrometer" );
211  ATH_MSG_INFO( "MisalignmentY : " << m_Misalign_y / CLHEP::micrometer << " micrometer" );
212  ATH_MSG_INFO( "MisalignmentZ : " << m_Misalign_z / CLHEP::micrometer << " micrometer" );
213  ATH_MSG_INFO( "MisalignmentAlpha : " << m_Misalign_alpha / CLHEP::mrad << " mrad" );
214  ATH_MSG_INFO( "MisalignmentBeta : " << m_Misalign_beta / CLHEP::mrad << " mrad" );
215  ATH_MSG_INFO( "MisalignmentGamma : " << m_Misalign_gamma / CLHEP::mrad << " mrad" );
216  } else {
217  ATH_MSG_INFO( "with maximum shift of " << m_Misalign_maxShift / CLHEP::micrometer << " micrometer" );
218  }
219  } else {
220  ATH_MSG_INFO( "Dry run, no misalignment will be generated." );
221  }
222 
223  return StatusCode::SUCCESS;
224  }
225 
226  //__________________________________________________________________________
228  {
229  ATH_MSG_DEBUG( "AlignAlg execute()" );
230  ++m_nEvents;
231 
232  if (m_firstEvent) {
233  int nSCT = 0;
234  int nPixel = 0;
235  int nTRT = 0;
236 
237  if (m_createFreshDB) {
238  m_IDAlignDBTool->createDB();
239  //m_trtaligndbservice->createAlignObjects(); //create DB for TRT? should be ok... //TODO
240  }
241 
242  if(m_doPix) setupPixel_AlignModule(nPixel);
244  if(m_doTRT) setupTRT_AlignModule(nTRT);
245 
246  ATH_MSG_INFO( "Back from AlignModuleObject Setup. " );
247  ATH_MSG_INFO( nPixel << " Pixel modules found." );
248  ATH_MSG_INFO( nSCT << " SCT modules found," );
249  ATH_MSG_INFO( nTRT << " TRT modules found." );
250 
251  ATH_MSG_INFO( m_ModuleList.size() << " entries in identifier list" );
252 
253  if (StatusCode::SUCCESS!=GenerateMisaligment()) {
254  ATH_MSG_ERROR( "GenerateMisalignment failed!" );
255  return StatusCode::FAILURE;
256  };
257 
258  m_firstEvent = false;
259  }
260 
261  return StatusCode::SUCCESS;
262  }
263 
264  //__________________________________________________________________________
266  {
267  ATH_MSG_DEBUG("CreateMisalignAlg finalize()" );
268 
269  m_ModuleList.clear();
270 
271  return StatusCode::SUCCESS;
272  }
273 
274  //__________________________________________________________________________
276  {
277  // SiDetectorElementCollection for SCT
279  const InDetDD::SiDetectorElementCollection* elements(*sctDetEleHandle);
280  if (not sctDetEleHandle.isValid() or elements==nullptr) {
281  ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " is not available.");
282  return;
283  }
284  for (const InDetDD::SiDetectorElement *element: *elements) {
285  const Identifier SCT_ModuleID = m_sctIdHelper->module_id(element->identify()); //from wafer id to module id
286  const IdentifierHash SCT_ModuleHash = m_sctIdHelper->wafer_hash(SCT_ModuleID);
287 
288  if (m_ModuleList.find(SCT_ModuleID) == m_ModuleList.end())
289  {
290  const InDetDD::SiDetectorElement *module = elements->getDetectorElement(SCT_ModuleHash);
291  m_ModuleList[SCT_ModuleID][0] = module->center()[0];
292  m_ModuleList[SCT_ModuleID][1] = module->center()[1];
293  m_ModuleList[SCT_ModuleID][2] = module->center()[2];
294  ++nSCT;
295  ATH_MSG_VERBOSE( "SCT module " << nSCT );
296  }
297 
298  if (m_sctIdHelper->side(element->identify()) == 0) { // inner side case
299  // Write out Visualization Lookup Tree
300  m_AthenaHashedID = SCT_ModuleID.get_identifier32().get_compact();
301  m_HumanReadableID = 1000000*2 /*2 = SCT*/
302  + 100000*m_sctIdHelper->layer_disk(SCT_ModuleID)
303  + 1000*(10+m_sctIdHelper->eta_module(SCT_ModuleID))
304  + m_sctIdHelper->phi_module(SCT_ModuleID);
305  if ( m_sctIdHelper->barrel_ec(SCT_ModuleID) != 0 ) {
306  m_HumanReadableID = m_sctIdHelper->barrel_ec(SCT_ModuleID)*(m_HumanReadableID + 10000000);
307  }
308 
309  ATH_MSG_VERBOSE( "Human Readable ID: " << m_HumanReadableID );
310 
312 
313  // Syntax is (ID, Level) where Level is from 1 to 3 (3 is single module level)
314  if (msgLvl(MSG::VERBOSE)) {
315  HepGeom::Transform3D InitialAlignment = Amg::EigenTransformToCLHEP(m_IDAlignDBTool->getTrans(SCT_ModuleID,3));
316  msg() << "Initial Alignment of module " << m_idHelper->show_to_string(SCT_ModuleID,nullptr,'/') << endmsg;
317  msg() << commonAlignmentOutput(InitialAlignment);
318  msg() << endmsg;
319  }
320  } // end inner side case
321  } //end loop over SCT elements
322  }
323 
324  //__________________________________________________________________________
326  {
327  // SiDetectorElementCollection for Pixel
329  const InDetDD::SiDetectorElementCollection* elements(*pixelDetEleHandle);
330  if (not pixelDetEleHandle.isValid() or elements==nullptr) {
331  ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
332  return;
333  }
334  for (const InDetDD::SiDetectorElement *element: *elements) {
335  // get the ID
336  const Identifier Pixel_ModuleID = element->identify();
337  const IdentifierHash Pixel_ModuleHash = m_pixelIdHelper->wafer_hash(Pixel_ModuleID);
338  // check the validity
339  if (Pixel_ModuleID.is_valid()) {
340  if (m_ModuleList.find(Pixel_ModuleID) == m_ModuleList.end()) {
341  const InDetDD::SiDetectorElement *module = elements->getDetectorElement(Pixel_ModuleHash);
342  m_ModuleList[Pixel_ModuleID][0] = module->center()[0];
343  m_ModuleList[Pixel_ModuleID][1] = module->center()[1];
344  m_ModuleList[Pixel_ModuleID][2] = module->center()[2];
345 
346  ++nPixel;
347  ATH_MSG_VERBOSE( "Pixel module " << nPixel );
348 
349  // Write out Visualization Lookup Tree
350  m_AthenaHashedID = Pixel_ModuleID.get_identifier32().get_compact();
351  m_HumanReadableID = 1000000*1 /*1 = Pixel*/
352  + 100000*m_pixelIdHelper->layer_disk(Pixel_ModuleID)
353  + 1000*(10+m_pixelIdHelper->eta_module(Pixel_ModuleID))
354  + m_pixelIdHelper->phi_module(Pixel_ModuleID);
355  if ( m_pixelIdHelper->barrel_ec(Pixel_ModuleID) != 0 ) {
356  m_HumanReadableID = m_pixelIdHelper->barrel_ec(Pixel_ModuleID)*(m_HumanReadableID + 10000000);
357  }
358 
359  ATH_MSG_VERBOSE( "Human Readable ID: " << m_HumanReadableID );
360 
362 
363  if (msgLvl(MSG::VERBOSE)) {
364  HepGeom::Transform3D InitialAlignment = Amg::EigenTransformToCLHEP(m_IDAlignDBTool->getTrans(Pixel_ModuleID,3));
365  msg() << "Initial Alignment of module " << m_idHelper->show_to_string(Pixel_ModuleID,nullptr,'/') << endmsg;
366  msg() << commonAlignmentOutput(InitialAlignment);
367  msg() << endmsg;
368  }
369  }
370  } else {
371  ATH_MSG_INFO( "not a valid PIXEL Module ID (setup)" );
372  }
373  }
374  }
375 
376  //__________________________________________________________________________
378  {
379  //TODO: writing into the Identifier tree is undone for TRT (AthenaHashedID and HumanReadableID)
380 
381  std::map< Identifier, std::vector<double> > trtModulesWithCOG;
382 
383  // TRT_DetElementContainer->TRT_DetElementCollection for TRT
385  const InDetDD::TRT_DetElementCollection* elements(trtDetEleHandle->getElements());
386  if (not trtDetEleHandle.isValid() or elements==nullptr) {
387  ATH_MSG_FATAL(m_trtDetEleCollKey.fullKey() << " is not available.");
388  return;
389  }
390 
391  //step through all detector elements (=strawlayers) and accumulate strawcenters per
392  // element (with DB granularity, i.e. phi sectors in endcap, bi-modules in barrel)
393  for (const InDetDD::TRT_BaseElement *element: *elements) {
394  const Identifier TRTID_orig = element->identify();
395  const Identifier TRTID = reduceTRTID(TRTID_orig);
396  bool insertSuccess{};
397  std::tie(std::ignore, insertSuccess) = trtModulesWithCOG.insert({TRTID,std::vector<double>(4,0.)}); //create fresh vector for module center
398  if (not insertSuccess){
399  ATH_MSG_VERBOSE("No insert was performed, identifier was already in the trtModulesWithCOG map");
400  }
401 
402  unsigned int nStraws = element->nStraws();
403  for (unsigned int l = 0; l<nStraws; l++) {
404  const Amg::Vector3D strawcenter = element->strawCenter(l);
405  trtModulesWithCOG[TRTID].at(0) += strawcenter.x(); /*sumx*/
406  trtModulesWithCOG[TRTID].at(1) += strawcenter.y(); /*sumy*/
407  trtModulesWithCOG[TRTID].at(2) += strawcenter.z(); /*sumz*/
408  trtModulesWithCOG[TRTID].at(3) += 1.; /*nStraws*/
409 
410  }
411 
412  ATH_MSG_DEBUG( "this strawlayer has " << nStraws << " straws." );
413  ATH_MSG_DEBUG( "strawcount of this module: " << trtModulesWithCOG[TRTID].at(3) );
414 
415  }
416 
417  //go through cog list and create one COG per TRT module (at DB granularity)
418  std::map< Identifier, std::vector<double> >::const_iterator iter2;
419  for (iter2 = trtModulesWithCOG.begin(); iter2!=trtModulesWithCOG.end(); ++iter2) {
420  const Identifier TRTID = iter2->first;
421  double nStraws = iter2->second.at(3);
422  nTRT++;
423  ATH_MSG_VERBOSE( "TRT module " << nTRT );
424  m_ModuleList[TRTID] = HepGeom::Point3D<double>(iter2->second.at(0)/nStraws, iter2->second.at(1)/nStraws,iter2->second.at(2)/nStraws);
425 
426  HepGeom::Transform3D InitialAlignment ;
427 
428  const Amg::Transform3D* p = m_trtaligndbservice->getAlignmentTransformPtr(TRTID,2) ;
429  if ( p ) {
430  if (msgLvl(MSG::VERBOSE)) {
431  InitialAlignment = Amg::EigenTransformToCLHEP(*p) ;
432  msg() << "Initial Alignment of module " << m_idHelper->show_to_string(TRTID,nullptr,'/') << endmsg;
433  msg() << commonAlignmentOutput(InitialAlignment);
434  msg() << endmsg;
435  }
436  } else {
437 
438  ATH_MSG_VERBOSE("No initial alignment for TRT module " << m_idHelper->show_to_string(TRTID,nullptr,'/') );
439  }
440 
441 
442  }
443  }
444 
445  //__________________________________________________________________________
447  {
448 
449  SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
450  ATH_CHECK(randsvc.isValid());
451  ATH_MSG_DEBUG( "Got RndmGenSvc" );
452 
453  int i = 0;
454 
455  /*
456  ===================================
457  Documentation of misalignment modes
458  ===================================
459 
460  MisalignMode =
461  0: nothing, no misalignments are generated
462  1: Misalignment of whole InDet by 6 parameters
463  2: random misalignment
464  3: IBL-stave temperature dependent bowing
465 
466  ====================================================
467  Global Distortions according to David Brown (LHC Detector Alignment Workshop 2006-09-04, slides page 11)
468  ====================================================
469  11: R delta R: Radial expansion linearly with r
470  12: Phi delta R: radial expansion sinuisoidally with phi
471  13: Z delta R: radial expansion linearly with z
472  21: R delta Phi: rotation linearly with r
473  22: Phi delta Phi: rotation sinusoidally with phi
474  23: Z delta Phi: rotation linearly with z
475  31: R delta Z: z-shift linearly with r
476  32: Phi delta Z: z-shift sinusoidally with phi
477  33: Z delta Z: z-shift linearly with z
478  */
479 
480  const double maxRadius=51.4*CLHEP::cm; // maximum radius of Silicon Detector (=outermost SCT radius)
481  const double minRadius=50.5*CLHEP::mm; // minimum radius of Silicon Detector (=innermost PIX radius)
482  const double maxLength=158.*CLHEP::cm; // maximum length of Silicon Detector barrel (=length of SCT barrel)
483 
484  const double maxDeltaR = m_Misalign_maxShift;
485  const double maxAngle = 2 * asin( m_Misalign_maxShift / (2*maxRadius));
486  const double maxAngleInner = 2 * asin ( m_Misalign_maxShift_Inner / (2*minRadius));
487  const double maxDeltaZ = m_Misalign_maxShift;
488  ATH_MSG_DEBUG( "maximum deltaPhi = " << maxAngle/CLHEP::mrad << " mrad" );
489  ATH_MSG_DEBUG( "maximum deltaPhi for 1/r term = " << maxAngleInner/CLHEP::mrad << " mrad" );
490  const InDetDD::SiDetectorElementCollection* pixelElements=nullptr;
491  const InDetDD::SiDetectorElementCollection* sctElements=nullptr;
492  if(m_doPix){
493  // SiDetectorElementCollection for Pixel
495  pixelElements = *pixelDetEleHandle;
496  if (not pixelDetEleHandle.isValid() or pixelElements==nullptr) {
497  ATH_MSG_FATAL(m_pixelDetEleCollKey.fullKey() << " is not available.");
498  return StatusCode::FAILURE;
499  }
500  }
501  if(m_doStrip){
502  // SiDetectorElementCollection for SCT
504  sctElements = *sctDetEleHandle;
505  if (not sctDetEleHandle.isValid() or sctElements==nullptr) {
506  ATH_MSG_FATAL(m_SCTDetEleCollKey.fullKey() << " is not available.");
507  return StatusCode::FAILURE;
508  }
509  }
510 
511  for (std::map<Identifier, HepGeom::Point3D<double> >::const_iterator iter = m_ModuleList.begin(); iter != m_ModuleList.end(); ++iter) {
512  ++i;
513  const Identifier& ModuleID = iter->first;
514 
515  const InDetDD::SiDetectorElement * SiModule = nullptr; //dummy to get moduleTransform() for silicon
516 
517  if (m_idHelper->is_pixel(ModuleID)) {
518  const IdentifierHash Pixel_ModuleHash = m_pixelIdHelper->wafer_hash(ModuleID);
519  if(pixelElements) SiModule = pixelElements->getDetectorElement(Pixel_ModuleHash);
520  else ATH_MSG_WARNING("Trying to access a Pixel module when running with no Pixel!");
521  //module = SiModule;
522  } else if (m_idHelper->is_sct(ModuleID)) {
523  const IdentifierHash SCT_ModuleHash = m_sctIdHelper->wafer_hash(ModuleID);
524  if(sctElements) SiModule = sctElements->getDetectorElement(SCT_ModuleHash);
525  else ATH_MSG_WARNING("Trying to access an SCT/Strop module when running with no SCT/Strip!");
526  //module = SiModule;OB
527  } else if (m_idHelper->is_trt(ModuleID)) {
528  //module = m_TRT_Manager->getElement(ModuleID);
529  //const InDetDD::TRT_BaseElement *p_TRT_Module = m_TRT_Manager->getElement(iter->second.moduleID());
530  } else {
531  ATH_MSG_WARNING( "Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
532  }
533 
534  //TRT alignment transformations are given in global frame in DB,
535  // that's not fully correct, since the level2 transform can rotate the system in which level1 transforms
536  // are applied ...
537 
538  //Si have a local coordinate system
539  // Take care: For SCT we have to ensure that module's
540  // system is taken, not the system of one of the wafers!
541  HepGeom::Transform3D localToGlobal = HepGeom::Transform3D();
542  if ((not m_idHelper->is_trt(ModuleID))){
543  if (SiModule){
544  localToGlobal=Amg::EigenTransformToCLHEP(SiModule->moduleTransform());
545  } else {
546  ATH_MSG_WARNING("Apparently in a silicon detector, but SiModule is a null pointer");
547  }
548  }
549  const HepGeom::Point3D<double> center = iter->second;
550 
551  //center of module in global coordinates
552  double r = center.rho(); //distance from beampipe
553  double phi = center.phi();
554  double z = center.z();
555 
556  HepGeom::Transform3D parameterizedTrafo;
557  HepGeom::Transform3D alignmentTrafo;
558 
559 
560  // prepare scale factor for different subsystems:
561  double ScaleFactor = 1.;
562 
563  if (m_idHelper->is_pixel(ModuleID))
564  {
565  if (m_pixelIdHelper->is_barrel(ModuleID)) {
566  ScaleFactor=m_ScalePixelBarrel;
567  }
568  else {
569  ScaleFactor=m_ScalePixelEndcap;
570  }
571  if (m_pixelIdHelper->is_blayer(ModuleID)) { // IBL
572  ScaleFactor=m_ScalePixelIBL;
573  }
574  if (m_pixelIdHelper->is_dbm(ModuleID)) { // DBM
575  ScaleFactor=m_ScalePixelDBM;
576  }
577 
578  } else if (m_idHelper->is_sct(ModuleID))
579  {
580  if (m_sctIdHelper->is_barrel(ModuleID)) {
581  ScaleFactor=m_ScaleSCTBarrel;
582  }
583  else {
584  ScaleFactor=m_ScaleSCTEndcap;
585  }
586 
587  } else if (m_idHelper->is_trt(ModuleID))
588  {
589  if (m_trtIdHelper->is_barrel(ModuleID)) {
590  ScaleFactor=m_ScaleTRTBarrel;
591  }
592  else {
593  ScaleFactor=m_ScaleTRTEndcap;
594  }
595  } else {
596  ATH_MSG_WARNING( "Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
597  }
598 
599 
600 
601  ATH_MSG_INFO( "ID Module " << i << " with ID " << m_idHelper->show_to_string(ModuleID,nullptr,'/') );
602  if (msgLvl(MSG::DEBUG)) {
603  msg() << "radius " << r / CLHEP::cm << " centimeter" << endmsg;
604  msg() << "phi " << phi << endmsg;
605  msg() << "z " << z / CLHEP::cm << " centimeter" << endmsg;
606  if (msgLvl(MSG::VERBOSE)) {
607  msg() << "localToGlobal transformation:" << endmsg;
608  msg() << "translation: " << localToGlobal.dx() / CLHEP::cm << ";" << localToGlobal.dy() / CLHEP::cm << ";" << localToGlobal.dz() / CLHEP::cm << endmsg;
609  msg() << "rotation: " << endmsg;
610  msg() << localToGlobal.xx() << " " << localToGlobal.xy() << " " << localToGlobal.xz() << endmsg;
611  msg() << localToGlobal.yx() << " " << localToGlobal.yy() << " " << localToGlobal.yz() << endmsg;
612  msg() << localToGlobal.zx() << " " << localToGlobal.zy() << " " << localToGlobal.zz() << endmsg;
613  }
614  }
615 
616  if (!m_MisalignmentMode) {
617  //no misalignment mode set
618  parameterizedTrafo = HepGeom::Transform3D(); // initialized as identity transformation
619  }
620 
621  else if (m_MisalignmentMode==1) {
622  //shift whole detector
623  HepGeom::Vector3D<double> shift(ScaleFactor*m_Misalign_x, ScaleFactor*m_Misalign_y, ScaleFactor*m_Misalign_z);
624 
625  CLHEP::HepRotation rot;
626  rot = CLHEP::HepRotationX(ScaleFactor*m_Misalign_alpha) * CLHEP::HepRotationY(ScaleFactor*m_Misalign_beta) * CLHEP::HepRotationZ(ScaleFactor*m_Misalign_gamma);
627 
628  if (ScaleFactor == 0.0) {
629  parameterizedTrafo = HepGeom::Transform3D(); // initialized as identity transformation
630  } else {
631  parameterizedTrafo = HepGeom::Transform3D(rot, shift);
632  }
633 
634  }
635 
636  else if (m_MisalignmentMode == 2) {
637 
638  // randomly misalign modules at L3
639  Rndm::Numbers RandMisX(randsvc, Rndm::Gauss(m_Misalign_x,m_RndmMisalignWidth_x*ScaleFactor));
640  Rndm::Numbers RandMisY(randsvc, Rndm::Gauss(m_Misalign_y,m_RndmMisalignWidth_y*ScaleFactor));
641  Rndm::Numbers RandMisZ(randsvc, Rndm::Gauss(m_Misalign_z,m_RndmMisalignWidth_z*ScaleFactor));
642  Rndm::Numbers RandMisalpha(randsvc, Rndm::Gauss(m_Misalign_alpha,m_RndmMisalignWidth_alpha*ScaleFactor));
643  Rndm::Numbers RandMisbeta(randsvc, Rndm::Gauss(m_Misalign_beta,m_RndmMisalignWidth_beta*ScaleFactor));
644  Rndm::Numbers RandMisgamma(randsvc, Rndm::Gauss(m_Misalign_gamma,m_RndmMisalignWidth_gamma*ScaleFactor));
645 
646  double randMisX = RandMisX(); //assign to variables to allow the values to be queried
647  double randMisY = RandMisY();
648  double randMisZ = RandMisZ();
649 
650  double randMisaplha = RandMisalpha();
651  double randMisbeta = RandMisbeta();
652  double randMisgamma = RandMisgamma();
653 
654  CLHEP::HepRotation rot;
655  HepGeom::Vector3D<double> shift;
656 
657 
658  if (ScaleFactor == 0.0) {
659  parameterizedTrafo = HepGeom::Transform3D(); // initialized as identity transformation
660  } else {
661  if (m_translation && m_rotation) {
662  shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
663  rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
664  parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
665  else if (!m_translation && m_rotation) {
666  shift = HepGeom::Vector3D<double>(0, 0, 0);
667  rot = CLHEP::HepRotationX(randMisaplha) * CLHEP::HepRotationY(randMisbeta) * CLHEP::HepRotationZ(randMisgamma);
668  parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
669  else if (m_translation && !m_rotation) {
670  shift = HepGeom::Vector3D<double>(randMisX, randMisY, randMisZ);
671  rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
672  parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
673  else { shift = HepGeom::Vector3D<double>(0, 0, 0);
674  rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
675  parameterizedTrafo = HepGeom::Transform3D(rot, shift);}
676  }
677 
678  }
679 
680  else if (m_MisalignmentMode==3) {
681  //shift whole detector
682  double deltaX;
683  if ( m_idHelper->is_pixel(ModuleID) && m_pixelIdHelper->is_blayer(ModuleID) ) {
684  //function is parameterized in global z
686 
687  } else {
688  //IBL-stave temperature distortion not applied to anything but IBL
689  deltaX = 0.;
690  ATH_MSG_DEBUG( "will not move this module for IBL temp distortion " );
691  }
692 
693  ATH_MSG_DEBUG( "deltaX for this module: " << deltaX/CLHEP::micrometer << " um" );
694  parameterizedTrafo = HepGeom::Translate3D(deltaX,0,0); // translation in x direction
695  }
696 
697  else if (m_MisalignmentMode == 7) {
698 
699 
700  std::string module_str = m_idHelper->show_to_string(ModuleID, nullptr, '/');
701 
702  if (module_str.substr(0, m_index.size()) == m_index) {
703 
704  // Handle translation
705  HepGeom::Vector3D<double> shift(0, 0, 0);
706  if (!m_local_translation.empty()) {
707  shift = HepGeom::Vector3D<double>(m_local_translation[0], m_local_translation[1], m_local_translation[2]);
708  }
709 
710  // Handle rotation
711  CLHEP::HepRotation rot = CLHEP::HepRotationX(0) * CLHEP::HepRotationY(0) * CLHEP::HepRotationZ(0);
712  if (!m_local_rotation.empty()) {
713  rot = CLHEP::HepRotationX(m_local_rotation[0]) * CLHEP::HepRotationX(m_local_rotation[1]) * CLHEP::HepRotationX(m_local_rotation[2]);
714  }
715 
716  // Assign transformation
717  parameterizedTrafo = HepGeom::Transform3D(rot, shift);
718  }
719  }
720 
721 
722  else { // systematic misalignments
723  if (m_MisalignmentMode/10==1) {
724  //radial misalignments
725  double deltaR;
726  if (m_MisalignmentMode==11) {
727  //R deltaR = radial expansion
728  if (m_idHelper->is_trt(ModuleID) && abs(m_trtIdHelper->barrel_ec(ModuleID))==2) {
729  //radial mode cannot handle TRT endcap, sorry
730  deltaR = 0.;
731  ATH_MSG_DEBUG( "will not move TRT endcap for radial distortion " );
732  } else {
733  //deltaR = 0.5 * cos ( 2*phi ) * r/maxRadius * maxDeltaR;
734  deltaR = r/maxRadius * maxDeltaR; //scale linearly in r
735  }
736  } else if (m_MisalignmentMode==12) {
737  //Phi deltaR = elliptical (egg-shape)
738  if (m_idHelper->is_trt(ModuleID) && abs(m_trtIdHelper->barrel_ec(ModuleID))==2) {
739  //elliptical mode cannot handle TRT endcap, sorry
740  deltaR = 0.;
741  ATH_MSG_DEBUG( "will not move TRT endcap for elliptical distortion " );
742  } else {
743  // deltaR = 0.5 * cos ( 2*phi ) * r/maxRadius * maxDeltaR;
744  deltaR = cos ( 2*phi ) * r/maxRadius * maxDeltaR;
745  }
746  } else if (m_MisalignmentMode==13) {
747  //Z deltaR = funnel
748  if (m_idHelper->is_trt(ModuleID) && abs(m_trtIdHelper->barrel_ec(ModuleID))==2) {
749  //funnel mode cannot handle TRT endcap, sorry
750  deltaR = 0.;
751  ATH_MSG_DEBUG( "will not move TRT endcap for funnel distortion " );
752  } else {
753  //deltaR = z/maxLength * maxDeltaR; // linearly in z
754  deltaR = 2. * z/maxLength * maxDeltaR; // linearly in z
755  }
756  } else {
757  ATH_MSG_DEBUG( "Wrong misalignment mode entered, doing nothing." );
758  deltaR=0;
759  }
760 
761  ATH_MSG_DEBUG( "deltaR for this module: " << deltaR / CLHEP::micrometer << " um" );
762  parameterizedTrafo = HepGeom::Translate3D(deltaR*cos(phi),deltaR * sin(phi),0.); // translation along R vector
763  }
764 
765  else if (m_MisalignmentMode/10==2) {
766  //azimuthal misalignments
767  double deltaPhi;
768  if (m_MisalignmentMode==21) {
769 
770  deltaPhi = r/maxRadius * maxAngle + minRadius/r * maxAngleInner; //linearly + reciprocal term in r
771  } else if (m_MisalignmentMode==22) {
772  //Phi deltaPhi = clamshell
773  // deltaPhi = std::abs( sin ( phi )) * maxAngle;
774  if (m_idHelper->is_trt(ModuleID) && abs(m_trtIdHelper->barrel_ec(ModuleID))==2) {
775  //clamshell mode cannot handle TRT endcap, sorry
776  deltaPhi = 0.;
777  ATH_MSG_DEBUG( "will not move TRT endcap for clamshell distortion " );
778  } else {
779  // deltaPhi = 0.5 * cos ( 2*phi ) * maxAngle;
780  deltaPhi = cos ( 2*phi ) * maxAngle;
781  }
782  } else if (m_MisalignmentMode==23) {
783  //Z deltaPhi = Twist
784  deltaPhi = 2*z/maxLength * maxAngle;
785  //deltaPhi = z/maxLength * maxAngle;
786  } else {
787  ATH_MSG_WARNING( "Wrong misalignment mode entered, doing nothing." );
788  deltaPhi=0;
789  }
790 
791  ATH_MSG_DEBUG( "deltaPhi for this module: " << deltaPhi/CLHEP::mrad << " mrad" );
792  parameterizedTrafo = HepGeom::RotateZ3D(deltaPhi); // rotation around z axis => in phi
793  }
794 
795  else if (m_MisalignmentMode/10==3) {
796  //z misalignments
797  double deltaZ;
798  if (m_MisalignmentMode==31) {
799  //R deltaZ = Telescope
800  deltaZ = r/maxRadius * maxDeltaZ; //scale linearly in r
801  } else if (m_MisalignmentMode==32) {
802 
803  if (m_idHelper->is_trt(ModuleID) && abs(m_trtIdHelper->barrel_ec(ModuleID))==2) {
804  //clamshell mode cannot handle TRT endcap, sorry
805  deltaZ = 0.;
806  ATH_MSG_DEBUG( "will not move TRT endcap for skew distortion " );
807  } else {
808 
809  deltaZ = cos ( 2*phi ) * maxDeltaZ;
810  }
811  } else if (m_MisalignmentMode==33) {
812  //Z deltaZ = Z expansion
813  // deltaZ = z/maxLength * maxDeltaZ;
814  deltaZ = 2. * z/maxLength * maxDeltaZ;
815  } else {
816  ATH_MSG_WARNING( "Wrong misalignment mode entered, doing nothing." );
817  deltaZ=0;
818  }
819 
820  ATH_MSG_DEBUG( "deltaZ for this module: " << deltaZ/CLHEP::micrometer << " um" );
821  parameterizedTrafo = HepGeom::Translate3D(0,0,deltaZ); // translation in z direction
822  }
823 
824  else {
825  //no or wrong misalignment selected
826  ATH_MSG_WARNING( "Wrong misalignment mode entered, doing nothing." );
827 
828  parameterizedTrafo = HepGeom::Transform3D(); // initialized as identity transformation
829  }
830  } //end of misalignment
831 
832  if ( m_MisalignmentMode==21 && m_idHelper->is_trt(ModuleID) && m_trtIdHelper->is_barrel(ModuleID) ) {
833  //curl for TRT barrel
834  ATH_MSG_DEBUG( "additional rotation for TRT barrel module!" );
835  HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
836  //rotate a TRT barrel module by the same angle again, but around its local z axis
837  //this is an approximation to accomodate the impossible curling of TRT segments
838  alignmentTrafo = parameterizedTrafo * realLocalToGlobalTRT * parameterizedTrafo * realLocalToGlobalTRT.inverse();
839  } else if (m_MisalignmentMode==23 && m_idHelper->is_trt(ModuleID) && m_trtIdHelper->is_barrel(ModuleID) ) {
840  //do the twist! (for TRT barrel)
841  HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
842  double deltaAlpha = (-2.) * r * maxAngle/maxLength;
843  ATH_MSG_DEBUG( "TRT barrel module alpha for twist: " << deltaAlpha/CLHEP::mrad << " mrad" );
844 
845  CLHEP::HepRotation twistForTRTRotation(HepGeom::Vector3D<double>(center.x(),center.y(),center.z()), deltaAlpha );
846  HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
847  // HepGeom::Transform3D twistForTRTRotation = HepGeom::RotateZ3D( r * maxAngle/maxLength );
848 
849  alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
850  } else if (m_MisalignmentMode==13 && m_idHelper->is_trt(ModuleID) && m_trtIdHelper->is_barrel(ModuleID) ) {
851  // funneling for TRT barrel
852  HepGeom::Transform3D realLocalToGlobalTRT = HepGeom::Translate3D(center.x(),center.y(),center.z());
853  double deltaAlpha = (-2.) * maxDeltaR/maxLength;
854  //double deltaAlpha = maxDeltaR/maxLength;
855  ATH_MSG_DEBUG( "TRT barrel module alpha for funnel: " << deltaAlpha/CLHEP::mrad << " mrad" );
856 
857  HepGeom::Vector3D<double> normalVector(center.x(),center.y(),center.z());
858  HepGeom::Vector3D<double> beamVector(0.,0.,1.);
859  HepGeom::Vector3D<double> rotationAxis = normalVector.cross(beamVector);
860  CLHEP::HepRotation twistForTRTRotation(rotationAxis, deltaAlpha );
861  HepGeom::Transform3D twistForTRT= HepGeom::Transform3D(twistForTRTRotation,HepGeom::Vector3D<double>(0.,0.,0.));
862 
863  alignmentTrafo = realLocalToGlobalTRT * twistForTRT * realLocalToGlobalTRT.inverse();
864 
865 
866 
867  } else if (m_MisalignmentMode==2 || m_MisalignmentMode==3 || m_MisalignmentMode==7) //random misalignment in local frame
868  {
869  alignmentTrafo = parameterizedTrafo;
870  }
871  else {
872  // final transformation executed in global coordinates, converted to local coordinates
873  alignmentTrafo = localToGlobal.inverse() * parameterizedTrafo * localToGlobal;
874  }
875 
876  if (msgLvl(MSG::INFO)) {
877  msg() << "Align Transformation x = (" << alignmentTrafo.getTranslation().x() / CLHEP::micrometer << " um)" << endmsg;
878  msg() << "Align Transformation y = (" << alignmentTrafo.getTranslation().y() / CLHEP::micrometer << " um)" << endmsg;
879  msg() << "Align Transformation z = (" << alignmentTrafo.getTranslation().z() / CLHEP::micrometer << " um)" << endmsg;
880  msg() << "Align Transformation x phi = (" << alignmentTrafo.getRotation().phiX() / CLHEP::deg << ")" << endmsg;
881  msg() << "Align Transformation x Theta = (" << alignmentTrafo.getRotation().thetaX() / CLHEP::deg << ")" << endmsg;
882  msg() << "Align Transformation y phi = (" << alignmentTrafo.getRotation().phiY() / CLHEP::deg << ")" << endmsg;
883  msg() << "Align Transformation y Theta = (" << alignmentTrafo.getRotation().thetaY() / CLHEP::deg << ")" << endmsg;
884  msg() << "Align Transformation z phi = (" << alignmentTrafo.getRotation().phiZ() / CLHEP::deg << ")" << endmsg;
885  msg() << "Align Transformation z Theta = (" << alignmentTrafo.getRotation().thetaZ() / CLHEP::deg << ")" << endmsg;
886  }
887 
888  // suppress tiny translations that occur due to trafo.inverse*trafo numerics
889  if ( std::abs(alignmentTrafo.getTranslation().x()) < 1e-10) {
890  HepGeom::Vector3D<double>
891  zeroSuppressedTranslation(0,alignmentTrafo.getTranslation().y(),alignmentTrafo.
892  getTranslation().z());
893  alignmentTrafo =
894  HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
895  }
896  if ( std::abs(alignmentTrafo.getTranslation().y()) < 1e-10) {
897  HepGeom::Vector3D<double>
898  zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),0,alignmentTrafo.
899  getTranslation().z());
900  alignmentTrafo =
901  HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
902  }
903  if ( std::abs(alignmentTrafo.getTranslation().z()) < 1e-10) {
904  HepGeom::Vector3D<double>
905  zeroSuppressedTranslation(alignmentTrafo.getTranslation().x(),alignmentTrafo.getTranslation().y(),0);
906  alignmentTrafo =
907  HepGeom::Transform3D(alignmentTrafo.getRotation(),zeroSuppressedTranslation);
908  }
909  if ( std::abs(alignmentTrafo.getRotation().getDelta()) < 1e-10) {
910  CLHEP::HepRotation zeroSuppressedRotation(alignmentTrafo.getRotation());
911  zeroSuppressedRotation.setDelta(0.);
912  alignmentTrafo =
913  HepGeom::Transform3D(zeroSuppressedRotation,alignmentTrafo.getTranslation());
914  }
915 
916 
917  Amg::Transform3D alignmentTrafoAmg = Amg::CLHEPTransformToEigen(alignmentTrafo);
918 
919  if (m_idHelper->is_sct(ModuleID) || m_idHelper->is_pixel(ModuleID)) {
920  if (m_IDAlignDBTool->tweakTrans(ModuleID,3, alignmentTrafoAmg)) {
921  ATH_MSG_INFO( "Update of alignment constants for module " << m_idHelper->show_to_string(ModuleID,nullptr,'/') << " successful" );
922  } else {
923  ATH_MSG_ERROR( "Update of alignment constants for module " << m_idHelper->show_to_string(ModuleID,nullptr,'/') << " not successful" );
924  }
925  } else if (m_idHelper->is_trt(ModuleID)) {
926  if (!m_trtIdHelper->is_barrel(ModuleID) && m_trtIdHelper->phi_module(ModuleID)!=0) {
927  //don't align - there's no trans in the DB for phi sectors other than 0
928  ATH_MSG_DEBUG( "TRT endcap phi sector " << m_trtIdHelper->phi_module(ModuleID) << " not aligned" );
929  } else {
930  //if (m_trtaligndbservice->tweakTrans(ModuleID,alignmentTrafo).isFailure()) {
931  if (m_trtaligndbservice->tweakAlignTransform(ModuleID,alignmentTrafoAmg,2).isFailure()) {
932  ATH_MSG_ERROR( "Update of alignment constants for module " << m_idHelper->show_to_string(ModuleID,nullptr,'/') << " not successful" );
933  } else {
934  ATH_MSG_INFO( "Update of alignment constants for module " << m_idHelper->show_to_string(ModuleID,nullptr,'/') << " successful" );
935  }
936  }
937  } else {
938  ATH_MSG_WARNING( "Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
939  }
940 
941  double alpha, beta, gamma;
942  m_IDAlignDBTool->extractAlphaBetaGamma(alignmentTrafoAmg, alpha, beta, gamma);
943 
944  m_AlignResults_x = alignmentTrafo.getTranslation().x();
945  m_AlignResults_y = alignmentTrafo.getTranslation().y();
946  m_AlignResults_z = alignmentTrafo.getTranslation().z();
950 
951 
953  LocalaGlobal = Amg::EigenTransformToCLHEP(SiModule->moduleTransform());
954  HepGeom::Point3D<double> alignedPosLocal(m_AlignResults_x,m_AlignResults_y,m_AlignResults_z);
955 
956 
957 
958 
959  m_Initial_center_x = center.x() ;
960  m_Initial_center_y = center.y() ;
961  m_Initial_center_z = center.z() ;
962 
963  HepGeom::Point3D<double> alignedPosGlobal = LocalaGlobal * alignedPosLocal;
964 
965  // Global Misalignment HERE
966  if (m_idHelper->is_sct(ModuleID)) {
967  // non-zero local center position gives additional radial shift of SCT endcap
968  const InDetDD::StripStereoAnnulusDesign *p_design_check = dynamic_cast<const InDetDD::StripStereoAnnulusDesign*>(&(SiModule->design()));
969  if (p_design_check){
970  Amg::Vector3D SCT_Center = p_design_check->sensorCenter();
971  double radialShift_x = SCT_Center[0]; // in sensor frame, x direction
972  double radialShift_y = SCT_Center[1]; // in sensor frame, y direction
973  HepGeom::Transform3D radial_shift = HepGeom::Translate3D(radialShift_x,radialShift_y,0); // the additional radial shift applied as translation
974  HepGeom::Transform3D LocalaaGlobal = LocalaGlobal * radial_shift; // apply additional radial shift
975  HepGeom::Point3D<double> SCT_endcap_alignedPosGlobal = LocalaaGlobal * alignedPosLocal; // corrected global transformation
976  m_Global_center_x = SCT_endcap_alignedPosGlobal.x();
977  m_Global_center_z = SCT_endcap_alignedPosGlobal.z();
978  m_Global_center_y = SCT_endcap_alignedPosGlobal.y();
979  }
980 
981  else { // no additional radial shift for SCT barrel
982  m_Global_center_x = alignedPosGlobal.x();
983  m_Global_center_y = alignedPosGlobal.y();
984  m_Global_center_z = alignedPosGlobal.z();
985 
986  }
987 
988  }
989 
990  else { // no additional radial shift for non-SCT elements
991  m_Global_center_x = alignedPosGlobal.x();
992  m_Global_center_y = alignedPosGlobal.y();
993  m_Global_center_z = alignedPosGlobal.z();
994  }
995 
996 
997  if (m_idHelper->is_sct(ModuleID)) {
1004  } else if (m_idHelper->is_pixel(ModuleID)) {
1011  } else if (m_idHelper->is_trt(ModuleID)) {
1018 
1019  } else {
1020  ATH_MSG_WARNING( "Something fishy, identifier is neither Pixel, nor SCT or TRT!" );
1021  }
1022 
1023  // Write out AlignResults ntuple
1024  if (StatusCode::SUCCESS!=ntupleSvc()->writeRecord("NTUPLES/CREATEMISALIGN/InitialAlignment")) {
1025  ATH_MSG_ERROR( "Could not write InitialAlignment ntuple." );
1026  }
1027 
1028  } // end of module loop
1029 
1030  // i = 0;
1031 
1032  //m_IDAlignDBTool->printDB(2);
1033  if(m_doPix || m_doStrip){
1034  if (StatusCode::SUCCESS!=m_IDAlignDBTool->outputObjs()) {
1035  ATH_MSG_ERROR( "Writing of AlignableTransforms failed" );
1036  } else {
1037  ATH_MSG_INFO( "AlignableTransforms were written" );
1038  ATH_MSG_INFO( "Writing database to textfile" );
1039  m_IDAlignDBTool->writeFile(false,m_asciiFileNameBase+"_Si.txt");
1040  ATH_MSG_INFO( "Writing IoV information to mysql file" );
1042  }
1043  }
1044 
1045  if(m_doTRT){
1046  if (StatusCode::SUCCESS!=m_trtaligndbservice->streamOutAlignObjects()) {
1047  ATH_MSG_ERROR( "Write of AlignableTransforms (TRT) failed" );
1048  } else {
1049  ATH_MSG_INFO( "AlignableTransforms for TRT were written" );
1050  ATH_MSG_INFO( "Writing TRT database to textfile" );
1051  if ( StatusCode::SUCCESS != m_trtaligndbservice->writeAlignTextFile(m_asciiFileNameBase+"_TRT.txt") ) {
1052  ATH_MSG_ERROR( "Failed to write AlignableTransforms (TRT) to txt file " << m_asciiFileNameBase+"_TRT.txt" );
1053  }
1054  ATH_MSG_INFO( "Writing IoV information for TRT to mysql file" );
1055  if ( StatusCode::SUCCESS
1057  ATH_MSG_ERROR( "Write of AIoV information (TRT) to mysql failed (tag=" << m_SQLiteTag << "_TRT)");
1058  }
1059  }
1060  }
1061 
1062  return StatusCode::SUCCESS;
1063 
1064  }
1065 
1066  //__________________________________________________________________________
1067  const HepGeom::Transform3D CreateMisalignAlg::BuildAlignTransform(const CLHEP::HepVector & AlignParams)
1068  {
1069  HepGeom::Vector3D<double> AlignShift(AlignParams[0],AlignParams[1],AlignParams[2]);
1070  CLHEP::HepRotation AlignRot;
1071 
1072  AlignRot = CLHEP::HepRotationX(AlignParams[3]) * CLHEP::HepRotationY(AlignParams[4]) * CLHEP::HepRotationZ(AlignParams[5]);
1073 
1074  HepGeom::Transform3D AlignTransform = HepGeom::Transform3D(AlignRot,AlignShift);
1075  return AlignTransform;
1076  }
1077 
1078  //__________________________________________________________________________
1080  {
1081  // msg(MSG::DEBUG) << "in CreateMisalignAlg::reduceTRTID" << endmsg;
1082  ATH_MSG_DEBUG( "reduceTRTID got Id " << m_idHelper->show_to_string(id,nullptr,'/'));
1083 
1084  int barrel_ec= m_trtIdHelper->barrel_ec(id);
1085  // attention: TRT DB only has one alignment correction per barrel module (+1/-1) pair
1086  // which is stored in -1 identifier
1087  if (barrel_ec==1) barrel_ec=-1; //only regard -1 barrel modules, +1 modules will belong to them
1088 
1089  //if (abs(barrel_ec)==2) phi_module=0;
1090  // only regard phi sector 0, the only one having an alignmentTrafo
1091  //does not work, since the center-of-mass of all phi sectors is on the beamline,so
1092  // transformations would become zero -> this has to be handled later
1093  int phi_module=m_trtIdHelper->phi_module(id);
1094 
1095  int layer_or_wheel=m_trtIdHelper->layer_or_wheel(id);
1096 
1097  int strawlayer=0;
1098  if (!m_trtIdHelper->is_barrel(id)) {
1099  strawlayer = m_trtIdHelper->straw_layer(id) / 4 * 4;
1100  // only strawlayers 0,4,8,12 are fed into DB for endcap
1101  }
1102 
1103  // if (msgLvl(MSG::DEBUG)) msg() << " and returns Id " << m_idHelper->show_to_string(m_trtIdHelper->module_id(barrel_ec,phi_module,layer_or_wheel),0,'/') << endmsg;
1104  ATH_MSG_DEBUG( " and returns Id " << m_idHelper->show_to_string(m_trtIdHelper->layer_id(barrel_ec,phi_module,layer_or_wheel,strawlayer),nullptr,'/'));
1105  // return m_trtIdHelper->module_id(barrel_ec,phi_module,layer_or_wheel);
1106  return m_trtIdHelper->layer_id(barrel_ec,phi_module,layer_or_wheel,strawlayer);
1107  }
1108 
1109  //__________________________________________________________________________
1111  {
1113  return reduceTRTID(id);
1114  }
1115 
1116  //__________________________________________________________________________
1117  double CreateMisalignAlg::getBowingMagParam(double temp_shift)
1118  {
1119  // IBL staves are straight at a set point of 15 degrees.
1120  // Get set point value to use for magnitude parameter from temp_shift starting at 15 degrees
1121  double T = 15 + temp_shift;
1122  return 1.53e-12 - 1.02e-13*T;
1123  }
1124 
1125  //__________________________________________________________________________
1126  double CreateMisalignAlg::getBowingTx(double p1, double z)
1127  {
1128  // Bowing fit function has the following form
1129  // [0]-[1]*(x+[2]) * (4.0*[2]*(x+[2])**2 - (x+[2])**3 - (2.0*[2])**3)
1130  // param 0 : is the baseline shift (fixed at 0 for MC)
1131  // param 1 : is the magnitude fit param (temp dependent input param)
1132  // param 2 : is the stave fix pointat both ends (fixed at 366.5)
1133  double p0 = 0;
1134  double p2 = 366.5;
1135  double Tx = p0 - p1*(z+p2) * (4.*p2*pow((z+p2),2) - pow((z+p2),3) - pow((2.*p2),3));
1136  return Tx;
1137  }
1138 
1139 } // end of namespace bracket
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_y
Gaudi::Property< double > m_RndmMisalignWidth_y
Definition: CreateMisalignAlg.h:94
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
AtlasDetectorID::is_pixel
bool is_pixel(Identifier id) const
Definition: AtlasDetectorID.h:767
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
InDetAlignment::CreateMisalignAlg::m_Misalign_z
Gaudi::Property< double > m_Misalign_z
Definition: CreateMisalignAlg.h:89
beamspotman.r
def r
Definition: beamspotman.py:674
InDetAlignment::CreateMisalignAlg::m_ScalePixelDBM
double m_ScalePixelDBM
Definition: CreateMisalignAlg.h:102
InDetAlignment::CreateMisalignAlg::m_AlignResults_alpha
NTuple::Item< double > m_AlignResults_alpha
AP rotation around x-axis.
Definition: CreateMisalignAlg.h:123
TRT_ID::layer_id
Identifier layer_id(int barrel_ec, int phi_module, int layer_or_wheel, int straw_layer) const
For an individual straw layer.
Definition: TRT_ID.h:494
InDetAlignment::CreateMisalignAlg::m_HumanReadableID
int m_HumanReadableID
Definition: CreateMisalignAlg.h:118
createLinkingScheme.iter
iter
Definition: createLinkingScheme.py:62
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDetAlignment::CreateMisalignAlg::m_ScalePixelEndcap
double m_ScalePixelEndcap
Definition: CreateMisalignAlg.h:105
add-xsec-uncert-quadrature-N.alpha
alpha
Definition: add-xsec-uncert-quadrature-N.py:110
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_ID
NTuple::Item< long > m_AlignResults_Identifier_ID
ID information for this module.
Definition: CreateMisalignAlg.h:126
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:27
AthCheckMacros.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
InDetAlignment::CreateMisalignAlg::m_Global_center_x
NTuple::Item< double > m_Global_center_x
Misaligned global center of module.
Definition: CreateMisalignAlg.h:138
TRT_DetElementCollection.h
IOVRange.h
Validity Range object. Holds two IOVTime instances (start and stop)
InDetAlignment::CreateMisalignAlg::m_local_translation
std::vector< double > m_local_translation
Specify misalignment with translation.
Definition: CreateMisalignAlg.h:84
InDetAlignment::CreateMisalignAlg::m_Initial_center_z
NTuple::Item< double > m_Initial_center_z
Initial global center of module.
Definition: CreateMisalignAlg.h:135
InDetAlignment::CreateMisalignAlg::m_Misalign_gamma
Gaudi::Property< double > m_Misalign_gamma
Definition: CreateMisalignAlg.h:92
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:777
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:615
InDetAlignment::CreateMisalignAlg::BuildAlignTransform
const HepGeom::Transform3D BuildAlignTransform(const CLHEP::HepVector &)
builds a HepGeom::Transform3D from the 6 Alignment Parameters
Definition: CreateMisalignAlg.cxx:1067
CreateMisalignAlg.h
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:161
InDetAlignment::CreateMisalignAlg::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: CreateMisalignAlg.h:165
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
InDetAlignment
Definition: CreateMisalignAlg.cxx:67
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
InDetAlignment::CreateMisalignAlg::m_Misalign_beta
Gaudi::Property< double > m_Misalign_beta
Definition: CreateMisalignAlg.h:91
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
deg
#define deg
Definition: SbPolyhedron.cxx:17
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
InDetAlignment::CreateMisalignAlg::m_ScaleTRTBarrel
double m_ScaleTRTBarrel
Definition: CreateMisalignAlg.h:108
InDetAlignment::CreateMisalignAlg::m_index
std::string m_index
Generate misalignment according to module indices.
Definition: CreateMisalignAlg.h:86
InDetAlignment::CreateMisalignAlg::m_AlignResults_gamma
NTuple::Item< double > m_AlignResults_gamma
AP rotation around z-axis.
Definition: CreateMisalignAlg.h:125
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:157
InDetAlignment::CreateMisalignAlg::m_ScaleSCTBarrel
double m_ScaleSCTBarrel
Definition: CreateMisalignAlg.h:106
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
InDetAlignment::CreateMisalignAlg::m_SQLiteTag
std::string m_SQLiteTag
tag name for the ConditionsDB
Definition: CreateMisalignAlg.h:75
AtlasDetectorID::is_trt
bool is_trt(Identifier id) const
Definition: AtlasDetectorID.h:789
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_LayerDisc
NTuple::Item< long > m_AlignResults_Identifier_LayerDisc
ID information for this module.
Definition: CreateMisalignAlg.h:129
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
SCT_ID::module_id
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: SCT_ID.h:416
PixelID::is_blayer
bool is_blayer(const Identifier &id) const
Test for b-layer - WARNING: id MUST be pixel id, otherwise answer is not accurate....
Definition: PixelID.h:629
InDetAlignment::CreateMisalignAlg::finalize
StatusCode finalize()
standard Athena-Algorithm method
Definition: CreateMisalignAlg.cxx:265
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_Eta
NTuple::Item< long > m_AlignResults_Identifier_Eta
ID information for this module.
Definition: CreateMisalignAlg.h:131
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
InDetAlignment::CreateMisalignAlg::m_ModuleList
std::map< Identifier, HepGeom::Point3D< double > > m_ModuleList
map of all SiIdentifiers to be misaligned and their centerpoints in global coordinates
Definition: CreateMisalignAlg.h:112
IOVTime::MINRUN
static constexpr uint32_t MINRUN
Definition: IOVTime.h:44
cm
const double cm
Definition: Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimParametrization/tools/FCAL_ChannelMap.cxx:25
InDetAlignment::CreateMisalignAlg::m_doTRT
bool m_doTRT
Definition: CreateMisalignAlg.h:163
python.PyAthena.module
module
Definition: PyAthena.py:131
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_BarrelEC
NTuple::Item< long > m_AlignResults_Identifier_BarrelEC
ID information for this module.
Definition: CreateMisalignAlg.h:128
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:58
AtlasDetectorID.h
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
InDetAlignment::CreateMisalignAlg::m_AlignResults_beta
NTuple::Item< double > m_AlignResults_beta
AP rotation aorund y-axis.
Definition: CreateMisalignAlg.h:124
PixelID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for g...
Definition: PixelID.h:601
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_beta
Gaudi::Property< double > m_RndmMisalignWidth_beta
Definition: CreateMisalignAlg.h:97
InDetAlignment::CreateMisalignAlg::m_createFreshDB
bool m_createFreshDB
Flag to call the createDB method of DBTool (to be switched off when adding misalignments to a given g...
Definition: CreateMisalignAlg.h:78
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
PixelID::wafer_hash
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition: PixelID.h:383
InDetAlignment::CreateMisalignAlg::m_trtDetEleCollKey
SG::ReadCondHandleKey< InDetDD::TRT_DetElementContainer > m_trtDetEleCollKey
Definition: CreateMisalignAlg.h:167
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_gamma
Gaudi::Property< double > m_RndmMisalignWidth_gamma
Definition: CreateMisalignAlg.h:98
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetAlignment::CreateMisalignAlg::getBowingTx
double getBowingTx(double p1, double z)
Definition: CreateMisalignAlg.cxx:1126
InDetDD::SiDetectorElement::moduleTransform
const Amg::Transform3D & moduleTransform() const
Module to global frame transform.
Definition: SiDetectorElement.cxx:173
InDetAlignment::CreateMisalignAlg::m_asciiFileNameBase
std::string m_asciiFileNameBase
filename basis for ASCII files with alignment constants
Definition: CreateMisalignAlg.h:74
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:27
InDetAlignment::CreateMisalignAlg::m_VisualizationLookupTree
TTree * m_VisualizationLookupTree
Definition: CreateMisalignAlg.h:115
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
InDetAlignment::CreateMisalignAlg::m_trtIdHelper
const TRT_ID * m_trtIdHelper
Definition: CreateMisalignAlg.h:68
python.SystemOfUnits.micrometer
float micrometer
Definition: SystemOfUnits.py:80
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_Phi
NTuple::Item< long > m_AlignResults_Identifier_Phi
ID information for this module.
Definition: CreateMisalignAlg.h:130
InDetAlignment::CreateMisalignAlg::m_trtaligndbservice
ServiceHandle< ITRT_AlignDbSvc > m_trtaligndbservice
Definition: CreateMisalignAlg.h:71
InDetDD::StripStereoAnnulusDesign
Definition: StripStereoAnnulusDesign.h:50
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetAlignment::CreateMisalignAlg::m_sctIdHelper
const SCT_ID * m_sctIdHelper
Definition: CreateMisalignAlg.h:67
InDetAlignment::CreateMisalignAlg::setupPixel_AlignModule
void setupPixel_AlignModule(int &)
Definition: CreateMisalignAlg.cxx:325
InDetAlignment::CreateMisalignAlg::m_rotation
bool m_rotation
Flag which turns on misalignment with rotation.
Definition: CreateMisalignAlg.h:83
InDetAlignment::CreateMisalignAlg::m_AlignResults_x
NTuple::Item< double > m_AlignResults_x
Alignment parameter sensitive coordinate.
Definition: CreateMisalignAlg.h:120
InDetAlignment::CreateMisalignAlg::m_Misalign_x
Gaudi::Property< double > m_Misalign_x
Definition: CreateMisalignAlg.h:87
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_z
Gaudi::Property< double > m_RndmMisalignWidth_z
Definition: CreateMisalignAlg.h:95
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDetAlignment::CreateMisalignAlg::m_idHelper
const AtlasDetectorID * m_idHelper
Definition: CreateMisalignAlg.h:65
InDetAlignment::CreateMisalignAlg::initialize
StatusCode initialize()
standard Athena-Algorithm method
Definition: CreateMisalignAlg.cxx:139
InDetAlignment::CreateMisalignAlg::m_ScaleTRTEndcap
double m_ScaleTRTEndcap
Definition: CreateMisalignAlg.h:109
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:860
TRT_ID::straw_layer
int straw_layer(const Identifier &id) const
Definition: TRT_ID.h:887
InDetAlignment::CreateMisalignAlg::m_ScaleSCTEndcap
double m_ScaleSCTEndcap
Definition: CreateMisalignAlg.h:107
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:878
compareGeometries.deltaX
float deltaX
Definition: compareGeometries.py:32
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
InDetAlignment::CreateMisalignAlg::m_doPix
bool m_doPix
Definition: CreateMisalignAlg.h:161
IInDetAlignDBTool.h
AthAlgorithm
Definition: AthAlgorithm.h:47
ReadCondHandleKey.h
InDetAlignment::CreateMisalignAlg::m_pixelIdHelper
const PixelID * m_pixelIdHelper
Definition: CreateMisalignAlg.h:66
InDetAlignment::CreateMisalignAlg::m_doStrip
bool m_doStrip
Definition: CreateMisalignAlg.h:162
InDetAlignment::CreateMisalignAlg::m_translation
bool m_translation
Flag which turns on misalignment with translation.
Definition: CreateMisalignAlg.h:82
InDetAlignment::CreateMisalignAlg::m_IBLBowingTshift
double m_IBLBowingTshift
The relative temp shift of set point that intriduces bowing (sign is important)
Definition: CreateMisalignAlg.h:103
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
InDetAlignment::CreateMisalignAlg::m_ScalePixelBarrel
double m_ScalePixelBarrel
Definition: CreateMisalignAlg.h:104
CLHEPtoEigenConverter.h
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:622
TRT_BaseElement.h
InDetAlignment::CreateMisalignAlg::setupTRT_AlignModule
void setupTRT_AlignModule(int &)
Definition: CreateMisalignAlg.cxx:377
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:647
InDetDD::StripStereoAnnulusDesign::sensorCenter
virtual Amg::Vector3D sensorCenter() const override
Return the centre of a sensor in the local reference frame.
Definition: StripStereoAnnulusDesign.cxx:262
InDetAlignment::CreateMisalignAlg::m_Initial_center_x
NTuple::Item< double > m_Initial_center_x
Initial global center of module.
Definition: CreateMisalignAlg.h:133
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
InDetAlignment::CreateMisalignAlg::m_firstEvent
bool m_firstEvent
Flag for Setup of AlignModuleList (1st event)
Definition: CreateMisalignAlg.h:77
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetAlignment::CreateMisalignAlg::m_AlignResults_y
NTuple::Item< double > m_AlignResults_y
AP not-so-sensitive coordinate.
Definition: CreateMisalignAlg.h:121
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
InDetAlignment::CreateMisalignAlg::m_IDAlignDBTool
ToolHandle< IInDetAlignDBTool > m_IDAlignDBTool
Definition: CreateMisalignAlg.h:70
InDetAlignment::CreateMisalignAlg::m_ScalePixelIBL
double m_ScalePixelIBL
Definition: CreateMisalignAlg.h:101
python.SystemOfUnits.mrad
float mrad
Definition: SystemOfUnits.py:127
InDetAlignment::CreateMisalignAlg::getBowingMagParam
double getBowingMagParam(double temp_shift)
Definition: CreateMisalignAlg.cxx:1117
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TRT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: TRT_ID.h:869
IOVTime::MINEVENT
static constexpr uint32_t MINEVENT
Definition: IOVTime.h:50
SiDetectorElement.h
InDetAlignment::CreateMisalignAlg::m_AlignResults_z
NTuple::Item< double > m_AlignResults_z
AP normal to module plane.
Definition: CreateMisalignAlg.h:122
InDetAlignment::CreateMisalignAlg::reduceTRTID
const Identifier reduceTRTID(Identifier id)
Definition: CreateMisalignAlg.cxx:1079
AlignableTransform.h
PixelID::is_dbm
bool is_dbm(const Identifier &id) const
Test for dbm - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for gene...
Definition: PixelID.h:608
StripStereoAnnulusDesign.h
InDetAlignment::CreateMisalignAlg::m_Global_center_y
NTuple::Item< double > m_Global_center_y
Misaligned global center of module.
Definition: CreateMisalignAlg.h:139
InDetAlignment::CreateMisalignAlg::m_Misalign_maxShift
double m_Misalign_maxShift
Maximum shift for global modes.
Definition: CreateMisalignAlg.h:99
InDetAlignment::CreateMisalignAlg::m_local_rotation
std::vector< double > m_local_rotation
Specify misalignment with rotation.
Definition: CreateMisalignAlg.h:85
InDetAlignment::CreateMisalignAlg::m_Initial_center_y
NTuple::Item< double > m_Initial_center_y
Initial global center of module.
Definition: CreateMisalignAlg.h:134
TRT_ID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel.
Definition: TRT_ID.h:851
InDetAlignment::CreateMisalignAlg::m_SCTDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_SCTDetEleCollKey
Definition: CreateMisalignAlg.h:166
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_alpha
Gaudi::Property< double > m_RndmMisalignWidth_alpha
Definition: CreateMisalignAlg.h:96
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:360
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
InDetAlignment::CreateMisalignAlg::m_nEvents
long int m_nEvents
Definition: CreateMisalignAlg.h:81
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetAlignment::CreateMisalignAlg::m_Misalign_alpha
Gaudi::Property< double > m_Misalign_alpha
Definition: CreateMisalignAlg.h:90
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
Amg::CLHEPTransformToEigen
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:38
InDetAlignment::CreateMisalignAlg::m_Misalign_y
Gaudi::Property< double > m_Misalign_y
Definition: CreateMisalignAlg.h:88
InDetAlignment::CreateMisalignAlg::m_AlignResults_Identifier_PixelSCT
NTuple::Item< long > m_AlignResults_Identifier_PixelSCT
ID information for this module.
Definition: CreateMisalignAlg.h:127
DEBUG
#define DEBUG
Definition: page_access.h:11
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Amg::EigenTransformToCLHEP
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Definition: CLHEPtoEigenConverter.h:120
InDetAlignment::CreateMisalignAlg::CreateMisalignAlg
CreateMisalignAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CreateMisalignAlg.cxx:70
InDetDD::TRT_DetElementContainer::getElements
const TRT_DetElementCollection * getElements() const
Definition: TRT_DetElementContainer.cxx:29
InDetAlignment::CreateMisalignAlg::execute
StatusCode execute()
standard Athena-Algorithm method
Definition: CreateMisalignAlg.cxx:227
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
InDetAlignment::CreateMisalignAlg::m_Global_center_z
NTuple::Item< double > m_Global_center_z
Misaligned global center of module.
Definition: CreateMisalignAlg.h:140
InDetAlignment::CreateMisalignAlg::setupSCT_AlignModule
void setupSCT_AlignModule(int &)
Definition: CreateMisalignAlg.cxx:275
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:13
ITRT_AlignDbSvc.h
abstract interface to Service to manage TRT alignment conditions
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
InDetDD::TRT_DetElementCollection
Class to hold collection of TRT detector elements.
Definition: TRT_DetElementCollection.h:26
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1062
InDetAlignment::CreateMisalignAlg::m_Misalign_maxShift_Inner
double m_Misalign_maxShift_Inner
Maximum shift of the Pixel B-layer in curl (d0 bias!)
Definition: CreateMisalignAlg.h:100
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
makeComparison.deltaZ
int deltaZ
Definition: makeComparison.py:46
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
InDetDD::SiDetectorElement::design
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:640
InDetAlignment::CreateMisalignAlg::GenerateMisaligment
StatusCode GenerateMisaligment()
the main function which calculates and applies a transformation to each detector element
Definition: CreateMisalignAlg.cxx:446
ntupleSvc
INTupleSvc * ntupleSvc()
Definition: ServiceAccessor.h:14
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
InDetAlignment::CreateMisalignAlg::~CreateMisalignAlg
~CreateMisalignAlg()
Default Destructor.
Definition: CreateMisalignAlg.cxx:133
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:9
InDetAlignment::CreateMisalignAlg::m_RndmMisalignWidth_x
Gaudi::Property< double > m_RndmMisalignWidth_x
Definition: CreateMisalignAlg.h:93
InDetAlignment::CreateMisalignAlg::m_AthenaHashedID
int m_AthenaHashedID
Definition: CreateMisalignAlg.h:117
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:52
TRT_ID::module_id
Identifier module_id(int barrel_ec, int phi_module, int layer_or_wheel) const
For an individual module phi sector.
Definition: TRT_ID.h:442
SCT_ID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be sct id, otherwise answer is not accurate. Use SiliconID for gen...
Definition: SCT_ID.h:721
InDetAlignment::CreateMisalignAlg::m_MisalignmentMode
int m_MisalignmentMode
Flag which Misalignment mode is to be generated.
Definition: CreateMisalignAlg.h:80
Identifier
Definition: IdentifierFieldParser.cxx:14