ATLAS Offline Software
InDetAlignDBTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // InDetAlignDBTool.cxx
6 // AlgTool to manage the SCT/pixel AlignableTransforms in the conditions store
7 // Richard Hawkings, started 8/4/05
8 
9 #include "CoralBase/AttributeListSpecification.h"
10 #include "CoralBase/Attribute.h"
11 
14 
15 #include <cmath>
16 #include <fstream>
17 #include <iostream>
18 
19 #include "GaudiKernel/NTuple.h"
20 #include "GaudiKernel/INTupleSvc.h"
21 #include "GaudiKernel/SmartDataPtr.h"
22 
23 #include "GaudiKernel/RndmGenerators.h"
24 #include "GaudiKernel/IRndmGenSvc.h"
25 
27 
33 
35 #include "InDetIdentifier/SCT_ID.h"
36 
39 
40 #include "InDetAlignDBTool.h"
41 
42 // alignment DBS ntuple 9002 definition
43 NTuple::Item<long> nt_dettype;
44 NTuple::Item<long> nt_bec;
45 NTuple::Item<long> nt_layer;
46 NTuple::Item<long> nt_ring;
47 NTuple::Item<long> nt_sector;
48 NTuple::Item<long> nt_side;
49 NTuple::Item<long> nt_level;
50 NTuple::Item<float> nt_xofs;
51 NTuple::Item<float> nt_yofs;
52 NTuple::Item<float> nt_zofs;
53 NTuple::Item<float> nt_phi;
54 NTuple::Item<float> nt_theta;
55 NTuple::Item<float> nt_psi;
56 NTuple::Item<float> nt_alpha;
57 NTuple::Item<float> nt_beta;
58 NTuple::Item<float> nt_gamma;
59 
61  const std::string& name, const IInterface* parent)
63  m_pixid(nullptr),
64  m_sctid(nullptr),
65  m_pixman(nullptr),
66  m_sctman(nullptr),
67  m_attrListCollection(nullptr),
68  m_par_newdb(true),
69  m_par_scttwoside(false),
70  m_par_fake(0),
71  m_par_condstream("AthenaOutputStreamTool/AthenaOutputStreamTool", this),
72  m_par_dbroot( "/Indet/Align" ),
73  m_par_dbkey( "/Indet/Align" ),
74  m_par_oldTextFile(false),
75  m_dynamicDB(false),
76  m_forceUserDBConfig(false)
77 {
78  declareInterface<IInDetAlignDBTool>(this);
79  declareProperty("NewDB", m_par_newdb); //Take out at some point; New is misleading!! Very old developments!
80  declareProperty("SCTTwoSide", m_par_scttwoside);
81  declareProperty("FakeDB", m_par_fake);
82  declareProperty("CondStream", m_par_condstream);
83  declareProperty("DBRoot", m_par_dbroot,"name of the root folder for constants");
84  declareProperty("DBKey", m_par_dbkey,"base part of the key for loading AlignableTransforms");
85  declareProperty("OldTextFile", m_par_oldTextFile);
86  declareProperty("forceUserDBConfig",m_forceUserDBConfig, "Set to true to override any DB auto-configuration");
87 }
88 
90 {}
91 
93 {
94 
95  ATH_MSG_DEBUG("InDetAlignDBTool initialize instance: " << name() );
96 
97  // get storegate access to conditions store
98  if (detStore().retrieve().isFailure()){
99  ATH_MSG_FATAL("Detector store not found");
100  }
101 
102  if ( m_par_condstream.retrieve().isFailure() ) {
103  ATH_MSG_FATAL( "Failed to retrieve AthenaOutputStreamTool");
104  return StatusCode::FAILURE;
105  } else
106  ATH_MSG_DEBUG( "Retrieved AthenaOutputStreamTool with name" << m_par_condstream.name());
107 
108  // attempt to get ID helpers from detector store
109  // (relying on GeoModel to put them)
110  m_alignobjs.clear();
111  m_alignchans.clear();
112  int ndet[2];
113  ndet[0]=0;
114  ndet[1]=0;
115 
116  //We use the presence of the DetManagers as proxies for whether we run with the detector enabled everywhere
117  if (StatusCode::SUCCESS!=detStore()->retrieve(m_pixman,m_pixmanName) || m_pixman==nullptr) {
118  ATH_MSG_INFO( "Could not find pixel manager "<<m_pixmanName<<" running without pixel");
119  }
120  else m_managers.push_back(m_pixman);
121 
122  if (StatusCode::SUCCESS!=detStore()->retrieve(m_sctman,m_sctmanName) || m_sctman==nullptr) {
123  ATH_MSG_INFO("Could not find SCT manager "<<m_sctmanName<<" running without SCT/Strip");
124  }
125  else m_managers.push_back(m_sctman);
126 
127  if(m_pixman){
129  m_dynamicDB = false;
130  }
132  m_par_dbroot = "/Indet/AlignL3";
133  m_dynamicDB = true;
134  }
135  }
136 
137  if (m_pixman && m_sctman){
139  ATH_MSG_FATAL("Pixel and SCT Managers have different alignfolder type registered --> Check ");
140  return StatusCode::FAILURE;
141  }
142  }
143 
145 
146  if(m_pixman && (detStore()->retrieve(m_pixid).isFailure())) {
147  ATH_MSG_FATAL("No Pixel ID Found!");
148  return StatusCode::FAILURE;
149  }
150 
151  if(m_sctman && (detStore()->retrieve(m_sctid).isFailure())) {
152  ATH_MSG_FATAL("No SCT ID Found!");
153  return StatusCode::FAILURE;
154  }
155 
156  //optionally fake up the geometry
157  if (m_par_fake==1) {
158  ATH_MSG_INFO("Initialising fake full ATLAS geometry");
159  fakeGeom(3,3,4,9);
160  } else if (m_par_fake==2) {
161  ATH_MSG_INFO("Initialising fake CTB geometry");
162  fakeGeom(3,0,4,0);
163  } else {
164  // setup list of alignable transforms from geometry
165  int chan[3];
166  int TransfLevel_low = 0; // depending on alignfolder sheme; 0 for old, 2 for new
167  if (m_dynamicDB) TransfLevel_low = 2;
168 
169  for (int i=0;i<3;++i) chan[i]=100*i;
170  std::string man_name;
171  int idet = 0;
172  for (auto manager:m_managers) {
173  for (const InDetDD::SiDetectorElement* element : * manager->getDetectorElementCollection()) {
174  if (element!=nullptr) {
175  const Identifier ident=element->identify();
176  int det,bec,layer,ring,sector,side;
177  if (idToDetSet(ident,det,bec,layer,ring,sector,side)) {
178  std::string level[3];
179  for (int i=TransfLevel_low;i<3;++i) {
180  level[i]=dirkey(det,bec,layer,1+i,sector);
181  // add this to list if not seen already
182  std::vector<std::string>::const_iterator ix=
183  find(m_alignobjs.begin(),m_alignobjs.end(),level[i]);
184  if (ix==m_alignobjs.end()) {
185  m_alignobjs.push_back(level[i]);
186  m_alignchans.push_back(chan[i]++);
187  }
188  }
189  ++ndet[idet];
190  } else {
191  ATH_MSG_ERROR("Si detector element type " << idet << " has no detset conversion" );
192  }
193  }
194  }
195  idet++;
196  }
197  }
198  ATH_MSG_INFO( "Geometry initialisation sees " << ndet[0] <<
199  " pixel and " << ndet[1] << " SCT modules giving " << m_alignobjs.size()
200  << " alignment keys" );
201 
202  if (msgLvl(MSG::DEBUG)) {
203  ATH_MSG_DEBUG( "Database root folder " << m_par_dbroot );
204  ATH_MSG_DEBUG( "Geometry initialisation sees " << ndet[0] <<
205  " pixel and " << ndet[1] << " SCT modules giving " << m_alignobjs.size()
206  << " alignment keys" );
207  ATH_MSG_DEBUG("Keys/channels are:");
208 
209  for (unsigned int i=0;i<m_alignobjs.size();++i)
210  ATH_MSG_DEBUG( " " << m_alignobjs[i] << " [" << m_alignchans[i] << "]" );
211 
212  if (m_par_newdb)
213  ATH_MSG_DEBUG("Assuming new COOL alignment DB model based on AlignableTransformContainer");
214  else
215  //Do we still use this anywhere? Candidate for removal?
216  ATH_MSG_DEBUG("Assuming old (Lisbon) alignment DB model based on separate AlignableTransforms");
217  }
218 
219  // make a new empty CondAttrListCollection with the IBLDist structure:
221  m_attrListCollection = new CondAttrListCollection(true); // not really sure....
222 
223  coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
224  spec->extend("stave", "int");
225  spec->extend("eta", "int");
226  spec->extend("mag", "float");
227  spec->extend("base", "float");
228  spec->extend("free", "float");
229 
230  const int ibl_stave_max = 14;
231  // create a full collection first with NULL entries to ensure fail save operation
232  for (int this_stave=0; this_stave<ibl_stave_max; this_stave++){
233 
234  coral::AttributeList atrlist(*spec);
235  // Set value of each row for the current channel
236  atrlist[ "stave" ].data<int>()=this_stave;
237  atrlist[ "eta" ].data<int>()=0;
238  atrlist[ "mag" ].data<float>()=0;
239  atrlist[ "base" ].data<float>()=0;
240  atrlist[ "free" ].data<float>()=0;
241  m_attrListCollection->add(100*(1+this_stave),atrlist);
242  }
243 
244  return StatusCode::SUCCESS;
245 }
246 
248 {
249  ATH_MSG_DEBUG( "InDetAlignDBTool finalize method called" );
250  return StatusCode::SUCCESS;
251 }
252 
254 {
255 
256  ATH_MSG_DEBUG("createDB method called");
257  // check not running in fake mode (need real geometry here)
258  if (m_par_fake) {
259  ATH_MSG_FATAL("Cannot create new database when geometry is faked");
260  }
262  AlignableTransformContainer* patc=nullptr;
263  // loop over all SiDetectorElements (pixel and SCT) and fill corresponding
264  // AlignableTransform objects with default values
265 
266  // first create the empty AlignableTransform objects in TDS
267  if (m_par_newdb) {
268  // check object does not already exist
269  if (detStore()->contains<AlignableTransformContainer>(m_par_dbroot)) {
270  ATH_MSG_ERROR("createDB: AlignableTransformContainer already exists");
271  return;
272  }
273  // put them in a collection /Indet/Align
274  ATH_MSG_DEBUG( "Setup database structures in AlignableTransformContainer");
276  }
277  else {
278  ATH_MSG_DEBUG( "Setup separate AlignableTransform for each layer");
279  }
280 
281  if (msgLvl(MSG::DEBUG)) {
282  if (m_par_scttwoside) ATH_MSG_DEBUG( "Produce separate transforms for each side of SCT modules" );
283  else ATH_MSG_DEBUG( "Treat both sides of SCT module as single entity" );
284  }
285 
286  for (unsigned int i=0;i<m_alignobjs.size();++i) {
288  if (m_par_newdb) {
289  // add to collection and set corresponding channel number
290  patc->push_back(pat);
291  patc->add(m_alignchans[i]);
292  } else {
293  // store directly in SG
294  // first check object not already there
295  if (detStore()->contains<AlignableTransform>(m_alignobjs[i])) {
296  ATH_MSG_FATAL( "create DB: AlignableTransform " << m_alignobjs[i] << " already exists" );
297  delete pat;
298  pat=nullptr;
299  return;
300  }
301  if (StatusCode::SUCCESS!=detStore()->record(pat,m_alignobjs[i]))
302  ATH_MSG_ERROR( "Could not record AlignableTransform "<< m_alignobjs[i] );
303  }
304  }
305  if (m_par_newdb) {
306  // record collection in SG
307  if (StatusCode::SUCCESS!=detStore()->record(patc,m_par_dbroot))
308  ATH_MSG_ERROR("Could not record AlignableTransformContainer");
309  ATH_MSG_DEBUG( "Collection has size " << patc->size() );
310  }
311 
312  // now loop over all detector modules and add null level 3 transforms
313  std::vector<std::string> level2;
315  const InDetDD::SCT_DetectorManager * testSCT = nullptr;
316  const InDetDD::PixelDetectorManager * testPixel = nullptr;
317  testPixel = dynamic_cast<const InDetDD::PixelDetectorManager *>(manager);
318  if(!testPixel) testSCT = dynamic_cast<const InDetDD::SCT_DetectorManager *>(manager);
319  for (const InDetDD::SiDetectorElement* element: *manager->getDetectorElementCollection()) {
320  if (element!=nullptr) {
321  const Identifier ident=element->identify();
322  std::string key=dirkey(ident,3);
323  // do not produce AlignableTrasnforms for SCT side 1 if option set
324  if (!(m_sctid && m_sctid->is_sct(ident) && m_sctid->side(ident)==1) || m_par_scttwoside) {
325  if ((pat=getTransPtr(key))) {
326  pat->add(ident,Amg::EigenTransformToCLHEP( Amg::Transform3D::Identity() ) );
327  }
328  else ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key );
329  }
330  // add level 2 transform if needed - do this the first time a module
331  // for this level 3 key is seen
332  std::vector<std::string>::const_iterator ix = find(level2.begin(),level2.end(),key);
333  if (ix==level2.end()) {
334  level2.push_back(key);
335  // construct identifier of level 2 transform
336  Identifier ident2;
337  if(testPixel){
338  if (m_pixid->is_pixel(ident)) {
340  m_pixid->phi_module(ident),0); // needed to be extended to phi-module due to DBM
341  }
342  }
343  if(testSCT){
344  if (m_sctid->is_sct(ident)) {
346  }
347  }
348  std::string key2=dirkey(ident,2);
349  if ((pat=getTransPtr(key2))) {
350  pat->add(ident2,Amg::EigenTransformToCLHEP( Amg::Transform3D::Identity() ) );
351  } else ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key2 );
352  }
353  }
354  }
355  }
356  // create the global ID object with positions for the pixels (one unit)
357  // and SCT barrel/endcap
358  Identifier ident1;
359  std::string key1=dirkey(ident1,1);
360  if ((pat=getTransPtr(key1))) {
361  Amg::Transform3D globshift;
362  globshift.setIdentity();
363  if(m_pixid){
364  // pixel - barrel and endcap as one, treated as barrel layer 0 module 0
365  ident1=m_pixid->wafer_id(0,0,0,0);
366  pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
367  }
368  if(m_sctid){
369  // SCT barrel - barrel 0 module 0
370  ident1=m_sctid->wafer_id(0,0,0,0,0);
371  pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
372  // SCT endcaps A and C
373  ident1=m_sctid->wafer_id(-2,0,0,0,0);
374  pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
375  ident1=m_sctid->wafer_id(2,0,0,0,0);
376  pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
377  }
378  } else {
379  ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key1 );
380  }
381  // sort the created objects (in case, usually come out sorted from GeoModel)
382  sortTrans();
383  // list out size of all created objects
384  ATH_MSG_DEBUG( "Dumping size of created AlignableTransform objects");
385  for (unsigned int i=0;i<m_alignobjs.size();++i)
386  if ((pat=getTransPtr(m_alignobjs[i]))) pat->print();
387 }
388 
390  int& layer, int& ring, int& sector, int& side) const {
391  // transform Identifier to list of integers specifiying dettype,bec,layer
392  // ring, sector, side
393  // note bec is +-1 or 0, not +-2 as returned by idenfitiers
394 
395  bool resok=false;
396  if (m_pixman && m_pixid->is_pixel(ident)) {
397  det=1;
400  ring=m_pixid->eta_module(ident);
401  sector=m_pixid->phi_module(ident);
402  side=0;
403  resok=true;
404  } else if (m_sctman && m_sctid->is_sct(ident)) {
405  det=2;
408  ring=m_sctid->eta_module(ident);
409  sector=m_sctid->phi_module(ident);
411  resok=true;
412  }
413  return resok;
414 }
415 
417  const int level) const {
418  // given SCT or pixel identifier, and level (1,2 or 3) return
419  // directory key name for associated alignment data
420  int det,bec,layer,ring,sector,side;
421  idToDetSet(ident,det,bec,layer,ring,sector,side);
422  return dirkey(det,bec,layer,level,sector);
423 }
424 
425 // This function is redundant for the main code.
426 // Kept for now as I did not want to touch functions like dispCSC() etc.
427 std::string InDetAlignDBTool::dirkey(const int det,const int bec,const
428  int layer, const int level) const {
429  // given SCT/pixel det/bec/layer, and level (1,2 or 3) return
430  // directory key name for associated alignment data
431  std::ostringstream result;
432  result << m_par_dbkey << "/" ;
433  if (level==1) {
434  result << "ID";
435  } else {
436  if (det==1) result << "PIX";
437  if (det==2) result << "SCT";
438  if (level==3) {
439  if (bec==1) result << "EA";
440  if (bec==0) result << "B";
441  if (bec==-1) result << "EC";
442  result << 1+layer;
443  }
444  }
445  return result.str();
446 }
447 
448 std::string InDetAlignDBTool::dirkey(const int det,const int bec,const
449  int layer, const int level, const int sector) const {
450  // given SCT/pixel det/bec/layer/sector, and level (1,2 or 3) return
451  // directory key name for associated alignment data
452  std::ostringstream result;
453  if (m_dynamicDB){
454  result << "/Indet/AlignL";
455  result << level;
456  result << "/" ; // new folders have L1, L2, L3 structure
457  }
458  else{
459  result << m_par_dbkey << "/" ;
460  }
461  if (level==1) {
462  result << "ID";
463  } else {
464  if (det==1) result << "PIX";
465  if (det==2) result << "SCT";
466  if (level==3) {
467  if (det==1 && abs(bec)==2) result << DBMkey(det,bec,level,sector);
468  else {
469  if (bec==1) result << "EA";
470  if (bec==0) result << "B";
471  if (bec==-1) result << "EC";
472  result << 1+layer;
473  }
474  }
475  }
476  return result.str();
477 }
478 
479 std::string InDetAlignDBTool::DBMkey(const int det,const int bec,
480  const int level, const int sector) const {
481  // given SCT/pixel det/bec/layer/sector, and level (1,2 or 3) return
482  // additional directory key name for associated DBM alignment
483  std::ostringstream result;
484  if (det==1 && level==3 && abs(bec)==2) { // slightly unnecessary check
485  if (bec==2) result << "EADBM";
486  if (bec==-2) result << "ECDBM";
487  result << 1+sector;
488  }
489  return result.str();
490 }
491 
492 //What is the meaning of the different values of "syst" here? From documentation:
493 // InDetAlignWrt.Dispsyst(1) shift randomly (1) or systematic (2)
494 // if 3/4 interpret (Rphi,R,Z) as (x,y,z)
495 // if (5) randomise the systematic shift (x,y)
496 void InDetAlignDBTool::dispGroup(const int dettype, const int bec,
497  const int layer,const int ring, const int sector,
498  const float rphidisp, const float rdisp, const float zdisp,
499  const int syst, const int level, const int skip) const {
500 
501  ATH_MSG_DEBUG( "dispGroup called: level " << level << " syst " << syst);
502  int nmod=0;
503  // random number service
504  SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
505  if(!randsvc.isValid()) ATH_MSG_ERROR("Cannot find RndmGenSvc" );
506 
507  Rndm::Numbers gauss(randsvc,Rndm::Gauss(0.,1.));
508  if (skip>0) {
509  ATH_MSG_DEBUG("Skip random numbers " << skip );
510  for (int i=0;i<skip;++i) gauss();
511  }
512  // for syst 5, choose random shifts based on the input numbers
513  float rpd=0,rd=0,zd=0;
514  if (syst==5) {
515  rpd=rphidisp*gauss();
516  rd=rdisp*gauss();
517  zd=zdisp*gauss();
518  }
519  // keep a list of level1/2 transform IDs to make sure they are only set once
520  std::vector<Identifier> lvl12id;
521  // loop over all pixel and SCT modules
523  for (int idet=1;idet<3;++idet) {
525  if (element!=nullptr) {
526  const Identifier ident=element->identify();
527  int mdet,mbec,mlayer,mring,msector,mside;
528  idToDetSet(ident,mdet,mbec,mlayer,mring,msector,mside);
529  // find matching modules - note side=1 modules never touched
530  if ((dettype==-1 || mdet==dettype) && (bec==-1 || std::abs(2*mbec)==bec) &&
531  (layer==-1 || mlayer==layer) && (ring==-1 || mring==ring) &&
532  (sector== -1 || msector==sector) && mside==0) {
533  // displace this module - first choose displacement type
534  // dont choose new displacements if seeing second side of SCT module
535  // ensures they both move together
536  // depends on the side1 module immediatly following side 0 in list
537  // which is currently the case - fragile
538  // also for syst 6 choose number only for new ring (eta) slice
539  if (dettype!=2 || mside!=1) {
540  if (syst==2 || syst==4 || (syst==6 && mring==-6)) {
541  rpd=rphidisp*gauss();
542  rd=rdisp*gauss();
543  zd=zdisp*gauss();
544  if (syst==6) ATH_MSG_DEBUG("New rndm at layer/ring " <<
545  mlayer << " " << mring << " z " << zd );
546  } else if (syst<5) {
547  rpd=rphidisp;
548  rd=rdisp;
549  zd=zdisp;
550  }
551  }
552  // interpretation as rphi/r or x/y
553  float xd,yd;
554  if (syst<=2 || syst==6) {
555  // rphi displacement - calculate from module position in x/y
556  const Amg::Vector3D modcent=element->center();
557  float dx=modcent.x();
558  float dy=modcent.y();
559  float dr=std::sqrt(dx*dx+dy*dy);
560  xd=(rd*dx-rpd*dy)/dr;
561  yd=(rd*dy+rpd*dx)/dr;
562  } else {
563  xd=rpd;
564  yd=rd;
565  }
566  // find the corresponding AlignableTransform object
567  std::string key=dirkey(mdet,mbec,mlayer,level);
568  // first get as const as transforms might have been read in
569  const AlignableTransform* cpat=cgetTransPtr(key);
570  pat=const_cast<AlignableTransform*>(cpat);
571  if (pat) {
572  Identifier ident2;
573  bool update=true;
574  if (level==3) {
575  ident2=ident;
576  } else if (level==2) {
577  // identifier for layer in level 2 transform
578  if (mdet==1) {
580  m_pixid->layer_disk(ident),0,0);
581  } else {
583  m_sctid->layer_disk(ident),0,0,0);
584  }
585  // check this identifier has not been updated before
586  std::vector<Identifier>::const_iterator ix=
587  find(lvl12id.begin(),lvl12id.end(),ident2);
588  if (ix==lvl12id.end()) {
589  lvl12id.push_back(ident2);
590  } else {
591  update=false;
592  }
593  } else {
594  // identifier for ID
595  if (mdet==1) {
596  ident2=m_pixid->wafer_id(0,0,0,0);
597  } else {
598  ident2=m_sctid->wafer_id(0,0,0,0,0);
599  }
600  // check this identifier has not been updated before
601  std::vector<Identifier>::const_iterator ix=
602  find(lvl12id.begin(),lvl12id.end(),ident2);
603  if (ix==lvl12id.end()) {
604  lvl12id.push_back(ident2);
605  } else {
606  update=false;
607  }
608  }
609  // update, adding to any existing shift
610  if (update) {
611 
612  Amg::Transform3D shift = Amg::Translation3D(xd,yd,zd) * Amg::RotationMatrix3D::Identity();
613  pat->tweak(ident2,Amg::EigenTransformToCLHEP(shift));
614  ATH_MSG_VERBOSE( "Updated module " << mdet << "," << mbec
615  << "," << mlayer << "," << mring << "," << msector << " to xyz" <<
616  xd << "," << yd << "," << zd );
617  ++nmod;
618  }
619  } else {
620  ATH_MSG_ERROR("Cannot find AlignableTransform for key" << key );
621  }
622  }
623  }
624  }
625  }
626  ATH_MSG_DEBUG( "Added displacement to " << nmod << " modules " << dettype << ","
627  << bec << "," << layer << " [" << rphidisp << "," << rdisp
628  << "," << zdisp << "]"
629  << " type " << syst );
630 }
631 
632 void InDetAlignDBTool::writeFile(const bool ntuple, const std::string& file)
633  const {
634  std::ofstream* outfile=nullptr;
635  SmartIF<INTupleSvc> ntsvc{Gaudi::svcLocator()->service("NTupleSvc")};
636  if(!ntsvc.isValid()) ATH_MSG_ERROR("Cannot find NTupleSvc" );
637  const std::string path=file+"/9002";
638  NTuplePtr nt(ntsvc.get(),path);
639 
640  if (ntuple) {
641  ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on ntuple 9002, path: " << file );
642  const int ntid=9002;
643  if (nt) {
644  ATH_MSG_DEBUG( "Ntuple " << path << " is already booked" );
645  } else {
646  ATH_MSG_DEBUG("Attempting to book ntuple " << path );
647  nt=ntsvc->book(file,ntid,CLID_ColumnWiseTuple,"AlignDB");
648  if (!nt) ATH_MSG_ERROR("Ntuple booking fails" );
649  }
650  StatusCode sc;
651  sc=nt->addItem("MODPROP/DetType",nt_dettype);
652  sc=nt->addItem("MODPROP/Bec",nt_bec);
653  sc=nt->addItem("MODPROP/Layer",nt_layer);
654  sc=nt->addItem("MODPROP/Ring",nt_ring);
655  sc=nt->addItem("MODPROP/Sector",nt_sector);
656  sc=nt->addItem("MODPROP/Side",nt_side);
657  sc=nt->addItem("MODPROP/Level",nt_level);
658  sc=nt->addItem("MODPROP/Xofs",nt_xofs);
659  sc=nt->addItem("MODPROP/Yofs",nt_yofs);
660  sc=nt->addItem("MODPROP/Zofs",nt_zofs);
661  sc=nt->addItem("MODPROP/Phi",nt_phi);
662  sc=nt->addItem("MODPROP/Theta",nt_theta);
663  sc=nt->addItem("MODPROP/Psi",nt_psi);
664  sc=nt->addItem("MODPROP/Phi",nt_phi);
665  sc=nt->addItem("MODPROP/Theta",nt_theta);
666  sc=nt->addItem("MODPROP/Psi",nt_psi);
667  if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
668  "Error booking ntuple 9002 contents" );
669  } else {
670  ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on text file: " << file );
671  outfile=new std::ofstream(file.c_str());
672  }
673  int nobj=0;
674  int ntrans=0;
675  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
676  iobj!=m_alignobjs.end();++iobj) {
677  const AlignableTransform* pat;
678  if ((pat=cgetTransPtr(*iobj))) {
679  ++nobj;
680  if (!ntuple) *outfile << *iobj << std::endl;
682  cit!=pat->end();++cit) {
683  const Identifier& ident=cit->identify();
684  const Amg::Transform3D& trans=Amg::CLHEPTransformToEigen( cit->transform() );
685  int det,bec,layer,ring,sector,side;
686  float dx,dy,dz,phi,theta,psi;
687  if (!idToDetSet(ident,det,bec,layer,ring,sector,side)) {
688  // can fail for testbeam whe identifier with all layer
689  // and wafer indices set to zero is not valid in the dictionary
690  // these transforms are not actually used by testbeam GeoModel anyway
691  ATH_MSG_WARNING( "Ident for unknown detector type in " << *iobj );
692  det=1;bec=0;layer=0;ring=0;sector=0;side=0;
693  }
694  Amg::Vector3D shift=trans.translation();
695  Amg::RotationMatrix3D rot=trans.rotation();
696  dx=shift.x();
697  dy=shift.y();
698  dz=shift.z();
699  double alpha, beta, gamma;
700  extractAlphaBetaGamma(trans, alpha, beta, gamma);
701 
702  //ATH_MSG_WARNING("THIS NEEDS TO BE CHECKED --- InDetAlignDBTool.cxx:647");
703  // checked and appears all good, keep this in for now in case we have to recheck things
704  Amg::Vector3D ea = rot.eulerAngles(2, 0, 2);
705 
706  phi= ea[0];
707  theta=ea[1];
708  psi=ea[2];
709  ++ntrans;
710  if (ntuple) {
711  nt_dettype=det;
712  nt_bec=bec;
713  nt_layer=layer;
714  nt_ring=ring;
715  nt_sector=sector;
716  nt_level=3;
717  // derive level by looking for objects ending in /ID, SCT or PIX
718  std::string r3=iobj->substr(iobj->size()-3,3);
719  if (r3=="/ID") nt_level=1;
720  if (r3=="SCT" || r3=="PIX") nt_level=2;
721  nt_side=side;
722  nt_xofs=dx;
723  nt_yofs=dy;
724  nt_zofs=dz;
725  nt_phi=phi;
726  nt_theta=theta;
727  nt_psi=psi;
728  nt_alpha=alpha;
729  nt_beta=beta;
730  nt_gamma=gamma;
731  if (StatusCode::SUCCESS!=nt->write()) ATH_MSG_ERROR("Problem filling ntuple 9002" );
732  } else {
733  *outfile << "2 " << det << " " << 2*bec << " " << layer << " " << sector <<
734  " " << ring << " " << side << " " << dx << " " << dy << " "
735  << dz << " " << alpha/CLHEP::mrad << " " << beta/CLHEP::mrad << " " << gamma/CLHEP::mrad << std::endl;
736  }
737  }
738  } else {
739  ATH_MSG_ERROR("Cannot find AlignableTransform for key "
740  << *iobj );
741  }
742  }
743  if (ntuple) {
744  } else {
745  outfile->close();
746  delete outfile;
747  }
748  ATH_MSG_DEBUG("Written " << nobj << " AlignableTransform objects" << " with " << ntrans << " transforms to text file" );
749 }
750 
751 // write extra txt file for new IBLDist
752 void InDetAlignDBTool::writeIBLDistFile( const std::string& file)
753  const {
754  std::ofstream* outfile=nullptr;
755 
756  ATH_MSG_DEBUG( "writeFile: Write IBLDist DB in text file: " << file );
757  outfile=new std::ofstream(file.c_str());
758  *outfile << "/Indet/IBLDist" << std::endl;
759 
760  const CondAttrListCollection* atrlistcol=nullptr;
761  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,"/Indet/IBLDist")) {
762  // loop over objects in collection
763  for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
764 
765  const coral::AttributeList& atrlist=citr->second;
766  *outfile << citr->first << " " << atrlist["stave"].data<int>()
767  << " " << atrlist["eta"].data<int>()
768  << " " << atrlist["mag"].data<float>()
769  << " " << atrlist["base"].data<float>() << std::endl;
770  }
771  }
772  else {
773  if (msgLvl(MSG::INFO))
774  msg(MSG::INFO) << "Cannot find IBLDist Container - cannot write IBLDist DB in text file " << endmsg;
775  }
776 
777  outfile->close();
778  delete outfile;
779 
780 }
781 
782 
783 // write extra txt file for new IBLDist
785  const {
786  std::ofstream* outfile=nullptr;
787 
788  if (m_dynamicDB){
789  ATH_MSG_DEBUG( "writeFile: Write GlobalFolder DB in text file: " << file );
790  outfile=new std::ofstream(file.c_str());
791  std::vector<std::string> folder_list = {"/Indet/AlignL1/ID", "/Indet/AlignL2/PIX", "/Indet/AlignL2/SCT"};
792 
793  for (std::vector<std::string>::iterator it = folder_list.begin(); it != folder_list.end(); ++it){
794 
795  *outfile << *it << std::endl;
796 
797  const CondAttrListCollection* atrlistcol=nullptr;
798  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,*it)) {
799  // loop over objects in collection
800  for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
801 
802  const coral::AttributeList& atrlist=citr->second;
803  *outfile << atrlist["subsystem"].data<int>()
804  << " " << atrlist["det"].data<int>()
805  << " " << atrlist["bec"].data<int>()
806  << " " << atrlist["layer"].data<int>()
807  << " " << atrlist["ring"].data<int>()
808  << " " << atrlist["sector"].data<int>()
809  << " " << atrlist["side"].data<int>()
810  << " " << atrlist["Tx"].data<float>()
811  << " " << atrlist["Ty"].data<float>()
812  << " " << atrlist["Tz"].data<float>()
813  << " " << atrlist["Rx"].data<float>()
814  << " " << atrlist["Ry"].data<float>()
815  << " " << atrlist["Rz"].data<float>() << std::endl;
816  }
817  }
818  else {
819  if (msgLvl(MSG::INFO))
820  msg(MSG::INFO) << "Cannot find " << *it << " Container - cannot write DB in text file " << endmsg;
821  }
822  }
823  outfile->close();
824  delete outfile;
825  }
826  else {
827  ATH_MSG_DEBUG( "writeFile: No dynamic Run2 DB structure is present --> skipping writing file " << file );
828  }
829 }
830 
831 
832 
833 void InDetAlignDBTool::readTextFile(const std::string& file) const {
834  // if (m_par_oldTextFile) return readOldTextFile(file);
835 
836  ATH_MSG_DEBUG("readTextFile - set alignment constants from text file: " << file );
837  std::ifstream infile;
838  infile.open(file.c_str());
839  if (!infile) {
840  ATH_MSG_ERROR("Error opening file " << file );
841  return;
842  }
843 
844  // loop over lines in file
845  int nobj=0;
846  int ntrans=0;
847 
848  std::string channelName; // Channel name
849  const AlignableTransform* pat = nullptr;
850 
851  while (infile) {
852  std::string tmpline;
853  std::getline(infile, tmpline);
854  if (!infile) break;
855 
856  // Skip comment line
857  if ((tmpline.substr(0,2) == "//") || (tmpline.substr(0,1) == "#")) continue;
858 
859  std::istringstream instring(tmpline);
860  std::string tmpstr;
861  instring >> tmpstr;
862 
863  // Skip blank line
864  if (tmpstr.empty()) continue;
865 
866  if (tmpstr[0] == '/') {
867  // Its a valid channel name
868  channelName = tmpstr;
869  ATH_MSG_DEBUG("Read in AlignableTransform data, key " << channelName );
870  // find the AlignableTransform with this key
871  pat = nullptr;
872  if (!(pat=cgetTransPtr(channelName))) {
873  ATH_MSG_ERROR("Cannot find AlignableTransform object for key"
874  << channelName );
875  } else {
876  nobj++;
877  }
878  } else {
879  // Its a data line
880 
881  if (!pat) {
882  // If pat = 0, then either no channel name was specified or it could not be found.
883  ATH_MSG_ERROR("No channel specified. Skipping input " );
884 
885  } else {
886  // normal data
887  std::istringstream datastream(tmpline);
888 
889  int subsystem,dettype,bec,layer,phiModule,etaModule,side;
890  float dx,dy,dz,alpha,beta,gamma;
891  datastream >> subsystem >> dettype >> bec >> layer >> phiModule >> etaModule >> side >> dx
892  >> dy >> dz >> alpha >> beta >> gamma;
893 
894  if (datastream.fail()) {
895  ATH_MSG_ERROR("Error in input" );
896  } else {
897  alpha *= CLHEP::mrad;
898  beta *= CLHEP::mrad;
899  gamma *= CLHEP::mrad;
900 
901  // construct identifier
903  if (dettype==1) {
904  ident=m_pixid->wafer_id(bec,layer,phiModule,etaModule);
905  } else if (dettype==2) {
907  } else {
908  ATH_MSG_ERROR("Cannot construct identifier for dettype "
909  << dettype );
910  }
911  if (!ident.is_valid()) {
912  ATH_MSG_ERROR("Error in identifier : " <<
913  " [" << subsystem << "," << dettype << "," << bec << "," << layer << "," <<
914  phiModule << "," << etaModule << "," << side << "] key " << channelName <<
915  " shift [" << dx << "," << dy << "," << dz << "]" );
916  } else {
917 
918  // construct new transform
919  // Order of rotations is defined as around z, then y, then x.
920  // For small angles it doesn't really matter though.
921  Amg::Translation3D newtranslation(dx,dy,dz);
922  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
923  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
924  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
925  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
926 
927 
928 
929  // find pointer to existing transform, currently missing write access
930  // via findIdent, so have to search manually
931  AlignableTransform* pat2;
932  pat2=const_cast<AlignableTransform*>(pat);
934  while ((itr->identify()!=ident) && (itr!=pat2->mend())) ++itr;
935  if (itr!=pat2->mend()) {
936  ++ntrans;
937  itr->setTransform( Amg::EigenTransformToCLHEP(newtrans) );
938  ATH_MSG_VERBOSE ( "Set transform done");
939  } else {
940  ATH_MSG_WARNING("Cannot find existing transform for");
941  }
942  // Can uses either id helper
943  ATH_MSG_DEBUG(m_pixid->show_to_string(ident) << " key " << channelName <<
944  " shift [" << dx << "," << dy << "," << dz << "]" );
945  }
946  } // end if (datastream.fail())
947  } // end if (!pat)
948  } // end if (tmpstr[0] == '/')
949  } // end while (infile)
950 
951  infile.close();
952  ATH_MSG_DEBUG( "Read " << nobj << " objects from file with " << ntrans << " transforms" );
953 }
954 
955 
956 void InDetAlignDBTool::readNtuple(const std::string& file) const {
957  ATH_MSG_DEBUG("readNtuple - set alignment constants from ntuple path: " << file );
958  SmartIF<INTupleSvc> ntsvc{Gaudi::svcLocator()->service("NTupleSvc")};
959  if(!ntsvc.isValid()) ATH_MSG_ERROR("Cannot find NTupleSvc" );
960  const std::string path=file+"/9002";
961  NTuplePtr nt(ntsvc.get(),path);
962  if (nt) {
963  StatusCode sc;
964  sc=nt->item( "MODPROP/DetType",nt_dettype);
965  sc=nt->item("MODPROP/Bec",nt_bec);
966  sc=nt->item("MODPROP/Layer",nt_layer);
967  sc=nt->item("MODPROP/Ring",nt_ring);
968  sc=nt->item("MODPROP/Sector",nt_sector);
969  sc=nt->item("MODPROP/Side",nt_side);
970  sc=nt->item("MODPROP/Level",nt_level);
971  sc=nt->item("MODPROP/Xofs",nt_xofs);
972  sc=nt->item("MODPROP/Yofs",nt_yofs);
973  sc=nt->item("MODPROP/Zofs",nt_zofs);
974  sc=nt->item("MODPROP/Phi",nt_phi);
975  sc=nt->item("MODPROP/Theta",nt_theta);
976  sc=nt->item("MODPROP/Psi",nt_psi);
977 
978  if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
979  "Error booking ntuple 9002 contents" );
980  int ntrans=0;
981  while (nt->read().isSuccess()) {
983  if (nt_dettype==1) {
985  } else if (nt_dettype==2) {
987  } else {
988  ATH_MSG_ERROR("Cannot construct identifier for dettype "
989  << nt_dettype );
990  }
991 
992  Amg::Translation3D newtranslation(nt_xofs,nt_yofs,nt_zofs);
993  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
994  newtrans *= Amg::AngleAxis3D(nt_psi, Amg::Vector3D(0.,0.,1.));
995  newtrans *= Amg::AngleAxis3D(nt_theta, Amg::Vector3D(0.,1.,0.));
996  newtrans *= Amg::AngleAxis3D(nt_phi, Amg::Vector3D(1.,0.,0.));
997 
998  setTrans(ident,nt_level,newtrans);
999  ++ntrans;
1000  }
1001  ATH_MSG_DEBUG( "Read " << ntrans << " transforms from ntuple");
1002  } else {
1003  ATH_MSG_ERROR( "Problem opening ntuple at path " << path );
1004  }
1005 }
1006 
1008  const Amg::Transform3D& trans) const {
1009 
1010  bool result=false;
1011 
1012  // New additions for new global folder structure -- setTrans for this might need to be revisited
1013  // No ATs exist for levels 1 & 2 --> need alternative
1014  if (m_dynamicDB && level!=3){
1016  if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1017  }
1018  else {
1019  // find transform key, then set appropriate transform
1020  // do storegate const retrieve, then cast to allow update of locked data
1021  std::string key=dirkey(ident,level);
1022  const AlignableTransform* pat;
1023  AlignableTransform* pat2;
1024  bool result=false;
1025  if ((pat=cgetTransPtr(key))) {
1026  pat2=const_cast<AlignableTransform*>(pat);
1027  if (pat2!=nullptr) {
1029  if (!result) ATH_MSG_ERROR( "Attempt to set non-existant transform" );
1030  }
1031  } else {
1032  ATH_MSG_ERROR( "setTrans: cannot retrieve AlignableTransform for key" << key );
1033  }
1034  }
1035 
1036  return result;
1037 }
1038 
1040  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const
1041 {
1042 
1043  Amg::Translation3D newtranslation(translate);
1044  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1045  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1046  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1047  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1048 
1049  return setTrans(ident, level, newtrans);
1050 }
1051 
1052 
1054  const Amg::Transform3D& trans) const {
1055 
1056  bool result=false;
1057 
1058  // New additions for new global folder structure
1059  // No ATs exist for levels 1 & 2 --> need alternative
1060  if (m_dynamicDB && level!=3){
1062  if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1063  }
1064  else {
1065  // find transform key, then set appropriate transform
1066  std::string key=dirkey(ident,level);
1067  const AlignableTransform* pat;
1068  AlignableTransform* pat2;
1069  if ((pat=cgetTransPtr(key))) {
1070  pat2=const_cast<AlignableTransform*>(pat);
1071  if (pat2!=nullptr) {
1073  if (!result) ATH_MSG_ERROR(
1074  "Attempt to tweak non-existent transform for element "<<m_pixid->show_to_string(ident));
1075  } else {
1076  ATH_MSG_ERROR("tweakTrans: cast fails for key " << key );
1077  }
1078  } else {
1079  ATH_MSG_ERROR(
1080  "tweakTrans: cannot retrieve AlignableTransform for key" << key );
1081  }
1082  }
1083 
1084  return result;
1085 }
1086 
1088  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const
1089 {
1090 
1091  Amg::Translation3D newtranslation(translate);
1092  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1093  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1094  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1095  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1096 
1097  return tweakTrans(ident, level, newtrans);
1098 }
1099 
1102  , const int& level
1103  ) const {
1104  if( level == 3 ) return ident ;
1105 
1106  if( m_pixid->is_pixel(ident) ) {
1107  if( level == 1 ) {
1108  return m_pixid->wafer_id( 0, 0, 0, 0 ) ;
1109  }
1110  if( level == 2 ) {
1111  int barrel_ec = m_pixid->barrel_ec( ident ) ;
1112  int layer_disk = m_pixid->layer_disk( ident ) ;
1113  return m_pixid->wafer_id( barrel_ec, layer_disk, 0, 0 ) ;
1114  }
1115  }
1117  if( m_sctid->is_sct(ident) ) {
1118  if( level == 1 ) {
1119  int barrel_ec = m_sctid->barrel_ec( ident ) ;
1120  return m_sctid->wafer_id( barrel_ec, 0, 0, 0, 0 ) ;
1121  }
1122  if( level == 2 ) {
1123  int barrel_ec = m_sctid->barrel_ec( ident ) ;
1124  int layer_disk = m_sctid->layer_disk( ident ) ;
1125  return m_sctid->wafer_id( barrel_ec, layer_disk, 0, 0, 0 ) ;
1126  }
1127  }
1128  return ident ;
1129 }
1130 
1133 
1136  if( !element ) {
1137  element = m_sctman->getDetectorElement( ident ) ;
1138  }
1139  if( !element ) {
1140  ATH_MSG_ERROR("getTransL123(): Module not found in PIX or SCT!" );
1141  return result ;
1142  }
1143  Amg::Transform3D trfL1 = getTrans( ident, 1 ) ;
1144  Amg::Transform3D trfL2 = getTrans( ident, 2 ) ;
1145  Amg::Transform3D trfL3 = getTrans( ident, 3 ) ;
1146  ATH_MSG_FATAL("Code needs to corrected otherwise you will get nonsensical results-- IndetAlignDBTool:2060");
1147  //const Amg::Transform3D trfNominal ; //= element->defModuleTransform() ;
1148  //result = trfNominal.inverse() * trfL1 * trfL2 * trfNominal * trfL3 ;
1149  result = trfL1 * trfL2 * trfL3 ;
1150  return result ;
1151 }
1152 
1157  const int level) const {
1160  const std::string key=dirkey(identifier,level);
1161  const AlignableTransform* pat;
1162  if ((pat=cgetTransPtr(key))) {
1164  if (itr!=pat->end()) result= Amg::CLHEPTransformToEigen(itr->transform());
1165  }
1166  return result;
1167 }
1168 
1170 
1171  ATH_MSG_DEBUG( "Output AlignableTranform objects to stream" << m_par_condstream );
1172  // get the AthenaOutputStream tool
1173 
1174  if (StatusCode::SUCCESS!=m_par_condstream->connectOutput()) {
1175  ATH_MSG_ERROR("Could not connect stream to output" );
1176  return StatusCode::FAILURE;
1177  }else{
1178  ATH_MSG_DEBUG("Stream is connected to output" );
1179  }
1180  // construct list of objects to be written out, either
1181  // AlignableTransformContainer or several of AlignableTransforms
1182  int npairs=m_alignobjs.size();
1183  if (m_par_newdb) npairs=1;
1184  IAthenaOutputStreamTool::TypeKeyPairs typekeys(npairs);
1185  if (m_par_newdb) {
1186  typekeys[0]=
1187  IAthenaOutputStreamTool::TypeKeyPair("AlignableTransformContainer",
1188  m_par_dbroot);
1189  if (!(detStore()->contains<AlignableTransformContainer>(m_par_dbroot)))
1190  ATH_MSG_ERROR(
1191  "Expected " << m_par_dbroot << " object not found" );
1192  } else {
1193  for (unsigned int i=0;i<m_alignobjs.size();++i) {
1194  typekeys[i]=IAthenaOutputStreamTool::TypeKeyPair("AlignableTransform",
1195  m_alignobjs[i]);
1196  if (!(detStore()->contains<AlignableTransform>(m_alignobjs[i])))
1197  ATH_MSG_ERROR("Expected " << m_alignobjs[i] << " object not found" );
1198  }
1199  }
1200  // write objects to stream
1201  if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys)) {
1202  }else{
1203  ATH_MSG_DEBUG("Streamed output objects" );
1204  }
1205 
1206  {
1207  // additional IBLDist DB
1208  ATH_MSG_DEBUG( "starting to register typeKey for IBLDist" );
1209  IAthenaOutputStreamTool::TypeKeyPairs typekeys_IBLDist(1);
1210  IAthenaOutputStreamTool::TypeKeyPair pair("CondAttrListCollection", "/Indet/IBLDist");
1211  typekeys_IBLDist[0] = pair;
1212 
1213  // write objects to stream
1214  if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys_IBLDist)) {
1215  ATH_MSG_ERROR("Could not stream output IBLDist objects" );
1216  return StatusCode::FAILURE;
1217  }else{
1218  ATH_MSG_DEBUG("Streamed output IBLDist objects" );
1219  }
1220 
1221  }
1222 
1223  // commit output
1224  if (StatusCode::SUCCESS!=m_par_condstream->commitOutput()) {
1225  ATH_MSG_ERROR("Could not commit output" );
1226  }
1227  ATH_MSG_DEBUG( "Written " << typekeys.size() << " objects to stream " << m_par_condstream);
1228  return StatusCode::SUCCESS;
1229 }
1230 
1231 void InDetAlignDBTool::fillDB(const std::string& tag,
1232  const unsigned int run1, const unsigned int event1,
1233  const unsigned int run2, const unsigned int event2) const {
1234 
1235  ATH_MSG_DEBUG( "fillDB: Data tag " << tag );
1236  ATH_MSG_DEBUG( "Run/evt1 [" << run1 << "," << event1 << "]" );
1237  ATH_MSG_DEBUG("Run/evt2 [" << run2 << "," << event2 << "]" );
1238 
1239  // get pointer to registration svc
1240  SmartIF<IIOVRegistrationSvc> regsvc{Gaudi::svcLocator()->service("IOVRegistrationSvc")};
1241  if (!regsvc.isValid()) {
1242  ATH_MSG_FATAL( "IOVRegistrationSvc not found" );
1243  return;
1244  }
1245  // loop over all AlignableTransform objects created earlier and save them
1246  int nobj=0;
1247  if (m_par_newdb) {
1248  if (StatusCode::SUCCESS==regsvc->registerIOV(
1249  "AlignableTransformContainer",m_par_dbroot,tag,run1,run2,event1,event2)) {
1250  ATH_MSG_DEBUG( "Stored AlignableTransform object " << m_par_dbroot );
1251  ++nobj;
1252  } else {
1253  ATH_MSG_ERROR("Failed (registerIOV) to store object " << m_par_dbroot );
1254  }
1255  } else {
1256  // old way - register all objects separately
1257  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1258  iobj!=m_alignobjs.end();++iobj) {
1259  if (StatusCode::SUCCESS==regsvc->registerIOV("AlignableTransform",
1260  *iobj,tag,run1,run2,event1,event2)) {
1261  ATH_MSG_DEBUG( "Stored AlignableTransform object " << *iobj );
1262  ++nobj;
1263  } else {
1264  ATH_MSG_ERROR("Failed (registerIOV) to store object " << *iobj );
1265  }
1266  }
1267  }
1268  ATH_MSG_DEBUG( " Written " << nobj << " AlignableTransform objects to conditions database" );
1269 }
1270 
1271 void InDetAlignDBTool::printDB(const int level) const {
1272 
1273  ATH_MSG_DEBUG("Printout InDetAlign database contents, detail level" << level );
1274 
1275  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1276  iobj!=m_alignobjs.end();++iobj) {
1277  const AlignableTransform* pat;
1278  if ((pat=cgetTransPtr(*iobj))) {
1279  ATH_MSG_DEBUG( "AlignableTransform object " << *iobj );
1280  int nobj=0;
1281  for (AlignableTransform::AlignTransMem_citr cit=pat->begin();
1282  cit!=pat->end();++cit) {
1283  const Identifier& ident=cit->identify();
1284  const Amg::Transform3D& trans= Amg::CLHEPTransformToEigen( cit->transform() );
1285  Amg::Vector3D shift=trans.translation();
1286  //Amg::RotationMatrix3D rot=trans.rotation();
1287  int det,bec,layer,ring,sector,side;
1288  if (idToDetSet(ident,det,bec,layer,ring,sector,side)) {
1289  if (level>1) {
1290  double alpha, beta, gamma;
1291  extractAlphaBetaGamma(trans, alpha, beta, gamma);
1292  ATH_MSG_DEBUG( "ID [" << det << "," << bec << "," << layer <<
1293  "," << ring << "," << sector << "," << side << "] Trans:(" <<
1294  shift.x() << "," << shift.y() << "," << shift.z() << ") Rot:{"
1295  << alpha << "," << beta << "," << gamma << "}");
1296  }
1297  ++nobj;
1298  } else {
1299  ATH_MSG_ERROR("Unknown identifier in AlignableTransform" );
1300  }
1301  }
1302  ATH_MSG_DEBUG( "Object contains " << nobj << " transforms" );
1303  } else {
1304  ATH_MSG_ERROR( "AlignableTransform " << *iobj << " not found" );
1305  }
1306  }
1307 }
1308 
1309 // ==========================================
1310 
1312  const {
1313  // look in collection to retrieve pointer to AlignableTransform object of
1314  // given key and return it, return 0 if not collection or key value not found
1316  AlignableTransform* pat=nullptr;
1317  if (m_par_newdb) {
1318  if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1320  dva!=patc->end();++dva) {
1321  if ((*dva)->tag()==key) {
1322  pat=*dva;
1323  break;
1324  }
1325  }
1326  }
1327  } else {
1328  if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1329  }
1330  return pat;
1331 }
1332 
1334  const {
1335  // look in collection to retrieve pointer to AlignableTransform object of
1336  // given key and return it, return 0 if not collection or key value not found
1337  // const version
1338  const AlignableTransformContainer* patc;
1339  const AlignableTransform* pat=nullptr;
1340  if (m_par_newdb) {
1341  if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1343  dva!=patc->end();++dva) {
1344  if ((*dva)->tag()==key) {
1345  pat=*dva;
1346  break;
1347  }
1348  }
1349  }
1350  } else {
1351  if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1352  }
1353  return pat;
1354 }
1355 
1356 void InDetAlignDBTool::fakeGeom(const int nbpix, const int necpix,
1357  const int nbsct, const int necsct) {
1358  // set alignment keys for fake geometry with given numbers of
1359  // barrel/endcap PIX/SCT layers
1360  // this code is somewhat fragile, trying to reproduce the order of
1361  // keys in the same way that GeoModel returns them
1362  // will not work for layouts with missing middle pixel layer
1363 
1364  int ichan3=200;
1365  // level 1 object - ID
1366  m_alignobjs.push_back(dirkey(1,0,0,1));
1367  m_alignchans.push_back(0);
1368  // level 2 objects - pixel
1369  if (nbpix!=0 || necpix!=0) {
1370  m_alignobjs.push_back(dirkey(1,0,0,2));
1371  m_alignchans.push_back(100);
1372  }
1373  // level 3 objects - pixel
1374  // objects done in this order to get COOL channels correct
1375  // endcap A pixel
1376  for (int i=0;i<necpix;++i) {
1377  m_alignobjs.push_back(dirkey(1,-1,i,3));
1378  m_alignchans.push_back(ichan3++);
1379  }
1380  // barrel pixel
1381  for (int i=0;i<nbpix;++i) {
1382  m_alignobjs.push_back(dirkey(1,0,i,3));
1383  m_alignchans.push_back(ichan3++);
1384  }
1385  // endcap C pixel
1386  for (int i=0;i<necpix;++i) {
1387  m_alignobjs.push_back(dirkey(1,1,i,3));
1388  m_alignchans.push_back(ichan3++);
1389  }
1390  // level 2 objects - SCT
1391  if (nbsct!=0 || necsct!=0) {
1392  m_alignobjs.push_back(dirkey(2,0,0,2));
1393  m_alignchans.push_back(101);
1394  }
1395  // level 3 objects - SCT
1396  // endcap A SCT
1397  for (int i=0;i<necsct;++i) {
1398  m_alignobjs.push_back(dirkey(2,-1,i,3));
1399  m_alignchans.push_back(ichan3++);
1400  }
1401  // barrel SCT
1402  for (int i=0;i<nbsct;++i) {
1403  m_alignobjs.push_back(dirkey(2,0,i,3));
1404  m_alignchans.push_back(ichan3++);
1405  }
1406  // endcap C SCT
1407  for (int i=0;i<necsct;++i) {
1408  m_alignobjs.push_back(dirkey(2,1,i,3));
1409  m_alignchans.push_back(ichan3++);
1410  }
1411 }
1412 
1414  // loop through all the AlignableTransform objects and sort them
1415 
1416  ATH_MSG_DEBUG( "Sorting all AlignableTransforms in TDS" );
1418  // use cget and a const cast to allow containers that have been read in
1419  // (and hence are locked by StoreGate) to be sorted
1420  for (unsigned int i=0;i<m_alignobjs.size();++i)
1421  if ((pat=const_cast<AlignableTransform*>(cgetTransPtr(m_alignobjs[i])))) pat->sortv();
1422 }
1423 
1425  double& alpha, double& beta, double &gamma) const
1426 {
1427  double siny = trans(0,2);
1428  beta = asin(siny);
1429  // Check if cosy = 0. This requires special treatment.
1430  // can check either element (1,2),(2,2) both equal zero
1431  // or (0,1) and (0,0)
1432  // Probably not likely it will be exactly 0 and may still
1433  // have some problems when very close to zero. We mostly
1434  // deal with small rotations so its not too important.
1435  if ((trans(1,2) == 0) && (trans(2,2) == 0)) {
1436  // alpha and gamma are degenerate. We arbitrarily choose
1437  // gamma = 0.
1438  gamma = 0;
1439  alpha = atan2(trans(1,1),trans(2,1));
1440  } else {
1441  alpha = atan2(-trans(1,2),trans(2,2));
1442  gamma = atan2(-trans(0,1),trans(0,0));
1443  if (alpha == 0) alpha = 0; // convert -0 to 0
1444  if (gamma == 0) gamma = 0; // convert -0 to 0
1445  }
1446 }
1447 
1448 
1449 bool InDetAlignDBTool::tweakIBLDist(const int stave, const float bowx) const {
1450 
1451  // find transform key, then set appropriate transform
1452  const CondAttrListCollection* atrlistcol1=nullptr;
1453  CondAttrListCollection* atrlistcol2=nullptr;
1454  bool result=false;
1455  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,"/Indet/IBLDist")) {
1456  // loop over objects in collection
1457  atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1458  if (atrlistcol2!=nullptr){
1459  for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1460 
1461  const coral::AttributeList& atrlist=citr->second;
1462  coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1463 
1464  if(atrlist2["stave"].data<int>()!=stave) continue;
1465  else {
1466  msg(MSG::DEBUG) << "IBLDist DB -- channel before update: " << citr->first
1467  << " ,stave: " << atrlist2["stave"].data<int>()
1468  << " ,mag: " << atrlist2["mag"].data<float>()
1469  << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1470 
1471  atrlist2["mag"].data<float>() += bowx;
1472  result = true;
1473  msg(MSG::DEBUG) << "IBLDist DB -- channel after update: " << citr->first
1474  << " ,stave: " << atrlist2["stave"].data<int>()
1475  << " ,mag: " << atrlist2["mag"].data<float>()
1476  << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1477 
1478  }
1479  }
1480  }
1481  else {
1482  ATH_MSG_ERROR("tweakIBLDist: cast fails for stave " << stave );
1483  return false;
1484  }
1485  }
1486  else {
1487  ATH_MSG_ERROR("tweakIBLDist: cannot retrieve CondAttrListCollection for key /Indet/IBLDist" );
1488  return false;
1489  }
1490 
1491  return result;
1492 }
1493 
1494 
1495 
1497  const Amg::Transform3D& trans ) const {
1498 
1499  // find transform key, then set appropriate transform
1500  const CondAttrListCollection* atrlistcol1=nullptr;
1501  CondAttrListCollection* atrlistcol2=nullptr;
1502  bool result=false;
1503  std::string key=dirkey(ident,level);
1504  int det,bec,layer,ring,sector,side;
1505  idToDetSet(ident,det,bec,layer,ring,sector,side);
1506  const unsigned int DBident=det*10000+2*bec*1000+layer*100+ring*10+sector;
1507  // so far not a very fancy DB identifier, but seems elaborate enough for this simple structure
1508 
1509  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,key)) {
1510  // loop over objects in collection
1511  //atrlistcol1->dump();
1512  atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1513  if (atrlistcol2!=nullptr){
1514  for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1515 
1516  const coral::AttributeList& atrlist=citr->second;
1517  coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1518 
1519  if(citr->first!=DBident) continue;
1520  else {
1521  msg(MSG::DEBUG) << "Tweak Old global DB -- channel: " << citr->first
1522  << " ,det: " << atrlist2["det"].data<int>()
1523  << " ,bec: " << atrlist2["bec"].data<int>()
1524  << " ,layer: " << atrlist2["layer"].data<int>()
1525  << " ,ring: " << atrlist2["ring"].data<int>()
1526  << " ,sector: " << atrlist2["sector"].data<int>()
1527  << " ,Tx: " << atrlist2["Tx"].data<float>()
1528  << " ,Ty: " << atrlist2["Ty"].data<float>()
1529  << " ,Tz: " << atrlist2["Tz"].data<float>()
1530  << " ,Rx: " << atrlist2["Rx"].data<float>()
1531  << " ,Ry: " << atrlist2["Ry"].data<float>()
1532  << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1533 
1534 
1535  // Order of rotations is defined as around z, then y, then x.
1536  Amg::Translation3D oldtranslation(atrlist2["Tx"].data<float>(),atrlist2["Ty"].data<float>(),atrlist2["Tz"].data<float>());
1537  Amg::Transform3D oldtrans = oldtranslation * Amg::RotationMatrix3D::Identity();
1538  oldtrans *= Amg::AngleAxis3D(atrlist2["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.));
1539  oldtrans *= Amg::AngleAxis3D(atrlist2["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.));
1540  oldtrans *= Amg::AngleAxis3D(atrlist2["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.));
1541 
1542  // get the new transform
1543  Amg::Transform3D newtrans = trans*oldtrans;
1544 
1545  // Extract the values we need to write to DB
1546  Amg::Vector3D shift=newtrans.translation();
1547  double alpha, beta, gamma;
1548  extractAlphaBetaGamma(newtrans, alpha, beta, gamma);
1549 
1550  atrlist2["Tx"].data<float>() = shift.x();
1551  atrlist2["Ty"].data<float>() = shift.y();
1552  atrlist2["Tz"].data<float>() = shift.z();
1553  atrlist2["Rx"].data<float>() = alpha/CLHEP::mrad ;
1554  atrlist2["Ry"].data<float>() = beta/CLHEP::mrad ;
1555  atrlist2["Rz"].data<float>() = gamma/CLHEP::mrad ;
1556 
1557  result = true;
1558  msg(MSG::DEBUG) << "Tweak New global DB -- channel: " << citr->first
1559  << " ,det: " << atrlist2["det"].data<int>()
1560  << " ,bec: " << atrlist2["bec"].data<int>()
1561  << " ,layer: " << atrlist2["layer"].data<int>()
1562  << " ,ring: " << atrlist2["ring"].data<int>()
1563  << " ,sector: " << atrlist2["sector"].data<int>()
1564  << " ,Tx: " << atrlist2["Tx"].data<float>()
1565  << " ,Ty: " << atrlist2["Ty"].data<float>()
1566  << " ,Tz: " << atrlist2["Tz"].data<float>()
1567  << " ,Rx: " << atrlist2["Rx"].data<float>()
1568  << " ,Ry: " << atrlist2["Ry"].data<float>()
1569  << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1570 
1571  }
1572  }
1573  }
1574  else {
1575  ATH_MSG_ERROR("tweakGlobalFolder: cast fails for DBident " << DBident );
1576  return false;
1577  }
1578  }
1579  else {
1580  ATH_MSG_ERROR("tweakGlobalFolder: cannot retrieve CondAttrListCollection for key " << key );
1581  return false;
1582  }
1583 
1584  return result;
1585 }
1586 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
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:760
nt_zofs
NTuple::Item< float > nt_zofs
Definition: InDetAlignDBTool.cxx:52
InDetAlignDBTool::sortTrans
virtual void sortTrans() const override
Definition: InDetAlignDBTool.cxx:1413
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
InDetAlignDBTool::DBMkey
virtual std::string DBMkey(const int, const int, const int, const int) const override
Definition: InDetAlignDBTool.cxx:479
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
InDetAlignDBTool::getTrans
virtual Amg::Transform3D getTrans(const Identifier &ident, const int level) const override
return value of particular transform specified by identifier and level calculates L1 and L2 identifie...
Definition: InDetAlignDBTool.cxx:1156
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
InDetAlignDBTool::outputObjs
virtual StatusCode outputObjs() override
Definition: InDetAlignDBTool.cxx:1169
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:100
get_generator_info.result
result
Definition: get_generator_info.py:21
InDetDD::SCT_DetectorManager
Definition: SCT_DetectorManager.h:49
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
run.infile
string infile
Definition: run.py:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
nt_xofs
NTuple::Item< float > nt_xofs
Definition: InDetAlignDBTool.cxx:50
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
AlignableTransformContainer
CondMultChanCollection< AlignableTransform > AlignableTransformContainer
Definition: AlignableTransformContainer.h:17
InDetDD::timedependent_run2
@ timedependent_run2
Definition: InDetDD_Defs.h:19
ParticleGun_SamplingFraction.bec
int bec
Definition: ParticleGun_SamplingFraction.py:89
nt_yofs
NTuple::Item< float > nt_yofs
Definition: InDetAlignDBTool.cxx:51
InDetAlignDBTool::m_par_newdb
bool m_par_newdb
Definition: InDetAlignDBTool.h:192
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
AtlasDetectorID::is_sct
bool is_sct(Identifier id) const
Definition: AtlasDetectorID.h:770
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
nt_side
NTuple::Item< long > nt_side
Definition: InDetAlignDBTool.cxx:48
CondMultChanCollection
A CondMultChanCollection is a template class which can hold a collection of T* objects which are inte...
Definition: CondMultChanCollection.h:52
AlignableTransform::AlignTransMem_citr
std::vector< AlignTransMember >::const_iterator AlignTransMem_citr
Definition: AlignableTransform.h:46
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
AlignableTransform::update
bool update(const Identifier &ident, const HepGeom::Transform3D &trans)
Definition: AlignableTransform.cxx:39
nt_theta
NTuple::Item< float > nt_theta
Definition: InDetAlignDBTool.cxx:54
skel.it
it
Definition: skel.GENtoEVGEN.py:396
nt_gamma
NTuple::Item< float > nt_gamma
Definition: InDetAlignDBTool.cxx:58
nt_alpha
NTuple::Item< float > nt_alpha
Definition: InDetAlignDBTool.cxx:56
InDetAlignDBTool::m_par_oldTextFile
bool m_par_oldTextFile
Definition: InDetAlignDBTool.h:202
AthCommonMsg< AlgTool >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
IIOVRegistrationSvc.h
This is an interface to a tool used to register conditions objects in the Interval of Validity (IOV) ...
InDetAlignDBTool::getTransL123
virtual Amg::Transform3D getTransL123(const Identifier &ident) const override
get cumulative L1, L2, L3 trafo for (L3-) module.
Definition: InDetAlignDBTool.cxx:1132
InDetAlignDBTool::tweakIBLDist
virtual bool tweakIBLDist(const int, const float) const override
This is the tweak function for the IBLDist DB.
Definition: InDetAlignDBTool.cxx:1449
InDetDD::static_run1
@ static_run1
Definition: InDetDD_Defs.h:19
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
xAOD::identifier
identifier
Definition: UncalibratedMeasurement_v1.cxx:15
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthenaAttributeList.h
python.SystemOfUnits.mrad
int mrad
Definition: SystemOfUnits.py:112
InDetAlignDBTool::m_pixmanName
Gaudi::Property< std::string > m_pixmanName
Definition: InDetAlignDBTool.h:212
InDetDD::SCT_DetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Definition: SCT_DetectorManager.cxx:64
nt_layer
NTuple::Item< long > nt_layer
Definition: InDetAlignDBTool.cxx:45
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
InDetAlignDBTool::m_managers
std::vector< const InDetDD::SiDetectorManager * > m_managers
Definition: InDetAlignDBTool.h:185
InDetAlignDBTool::~InDetAlignDBTool
virtual ~InDetAlignDBTool()
Definition: InDetAlignDBTool.cxx:89
InDetAlignDBTool::getTransPtr
AlignableTransform * getTransPtr(const std::string &key) const
Definition: InDetAlignDBTool.cxx:1311
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
module_driven_slicing.key2
key2
Definition: module_driven_slicing.py:159
nt_dettype
NTuple::Item< long > nt_dettype
Definition: InDetAlignDBTool.cxx:43
InDetAlignDBTool::m_dynamicDB
bool m_dynamicDB
Definition: InDetAlignDBTool.h:209
InDetAlignDBTool::cgetTransPtr
const AlignableTransform * cgetTransPtr(const std::string &key) const
Definition: InDetAlignDBTool.cxx:1333
nt_level
NTuple::Item< long > nt_level
Definition: InDetAlignDBTool.cxx:49
InDetAlignDBTool::m_alignchans
std::vector< int > m_alignchans
Definition: InDetAlignDBTool.h:188
TRT::Hit::side
@ side
Definition: HitInfo.h:83
InDetDD::SCT_DetectorManager::getDetectorElementCollection
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collectiom
Definition: SCT_DetectorManager.cxx:88
nt_bec
NTuple::Item< long > nt_bec
Definition: InDetAlignDBTool.cxx:44
InDetAlignDBTool::m_par_fake
int m_par_fake
Definition: InDetAlignDBTool.h:194
InDetDD::PixelDetectorManager::getDetectorElementCollection
virtual const SiDetectorElementCollection * getDetectorElementCollection() const override
access to whole collection via Iterators
Definition: PixelDetectorManager.cxx:105
InDetDD_Defs.h
PixelDetectorManager.h
InDetAlignDBTool::extractAlphaBetaGamma
void extractAlphaBetaGamma(const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const override
Definition: InDetAlignDBTool.cxx:1424
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetAlignDBTool::m_par_dbroot
Gaudi::Property< std::string > m_par_dbroot
name of the root folder for constants, which can be set via the <key> syntax.
Definition: InDetAlignDBTool.h:198
TrigVtx::gamma
@ gamma
Definition: TrigParticleTable.h:26
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDetAlignDBTool::m_pixid
const PixelID * m_pixid
Definition: InDetAlignDBTool.h:181
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
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
maskDeadModules.run1
run1
Definition: maskDeadModules.py:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AlignableTransformContainer.h
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetAlignDBTool::tweakGlobalFolder
virtual bool tweakGlobalFolder(const Identifier &ident, const int level, const Amg::Transform3D &trans) const
This is the tweak function for the GlobalFolder DB.
Definition: InDetAlignDBTool.cxx:1496
file
TFile * file
Definition: tile_monitor.h:29
IAthenaOutputStreamTool::TypeKeyPair
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
Definition: IAthenaOutputStreamTool.h:99
test_pyathena.parent
parent
Definition: test_pyathena.py:15
InDetAlignDBTool::finalize
virtual StatusCode finalize() override
Definition: InDetAlignDBTool.cxx:247
nt_beta
NTuple::Item< float > nt_beta
Definition: InDetAlignDBTool.cxx:57
plotBeamSpotCompare.xd
xd
Definition: plotBeamSpotCompare.py:220
nt_ring
NTuple::Item< long > nt_ring
Definition: InDetAlignDBTool.cxx:46
AlignableTransform
Definition: AlignableTransform.h:24
InDetAlignDBTool::m_par_condstream
ToolHandle< IAthenaOutputStreamTool > m_par_condstream
Definition: InDetAlignDBTool.h:195
InDetAlignDBTool::m_par_scttwoside
bool m_par_scttwoside
Definition: InDetAlignDBTool.h:193
CLHEPtoEigenConverter.h
ReadCellNoiseFromCoolCompare.run2
run2
Definition: ReadCellNoiseFromCoolCompare.py:53
CondMultChanCollection::add
void add(ChanNum chanNum)
Adding in channel numbers.
Definition: CondMultChanCollection.h:199
InDetAlignDBTool::printDB
virtual void printDB(const int level) const override
Definition: InDetAlignDBTool.cxx:1271
dso-stats.pat
pat
Definition: dso-stats.py:39
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
InDetAlignDBTool::setTrans
virtual bool setTrans(const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
Definition: InDetAlignDBTool.cxx:1007
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
InDetDD::PixelDetectorManager
Definition: PixelDetectorManager.h:47
InDetAlignDBTool::m_pixman
const InDetDD::PixelDetectorManager * m_pixman
Definition: InDetAlignDBTool.h:183
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AlignableTransform::AlignTransMem_itr
std::vector< AlignTransMember >::iterator AlignTransMem_itr
Definition: AlignableTransform.h:51
InDetAlignDBTool::writeGlobalFolderFile
virtual void writeGlobalFolderFile(const std::string &file) const override
Definition: InDetAlignDBTool.cxx:784
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetAlignDBTool::dispGroup
virtual void dispGroup(const int dettype, const int bec, const int layer, const int ring, const int sector, const float rphidisp, const float rdisp, const float zdisp, const int syst, const int level, const int skip) const override
Definition: InDetAlignDBTool.cxx:496
InDetAlignDBTool::m_sctman
const InDetDD::SCT_DetectorManager * m_sctman
Definition: InDetAlignDBTool.h:184
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
nt_sector
NTuple::Item< long > nt_sector
Definition: InDetAlignDBTool.cxx:47
SiDetectorElementCollection.h
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
InDetAlignDBTool::InDetAlignDBTool
InDetAlignDBTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InDetAlignDBTool.cxx:60
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
InDetAlignDBTool::m_sctmanName
Gaudi::Property< std::string > m_sctmanName
Definition: InDetAlignDBTool.h:213
makeTRTBarrelCans.dy
tuple dy
Definition: makeTRTBarrelCans.py:21
InDetAlignDBTool::writeFile
virtual void writeFile(const bool ntuple, const std::string &file) const override
Definition: InDetAlignDBTool.cxx:632
InDetAlignDBTool::tweakTrans
virtual bool tweakTrans(const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
Definition: InDetAlignDBTool.cxx:1053
TRT::Hit::phiModule
@ phiModule
Definition: HitInfo.h:80
python.SystemOfUnits.gauss
int gauss
Definition: SystemOfUnits.py:230
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:574
InDetAlignDBTool::m_par_dbkey
std::string m_par_dbkey
the base part of the key for loading AlignableTransform objects from the Transient Data Store.
Definition: InDetAlignDBTool.h:201
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetAlignDBTool::dirkey
virtual std::string dirkey(const Identifier &, const int) const override
Definition: InDetAlignDBTool.cxx:416
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
InDetAlignDBTool::m_sctid
const SCT_ID * m_sctid
Definition: InDetAlignDBTool.h:182
Amg::CLHEPTransformToEigen
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:38
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DEBUG
#define DEBUG
Definition: page_access.h:11
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
AthCommonMsg< AlgTool >::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
InDetDD::SiDetectorManager
Definition: SiDetectorManager.h:60
InDetAlignDBTool.h
InDetAlignDBTool::idToDetSet
virtual bool idToDetSet(const Identifier ident, int &det, int &bec, int &layer, int &ring, int &sector, int &side) const override
Definition: InDetAlignDBTool.cxx:389
nt_phi
NTuple::Item< float > nt_phi
Definition: InDetAlignDBTool.cxx:53
InDetAlignDBTool::writeIBLDistFile
virtual void writeIBLDistFile(const std::string &file) const override
Definition: InDetAlignDBTool.cxx:752
nt_psi
NTuple::Item< float > nt_psi
Definition: InDetAlignDBTool.cxx:55
InDetDD::InDetDetectorManager::m_alignfoldertype
AlignFolderType m_alignfoldertype
Definition: InDetDetectorManager.h:96
InDetAlignDBTool::initialize
virtual StatusCode initialize() override
Definition: InDetAlignDBTool.cxx:92
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
AlignableTransform::mend
AlignTransMem_itr mend()
Definition: AlignableTransform.h:113
InDetAlignDBTool::m_forceUserDBConfig
bool m_forceUserDBConfig
Definition: InDetAlignDBTool.h:210
InDetAlignDBTool::createDB
virtual void createDB() const override
Definition: InDetAlignDBTool.cxx:253
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
beamspotnt.nt
def nt
Definition: bin/beamspotnt.py:1063
skip
bool skip
Definition: TrigGlobEffCorrValidation.cxx:190
AthAlgTool
Definition: AthAlgTool.h:26
SCT_ID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition: SCT_ID.h:464
InDetAlignDBTool::readTextFile
virtual void readTextFile(const std::string &file) const override
Definition: InDetAlignDBTool.cxx:833
SCT_DetectorManager.h
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
InDetAlignDBTool::readNtuple
virtual void readNtuple(const std::string &file) const override
Definition: InDetAlignDBTool.cxx:956
L1TopoSimulationConfig.subsystem
subsystem
Definition: L1TopoSimulationConfig.py:263
InDetAlignDBTool::fillDB
virtual void fillDB(const std::string &tag, const unsigned int run1, const unsigned int event1, const unsigned int run2, const unsigned int event2) const override
Definition: InDetAlignDBTool.cxx:1231
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
InDetAlignDBTool::fakeGeom
void fakeGeom(const int nbpix, const int necpix, const int nbsct, const int necsct)
Definition: InDetAlignDBTool.cxx:1356
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
AlignableTransform::tweak
bool tweak(const Identifier &ident, const HepGeom::Transform3D &trans)
Definition: AlignableTransform.cxx:48
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80
InDetAlignDBTool::m_alignobjs
std::vector< std::string > m_alignobjs
Definition: InDetAlignDBTool.h:187
InDetAlignDBTool::m_attrListCollection
CondAttrListCollection * m_attrListCollection
Definition: InDetAlignDBTool.h:190
Identifier
Definition: IdentifierFieldParser.cxx:14
AlignableTransform::mbegin
AlignTransMem_itr mbegin()
Definition: AlignableTransform.h:111
module_driven_slicing.key1
key1
Definition: module_driven_slicing.py:158
InDetAlignDBTool::getL1L2fromL3Identifier
virtual Identifier getL1L2fromL3Identifier(const Identifier &ident, const int &level) const override
convert L3 module identifier to L1 or L2
Definition: InDetAlignDBTool.cxx:1101