ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignDBTool Class Reference

#include <InDetAlignDBTool.h>

Inheritance diagram for InDetAlignDBTool:

Public Member Functions

 InDetAlignDBTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~InDetAlignDBTool ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual void createDB () const override
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
virtual void writeFile (const bool ntuple, const std::string &file) const override
virtual void writeIBLDistFile (const std::string &file) const override
virtual void writeGlobalFolderFile (const std::string &file) const override
virtual void readTextFile (const std::string &file) const override
virtual void readNtuple (const std::string &file) const override
virtual bool idToDetSet (const Identifier ident, int &det, int &bec, int &layer, int &ring, int &sector, int &side) const override
virtual std::string dirkey (const Identifier &, const int) const override
virtual std::string dirkey (const int, const int, const int, const int) const override
virtual std::string dirkey (const int, const int, const int, const int, const int) const override
virtual std::string DBMkey (const int, const int, const int, const int) const override
virtual bool setTrans (const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
virtual bool setTrans (const Identifier &ident, const int level, const Amg::Vector3D &translate, double alpha, double beta, double gamma) const override
virtual bool tweakTrans (const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
virtual bool tweakTrans (const Identifier &ident, const int level, const Amg::Vector3D &translate, double alpha, double beta, double gamma) const override
virtual bool tweakIBLDist (const int, const float) const override
 This is the tweak function for the IBLDist DB.
virtual bool tweakGlobalFolder (const Identifier &ident, const int level, const Amg::Transform3D &trans) const
 This is the tweak function for the GlobalFolder DB.
virtual Identifier getL1L2fromL3Identifier (const Identifier &ident, const int &level) const override
 convert L3 module identifier to L1 or L2
virtual Amg::Transform3D getTransL123 (const Identifier &ident) const override
 get cumulative L1, L2, L3 trafo for (L3-) module.
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 identifiers automatically by getL1L2fromL3Identifier if L3 identifier passed.
virtual StatusCode outputObjs () override
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
virtual void printDB (const int level) const override
virtual void sortTrans () const override
void extractAlphaBetaGamma (const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const override
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

AlignableTransformgetTransPtr (const std::string &key) const
const AlignableTransformcgetTransPtr (const std::string &key) const
void fakeGeom (const int nbpix, const int necpix, const int nbsct, const int necsct)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const PixelIDm_pixid {}
const SCT_IDm_sctid {}
const InDetDD::PixelDetectorManagerm_pixman {}
const InDetDD::SCT_DetectorManagerm_sctman {}
bool m_dynamicDB {false}
std::vector< const InDetDD::SiDetectorManager * > m_managers
std::vector< std::string > m_alignobjs
std::vector< int > m_alignchans
CondAttrListCollectionm_attrListCollection {}
std::string m_par_dbkey
Gaudi::Property< bool > m_par_newdb {this, "NewDB", true, "create database using new (collection) format"}
Gaudi::Property< bool > m_par_scttwoside {this, "SCTTwoSide", false, "create structures with separated SCT module sides"}
Gaudi::Property< int > m_par_fake {this, "FakeDB", 0, "set to 1 to fake full ATLAS geom, 2 to fake CTB geom"}
ToolHandle< IAthenaOutputStreamToolm_par_condstream {this, "CondStream", "AthenaOutputStreamTool/AthenaOutputStreamTool"}
Gaudi::Property< std::string > m_par_dbroot { this, "DBRoot", "/Indet/Align", "Root folder for alignment" }
 name of the root folder for constants, which can be set via the <key> syntax.
Gaudi::Property< bool > m_par_oldTextFile {this, "OldTextFile", false, "Input text file using old format"}
Gaudi::Property< bool > m_forceUserDBConfig {this, "forceUserDBConfig", false, "Set to true to override any DB auto-configuration"}
Gaudi::Property< std::string > m_pixmanName {this, "PixelManager", "Pixel", "Pixel manager name" }
Gaudi::Property< std::string > m_sctmanName {this, "SCT_Manager", "SCT", "SCT manager name" }
Gaudi::Property< bool > m_doPix {this, "AlignPixel", true, "Include Pixel" }
Gaudi::Property< bool > m_doStrip {this, "AlignStrip", true, "Include SCT/ITkStrip" }
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 53 of file InDetAlignDBTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ InDetAlignDBTool()

InDetAlignDBTool::InDetAlignDBTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 60 of file InDetAlignDBTool.cxx.

62 : AthAlgTool(type,name,parent)
63{
64 declareInterface<IInDetAlignDBTool>(this);
65}
AthAlgTool()
Default constructor:

◆ ~InDetAlignDBTool()

InDetAlignDBTool::~InDetAlignDBTool ( )
virtual

Definition at line 67 of file InDetAlignDBTool.cxx.

68{}

Member Function Documentation

◆ cgetTransPtr()

const AlignableTransform * InDetAlignDBTool::cgetTransPtr ( const std::string & key) const
private

Definition at line 1317 of file InDetAlignDBTool.cxx.

1318 {
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}
CondMultChanCollection< AlignableTransform > AlignableTransformContainer
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Gaudi::Property< std::string > m_par_dbroot
name of the root folder for constants, which can be set via the <key> syntax.
Gaudi::Property< bool > m_par_newdb
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ createDB()

void InDetAlignDBTool::createDB ( ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 233 of file InDetAlignDBTool.cxx.

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 }
240 AlignableTransform* pat;
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
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) {
266 pat=new AlignableTransform(m_alignobjs[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
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;
293 for (const InDetDD::SiDetectorManager * manager: m_managers) {
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)) {
318 ident2=m_pixid->wafer_id(m_pixid->barrel_ec(ident), m_pixid->layer_disk(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)) {
324 ident2=m_sctid->wafer_id(m_sctid->barrel_ec(ident), m_sctid->layer_disk(ident),0,0,0);
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}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
void add(ChanNum chanNum)
Adding in channel numbers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
std::vector< std::string > m_alignobjs
Gaudi::Property< int > m_par_fake
virtual std::string dirkey(const Identifier &, const int) const override
virtual void sortTrans() const override
Gaudi::Property< bool > m_par_scttwoside
std::vector< const InDetDD::SiDetectorManager * > m_managers
const PixelID * m_pixid
std::vector< int > m_alignchans
const SCT_ID * m_sctid
AlignableTransform * getTransPtr(const std::string &key) const
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Eigen::Affine3d Transform3D
@ ident
Definition HitInfo.h:77

◆ DBMkey()

std::string InDetAlignDBTool::DBMkey ( const int det,
const int bec,
const int level,
const int sector ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 460 of file InDetAlignDBTool.cxx.

461 {
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}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ dirkey() [1/3]

std::string InDetAlignDBTool::dirkey ( const Identifier & ident,
const int level ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 395 of file InDetAlignDBTool.cxx.

396 {
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}
virtual bool idToDetSet(const Identifier ident, int &det, int &bec, int &layer, int &ring, int &sector, int &side) const override
@ layer
Definition HitInfo.h:79

◆ dirkey() [2/3]

std::string InDetAlignDBTool::dirkey ( const int det,
const int bec,
const int layer,
const int level ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 406 of file InDetAlignDBTool.cxx.

407 {
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}
std::string m_par_dbkey

◆ dirkey() [3/3]

std::string InDetAlignDBTool::dirkey ( const int det,
const int bec,
const int layer,
const int level,
const int sector ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 427 of file InDetAlignDBTool.cxx.

428 {
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}
virtual std::string DBMkey(const int, const int, const int, const int) const override

◆ dispGroup()

void InDetAlignDBTool::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
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 477 of file InDetAlignDBTool.cxx.

480 {
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
503 AlignableTransform* pat;
504 for (int idet=1;idet<3;++idet) {
505 for (const InDetDD::SiDetectorElement* element: *(idet==1 ? m_pixman->getDetectorElementCollection() : m_sctman->getDetectorElementCollection())) {
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) {
560 ident2=m_pixid->wafer_id(m_pixid->barrel_ec(ident),
561 m_pixid->layer_disk(ident),0,0);
562 } else {
563 ident2=m_sctid->wafer_id(m_sctid->barrel_ec(ident),
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}
#define ATH_MSG_VERBOSE(x)
const AlignableTransform * cgetTransPtr(const std::string &key) const
const InDetDD::PixelDetectorManager * m_pixman
const InDetDD::SCT_DetectorManager * m_sctman
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extractAlphaBetaGamma()

void InDetAlignDBTool::extractAlphaBetaGamma ( const Amg::Transform3D & trans,
double & alpha,
double & beta,
double & gamma ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1408 of file InDetAlignDBTool.cxx.

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}

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ fakeGeom()

void InDetAlignDBTool::fakeGeom ( const int nbpix,
const int necpix,
const int nbsct,
const int necsct )
private

Definition at line 1340 of file InDetAlignDBTool.cxx.

1341 {
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}

◆ fillDB()

void InDetAlignDBTool::fillDB ( const std::string & tag,
const unsigned int run1,
const unsigned int event1,
const unsigned int run2,
const unsigned int event2 ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1215 of file InDetAlignDBTool.cxx.

1217 {
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}

◆ finalize()

StatusCode InDetAlignDBTool::finalize ( )
overridevirtual

Definition at line 227 of file InDetAlignDBTool.cxx.

228{
229 ATH_MSG_DEBUG( "InDetAlignDBTool finalize method called" );
230 return StatusCode::SUCCESS;
231}

◆ getL1L2fromL3Identifier()

Identifier InDetAlignDBTool::getL1L2fromL3Identifier ( const Identifier & ident,
const int & level ) const
overridevirtual

convert L3 module identifier to L1 or L2

< no translation needed

check whether PIX

< Whole pixel det. at L1

check whether SCT

< barrel + 2 x EC at L1

< take care of the case where level != 1,2,3 or ident neither pix nor sct

Implements IInDetAlignDBTool.

Definition at line 1085 of file InDetAlignDBTool.cxx.

1087 {
1088 if( level == 3 ) return ident ;
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}

◆ getTrans()

Amg::Transform3D InDetAlignDBTool::getTrans ( const Identifier & ident,
const int level ) const
overridevirtual

return value of particular transform specified by identifier and level calculates L1 and L2 identifiers automatically by getL1L2fromL3Identifier if L3 identifier passed.

return value of particular transform specified by identifier and level calculates L1 and L2 identifiers automatically by getL1L2fromL3Identifier if L3 identifier passed

L1, L2 are in global, L3 in local frame.

Implements IInDetAlignDBTool.

Definition at line 1140 of file InDetAlignDBTool.cxx.

1141 {
1142 const Identifier identifier = getL1L2fromL3Identifier( ident, level ) ;
1144 const std::string key=dirkey(identifier,level);
1145 const AlignableTransform* pat;
1146 if ((pat=cgetTransPtr(key))) {
1147 AlignableTransform::AlignTransMem_citr itr=pat->findIdent(identifier);
1148 if (itr!=pat->end()) result= Amg::CLHEPTransformToEigen(itr->transform());
1149 }
1150 return result;
1151}
std::vector< AlignTransMember >::const_iterator AlignTransMem_citr
virtual Identifier getL1L2fromL3Identifier(const Identifier &ident, const int &level) const override
convert L3 module identifier to L1 or L2
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.

◆ getTransL123()

Amg::Transform3D InDetAlignDBTool::getTransL123 ( const Identifier & ident) const
overridevirtual

get cumulative L1, L2, L3 trafo for (L3-) module.

get cumulative L1, L2, L3 trafo for (L3-) module

Result is in local frame.

Implements IInDetAlignDBTool.

Definition at line 1116 of file InDetAlignDBTool.cxx.

1116 {
1117
1119 const InDetDD::SiDetectorElement* element = m_pixman->getDetectorElement( ident ) ;
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}
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...

◆ getTransPtr()

AlignableTransform * InDetAlignDBTool::getTransPtr ( const std::string & key) const
private

Definition at line 1295 of file InDetAlignDBTool.cxx.

1296 {
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}
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842

◆ idToDetSet()

bool InDetAlignDBTool::idToDetSet ( const Identifier ident,
int & det,
int & bec,
int & layer,
int & ring,
int & sector,
int & side ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 368 of file InDetAlignDBTool.cxx.

369 {
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;
377 bec=m_pixid->barrel_ec(ident)/2;
378 layer=m_pixid->layer_disk(ident);
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;
385 bec=m_sctid->barrel_ec(ident)/2;
386 layer=m_sctid->layer_disk(ident);
387 ring=m_sctid->eta_module(ident);
388 sector=m_sctid->phi_module(ident);
389 side=m_sctid->side(ident);
390 resok=true;
391 }
392 return resok;
393}

◆ initialize()

StatusCode InDetAlignDBTool::initialize ( )
overridevirtual

Definition at line 70 of file InDetAlignDBTool.cxx.

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){
108 if (m_pixman->m_alignfoldertype == InDetDD::static_run1 && !m_forceUserDBConfig){
109 m_dynamicDB = false;
110 }
111 if (m_pixman->m_alignfoldertype == InDetDD::timedependent_run2 && !m_forceUserDBConfig){
112 m_par_dbroot = "/Indet/AlignL3";
113 m_dynamicDB = true;
114 }
115 }
116
117 if (m_pixman && m_sctman){
118 if (m_pixman->m_alignfoldertype!=m_sctman->m_alignfoldertype) {
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}
#define ATH_MSG_INFO(x)
ToolHandle< IAthenaOutputStreamTool > m_par_condstream
Gaudi::Property< std::string > m_sctmanName
Gaudi::Property< bool > m_forceUserDBConfig
Gaudi::Property< bool > m_doStrip
Gaudi::Property< std::string > m_pixmanName
void fakeGeom(const int nbpix, const int necpix, const int nbsct, const int necsct)
CondAttrListCollection * m_attrListCollection
Gaudi::Property< bool > m_doPix
@ timedependent_run2

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & IInDetAlignDBTool::interfaceID ( )
inlinestaticinherited

Definition at line 70 of file IInDetAlignDBTool.h.

static const InterfaceID IID_INDETALIGN_IInDetAlignDBTool("IInDetAlignDBTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ outputObjs()

StatusCode InDetAlignDBTool::outputObjs ( )
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1153 of file InDetAlignDBTool.cxx.

1153 {
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;
1169 if (m_par_newdb) {
1170 typekeys[0]=
1171 IAthenaOutputStreamTool::TypeKeyPair("AlignableTransformContainer",
1172 m_par_dbroot);
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]);
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}
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
std::vector< TypeKeyPair > TypeKeyPairs

◆ printDB()

void InDetAlignDBTool::printDB ( const int level) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1255 of file InDetAlignDBTool.cxx.

1255 {
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;
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;
1275 extractAlphaBetaGamma(trans, 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}
void extractAlphaBetaGamma(const Amg::Transform3D &trans, double &alpha, double &beta, double &gamma) const override

◆ readNtuple()

void InDetAlignDBTool::readNtuple ( const std::string & file) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 940 of file InDetAlignDBTool.cxx.

940 {
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) {
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()) {
966 Identifier ident=Identifier();
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
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}
NTuple::Item< float > nt_zofs
NTuple::Item< float > nt_xofs
NTuple::Item< float > nt_phi
NTuple::Item< long > nt_layer
NTuple::Item< float > nt_yofs
NTuple::Item< long > nt_ring
NTuple::Item< long > nt_side
NTuple::Item< long > nt_sector
NTuple::Item< float > nt_theta
NTuple::Item< long > nt_bec
NTuple::Item< long > nt_dettype
NTuple::Item< float > nt_psi
NTuple::Item< long > nt_level
static Double_t sc
virtual bool setTrans(const Identifier &ident, const int level, const Amg::Transform3D &trans) const override
Eigen::AngleAxisd AngleAxis3D
::StatusCode StatusCode
StatusCode definition for legacy code.
path
python interpreter configuration --------------------------------------—
Definition athena.py:128
TFile * file

◆ readTextFile()

void InDetAlignDBTool::readTextFile ( const std::string & file) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 817 of file InDetAlignDBTool.cxx.

817 {
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
886 Identifier ident=Identifier();
887 if (dettype==1) {
888 ident=m_pixid->wafer_id(bec,layer,phiModule,etaModule);
889 } else if (dettype==2) {
890 ident=m_sctid->wafer_id(bec,layer,phiModule,etaModule,side);
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}
#define ATH_MSG_WARNING(x)
AlignTransMem_itr mend()
std::vector< AlignTransMember >::iterator AlignTransMem_itr
AlignTransMem_itr mbegin()
@ phiModule
Definition HitInfo.h:80
str infile
Definition run.py:13

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setTrans() [1/2]

bool InDetAlignDBTool::setTrans ( const Identifier & ident,
const int level,
const Amg::Transform3D & trans ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 991 of file InDetAlignDBTool.cxx.

992 {
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){
999 result=tweakGlobalFolder(ident, level, trans);
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) {
1012 result=pat2->update(ident, Amg::EigenTransformToCLHEP(trans) );
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}
bool update(const Identifier &ident, const HepGeom::Transform3D &trans)
virtual bool tweakGlobalFolder(const Identifier &ident, const int level, const Amg::Transform3D &trans) const
This is the tweak function for the GlobalFolder DB.

◆ setTrans() [2/2]

bool InDetAlignDBTool::setTrans ( const Identifier & ident,
const int level,
const Amg::Vector3D & translate,
double alpha,
double beta,
double gamma ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1023 of file InDetAlignDBTool.cxx.

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}

◆ sortTrans()

void InDetAlignDBTool::sortTrans ( ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1397 of file InDetAlignDBTool.cxx.

1397 {
1398 // loop through all the AlignableTransform objects and sort them
1399
1400 ATH_MSG_DEBUG( "Sorting all AlignableTransforms in TDS" );
1401 AlignableTransform* pat;
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}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ tweakGlobalFolder()

bool InDetAlignDBTool::tweakGlobalFolder ( const Identifier & ident,
const int level,
const Amg::Transform3D & trans ) const
virtual

This is the tweak function for the GlobalFolder DB.

Definition at line 1480 of file InDetAlignDBTool.cxx.

1481 {
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}
#define endmsg
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
MsgStream & msg() const
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator

◆ tweakIBLDist()

bool InDetAlignDBTool::tweakIBLDist ( const int stave,
const float bowx ) const
overridevirtual

This is the tweak function for the IBLDist DB.

Implements IInDetAlignDBTool.

Definition at line 1433 of file InDetAlignDBTool.cxx.

1433 {
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}

◆ tweakTrans() [1/2]

bool InDetAlignDBTool::tweakTrans ( const Identifier & ident,
const int level,
const Amg::Transform3D & trans ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1037 of file InDetAlignDBTool.cxx.

1038 {
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){
1045 result=tweakGlobalFolder(ident, level, trans);
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) {
1056 result=pat2->tweak(ident,Amg::EigenTransformToCLHEP(trans));
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 {
1064 "tweakTrans: cannot retrieve AlignableTransform for key" << key );
1065 }
1066 }
1067
1068 return result;
1069}
bool tweak(const Identifier &ident, const HepGeom::Transform3D &trans)

◆ tweakTrans() [2/2]

bool InDetAlignDBTool::tweakTrans ( const Identifier & ident,
const int level,
const Amg::Vector3D & translate,
double alpha,
double beta,
double gamma ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1071 of file InDetAlignDBTool.cxx.

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}
virtual bool tweakTrans(const Identifier &ident, const int level, const Amg::Transform3D &trans) const override

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

◆ writeFile()

void InDetAlignDBTool::writeFile ( const bool ntuple,
const std::string & file ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 613 of file InDetAlignDBTool.cxx.

614 {
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 }
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;
682 extractAlphaBetaGamma(trans, 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) {
694 nt_bec=bec;
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;
704 nt_xofs=dx;
705 nt_yofs=dy;
706 nt_zofs=dz;
707 nt_phi=phi;
709 nt_psi=psi;
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}
Scalar phi() const
phi method
Scalar theta() const
theta method
NTuple::Item< float > nt_beta
NTuple::Item< float > nt_gamma
NTuple::Item< float > nt_alpha
Eigen::Matrix< double, 3, 3 > RotationMatrix3D

◆ writeGlobalFolderFile()

void InDetAlignDBTool::writeGlobalFolderFile ( const std::string & file) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 768 of file InDetAlignDBTool.cxx.

769 {
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}

◆ writeIBLDistFile()

void InDetAlignDBTool::writeIBLDistFile ( const std::string & file) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 736 of file InDetAlignDBTool.cxx.

737 {
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}

Member Data Documentation

◆ m_alignchans

std::vector<int> InDetAlignDBTool::m_alignchans
private

Definition at line 189 of file InDetAlignDBTool.h.

◆ m_alignobjs

std::vector<std::string> InDetAlignDBTool::m_alignobjs
private

Definition at line 188 of file InDetAlignDBTool.h.

◆ m_attrListCollection

CondAttrListCollection* InDetAlignDBTool::m_attrListCollection {}
private

Definition at line 191 of file InDetAlignDBTool.h.

191{};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doPix

Gaudi::Property<bool> InDetAlignDBTool::m_doPix {this, "AlignPixel", true, "Include Pixel" }
private

Definition at line 206 of file InDetAlignDBTool.h.

206{this, "AlignPixel", true, "Include Pixel" };

◆ m_doStrip

Gaudi::Property<bool> InDetAlignDBTool::m_doStrip {this, "AlignStrip", true, "Include SCT/ITkStrip" }
private

Definition at line 207 of file InDetAlignDBTool.h.

207{this, "AlignStrip", true, "Include SCT/ITkStrip" };

◆ m_dynamicDB

bool InDetAlignDBTool::m_dynamicDB {false}
private

Definition at line 185 of file InDetAlignDBTool.h.

185{false};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_forceUserDBConfig

Gaudi::Property<bool> InDetAlignDBTool::m_forceUserDBConfig {this, "forceUserDBConfig", false, "Set to true to override any DB auto-configuration"}
private

Definition at line 203 of file InDetAlignDBTool.h.

203{this, "forceUserDBConfig", false, "Set to true to override any DB auto-configuration"};

◆ m_managers

std::vector<const InDetDD::SiDetectorManager *> InDetAlignDBTool::m_managers
private

Definition at line 186 of file InDetAlignDBTool.h.

◆ m_par_condstream

ToolHandle<IAthenaOutputStreamTool> InDetAlignDBTool::m_par_condstream {this, "CondStream", "AthenaOutputStreamTool/AthenaOutputStreamTool"}
private

Definition at line 198 of file InDetAlignDBTool.h.

198{this, "CondStream", "AthenaOutputStreamTool/AthenaOutputStreamTool"};

◆ m_par_dbkey

std::string InDetAlignDBTool::m_par_dbkey
private

Definition at line 193 of file InDetAlignDBTool.h.

◆ m_par_dbroot

Gaudi::Property<std::string> InDetAlignDBTool::m_par_dbroot { this, "DBRoot", "/Indet/Align", "Root folder for alignment" }
private

name of the root folder for constants, which can be set via the <key> syntax.

Default: /Indet/Align.

Definition at line 201 of file InDetAlignDBTool.h.

201{ this, "DBRoot", "/Indet/Align", "Root folder for alignment" };

◆ m_par_fake

Gaudi::Property<int> InDetAlignDBTool::m_par_fake {this, "FakeDB", 0, "set to 1 to fake full ATLAS geom, 2 to fake CTB geom"}
private

Definition at line 197 of file InDetAlignDBTool.h.

197{this, "FakeDB", 0, "set to 1 to fake full ATLAS geom, 2 to fake CTB geom"};

◆ m_par_newdb

Gaudi::Property<bool> InDetAlignDBTool::m_par_newdb {this, "NewDB", true, "create database using new (collection) format"}
private

Definition at line 195 of file InDetAlignDBTool.h.

195{this, "NewDB", true, "create database using new (collection) format"}; // FIXME: "New" is misleading

◆ m_par_oldTextFile

Gaudi::Property<bool> InDetAlignDBTool::m_par_oldTextFile {this, "OldTextFile", false, "Input text file using old format"}
private

Definition at line 202 of file InDetAlignDBTool.h.

202{this, "OldTextFile", false, "Input text file using old format"};

◆ m_par_scttwoside

Gaudi::Property<bool> InDetAlignDBTool::m_par_scttwoside {this, "SCTTwoSide", false, "create structures with separated SCT module sides"}
private

Definition at line 196 of file InDetAlignDBTool.h.

196{this, "SCTTwoSide", false, "create structures with separated SCT module sides"};

◆ m_pixid

const PixelID* InDetAlignDBTool::m_pixid {}
private

Definition at line 181 of file InDetAlignDBTool.h.

181{};

◆ m_pixman

const InDetDD::PixelDetectorManager* InDetAlignDBTool::m_pixman {}
private

Definition at line 183 of file InDetAlignDBTool.h.

183{};

◆ m_pixmanName

Gaudi::Property<std::string> InDetAlignDBTool::m_pixmanName {this, "PixelManager", "Pixel", "Pixel manager name" }
private

Definition at line 204 of file InDetAlignDBTool.h.

204{this, "PixelManager", "Pixel", "Pixel manager name" };

◆ m_sctid

const SCT_ID* InDetAlignDBTool::m_sctid {}
private

Definition at line 182 of file InDetAlignDBTool.h.

182{};

◆ m_sctman

const InDetDD::SCT_DetectorManager* InDetAlignDBTool::m_sctman {}
private

Definition at line 184 of file InDetAlignDBTool.h.

184{};

◆ m_sctmanName

Gaudi::Property<std::string> InDetAlignDBTool::m_sctmanName {this, "SCT_Manager", "SCT", "SCT manager name" }
private

Definition at line 205 of file InDetAlignDBTool.h.

205{this, "SCT_Manager", "SCT", "SCT manager name" };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: