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