ATLAS Offline Software
InDetAlignDBTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 
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  IRndmGenSvc* randsvc;
505  if (StatusCode::SUCCESS!=service("RndmGenSvc",randsvc,true))
506  ATH_MSG_ERROR("Cannot find RndmGenSvc" );
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  INTupleSvc* ntsvc;
636  if (StatusCode::SUCCESS!=service("NTupleSvc",ntsvc,true))
637  ATH_MSG_ERROR("Cannot find NTupleSvc" );
638  const std::string path=file+"/9002";
639  NTuplePtr nt(ntsvc,path);
640 
641  if (ntuple) {
642  ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on ntuple 9002, path: " << file );
643  const int ntid=9002;
644  if (nt) {
645  ATH_MSG_DEBUG( "Ntuple " << path << " is already booked" );
646  } else {
647  ATH_MSG_DEBUG("Attempting to book ntuple " << path );
648  nt=ntsvc->book(file,ntid,CLID_ColumnWiseTuple,"AlignDB");
649  if (!nt) ATH_MSG_ERROR("Ntuple booking fails" );
650  }
651  StatusCode sc;
652  sc=nt->addItem("MODPROP/DetType",nt_dettype);
653  sc=nt->addItem("MODPROP/Bec",nt_bec);
654  sc=nt->addItem("MODPROP/Layer",nt_layer);
655  sc=nt->addItem("MODPROP/Ring",nt_ring);
656  sc=nt->addItem("MODPROP/Sector",nt_sector);
657  sc=nt->addItem("MODPROP/Side",nt_side);
658  sc=nt->addItem("MODPROP/Level",nt_level);
659  sc=nt->addItem("MODPROP/Xofs",nt_xofs);
660  sc=nt->addItem("MODPROP/Yofs",nt_yofs);
661  sc=nt->addItem("MODPROP/Zofs",nt_zofs);
662  sc=nt->addItem("MODPROP/Phi",nt_phi);
663  sc=nt->addItem("MODPROP/Theta",nt_theta);
664  sc=nt->addItem("MODPROP/Psi",nt_psi);
665  sc=nt->addItem("MODPROP/Phi",nt_phi);
666  sc=nt->addItem("MODPROP/Theta",nt_theta);
667  sc=nt->addItem("MODPROP/Psi",nt_psi);
668  if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
669  "Error booking ntuple 9002 contents" );
670  } else {
671  ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on text file: " << file );
672  outfile=new std::ofstream(file.c_str());
673  }
674  int nobj=0;
675  int ntrans=0;
676  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
677  iobj!=m_alignobjs.end();++iobj) {
678  const AlignableTransform* pat;
679  if ((pat=cgetTransPtr(*iobj))) {
680  ++nobj;
681  if (!ntuple) *outfile << *iobj << std::endl;
683  cit!=pat->end();++cit) {
684  const Identifier& ident=cit->identify();
685  const Amg::Transform3D& trans=Amg::CLHEPTransformToEigen( cit->transform() );
686  int det,bec,layer,ring,sector,side;
687  float dx,dy,dz,phi,theta,psi;
688  if (!idToDetSet(ident,det,bec,layer,ring,sector,side)) {
689  // can fail for testbeam whe identifier with all layer
690  // and wafer indices set to zero is not valid in the dictionary
691  // these transforms are not actually used by testbeam GeoModel anyway
692  ATH_MSG_WARNING( "Ident for unknown detector type in " << *iobj );
693  det=1;bec=0;layer=0;ring=0;sector=0;side=0;
694  }
695  Amg::Vector3D shift=trans.translation();
696  Amg::RotationMatrix3D rot=trans.rotation();
697  dx=shift.x();
698  dy=shift.y();
699  dz=shift.z();
700  double alpha, beta, gamma;
701  extractAlphaBetaGamma(trans, alpha, beta, gamma);
702 
703  //ATH_MSG_WARNING("THIS NEEDS TO BE CHECKED --- InDetAlignDBTool.cxx:647");
704  // checked and appears all good, keep this in for now in case we have to recheck things
705  Amg::Vector3D ea = rot.eulerAngles(2, 0, 2);
706 
707  phi= ea[0];
708  theta=ea[1];
709  psi=ea[2];
710  ++ntrans;
711  if (ntuple) {
712  nt_dettype=det;
713  nt_bec=bec;
714  nt_layer=layer;
715  nt_ring=ring;
716  nt_sector=sector;
717  nt_level=3;
718  // derive level by looking for objects ending in /ID, SCT or PIX
719  std::string r3=iobj->substr(iobj->size()-3,3);
720  if (r3=="/ID") nt_level=1;
721  if (r3=="SCT" || r3=="PIX") nt_level=2;
722  nt_side=side;
723  nt_xofs=dx;
724  nt_yofs=dy;
725  nt_zofs=dz;
726  nt_phi=phi;
727  nt_theta=theta;
728  nt_psi=psi;
729  nt_alpha=alpha;
730  nt_beta=beta;
731  nt_gamma=gamma;
732  if (StatusCode::SUCCESS!=nt->write()) ATH_MSG_ERROR("Problem filling ntuple 9002" );
733  } else {
734  *outfile << "2 " << det << " " << 2*bec << " " << layer << " " << sector <<
735  " " << ring << " " << side << " " << dx << " " << dy << " "
736  << dz << " " << alpha/CLHEP::mrad << " " << beta/CLHEP::mrad << " " << gamma/CLHEP::mrad << std::endl;
737  }
738  }
739  } else {
740  ATH_MSG_ERROR("Cannot find AlignableTransform for key "
741  << *iobj );
742  }
743  }
744  if (ntuple) {
745  } else {
746  outfile->close();
747  delete outfile;
748  }
749  ATH_MSG_DEBUG("Written " << nobj << " AlignableTransform objects" << " with " << ntrans << " transforms to text file" );
750 }
751 
752 // write extra txt file for new IBLDist
753 void InDetAlignDBTool::writeIBLDistFile( const std::string& file)
754  const {
755  std::ofstream* outfile=nullptr;
756 
757  ATH_MSG_DEBUG( "writeFile: Write IBLDist DB in text file: " << file );
758  outfile=new std::ofstream(file.c_str());
759  *outfile << "/Indet/IBLDist" << std::endl;
760 
761  const CondAttrListCollection* atrlistcol=nullptr;
762  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,"/Indet/IBLDist")) {
763  // loop over objects in collection
764  for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
765 
766  const coral::AttributeList& atrlist=citr->second;
767  *outfile << citr->first << " " << atrlist["stave"].data<int>()
768  << " " << atrlist["eta"].data<int>()
769  << " " << atrlist["mag"].data<float>()
770  << " " << atrlist["base"].data<float>() << std::endl;
771  }
772  }
773  else {
774  if (msgLvl(MSG::INFO))
775  msg(MSG::INFO) << "Cannot find IBLDist Container - cannot write IBLDist DB in text file " << endmsg;
776  }
777 
778  outfile->close();
779  delete outfile;
780 
781 }
782 
783 
784 // write extra txt file for new IBLDist
786  const {
787  std::ofstream* outfile=nullptr;
788 
789  if (m_dynamicDB){
790  ATH_MSG_DEBUG( "writeFile: Write GlobalFolder DB in text file: " << file );
791  outfile=new std::ofstream(file.c_str());
792  std::vector<std::string> folder_list = {"/Indet/AlignL1/ID", "/Indet/AlignL2/PIX", "/Indet/AlignL2/SCT"};
793 
794  for (std::vector<std::string>::iterator it = folder_list.begin(); it != folder_list.end(); ++it){
795 
796  *outfile << *it << std::endl;
797 
798  const CondAttrListCollection* atrlistcol=nullptr;
799  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,*it)) {
800  // loop over objects in collection
801  for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
802 
803  const coral::AttributeList& atrlist=citr->second;
804  *outfile << atrlist["subsystem"].data<int>()
805  << " " << atrlist["det"].data<int>()
806  << " " << atrlist["bec"].data<int>()
807  << " " << atrlist["layer"].data<int>()
808  << " " << atrlist["ring"].data<int>()
809  << " " << atrlist["sector"].data<int>()
810  << " " << atrlist["side"].data<int>()
811  << " " << atrlist["Tx"].data<float>()
812  << " " << atrlist["Ty"].data<float>()
813  << " " << atrlist["Tz"].data<float>()
814  << " " << atrlist["Rx"].data<float>()
815  << " " << atrlist["Ry"].data<float>()
816  << " " << atrlist["Rz"].data<float>() << std::endl;
817  }
818  }
819  else {
820  if (msgLvl(MSG::INFO))
821  msg(MSG::INFO) << "Cannot find " << *it << " Container - cannot write DB in text file " << endmsg;
822  }
823  }
824  outfile->close();
825  delete outfile;
826  }
827  else {
828  ATH_MSG_DEBUG( "writeFile: No dynamic Run2 DB structure is present --> skipping writing file " << file );
829  }
830 }
831 
832 
833 
834 void InDetAlignDBTool::readTextFile(const std::string& file) const {
835  // if (m_par_oldTextFile) return readOldTextFile(file);
836 
837  ATH_MSG_DEBUG("readTextFile - set alignment constants from text file: " << file );
838  std::ifstream infile;
839  infile.open(file.c_str());
840  if (!infile) {
841  ATH_MSG_ERROR("Error opening file " << file );
842  return;
843  }
844 
845  // loop over lines in file
846  int nobj=0;
847  int ntrans=0;
848 
849  std::string channelName; // Channel name
850  const AlignableTransform* pat = nullptr;
851 
852  while (infile) {
853  std::string tmpline;
854  std::getline(infile, tmpline);
855  if (!infile) break;
856 
857  // Skip comment line
858  if ((tmpline.substr(0,2) == "//") || (tmpline.substr(0,1) == "#")) continue;
859 
860  std::istringstream instring(tmpline);
861  std::string tmpstr;
862  instring >> tmpstr;
863 
864  // Skip blank line
865  if (tmpstr.empty()) continue;
866 
867  if (tmpstr[0] == '/') {
868  // Its a valid channel name
869  channelName = tmpstr;
870  ATH_MSG_DEBUG("Read in AlignableTransform data, key " << channelName );
871  // find the AlignableTransform with this key
872  pat = nullptr;
873  if (!(pat=cgetTransPtr(channelName))) {
874  ATH_MSG_ERROR("Cannot find AlignableTransform object for key"
875  << channelName );
876  } else {
877  nobj++;
878  }
879  } else {
880  // Its a data line
881 
882  if (!pat) {
883  // If pat = 0, then either no channel name was specified or it could not be found.
884  ATH_MSG_ERROR("No channel specified. Skipping input " );
885 
886  } else {
887  // normal data
888  std::istringstream datastream(tmpline);
889 
890  int subsystem,dettype,bec,layer,phiModule,etaModule,side;
891  float dx,dy,dz,alpha,beta,gamma;
892  datastream >> subsystem >> dettype >> bec >> layer >> phiModule >> etaModule >> side >> dx
893  >> dy >> dz >> alpha >> beta >> gamma;
894 
895  if (datastream.fail()) {
896  ATH_MSG_ERROR("Error in input" );
897  } else {
898  alpha *= CLHEP::mrad;
899  beta *= CLHEP::mrad;
900  gamma *= CLHEP::mrad;
901 
902  // construct identifier
904  if (dettype==1) {
905  ident=m_pixid->wafer_id(bec,layer,phiModule,etaModule);
906  } else if (dettype==2) {
908  } else {
909  ATH_MSG_ERROR("Cannot construct identifier for dettype "
910  << dettype );
911  }
912  if (!ident.is_valid()) {
913  ATH_MSG_ERROR("Error in identifier : " <<
914  " [" << subsystem << "," << dettype << "," << bec << "," << layer << "," <<
915  phiModule << "," << etaModule << "," << side << "] key " << channelName <<
916  " shift [" << dx << "," << dy << "," << dz << "]" );
917  } else {
918 
919  // construct new transform
920  // Order of rotations is defined as around z, then y, then x.
921  // For small angles it doesn't really matter though.
922  Amg::Translation3D newtranslation(dx,dy,dz);
923  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
924  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
925  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
926  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
927 
928 
929 
930  // find pointer to existing transform, currently missing write access
931  // via findIdent, so have to search manually
932  AlignableTransform* pat2;
933  pat2=const_cast<AlignableTransform*>(pat);
935  while ((itr->identify()!=ident) && (itr!=pat2->mend())) ++itr;
936  if (itr!=pat2->mend()) {
937  ++ntrans;
938  itr->setTransform( Amg::EigenTransformToCLHEP(newtrans) );
939  ATH_MSG_VERBOSE ( "Set transform done");
940  } else {
941  ATH_MSG_WARNING("Cannot find existing transform for");
942  }
943  // Can uses either id helper
944  ATH_MSG_DEBUG(m_pixid->show_to_string(ident) << " key " << channelName <<
945  " shift [" << dx << "," << dy << "," << dz << "]" );
946  }
947  } // end if (datastream.fail())
948  } // end if (!pat)
949  } // end if (tmpstr[0] == '/')
950  } // end while (infile)
951 
952  infile.close();
953  ATH_MSG_DEBUG( "Read " << nobj << " objects from file with " << ntrans << " transforms" );
954 }
955 
956 
957 void InDetAlignDBTool::readNtuple(const std::string& file) const {
958  ATH_MSG_DEBUG("readNtuple - set alignment constants from ntuple path: " << file );
959  INTupleSvc* ntsvc;
960  if (StatusCode::SUCCESS!=service("NTupleSvc",ntsvc,true))
961  ATH_MSG_ERROR("Cannot find NTupleSvc" );
962  const std::string path=file+"/9002";
963  NTuplePtr nt(ntsvc,path);
964  if (nt) {
965  StatusCode sc;
966  sc=nt->item( "MODPROP/DetType",nt_dettype);
967  sc=nt->item("MODPROP/Bec",nt_bec);
968  sc=nt->item("MODPROP/Layer",nt_layer);
969  sc=nt->item("MODPROP/Ring",nt_ring);
970  sc=nt->item("MODPROP/Sector",nt_sector);
971  sc=nt->item("MODPROP/Side",nt_side);
972  sc=nt->item("MODPROP/Level",nt_level);
973  sc=nt->item("MODPROP/Xofs",nt_xofs);
974  sc=nt->item("MODPROP/Yofs",nt_yofs);
975  sc=nt->item("MODPROP/Zofs",nt_zofs);
976  sc=nt->item("MODPROP/Phi",nt_phi);
977  sc=nt->item("MODPROP/Theta",nt_theta);
978  sc=nt->item("MODPROP/Psi",nt_psi);
979 
980  if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
981  "Error booking ntuple 9002 contents" );
982  int ntrans=0;
983  while (nt->read().isSuccess()) {
985  if (nt_dettype==1) {
987  } else if (nt_dettype==2) {
989  } else {
990  ATH_MSG_ERROR("Cannot construct identifier for dettype "
991  << nt_dettype );
992  }
993 
994  Amg::Translation3D newtranslation(nt_xofs,nt_yofs,nt_zofs);
995  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
996  newtrans *= Amg::AngleAxis3D(nt_psi, Amg::Vector3D(0.,0.,1.));
997  newtrans *= Amg::AngleAxis3D(nt_theta, Amg::Vector3D(0.,1.,0.));
998  newtrans *= Amg::AngleAxis3D(nt_phi, Amg::Vector3D(1.,0.,0.));
999 
1000  setTrans(ident,nt_level,newtrans);
1001  ++ntrans;
1002  }
1003  ATH_MSG_DEBUG( "Read " << ntrans << " transforms from ntuple");
1004  } else {
1005  ATH_MSG_ERROR( "Problem opening ntuple at path " << path );
1006  }
1007 }
1008 
1010  const Amg::Transform3D& trans) const {
1011 
1012  bool result=false;
1013 
1014  // New additions for new global folder structure -- setTrans for this might need to be revisited
1015  // No ATs exist for levels 1 & 2 --> need alternative
1016  if (m_dynamicDB && level!=3){
1018  if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1019  }
1020  else {
1021  // find transform key, then set appropriate transform
1022  // do storegate const retrieve, then cast to allow update of locked data
1023  std::string key=dirkey(ident,level);
1024  const AlignableTransform* pat;
1025  AlignableTransform* pat2;
1026  bool result=false;
1027  if ((pat=cgetTransPtr(key))) {
1028  pat2=const_cast<AlignableTransform*>(pat);
1029  if (pat2!=nullptr) {
1031  if (!result) ATH_MSG_ERROR( "Attempt to set non-existant transform" );
1032  }
1033  } else {
1034  ATH_MSG_ERROR( "setTrans: cannot retrieve AlignableTransform for key" << key );
1035  }
1036  }
1037 
1038  return result;
1039 }
1040 
1042  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const
1043 {
1044 
1045  Amg::Translation3D newtranslation(translate);
1046  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1047  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1048  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1049  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1050 
1051  return setTrans(ident, level, newtrans);
1052 }
1053 
1054 
1056  const Amg::Transform3D& trans) const {
1057 
1058  bool result=false;
1059 
1060  // New additions for new global folder structure
1061  // No ATs exist for levels 1 & 2 --> need alternative
1062  if (m_dynamicDB && level!=3){
1064  if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1065  }
1066  else {
1067  // find transform key, then set appropriate transform
1068  std::string key=dirkey(ident,level);
1069  const AlignableTransform* pat;
1070  AlignableTransform* pat2;
1071  if ((pat=cgetTransPtr(key))) {
1072  pat2=const_cast<AlignableTransform*>(pat);
1073  if (pat2!=nullptr) {
1075  if (!result) ATH_MSG_ERROR(
1076  "Attempt to tweak non-existent transform for element "<<m_pixid->show_to_string(ident));
1077  } else {
1078  ATH_MSG_ERROR("tweakTrans: cast fails for key " << key );
1079  }
1080  } else {
1081  ATH_MSG_ERROR(
1082  "tweakTrans: cannot retrieve AlignableTransform for key" << key );
1083  }
1084  }
1085 
1086  return result;
1087 }
1088 
1090  const Amg::Vector3D& translate, double alpha, double beta, double gamma) const
1091 {
1092 
1093  Amg::Translation3D newtranslation(translate);
1094  Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1095  newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1096  newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1097  newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1098 
1099  return tweakTrans(ident, level, newtrans);
1100 }
1101 
1104  , const int& level
1105  ) const {
1106  if( level == 3 ) return ident ;
1107 
1108  if( m_pixid->is_pixel(ident) ) {
1109  if( level == 1 ) {
1110  return m_pixid->wafer_id( 0, 0, 0, 0 ) ;
1111  }
1112  if( level == 2 ) {
1113  int barrel_ec = m_pixid->barrel_ec( ident ) ;
1114  int layer_disk = m_pixid->layer_disk( ident ) ;
1115  return m_pixid->wafer_id( barrel_ec, layer_disk, 0, 0 ) ;
1116  }
1117  }
1119  if( m_sctid->is_sct(ident) ) {
1120  if( level == 1 ) {
1121  int barrel_ec = m_sctid->barrel_ec( ident ) ;
1122  return m_sctid->wafer_id( barrel_ec, 0, 0, 0, 0 ) ;
1123  }
1124  if( level == 2 ) {
1125  int barrel_ec = m_sctid->barrel_ec( ident ) ;
1126  int layer_disk = m_sctid->layer_disk( ident ) ;
1127  return m_sctid->wafer_id( barrel_ec, layer_disk, 0, 0, 0 ) ;
1128  }
1129  }
1130  return ident ;
1131 }
1132 
1135 
1138  if( !element ) {
1139  element = m_sctman->getDetectorElement( ident ) ;
1140  }
1141  if( !element ) {
1142  ATH_MSG_ERROR("getTransL123(): Module not found in PIX or SCT!" );
1143  return result ;
1144  }
1145  Amg::Transform3D trfL1 = getTrans( ident, 1 ) ;
1146  Amg::Transform3D trfL2 = getTrans( ident, 2 ) ;
1147  Amg::Transform3D trfL3 = getTrans( ident, 3 ) ;
1148  ATH_MSG_FATAL("Code needs to corrected otherwise you will get nonsensical results-- IndetAlignDBTool:2060");
1149  //const Amg::Transform3D trfNominal ; //= element->defModuleTransform() ;
1150  //result = trfNominal.inverse() * trfL1 * trfL2 * trfNominal * trfL3 ;
1151  result = trfL1 * trfL2 * trfL3 ;
1152  return result ;
1153 }
1154 
1159  const int level) const {
1162  const std::string key=dirkey(identifier,level);
1163  const AlignableTransform* pat;
1164  if ((pat=cgetTransPtr(key))) {
1166  if (itr!=pat->end()) result= Amg::CLHEPTransformToEigen(itr->transform());
1167  }
1168  return result;
1169 }
1170 
1172 
1173  ATH_MSG_DEBUG( "Output AlignableTranform objects to stream" << m_par_condstream );
1174  // get the AthenaOutputStream tool
1175 
1176  if (StatusCode::SUCCESS!=m_par_condstream->connectOutput()) {
1177  ATH_MSG_ERROR("Could not connect stream to output" );
1178  return StatusCode::FAILURE;
1179  }else{
1180  ATH_MSG_DEBUG("Stream is connected to output" );
1181  }
1182  // construct list of objects to be written out, either
1183  // AlignableTransformContainer or several of AlignableTransforms
1184  int npairs=m_alignobjs.size();
1185  if (m_par_newdb) npairs=1;
1186  IAthenaOutputStreamTool::TypeKeyPairs typekeys(npairs);
1187  if (m_par_newdb) {
1188  typekeys[0]=
1189  IAthenaOutputStreamTool::TypeKeyPair("AlignableTransformContainer",
1190  m_par_dbroot);
1191  if (!(detStore()->contains<AlignableTransformContainer>(m_par_dbroot)))
1192  ATH_MSG_ERROR(
1193  "Expected " << m_par_dbroot << " object not found" );
1194  } else {
1195  for (unsigned int i=0;i<m_alignobjs.size();++i) {
1196  typekeys[i]=IAthenaOutputStreamTool::TypeKeyPair("AlignableTransform",
1197  m_alignobjs[i]);
1198  if (!(detStore()->contains<AlignableTransform>(m_alignobjs[i])))
1199  ATH_MSG_ERROR("Expected " << m_alignobjs[i] << " object not found" );
1200  }
1201  }
1202  // write objects to stream
1203  if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys)) {
1204  }else{
1205  ATH_MSG_DEBUG("Streamed output objects" );
1206  }
1207 
1208  {
1209  // additional IBLDist DB
1210  ATH_MSG_DEBUG( "starting to register typeKey for IBLDist" );
1211  IAthenaOutputStreamTool::TypeKeyPairs typekeys_IBLDist(1);
1212  IAthenaOutputStreamTool::TypeKeyPair pair("CondAttrListCollection", "/Indet/IBLDist");
1213  typekeys_IBLDist[0] = pair;
1214 
1215  // write objects to stream
1216  if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys_IBLDist)) {
1217  ATH_MSG_ERROR("Could not stream output IBLDist objects" );
1218  return StatusCode::FAILURE;
1219  }else{
1220  ATH_MSG_DEBUG("Streamed output IBLDist objects" );
1221  }
1222 
1223  }
1224 
1225  // commit output
1226  if (StatusCode::SUCCESS!=m_par_condstream->commitOutput()) {
1227  ATH_MSG_ERROR("Could not commit output" );
1228  }
1229  ATH_MSG_DEBUG( "Written " << typekeys.size() << " objects to stream " << m_par_condstream);
1230  return StatusCode::SUCCESS;
1231 }
1232 
1233 void InDetAlignDBTool::fillDB(const std::string& tag,
1234  const unsigned int run1, const unsigned int event1,
1235  const unsigned int run2, const unsigned int event2) const {
1236 
1237  ATH_MSG_DEBUG( "fillDB: Data tag " << tag );
1238  ATH_MSG_DEBUG( "Run/evt1 [" << run1 << "," << event1 << "]" );
1239  ATH_MSG_DEBUG("Run/evt2 [" << run2 << "," << event2 << "]" );
1240 
1241  // get pointer to registration svc
1242  IIOVRegistrationSvc* regsvc;
1243  if (StatusCode::SUCCESS!=
1244  service("IOVRegistrationSvc",regsvc)) {
1245  ATH_MSG_FATAL( "IOVRegistrationSvc not found" );
1246  return;
1247  }
1248  // loop over all AlignableTransform objects created earlier and save them
1249  int nobj=0;
1250  if (m_par_newdb) {
1251  if (StatusCode::SUCCESS==regsvc->registerIOV(
1252  "AlignableTransformContainer",m_par_dbroot,tag,run1,run2,event1,event2)) {
1253  ATH_MSG_DEBUG( "Stored AlignableTransform object " << m_par_dbroot );
1254  ++nobj;
1255  } else {
1256  ATH_MSG_ERROR("Failed (registerIOV) to store object " << m_par_dbroot );
1257  }
1258  } else {
1259  // old way - register all objects separately
1260  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1261  iobj!=m_alignobjs.end();++iobj) {
1262  if (StatusCode::SUCCESS==regsvc->registerIOV("AlignableTransform",
1263  *iobj,tag,run1,run2,event1,event2)) {
1264  ATH_MSG_DEBUG( "Stored AlignableTransform object " << *iobj );
1265  ++nobj;
1266  } else {
1267  ATH_MSG_ERROR("Failed (registerIOV) to store object " << *iobj );
1268  }
1269  }
1270  }
1271  ATH_MSG_DEBUG( " Written " << nobj << " AlignableTransform objects to conditions database" );
1272 }
1273 
1274 void InDetAlignDBTool::printDB(const int level) const {
1275 
1276  ATH_MSG_DEBUG("Printout InDetAlign database contents, detail level" << level );
1277 
1278  for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1279  iobj!=m_alignobjs.end();++iobj) {
1280  const AlignableTransform* pat;
1281  if ((pat=cgetTransPtr(*iobj))) {
1282  ATH_MSG_DEBUG( "AlignableTransform object " << *iobj );
1283  int nobj=0;
1284  for (AlignableTransform::AlignTransMem_citr cit=pat->begin();
1285  cit!=pat->end();++cit) {
1286  const Identifier& ident=cit->identify();
1287  const Amg::Transform3D& trans= Amg::CLHEPTransformToEigen( cit->transform() );
1288  Amg::Vector3D shift=trans.translation();
1289  //Amg::RotationMatrix3D rot=trans.rotation();
1290  int det,bec,layer,ring,sector,side;
1291  if (idToDetSet(ident,det,bec,layer,ring,sector,side)) {
1292  if (level>1) {
1293  double alpha, beta, gamma;
1294  extractAlphaBetaGamma(trans, alpha, beta, gamma);
1295  ATH_MSG_DEBUG( "ID [" << det << "," << bec << "," << layer <<
1296  "," << ring << "," << sector << "," << side << "] Trans:(" <<
1297  shift.x() << "," << shift.y() << "," << shift.z() << ") Rot:{"
1298  << alpha << "," << beta << "," << gamma << "}");
1299  }
1300  ++nobj;
1301  } else {
1302  ATH_MSG_ERROR("Unknown identifier in AlignableTransform" );
1303  }
1304  }
1305  ATH_MSG_DEBUG( "Object contains " << nobj << " transforms" );
1306  } else {
1307  ATH_MSG_ERROR( "AlignableTransform " << *iobj << " not found" );
1308  }
1309  }
1310 }
1311 
1312 // ==========================================
1313 
1315  const {
1316  // look in collection to retrieve pointer to AlignableTransform object of
1317  // given key and return it, return 0 if not collection or key value not found
1319  AlignableTransform* pat=nullptr;
1320  if (m_par_newdb) {
1321  if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1323  dva!=patc->end();++dva) {
1324  if ((*dva)->tag()==key) {
1325  pat=*dva;
1326  break;
1327  }
1328  }
1329  }
1330  } else {
1331  if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1332  }
1333  return pat;
1334 }
1335 
1337  const {
1338  // look in collection to retrieve pointer to AlignableTransform object of
1339  // given key and return it, return 0 if not collection or key value not found
1340  // const version
1341  const AlignableTransformContainer* patc;
1342  const AlignableTransform* pat=nullptr;
1343  if (m_par_newdb) {
1344  if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1346  dva!=patc->end();++dva) {
1347  if ((*dva)->tag()==key) {
1348  pat=*dva;
1349  break;
1350  }
1351  }
1352  }
1353  } else {
1354  if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1355  }
1356  return pat;
1357 }
1358 
1359 void InDetAlignDBTool::fakeGeom(const int nbpix, const int necpix,
1360  const int nbsct, const int necsct) {
1361  // set alignment keys for fake geometry with given numbers of
1362  // barrel/endcap PIX/SCT layers
1363  // this code is somewhat fragile, trying to reproduce the order of
1364  // keys in the same way that GeoModel returns them
1365  // will not work for layouts with missing middle pixel layer
1366 
1367  int ichan3=200;
1368  // level 1 object - ID
1369  m_alignobjs.push_back(dirkey(1,0,0,1));
1370  m_alignchans.push_back(0);
1371  // level 2 objects - pixel
1372  if (nbpix!=0 || necpix!=0) {
1373  m_alignobjs.push_back(dirkey(1,0,0,2));
1374  m_alignchans.push_back(100);
1375  }
1376  // level 3 objects - pixel
1377  // objects done in this order to get COOL channels correct
1378  // endcap A pixel
1379  for (int i=0;i<necpix;++i) {
1380  m_alignobjs.push_back(dirkey(1,-1,i,3));
1381  m_alignchans.push_back(ichan3++);
1382  }
1383  // barrel pixel
1384  for (int i=0;i<nbpix;++i) {
1385  m_alignobjs.push_back(dirkey(1,0,i,3));
1386  m_alignchans.push_back(ichan3++);
1387  }
1388  // endcap C pixel
1389  for (int i=0;i<necpix;++i) {
1390  m_alignobjs.push_back(dirkey(1,1,i,3));
1391  m_alignchans.push_back(ichan3++);
1392  }
1393  // level 2 objects - SCT
1394  if (nbsct!=0 || necsct!=0) {
1395  m_alignobjs.push_back(dirkey(2,0,0,2));
1396  m_alignchans.push_back(101);
1397  }
1398  // level 3 objects - SCT
1399  // endcap A SCT
1400  for (int i=0;i<necsct;++i) {
1401  m_alignobjs.push_back(dirkey(2,-1,i,3));
1402  m_alignchans.push_back(ichan3++);
1403  }
1404  // barrel SCT
1405  for (int i=0;i<nbsct;++i) {
1406  m_alignobjs.push_back(dirkey(2,0,i,3));
1407  m_alignchans.push_back(ichan3++);
1408  }
1409  // endcap C SCT
1410  for (int i=0;i<necsct;++i) {
1411  m_alignobjs.push_back(dirkey(2,1,i,3));
1412  m_alignchans.push_back(ichan3++);
1413  }
1414 }
1415 
1417  // loop through all the AlignableTransform objects and sort them
1418 
1419  ATH_MSG_DEBUG( "Sorting all AlignableTransforms in TDS" );
1421  // use cget and a const cast to allow containers that have been read in
1422  // (and hence are locked by StoreGate) to be sorted
1423  for (unsigned int i=0;i<m_alignobjs.size();++i)
1424  if ((pat=const_cast<AlignableTransform*>(cgetTransPtr(m_alignobjs[i])))) pat->sortv();
1425 }
1426 
1428  double& alpha, double& beta, double &gamma) const
1429 {
1430  double siny = trans(0,2);
1431  beta = asin(siny);
1432  // Check if cosy = 0. This requires special treatment.
1433  // can check either element (1,2),(2,2) both equal zero
1434  // or (0,1) and (0,0)
1435  // Probably not likely it will be exactly 0 and may still
1436  // have some problems when very close to zero. We mostly
1437  // deal with small rotations so its not too important.
1438  if ((trans(1,2) == 0) && (trans(2,2) == 0)) {
1439  // alpha and gamma are degenerate. We arbitrarily choose
1440  // gamma = 0.
1441  gamma = 0;
1442  alpha = atan2(trans(1,1),trans(2,1));
1443  } else {
1444  alpha = atan2(-trans(1,2),trans(2,2));
1445  gamma = atan2(-trans(0,1),trans(0,0));
1446  if (alpha == 0) alpha = 0; // convert -0 to 0
1447  if (gamma == 0) gamma = 0; // convert -0 to 0
1448  }
1449 }
1450 
1451 
1452 bool InDetAlignDBTool::tweakIBLDist(const int stave, const float bowx) const {
1453 
1454  // find transform key, then set appropriate transform
1455  const CondAttrListCollection* atrlistcol1=nullptr;
1456  CondAttrListCollection* atrlistcol2=nullptr;
1457  bool result=false;
1458  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,"/Indet/IBLDist")) {
1459  // loop over objects in collection
1460  atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1461  if (atrlistcol2!=nullptr){
1462  for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1463 
1464  const coral::AttributeList& atrlist=citr->second;
1465  coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1466 
1467  if(atrlist2["stave"].data<int>()!=stave) continue;
1468  else {
1469  msg(MSG::DEBUG) << "IBLDist DB -- channel before update: " << citr->first
1470  << " ,stave: " << atrlist2["stave"].data<int>()
1471  << " ,mag: " << atrlist2["mag"].data<float>()
1472  << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1473 
1474  atrlist2["mag"].data<float>() += bowx;
1475  result = true;
1476  msg(MSG::DEBUG) << "IBLDist DB -- channel after update: " << citr->first
1477  << " ,stave: " << atrlist2["stave"].data<int>()
1478  << " ,mag: " << atrlist2["mag"].data<float>()
1479  << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1480 
1481  }
1482  }
1483  }
1484  else {
1485  ATH_MSG_ERROR("tweakIBLDist: cast fails for stave " << stave );
1486  return false;
1487  }
1488  }
1489  else {
1490  ATH_MSG_ERROR("tweakIBLDist: cannot retrieve CondAttrListCollection for key /Indet/IBLDist" );
1491  return false;
1492  }
1493 
1494  return result;
1495 }
1496 
1497 
1498 
1500  const Amg::Transform3D& trans ) const {
1501 
1502  // find transform key, then set appropriate transform
1503  const CondAttrListCollection* atrlistcol1=nullptr;
1504  CondAttrListCollection* atrlistcol2=nullptr;
1505  bool result=false;
1506  std::string key=dirkey(ident,level);
1507  int det,bec,layer,ring,sector,side;
1508  idToDetSet(ident,det,bec,layer,ring,sector,side);
1509  const unsigned int DBident=det*10000+2*bec*1000+layer*100+ring*10+sector;
1510  // so far not a very fancy DB identifier, but seems elaborate enough for this simple structure
1511 
1512  if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,key)) {
1513  // loop over objects in collection
1514  //atrlistcol1->dump();
1515  atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1516  if (atrlistcol2!=nullptr){
1517  for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1518 
1519  const coral::AttributeList& atrlist=citr->second;
1520  coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1521 
1522  if(citr->first!=DBident) continue;
1523  else {
1524  msg(MSG::DEBUG) << "Tweak Old global DB -- channel: " << citr->first
1525  << " ,det: " << atrlist2["det"].data<int>()
1526  << " ,bec: " << atrlist2["bec"].data<int>()
1527  << " ,layer: " << atrlist2["layer"].data<int>()
1528  << " ,ring: " << atrlist2["ring"].data<int>()
1529  << " ,sector: " << atrlist2["sector"].data<int>()
1530  << " ,Tx: " << atrlist2["Tx"].data<float>()
1531  << " ,Ty: " << atrlist2["Ty"].data<float>()
1532  << " ,Tz: " << atrlist2["Tz"].data<float>()
1533  << " ,Rx: " << atrlist2["Rx"].data<float>()
1534  << " ,Ry: " << atrlist2["Ry"].data<float>()
1535  << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1536 
1537 
1538  // Order of rotations is defined as around z, then y, then x.
1539  Amg::Translation3D oldtranslation(atrlist2["Tx"].data<float>(),atrlist2["Ty"].data<float>(),atrlist2["Tz"].data<float>());
1540  Amg::Transform3D oldtrans = oldtranslation * Amg::RotationMatrix3D::Identity();
1541  oldtrans *= Amg::AngleAxis3D(atrlist2["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.));
1542  oldtrans *= Amg::AngleAxis3D(atrlist2["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.));
1543  oldtrans *= Amg::AngleAxis3D(atrlist2["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.));
1544 
1545  // get the new transform
1546  Amg::Transform3D newtrans = trans*oldtrans;
1547 
1548  // Extract the values we need to write to DB
1549  Amg::Vector3D shift=newtrans.translation();
1550  double alpha, beta, gamma;
1551  extractAlphaBetaGamma(newtrans, alpha, beta, gamma);
1552 
1553  atrlist2["Tx"].data<float>() = shift.x();
1554  atrlist2["Ty"].data<float>() = shift.y();
1555  atrlist2["Tz"].data<float>() = shift.z();
1556  atrlist2["Rx"].data<float>() = alpha/CLHEP::mrad ;
1557  atrlist2["Ry"].data<float>() = beta/CLHEP::mrad ;
1558  atrlist2["Rz"].data<float>() = gamma/CLHEP::mrad ;
1559 
1560  result = true;
1561  msg(MSG::DEBUG) << "Tweak New global DB -- channel: " << citr->first
1562  << " ,det: " << atrlist2["det"].data<int>()
1563  << " ,bec: " << atrlist2["bec"].data<int>()
1564  << " ,layer: " << atrlist2["layer"].data<int>()
1565  << " ,ring: " << atrlist2["ring"].data<int>()
1566  << " ,sector: " << atrlist2["sector"].data<int>()
1567  << " ,Tx: " << atrlist2["Tx"].data<float>()
1568  << " ,Ty: " << atrlist2["Ty"].data<float>()
1569  << " ,Tz: " << atrlist2["Tz"].data<float>()
1570  << " ,Rx: " << atrlist2["Rx"].data<float>()
1571  << " ,Ry: " << atrlist2["Ry"].data<float>()
1572  << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1573 
1574  }
1575  }
1576  }
1577  else {
1578  ATH_MSG_ERROR("tweakGlobalFolder: cast fails for DBident " << DBident );
1579  return false;
1580  }
1581  }
1582  else {
1583  ATH_MSG_ERROR("tweakGlobalFolder: cannot retrieve CondAttrListCollection for key " << key );
1584  return false;
1585  }
1586 
1587  return result;
1588 }
1589 
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:1416
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:1158
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:1171
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:99
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:126
run.infile
string infile
Definition: run.py:13
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
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
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:71
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:423
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:1134
InDetAlignDBTool::tweakIBLDist
virtual bool tweakIBLDist(const int, const float) const override
This is the tweak function for the IBLDist DB.
Definition: InDetAlignDBTool.cxx:1452
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
IIOVRegistrationSvc::registerIOV
virtual StatusCode registerIOV(const std::string &typeName) const =0
Register IOV DB for an object given its typeName - run/LB numbers interval or times interval and tag ...
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:1314
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:1336
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:1427
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:92
InDetAlignDBTool::m_pixid
const PixelID * m_pixid
Definition: InDetAlignDBTool.h:181
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
WritePulseShapeToCool.det
det
Definition: WritePulseShapeToCool.py:204
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:1499
file
TFile * file
Definition: tile_monitor.h:29
IAthenaOutputStreamTool::TypeKeyPair
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
Definition: IAthenaOutputStreamTool.h:98
test_pyathena.parent
parent
Definition: test_pyathena.py:15
InDetAlignDBTool::finalize
virtual StatusCode finalize() override
Definition: InDetAlignDBTool.cxx:247
IIOVRegistrationSvc
This is an interface to a service used to register conditions objects in the Interval of Validity (IO...
Definition: IIOVRegistrationSvc.h:52
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:1274
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:1009
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:192
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:785
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
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
InDetAlignDBTool::tweakTrans
virtual bool tweakTrans(const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
Definition: InDetAlignDBTool.cxx:1055
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:753
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:834
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:957
L1TopoSimulationConfig.subsystem
subsystem
Definition: L1TopoSimulationConfig.py:242
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:1233
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetAlignDBTool::fakeGeom
void fakeGeom(const int nbpix, const int necpix, const int nbsct, const int necsct)
Definition: InDetAlignDBTool.cxx:1359
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
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:1103