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 54 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 64 of file InDetAlignDBTool.cxx.

66 : AthAlgTool(type,name,parent)
67{
68 declareInterface<IInDetAlignDBTool>(this);
69}
AthAlgTool()
Default constructor:

◆ ~InDetAlignDBTool()

InDetAlignDBTool::~InDetAlignDBTool ( )
virtual

Definition at line 71 of file InDetAlignDBTool.cxx.

72{}

Member Function Documentation

◆ cgetTransPtr()

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

Definition at line 1321 of file InDetAlignDBTool.cxx.

1322 {
1323 // look in collection to retrieve pointer to AlignableTransform object of
1324 // given key and return it, return 0 if not collection or key value not found
1325 // const version
1326 const AlignableTransformContainer* patc;
1327 const AlignableTransform* pat=nullptr;
1328 if (m_par_newdb) {
1329 if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1331 dva!=patc->end();++dva) {
1332 if ((*dva)->tag()==key) {
1333 pat=*dva;
1334 break;
1335 }
1336 }
1337 }
1338 } else {
1339 if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1340 }
1341 return pat;
1342}
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

◆ createDB()

void InDetAlignDBTool::createDB ( ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 237 of file InDetAlignDBTool.cxx.

238{
239 ATH_MSG_DEBUG("createDB method called");
240 // check not running in fake mode (need real geometry here)
241 if (m_par_fake) {
242 ATH_MSG_FATAL("Cannot create new database when geometry is faked");
243 }
244 AlignableTransform* pat;
245 AlignableTransformContainer* patc=nullptr;
246 // loop over all SiDetectorElements (pixel and SCT) and fill corresponding
247 // AlignableTransform objects with default values
248
249 // first create the empty AlignableTransform objects in TDS
250 if (m_par_newdb) {
251 // check object does not already exist
253 ATH_MSG_ERROR("createDB: AlignableTransformContainer already exists");
254 return;
255 }
256 // put them in a collection /Indet/Align
257 ATH_MSG_DEBUG( "Setup database structures in AlignableTransformContainer");
259 }
260 else {
261 ATH_MSG_DEBUG( "Setup separate AlignableTransform for each layer");
262 }
263
264 if (msgLvl(MSG::DEBUG)) {
265 if (m_par_scttwoside) ATH_MSG_DEBUG( "Produce separate transforms for each side of SCT modules" );
266 else ATH_MSG_DEBUG( "Treat both sides of SCT module as single entity" );
267 }
268
269 for (unsigned int i=0;i<m_alignobjs.size();++i) {
270 pat=new AlignableTransform(m_alignobjs[i]);
271 if (m_par_newdb) {
272 // add to collection and set corresponding channel number
273 patc->push_back(pat);
274 patc->add(m_alignchans[i]);
275 } else {
276 // store directly in SG
277 // first check object not already there
279 ATH_MSG_FATAL( "create DB: AlignableTransform " << m_alignobjs[i] << " already exists" );
280 delete pat;
281 pat=nullptr;
282 return;
283 }
284 if (StatusCode::SUCCESS!=detStore()->record(pat,m_alignobjs[i]))
285 ATH_MSG_ERROR( "Could not record AlignableTransform "<< m_alignobjs[i] );
286 }
287 }
288 if (m_par_newdb) {
289 // record collection in SG
290 if (StatusCode::SUCCESS!=detStore()->record(patc,m_par_dbroot))
291 ATH_MSG_ERROR("Could not record AlignableTransformContainer");
292 ATH_MSG_DEBUG( "Collection has size " << patc->size() );
293 }
294
295 // now loop over all detector modules and add null level 3 transforms
296 std::vector<std::string> level2;
297 for (const InDetDD::SiDetectorManager * manager: m_managers) {
298 const InDetDD::SCT_DetectorManager * testSCT = nullptr;
299 const InDetDD::PixelDetectorManager * testPixel = nullptr;
300 testPixel = dynamic_cast<const InDetDD::PixelDetectorManager *>(manager);
301 if(!testPixel) testSCT = dynamic_cast<const InDetDD::SCT_DetectorManager *>(manager);
302 for (const InDetDD::SiDetectorElement* element: *manager->getDetectorElementCollection()) {
303 if (element!=nullptr) {
304 const Identifier ident=element->identify();
305 std::string key=dirkey(ident,3);
306 // do not produce AlignableTrasnforms for SCT side 1 if option set
307 if (!(m_sctid && m_sctid->is_sct(ident) && m_sctid->side(ident)==1) || m_par_scttwoside) {
308 if ((pat=getTransPtr(key))) {
309 pat->add(ident,Amg::EigenTransformToCLHEP( Amg::Transform3D::Identity() ) );
310 }
311 else ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key );
312 }
313 // add level 2 transform if needed - do this the first time a module
314 // for this level 3 key is seen
315 std::vector<std::string>::const_iterator ix = find(level2.begin(),level2.end(),key);
316 if (ix==level2.end()) {
317 level2.push_back(std::move(key));
318 // construct identifier of level 2 transform
319 Identifier ident2;
320 if(testPixel){
321 if (m_pixid->is_pixel(ident)) {
322 ident2=m_pixid->wafer_id(m_pixid->barrel_ec(ident), m_pixid->layer_disk(ident),
323 m_pixid->phi_module(ident),0); // needed to be extended to phi-module due to DBM
324 }
325 }
326 if(testSCT){
327 if (m_sctid->is_sct(ident)) {
328 ident2=m_sctid->wafer_id(m_sctid->barrel_ec(ident), m_sctid->layer_disk(ident),0,0,0);
329 }
330 }
331 std::string key2=dirkey(ident,2);
332 if ((pat=getTransPtr(key2))) {
333 pat->add(ident2,Amg::EigenTransformToCLHEP( Amg::Transform3D::Identity() ) );
334 } else ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key2 );
335 }
336 }
337 }
338 }
339 // create the global ID object with positions for the pixels (one unit)
340 // and SCT barrel/endcap
341 Identifier ident1;
342 std::string key1=dirkey(ident1,1);
343 if ((pat=getTransPtr(key1))) {
344 Amg::Transform3D globshift;
345 globshift.setIdentity();
346 if(m_pixid){
347 // pixel - barrel and endcap as one, treated as barrel layer 0 module 0
348 ident1=m_pixid->wafer_id(0,0,0,0);
349 pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
350 }
351 if(m_sctid){
352 // SCT barrel - barrel 0 module 0
353 ident1=m_sctid->wafer_id(0,0,0,0,0);
354 pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
355 // SCT endcaps A and C
356 ident1=m_sctid->wafer_id(-2,0,0,0,0);
357 pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
358 ident1=m_sctid->wafer_id(2,0,0,0,0);
359 pat->add(ident1,Amg::EigenTransformToCLHEP(globshift));
360 }
361 } else {
362 ATH_MSG_ERROR( "Cannot retrieve AlignableTransform for key " << key1 );
363 }
364 // sort the created objects (in case, usually come out sorted from GeoModel)
365 sortTrans();
366 // list out size of all created objects
367 ATH_MSG_DEBUG( "Dumping size of created AlignableTransform objects");
368 for (unsigned int i=0;i<m_alignobjs.size();++i)
369 if ((pat=getTransPtr(m_alignobjs[i]))) pat->print();
370}
#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:116
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:140
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 464 of file InDetAlignDBTool.cxx.

465 {
466 // given SCT/pixel det/bec/layer/sector, and level (1,2 or 3) return
467 // additional directory key name for associated DBM alignment
468 std::ostringstream result;
469 if (det==1 && level==3 && abs(bec)==2) { // slightly unnecessary check
470 if (bec==2) result << "EADBM";
471 if (bec==-2) result << "ECDBM";
472 result << 1+sector;
473 }
474 return result.str();
475}

◆ 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 399 of file InDetAlignDBTool.cxx.

400 {
401 // given SCT or pixel identifier, and level (1,2 or 3) return
402 // directory key name for associated alignment data
403 int det,bec,layer,ring,sector,side;
404 idToDetSet(ident,det,bec,layer,ring,sector,side);
405 return dirkey(det,bec,layer,level,sector);
406}
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 410 of file InDetAlignDBTool.cxx.

411 {
412 // given SCT/pixel det/bec/layer, and level (1,2 or 3) return
413 // directory key name for associated alignment data
414 std::ostringstream result;
415 result << m_par_dbkey << "/" ;
416 if (level==1) {
417 result << "ID";
418 } else {
419 if (det==1) result << "PIX";
420 if (det==2) result << "SCT";
421 if (level==3) {
422 if (bec==1) result << "EA";
423 if (bec==0) result << "B";
424 if (bec==-1) result << "EC";
425 result << 1+layer;
426 }
427 }
428 return result.str();
429}
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 431 of file InDetAlignDBTool.cxx.

432 {
433 // given SCT/pixel det/bec/layer/sector, and level (1,2 or 3) return
434 // directory key name for associated alignment data
435 // re-write using std::format at some point...
436 std::ostringstream result;
437 if (m_dynamicDB){
438 result << "/Indet/AlignL";
439 result << level;
440 result << "/" ; // new folders have L1, L2, L3 structure
441 }
442 else{
443 result << m_par_dbkey << "/" ;
444 }
445 if (level==1) {
446 result << "ID";
447 } else {
448 if (det==1) result << "PIX";
449 if (det==2) result << "SCT";
450 if (level==3) {
451 if (det==1 && abs(bec)==2) result << DBMkey(det,bec,level,sector);
452 else {
453 if (bec==1) result << "EA";
454 if (bec==0) result << "B";
455 if (bec==-1) result << "EC";
456 result << 1+layer;
457 }
458 }
459 }
460 return result.str();
461
462}
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 481 of file InDetAlignDBTool.cxx.

484 {
485
486 ATH_MSG_DEBUG( "dispGroup called: level " << level << " syst " << syst);
487 int nmod=0;
488 // random number service
489 SmartIF<IRndmGenSvc> randsvc{Gaudi::svcLocator()->service("RndmGenSvc")};
490 if(!randsvc.isValid()) ATH_MSG_ERROR("Cannot find RndmGenSvc" );
491
492 Rndm::Numbers gauss(randsvc,Rndm::Gauss(0.,1.));
493 if (skip>0) {
494 ATH_MSG_DEBUG("Skip random numbers " << skip );
495 for (int i=0;i<skip;++i) gauss();
496 }
497 // for syst 5, choose random shifts based on the input numbers
498 float rpd=0,rd=0,zd=0;
499 if (syst==5) {
500 rpd=rphidisp*gauss();
501 rd=rdisp*gauss();
502 zd=zdisp*gauss();
503 }
504 // keep a list of level1/2 transform IDs to make sure they are only set once
505 std::vector<Identifier> lvl12id;
506 // loop over all pixel and SCT modules
507 AlignableTransform* pat;
508 for (int idet=1;idet<3;++idet) {
509 for (const InDetDD::SiDetectorElement* element: *(idet==1 ? m_pixman->getDetectorElementCollection() : m_sctman->getDetectorElementCollection())) {
510 if (element!=nullptr) {
511 const Identifier ident=element->identify();
512 int mdet,mbec,mlayer,mring,msector,mside;
513 idToDetSet(ident,mdet,mbec,mlayer,mring,msector,mside);
514 // find matching modules - note side=1 modules never touched
515 if ((dettype==-1 || mdet==dettype) && (bec==-1 || std::abs(2*mbec)==bec) &&
516 (layer==-1 || mlayer==layer) && (ring==-1 || mring==ring) &&
517 (sector== -1 || msector==sector) && mside==0) {
518 // displace this module - first choose displacement type
519 // dont choose new displacements if seeing second side of SCT module
520 // ensures they both move together
521 // depends on the side1 module immediatly following side 0 in list
522 // which is currently the case - fragile
523 // also for syst 6 choose number only for new ring (eta) slice
524 if (dettype!=2 || mside!=1) {
525 if (syst==2 || syst==4 || (syst==6 && mring==-6)) {
526 rpd=rphidisp*gauss();
527 rd=rdisp*gauss();
528 zd=zdisp*gauss();
529 if (syst==6) ATH_MSG_DEBUG("New rndm at layer/ring " <<
530 mlayer << " " << mring << " z " << zd );
531 } else if (syst<5) {
532 rpd=rphidisp;
533 rd=rdisp;
534 zd=zdisp;
535 }
536 }
537 // interpretation as rphi/r or x/y
538 float xd,yd;
539 if (syst<=2 || syst==6) {
540 // rphi displacement - calculate from module position in x/y
541 const Amg::Vector3D modcent=element->center();
542 float dx=modcent.x();
543 float dy=modcent.y();
544 float dr=std::sqrt(dx*dx+dy*dy);
545 xd=(rd*dx-rpd*dy)/dr;
546 yd=(rd*dy+rpd*dx)/dr;
547 } else {
548 xd=rpd;
549 yd=rd;
550 }
551 // find the corresponding AlignableTransform object
552 std::string key=dirkey(mdet,mbec,mlayer,level);
553 // first get as const as transforms might have been read in
554 const AlignableTransform* cpat=cgetTransPtr(key);
555 pat=const_cast<AlignableTransform*>(cpat);
556 if (pat) {
557 Identifier ident2;
558 bool update=true;
559 if (level==3) {
560 ident2=ident;
561 } else if (level==2) {
562 // identifier for layer in level 2 transform
563 if (mdet==1) {
564 ident2=m_pixid->wafer_id(m_pixid->barrel_ec(ident),
565 m_pixid->layer_disk(ident),0,0);
566 } else {
567 ident2=m_sctid->wafer_id(m_sctid->barrel_ec(ident),
568 m_sctid->layer_disk(ident),0,0,0);
569 }
570 // check this identifier has not been updated before
571 std::vector<Identifier>::const_iterator ix=
572 find(lvl12id.begin(),lvl12id.end(),ident2);
573 if (ix==lvl12id.end()) {
574 lvl12id.push_back(ident2);
575 } else {
576 update=false;
577 }
578 } else {
579 // identifier for ID
580 if (mdet==1) {
581 ident2=m_pixid->wafer_id(0,0,0,0);
582 } else {
583 ident2=m_sctid->wafer_id(0,0,0,0,0);
584 }
585 // check this identifier has not been updated before
586 std::vector<Identifier>::const_iterator ix=
587 find(lvl12id.begin(),lvl12id.end(),ident2);
588 if (ix==lvl12id.end()) {
589 lvl12id.push_back(ident2);
590 } else {
591 update=false;
592 }
593 }
594 // update, adding to any existing shift
595 if (update) {
596
597 Amg::Transform3D shift = Amg::Translation3D(xd,yd,zd) * Amg::RotationMatrix3D::Identity();
598 pat->tweak(ident2,Amg::EigenTransformToCLHEP(shift));
599 ATH_MSG_VERBOSE( "Updated module " << mdet << "," << mbec
600 << "," << mlayer << "," << mring << "," << msector << " to xyz" <<
601 xd << "," << yd << "," << zd );
602 ++nmod;
603 }
604 } else {
605 ATH_MSG_ERROR("Cannot find AlignableTransform for key" << key <<" in AlignableTransform container");
606 }
607 }
608 }
609 }
610 }
611 ATH_MSG_DEBUG( "Added displacement to " << nmod << " modules " << dettype << ","
612 << bec << "," << layer << " [" << rphidisp << "," << rdisp
613 << "," << zdisp << "]"
614 << " type " << syst );
615}
#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
virtual void shift(size_t pos, ptrdiff_t offs) override
Shift the elements of the container.

◆ 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 1412 of file InDetAlignDBTool.cxx.

1414{
1415 double siny = trans(0,2);
1416 beta = asin(siny);
1417 // Check if cosy = 0. This requires special treatment.
1418 // can check either element (1,2),(2,2) both equal zero
1419 // or (0,1) and (0,0)
1420 // Probably not likely it will be exactly 0 and may still
1421 // have some problems when very close to zero. We mostly
1422 // deal with small rotations so its not too important.
1423 if ((trans(1,2) == 0) && (trans(2,2) == 0)) {
1424 // alpha and gamma are degenerate. We arbitrarily choose
1425 // gamma = 0.
1426 gamma = 0;
1427 alpha = atan2(trans(1,1),trans(2,1));
1428 } else {
1429 alpha = atan2(-trans(1,2),trans(2,2));
1430 gamma = atan2(-trans(0,1),trans(0,0));
1431 if (alpha == 0) alpha = 0; // convert -0 to 0
1432 if (gamma == 0) gamma = 0; // convert -0 to 0
1433 }
1434}

◆ 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 1344 of file InDetAlignDBTool.cxx.

1345 {
1346 // set alignment keys for fake geometry with given numbers of
1347 // barrel/endcap PIX/SCT layers
1348 // this code is somewhat fragile, trying to reproduce the order of
1349 // keys in the same way that GeoModel returns them
1350 // will not work for layouts with missing middle pixel layer
1351
1352 int ichan3=200;
1353 // level 1 object - ID
1354 m_alignobjs.push_back(dirkey(1,0,0,1));
1355 m_alignchans.push_back(0);
1356 // level 2 objects - pixel
1357 if (nbpix!=0 || necpix!=0) {
1358 m_alignobjs.push_back(dirkey(1,0,0,2));
1359 m_alignchans.push_back(100);
1360 }
1361 // level 3 objects - pixel
1362 // objects done in this order to get COOL channels correct
1363 // endcap A pixel
1364 for (int i=0;i<necpix;++i) {
1365 m_alignobjs.push_back(dirkey(1,-1,i,3));
1366 m_alignchans.push_back(ichan3++);
1367 }
1368 // barrel pixel
1369 for (int i=0;i<nbpix;++i) {
1370 m_alignobjs.push_back(dirkey(1,0,i,3));
1371 m_alignchans.push_back(ichan3++);
1372 }
1373 // endcap C pixel
1374 for (int i=0;i<necpix;++i) {
1375 m_alignobjs.push_back(dirkey(1,1,i,3));
1376 m_alignchans.push_back(ichan3++);
1377 }
1378 // level 2 objects - SCT
1379 if (nbsct!=0 || necsct!=0) {
1380 m_alignobjs.push_back(dirkey(2,0,0,2));
1381 m_alignchans.push_back(101);
1382 }
1383 // level 3 objects - SCT
1384 // endcap A SCT
1385 for (int i=0;i<necsct;++i) {
1386 m_alignobjs.push_back(dirkey(2,-1,i,3));
1387 m_alignchans.push_back(ichan3++);
1388 }
1389 // barrel SCT
1390 for (int i=0;i<nbsct;++i) {
1391 m_alignobjs.push_back(dirkey(2,0,i,3));
1392 m_alignchans.push_back(ichan3++);
1393 }
1394 // endcap C SCT
1395 for (int i=0;i<necsct;++i) {
1396 m_alignobjs.push_back(dirkey(2,1,i,3));
1397 m_alignchans.push_back(ichan3++);
1398 }
1399}

◆ 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 1219 of file InDetAlignDBTool.cxx.

1221 {
1222
1223 ATH_MSG_DEBUG( "fillDB: Data tag " << tag );
1224 ATH_MSG_DEBUG( "Run/evt1 [" << run1 << "," << event1 << "]" );
1225 ATH_MSG_DEBUG("Run/evt2 [" << run2 << "," << event2 << "]" );
1226
1227 // get pointer to registration svc
1228 SmartIF<IIOVRegistrationSvc> regsvc{Gaudi::svcLocator()->service("IOVRegistrationSvc")};
1229 if (!regsvc.isValid()) {
1230 ATH_MSG_FATAL( "IOVRegistrationSvc not found" );
1231 return;
1232 }
1233 // loop over all AlignableTransform objects created earlier and save them
1234 int nobj=0;
1235 if (m_par_newdb) {
1236 if (StatusCode::SUCCESS==regsvc->registerIOV(
1237 "AlignableTransformContainer",m_par_dbroot,tag,run1,run2,event1,event2)) {
1238 ATH_MSG_DEBUG( "Stored AlignableTransform object " << m_par_dbroot );
1239 ++nobj;
1240 } else {
1241 ATH_MSG_ERROR("Failed (registerIOV) to store object " << m_par_dbroot );
1242 }
1243 } else {
1244 // old way - register all objects separately
1245 for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1246 iobj!=m_alignobjs.end();++iobj) {
1247 if (StatusCode::SUCCESS==regsvc->registerIOV("AlignableTransform",
1248 *iobj,tag,run1,run2,event1,event2)) {
1249 ATH_MSG_DEBUG( "Stored AlignableTransform object " << *iobj );
1250 ++nobj;
1251 } else {
1252 ATH_MSG_ERROR("Failed (registerIOV) to store object " << *iobj );
1253 }
1254 }
1255 }
1256 ATH_MSG_DEBUG( " Written " << nobj << " AlignableTransform objects to conditions database" );
1257}

◆ finalize()

StatusCode InDetAlignDBTool::finalize ( )
overridevirtual

Definition at line 231 of file InDetAlignDBTool.cxx.

232{
233 ATH_MSG_DEBUG( "InDetAlignDBTool finalize method called" );
234 return StatusCode::SUCCESS;
235}

◆ 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 1089 of file InDetAlignDBTool.cxx.

1091 {
1092 if( level == 3 ) return ident ;
1094 if( m_pixid->is_pixel(ident) ) {
1095 if( level == 1 ) {
1096 return m_pixid->wafer_id( 0, 0, 0, 0 ) ;
1097 }
1098 if( level == 2 ) {
1099 int barrel_ec = m_pixid->barrel_ec( ident ) ;
1100 int layer_disk = m_pixid->layer_disk( ident ) ;
1101 return m_pixid->wafer_id( barrel_ec, layer_disk, 0, 0 ) ;
1102 }
1103 }
1105 if( m_sctid->is_sct(ident) ) {
1106 if( level == 1 ) {
1107 int barrel_ec = m_sctid->barrel_ec( ident ) ;
1108 return m_sctid->wafer_id( barrel_ec, 0, 0, 0, 0 ) ;
1109 }
1110 if( level == 2 ) {
1111 int barrel_ec = m_sctid->barrel_ec( ident ) ;
1112 int layer_disk = m_sctid->layer_disk( ident ) ;
1113 return m_sctid->wafer_id( barrel_ec, layer_disk, 0, 0, 0 ) ;
1114 }
1115 }
1116 return ident ;
1117}

◆ 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 1144 of file InDetAlignDBTool.cxx.

1145 {
1146 const Identifier identifier = getL1L2fromL3Identifier( ident, level ) ;
1148 const std::string key=dirkey(identifier,level);
1149 const AlignableTransform* pat;
1150 if ((pat=cgetTransPtr(key))) {
1151 AlignableTransform::AlignTransMem_citr itr=pat->findIdent(identifier);
1152 if (itr!=pat->end()) result= Amg::CLHEPTransformToEigen(itr->transform());
1153 }
1154 return result;
1155}
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 1120 of file InDetAlignDBTool.cxx.

1120 {
1121
1123 const InDetDD::SiDetectorElement* element = m_pixman->getDetectorElement( ident ) ;
1124 if( !element ) {
1125 element = m_sctman->getDetectorElement( ident ) ;
1126 }
1127 if( !element ) {
1128 ATH_MSG_ERROR("getTransL123(): Module not found in PIX or SCT!" );
1129 return result ;
1130 }
1131 Amg::Transform3D trfL1 = getTrans( ident, 1 ) ;
1132 Amg::Transform3D trfL2 = getTrans( ident, 2 ) ;
1133 Amg::Transform3D trfL3 = getTrans( ident, 3 ) ;
1134 ATH_MSG_FATAL("Code needs to corrected otherwise you will get nonsensical results-- IndetAlignDBTool:2060");
1135 //const Amg::Transform3D trfNominal ; //= element->defModuleTransform() ;
1136 //result = trfNominal.inverse() * trfL1 * trfL2 * trfNominal * trfL3 ;
1137 result = trfL1 * trfL2 * trfL3 ;
1138 return result ;
1139}
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 1299 of file InDetAlignDBTool.cxx.

1300 {
1301 // look in collection to retrieve pointer to AlignableTransform object of
1302 // given key and return it, return 0 if not collection or key value not found
1304 AlignableTransform* pat=nullptr;
1305 if (m_par_newdb) {
1306 if (StatusCode::SUCCESS==detStore()->retrieve(patc,m_par_dbroot )) {
1308 dva!=patc->end();++dva) {
1309 if ((*dva)->tag()==key) {
1310 pat=*dva;
1311 break;
1312 }
1313 }
1314 }
1315 } else {
1316 if (StatusCode::SUCCESS!=detStore()->retrieve(pat,key)) pat=nullptr;
1317 }
1318 return pat;
1319}
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 372 of file InDetAlignDBTool.cxx.

373 {
374 // transform Identifier to list of integers specifiying dettype,bec,layer
375 // ring, sector, side
376 // note bec is +-1 or 0, not +-2 as returned by idenfitiers
377
378 bool resok=false;
379 if (m_pixman && m_pixid->is_pixel(ident)) {
380 det=1;
381 bec=m_pixid->barrel_ec(ident)/2;
382 layer=m_pixid->layer_disk(ident);
383 ring=m_pixid->eta_module(ident);
384 sector=m_pixid->phi_module(ident);
385 side=0;
386 resok=true;
387 } else if (m_sctman && m_sctid->is_sct(ident)) {
388 det=2;
389 bec=m_sctid->barrel_ec(ident)/2;
390 layer=m_sctid->layer_disk(ident);
391 ring=m_sctid->eta_module(ident);
392 sector=m_sctid->phi_module(ident);
393 side=m_sctid->side(ident);
394 resok=true;
395 }
396 return resok;
397}

◆ initialize()

StatusCode InDetAlignDBTool::initialize ( )
overridevirtual

Definition at line 74 of file InDetAlignDBTool.cxx.

75{
76
77 ATH_MSG_DEBUG("InDetAlignDBTool initialize instance: " << name() );
78
79 // get storegate access to conditions store
80 if (detStore().retrieve().isFailure()){
81 ATH_MSG_FATAL("Detector store not found");
82 }
83
84 if ( m_par_condstream.retrieve().isFailure() ) {
85 ATH_MSG_FATAL( "Failed to retrieve AthenaOutputStreamTool");
86 return StatusCode::FAILURE;
87 } else
88 ATH_MSG_DEBUG( "Retrieved AthenaOutputStreamTool with name" << m_par_condstream.name());
89
90 // attempt to get ID helpers from detector store
91 // (relying on GeoModel to put them)
92 m_alignobjs.clear();
93 m_alignchans.clear();
94 int ndet[2];
95 ndet[0]=0;
96 ndet[1]=0;
97 if(m_doPix){
98 if (detStore()->retrieve(m_pixman,m_pixmanName)!=StatusCode::SUCCESS || m_pixman==nullptr) {
99 ATH_MSG_INFO( "Could not find pixel manager "<<m_pixmanName<<" running without pixel");
100 }
101 else m_managers.push_back(m_pixman);
102 }
103
104 if(m_doStrip){
105 if (detStore()->retrieve(m_sctman,m_sctmanName)!=StatusCode::SUCCESS || m_sctman==nullptr) {
106 ATH_MSG_INFO("Could not find SCT manager "<<m_sctmanName<<" running without SCT/Strip");
107 }
108 else m_managers.push_back(m_sctman);
109 }
110
111 if(m_pixman){
112 if (m_pixman->m_alignfoldertype == InDetDD::static_run1 && !m_forceUserDBConfig){
113 m_dynamicDB = false;
114 }
115 if (m_pixman->m_alignfoldertype == InDetDD::timedependent_run2 && !m_forceUserDBConfig){
116 m_par_dbroot = "/Indet/AlignL3";
117 m_dynamicDB = true;
118 }
119 }
120
121 if (m_pixman && m_sctman){
122 if (m_pixman->m_alignfoldertype!=m_sctman->m_alignfoldertype) {
123 ATH_MSG_FATAL("Pixel and SCT Managers have different alignfolder type registered --> Check ");
124 return StatusCode::FAILURE;
125 }
126 }
127
128 m_par_dbkey = m_par_dbroot.value();
129
130 if(m_pixman && (detStore()->retrieve(m_pixid).isFailure())) {
131 ATH_MSG_FATAL("No Pixel ID Found!");
132 return StatusCode::FAILURE;
133 }
134
135 if(m_sctman && (detStore()->retrieve(m_sctid).isFailure())) {
136 ATH_MSG_FATAL("No SCT ID Found!");
137 return StatusCode::FAILURE;
138 }
139
140 //optionally fake up the geometry
141 if (m_par_fake==1) {
142 ATH_MSG_INFO("Initialising fake full ATLAS geometry");
143 fakeGeom(3,3,4,9);
144 } else if (m_par_fake==2) {
145 ATH_MSG_INFO("Initialising fake CTB geometry");
146 fakeGeom(3,0,4,0);
147 } else {
148 // setup list of alignable transforms from geometry
149 int chan[3];
150 int TransfLevel_low = 0; // depending on alignfolder sheme; 0 for old, 2 for new
151 if (m_dynamicDB) TransfLevel_low = 2;
152
153 for (int i=0;i<3;++i) chan[i]=100*i;
154 std::string man_name;
155 int idet = 0;
156 for (auto manager:m_managers) {
157 for (const InDetDD::SiDetectorElement* element : * manager->getDetectorElementCollection()) {
158 if (element!=nullptr) {
159 const Identifier ident=element->identify();
160 int det,bec,layer,ring,sector,side;
161 if (idToDetSet(ident,det,bec,layer,ring,sector,side)) {
162 std::string level[3];
163 for (int i=TransfLevel_low;i<3;++i) {
164 level[i]=dirkey(det,bec,layer,1+i,sector);
165 // add this to list if not seen already
166 std::vector<std::string>::const_iterator ix=
167 find(m_alignobjs.begin(),m_alignobjs.end(),level[i]);
168 if (ix==m_alignobjs.end()) {
169 m_alignobjs.push_back(level[i]);
170 m_alignchans.push_back(chan[i]++);
171 }
172 }
173 ++ndet[idet];
174 } else {
175 ATH_MSG_ERROR("Si detector element type " << idet << " has no detset conversion" );
176 }
177 }
178 }
179 idet++;
180 }
181 }
182 ATH_MSG_INFO( "Geometry initialisation sees " << ndet[0] <<
183 " pixel and " << ndet[1] << " SCT modules giving " << m_alignobjs.size()
184 << " alignment keys" );
185
186 if (msgLvl(MSG::DEBUG)) {
187 ATH_MSG_DEBUG( "Database root folder " << m_par_dbroot );
188 ATH_MSG_DEBUG( "Geometry initialisation sees " << ndet[0] <<
189 " pixel and " << ndet[1] << " SCT modules giving " << m_alignobjs.size()
190 << " alignment keys" );
191 ATH_MSG_DEBUG("Keys/channels are:");
192
193 for (unsigned int i=0;i<m_alignobjs.size();++i)
194 ATH_MSG_DEBUG( " " << m_alignobjs[i] << " [" << m_alignchans[i] << "]" );
195
196 if (m_par_newdb)
197 ATH_MSG_DEBUG("Assuming new COOL alignment DB model based on AlignableTransformContainer");
198 else
199 //Do we still use this anywhere? Candidate for removal?
200 ATH_MSG_DEBUG("Assuming old (Lisbon) alignment DB model based on separate AlignableTransforms");
201 }
202
203 // make a new empty CondAttrListCollection with the IBLDist structure:
205 m_attrListCollection = new CondAttrListCollection(true); // not really sure....
206
207 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
208 spec->extend("stave", "int");
209 spec->extend("eta", "int");
210 spec->extend("mag", "float");
211 spec->extend("base", "float");
212 spec->extend("free", "float");
213
214 const int ibl_stave_max = 14;
215 // create a full collection first with NULL entries to ensure fail save operation
216 for (int this_stave=0; this_stave<ibl_stave_max; this_stave++){
217
218 coral::AttributeList atrlist(*spec);
219 // Set value of each row for the current channel
220 atrlist[ "stave" ].data<int>()=this_stave;
221 atrlist[ "eta" ].data<int>()=0;
222 atrlist[ "mag" ].data<float>()=0;
223 atrlist[ "base" ].data<float>()=0;
224 atrlist[ "free" ].data<float>()=0;
225 m_attrListCollection->add(100*(1+this_stave),atrlist);
226 }
227
228 return StatusCode::SUCCESS;
229}
#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 1157 of file InDetAlignDBTool.cxx.

1157 {
1158
1159 ATH_MSG_DEBUG( "Output AlignableTranform objects to stream" << m_par_condstream );
1160 // get the AthenaOutputStream tool
1161
1162 if (StatusCode::SUCCESS!=m_par_condstream->connectOutput()) {
1163 ATH_MSG_ERROR("Could not connect stream to output" );
1164 return StatusCode::FAILURE;
1165 }else{
1166 ATH_MSG_DEBUG("Stream is connected to output" );
1167 }
1168 // construct list of objects to be written out, either
1169 // AlignableTransformContainer or several of AlignableTransforms
1170 int npairs=m_alignobjs.size();
1171 if (m_par_newdb) npairs=1;
1173 if (m_par_newdb) {
1174 typekeys[0]=
1175 IAthenaOutputStreamTool::TypeKeyPair("AlignableTransformContainer",
1176 m_par_dbroot);
1179 "Expected " << m_par_dbroot << " object not found" );
1180 } else {
1181 for (unsigned int i=0;i<m_alignobjs.size();++i) {
1182 typekeys[i]=IAthenaOutputStreamTool::TypeKeyPair("AlignableTransform",
1183 m_alignobjs[i]);
1185 ATH_MSG_ERROR("Expected " << m_alignobjs[i] << " object not found" );
1186 }
1187 }
1188 // write objects to stream
1189 if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys)) {
1190 }else{
1191 ATH_MSG_DEBUG("Streamed output objects" );
1192 }
1193
1194 {
1195 // additional IBLDist DB
1196 ATH_MSG_DEBUG( "starting to register typeKey for IBLDist" );
1197 IAthenaOutputStreamTool::TypeKeyPairs typekeys_IBLDist(1);
1198 IAthenaOutputStreamTool::TypeKeyPair pair("CondAttrListCollection", "/Indet/IBLDist");
1199 typekeys_IBLDist[0] = std::move(pair);
1200
1201 // write objects to stream
1202 if (StatusCode::SUCCESS!=m_par_condstream->streamObjects(typekeys_IBLDist)) {
1203 ATH_MSG_ERROR("Could not stream output IBLDist objects" );
1204 return StatusCode::FAILURE;
1205 }else{
1206 ATH_MSG_DEBUG("Streamed output IBLDist objects" );
1207 }
1208
1209 }
1210
1211 // commit output
1212 if (StatusCode::SUCCESS!=m_par_condstream->commitOutput()) {
1213 ATH_MSG_ERROR("Could not commit output" );
1214 }
1215 ATH_MSG_DEBUG( "Written " << typekeys.size() << " objects to stream " << m_par_condstream);
1216 return StatusCode::SUCCESS;
1217}
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 1259 of file InDetAlignDBTool.cxx.

1259 {
1260
1261 ATH_MSG_DEBUG("Printout InDetAlign database contents, detail level" << level );
1262
1263 for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1264 iobj!=m_alignobjs.end();++iobj) {
1265 const AlignableTransform* pat;
1266 if ((pat=cgetTransPtr(*iobj))) {
1267 ATH_MSG_DEBUG( "AlignableTransform object " << *iobj );
1268 int nobj=0;
1270 cit!=pat->end();++cit) {
1271 const Identifier& ident=cit->identify();
1272 const Amg::Transform3D& trans= Amg::CLHEPTransformToEigen( cit->transform() );
1273 Amg::Vector3D shift=trans.translation();
1274 //Amg::RotationMatrix3D rot=trans.rotation();
1275 int det,bec,layer,ring,sector,side;
1276 if (idToDetSet(ident,det,bec,layer,ring,sector,side)) {
1277 if (level>1) {
1278 double alpha, beta, gamma;
1279 extractAlphaBetaGamma(trans, alpha, beta, gamma);
1280 ATH_MSG_DEBUG( "ID [" << det << "," << bec << "," << layer <<
1281 "," << ring << "," << sector << "," << side << "] Trans:(" <<
1282 shift.x() << "," << shift.y() << "," << shift.z() << ") Rot:{"
1283 << alpha << "," << beta << "," << gamma << "}");
1284 }
1285 ++nobj;
1286 } else {
1287 ATH_MSG_ERROR("Unknown identifier in AlignableTransform" );
1288 }
1289 }
1290 ATH_MSG_DEBUG( "Object contains " << nobj << " transforms" );
1291 } else {
1292 ATH_MSG_ERROR( "AlignableTransform " << *iobj << " not found" );
1293 }
1294 }
1295}
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 944 of file InDetAlignDBTool.cxx.

944 {
945 ATH_MSG_DEBUG("readNtuple - set alignment constants from ntuple path: " << file );
946 SmartIF<INTupleSvc> ntsvc{Gaudi::svcLocator()->service("NTupleSvc")};
947 if(!ntsvc.isValid()) ATH_MSG_ERROR("Cannot find NTupleSvc" );
948 const std::string path=file+"/9002";
949 NTuplePtr nt(ntsvc.get(),path);
950 if (nt) {
952 sc=nt->item( "MODPROP/DetType",nt_dettype);
953 sc=nt->item("MODPROP/Bec",nt_bec);
954 sc=nt->item("MODPROP/Layer",nt_layer);
955 sc=nt->item("MODPROP/Ring",nt_ring);
956 sc=nt->item("MODPROP/Sector",nt_sector);
957 sc=nt->item("MODPROP/Side",nt_side);
958 sc=nt->item("MODPROP/Level",nt_level);
959 sc=nt->item("MODPROP/Xofs",nt_xofs);
960 sc=nt->item("MODPROP/Yofs",nt_yofs);
961 sc=nt->item("MODPROP/Zofs",nt_zofs);
962 sc=nt->item("MODPROP/Phi",nt_phi);
963 sc=nt->item("MODPROP/Theta",nt_theta);
964 sc=nt->item("MODPROP/Psi",nt_psi);
965
966 if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
967 "Error booking ntuple 9002 contents" );
968 int ntrans=0;
969 while (nt->read().isSuccess()) {
970 Identifier ident=Identifier();
971 if (nt_dettype==1) {
973 } else if (nt_dettype==2) {
975 } else {
976 ATH_MSG_ERROR("Cannot construct identifier for dettype "
977 << nt_dettype );
978 }
979
981 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
982 newtrans *= Amg::AngleAxis3D(nt_psi, Amg::Vector3D(0.,0.,1.));
983 newtrans *= Amg::AngleAxis3D(nt_theta, Amg::Vector3D(0.,1.,0.));
984 newtrans *= Amg::AngleAxis3D(nt_phi, Amg::Vector3D(1.,0.,0.));
985
986 setTrans(ident,nt_level,newtrans);
987 ++ntrans;
988 }
989 ATH_MSG_DEBUG( "Read " << ntrans << " transforms from ntuple");
990 } else {
991 ATH_MSG_ERROR( "Problem opening ntuple at path " << path );
992 }
993}
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:130
TFile * file

◆ readTextFile()

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

Implements IInDetAlignDBTool.

Definition at line 821 of file InDetAlignDBTool.cxx.

821 {
822 // if (m_par_oldTextFile) return readOldTextFile(file);
823
824 ATH_MSG_DEBUG("readTextFile - set alignment constants from text file: " << file );
825 std::ifstream infile;
826 infile.open(file.c_str());
827 if (!infile) {
828 ATH_MSG_ERROR("Error opening file " << file );
829 return;
830 }
831
832 // loop over lines in file
833 int nobj=0;
834 int ntrans=0;
835
836 std::string channelName; // Channel name
837 const AlignableTransform* pat = nullptr;
838
839 while (infile) {
840 std::string tmpline;
841 std::getline(infile, tmpline);
842 if (!infile) break;
843
844 // Skip comment line
845 if ((tmpline.substr(0,2) == "//") || (tmpline.substr(0,1) == "#")) continue;
846
847 std::istringstream instring(tmpline);
848 std::string tmpstr;
849 instring >> tmpstr;
850
851 // Skip blank line
852 if (tmpstr.empty()) continue;
853
854 if (tmpstr[0] == '/') {
855 // Its a valid channel name
856 channelName = std::move(tmpstr);
857 ATH_MSG_DEBUG("Read in AlignableTransform data, key " << channelName );
858 // find the AlignableTransform with this key
859 pat = nullptr;
860 if (!(pat=cgetTransPtr(channelName))) {
861 ATH_MSG_ERROR("Cannot find AlignableTransform object for key"
862 << channelName << " when reading text file");
863 } else {
864 nobj++;
865 }
866 } else {
867 // Its a data line
868
869 if (!pat) {
870 // If pat = 0, then either no channel name was specified or it could not be found.
871 ATH_MSG_ERROR("No channel specified. Skipping input " );
872
873 } else {
874 // normal data
875 std::istringstream datastream(tmpline);
876
877 int subsystem,dettype,bec,layer,phiModule,etaModule,side;
878 float dx,dy,dz,alpha,beta,gamma;
879 datastream >> subsystem >> dettype >> bec >> layer >> phiModule >> etaModule >> side >> dx
880 >> dy >> dz >> alpha >> beta >> gamma;
881
882 if (datastream.fail()) {
883 ATH_MSG_ERROR("Error in input" );
884 } else {
885 alpha *= CLHEP::mrad;
886 beta *= CLHEP::mrad;
887 gamma *= CLHEP::mrad;
888
889 // construct identifier
890 Identifier ident=Identifier();
891 if (dettype==1) {
892 ident=m_pixid->wafer_id(bec,layer,phiModule,etaModule);
893 } else if (dettype==2) {
894 ident=m_sctid->wafer_id(bec,layer,phiModule,etaModule,side);
895 } else {
896 ATH_MSG_ERROR("Cannot construct identifier for dettype "
897 << dettype );
898 }
899 if (!ident.is_valid()) {
900 ATH_MSG_ERROR("Error in identifier : " <<
901 " [" << subsystem << "," << dettype << "," << bec << "," << layer << "," <<
902 phiModule << "," << etaModule << "," << side << "] key " << channelName <<
903 " shift [" << dx << "," << dy << "," << dz << "]" );
904 } else {
905
906 // construct new transform
907 // Order of rotations is defined as around z, then y, then x.
908 // For small angles it doesn't really matter though.
909 Amg::Translation3D newtranslation(dx,dy,dz);
910 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
911 newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
912 newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
913 newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
914
915
916
917 // find pointer to existing transform, currently missing write access
918 // via findIdent, so have to search manually
919 AlignableTransform* pat2;
920 pat2=const_cast<AlignableTransform*>(pat);
922 while ((itr->identify()!=ident) && (itr!=pat2->mend())) ++itr;
923 if (itr!=pat2->mend()) {
924 ++ntrans;
925 itr->setTransform( Amg::EigenTransformToCLHEP(newtrans) );
926 ATH_MSG_VERBOSE ( "Set transform done");
927 } else {
928 ATH_MSG_WARNING("Cannot find existing transform for");
929 }
930 // Can uses either id helper
931 ATH_MSG_DEBUG(m_pixid->show_to_string(ident) << " key " << channelName <<
932 " shift [" << dx << "," << dy << "," << dz << "]" );
933 }
934 } // end if (datastream.fail())
935 } // end if (!pat)
936 } // end if (tmpstr[0] == '/')
937 } // end while (infile)
938
939 infile.close();
940 ATH_MSG_DEBUG( "Read " << nobj << " objects from file with " << ntrans << " transforms" );
941}
#define ATH_MSG_WARNING(x)
AlignTransMem_itr mend()
std::vector< AlignTransMember >::iterator AlignTransMem_itr
AlignTransMem_itr mbegin()
@ phiModule
Definition HitInfo.h:80

◆ 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 995 of file InDetAlignDBTool.cxx.

996 {
997
998 bool result=false;
999
1000 // New additions for new global folder structure -- setTrans for this might need to be revisited
1001 // No ATs exist for levels 1 & 2 --> need alternative
1002 if (m_dynamicDB && level!=3){
1003 result=tweakGlobalFolder(ident, level, trans);
1004 if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1005 }
1006 else {
1007 // find transform key, then set appropriate transform
1008 // do storegate const retrieve, then cast to allow update of locked data
1009 std::string key=dirkey(ident,level);
1010 const AlignableTransform* pat;
1011 AlignableTransform* pat2;
1012 bool result=false;
1013 if ((pat=cgetTransPtr(key))) {
1014 pat2=const_cast<AlignableTransform*>(pat);
1015 if (pat2!=nullptr) {
1016 result=pat2->update(ident, Amg::EigenTransformToCLHEP(trans) );
1017 if (!result) ATH_MSG_ERROR( "Attempt to set non-existant transform" );
1018 }
1019 } else {
1020 ATH_MSG_ERROR( "setTrans: cannot retrieve AlignableTransform for key" << key );
1021 }
1022 }
1023
1024 return result;
1025}
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 1027 of file InDetAlignDBTool.cxx.

1029{
1030
1031 Amg::Translation3D newtranslation(translate);
1032 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1033 newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1034 newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1035 newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1036
1037 return setTrans(ident, level, newtrans);
1038}

◆ sortTrans()

void InDetAlignDBTool::sortTrans ( ) const
overridevirtual

Implements IInDetAlignDBTool.

Definition at line 1401 of file InDetAlignDBTool.cxx.

1401 {
1402 // loop through all the AlignableTransform objects and sort them
1403
1404 ATH_MSG_DEBUG( "Sorting all AlignableTransforms in TDS" );
1405 AlignableTransform* pat;
1406 // use cget and a const cast to allow containers that have been read in
1407 // (and hence are locked by StoreGate) to be sorted
1408 for (unsigned int i=0;i<m_alignobjs.size();++i)
1409 if ((pat=const_cast<AlignableTransform*>(cgetTransPtr(m_alignobjs[i])))) pat->sortv();
1410}

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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 1484 of file InDetAlignDBTool.cxx.

1485 {
1486
1487 // find transform key, then set appropriate transform
1488 const CondAttrListCollection* atrlistcol1=nullptr;
1489 CondAttrListCollection* atrlistcol2=nullptr;
1490 bool result=false;
1491 std::string key=dirkey(ident,level);
1492 int det,bec,layer,ring,sector,side;
1493 idToDetSet(ident,det,bec,layer,ring,sector,side);
1494 const unsigned int DBident=det*10000+2*bec*1000+layer*100+ring*10+sector;
1495 // so far not a very fancy DB identifier, but seems elaborate enough for this simple structure
1496
1497 if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,key)) {
1498 // loop over objects in collection
1499 //atrlistcol1->dump();
1500 atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1501 if (atrlistcol2!=nullptr){
1502 for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1503
1504 const coral::AttributeList& atrlist=citr->second;
1505 coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1506
1507 if(citr->first!=DBident) continue;
1508 else {
1509 msg(MSG::DEBUG) << "Tweak Old global DB -- channel: " << citr->first
1510 << " ,det: " << atrlist2["det"].data<int>()
1511 << " ,bec: " << atrlist2["bec"].data<int>()
1512 << " ,layer: " << atrlist2["layer"].data<int>()
1513 << " ,ring: " << atrlist2["ring"].data<int>()
1514 << " ,sector: " << atrlist2["sector"].data<int>()
1515 << " ,Tx: " << atrlist2["Tx"].data<float>()
1516 << " ,Ty: " << atrlist2["Ty"].data<float>()
1517 << " ,Tz: " << atrlist2["Tz"].data<float>()
1518 << " ,Rx: " << atrlist2["Rx"].data<float>()
1519 << " ,Ry: " << atrlist2["Ry"].data<float>()
1520 << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1521
1522
1523 // Order of rotations is defined as around z, then y, then x.
1524 Amg::Translation3D oldtranslation(atrlist2["Tx"].data<float>(),atrlist2["Ty"].data<float>(),atrlist2["Tz"].data<float>());
1525 Amg::Transform3D oldtrans = oldtranslation * Amg::RotationMatrix3D::Identity();
1526 oldtrans *= Amg::AngleAxis3D(atrlist2["Rz"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,0.,1.));
1527 oldtrans *= Amg::AngleAxis3D(atrlist2["Ry"].data<float>()*CLHEP::mrad, Amg::Vector3D(0.,1.,0.));
1528 oldtrans *= Amg::AngleAxis3D(atrlist2["Rx"].data<float>()*CLHEP::mrad, Amg::Vector3D(1.,0.,0.));
1529
1530 // get the new transform
1531 Amg::Transform3D newtrans = trans*oldtrans;
1532
1533 // Extract the values we need to write to DB
1534 Amg::Vector3D shift=newtrans.translation();
1535 double alpha, beta, gamma;
1536 extractAlphaBetaGamma(newtrans, alpha, beta, gamma);
1537
1538 atrlist2["Tx"].data<float>() = shift.x();
1539 atrlist2["Ty"].data<float>() = shift.y();
1540 atrlist2["Tz"].data<float>() = shift.z();
1541 atrlist2["Rx"].data<float>() = alpha/CLHEP::mrad ;
1542 atrlist2["Ry"].data<float>() = beta/CLHEP::mrad ;
1543 atrlist2["Rz"].data<float>() = gamma/CLHEP::mrad ;
1544
1545 result = true;
1546 msg(MSG::DEBUG) << "Tweak New global DB -- channel: " << citr->first
1547 << " ,det: " << atrlist2["det"].data<int>()
1548 << " ,bec: " << atrlist2["bec"].data<int>()
1549 << " ,layer: " << atrlist2["layer"].data<int>()
1550 << " ,ring: " << atrlist2["ring"].data<int>()
1551 << " ,sector: " << atrlist2["sector"].data<int>()
1552 << " ,Tx: " << atrlist2["Tx"].data<float>()
1553 << " ,Ty: " << atrlist2["Ty"].data<float>()
1554 << " ,Tz: " << atrlist2["Tz"].data<float>()
1555 << " ,Rx: " << atrlist2["Rx"].data<float>()
1556 << " ,Ry: " << atrlist2["Ry"].data<float>()
1557 << " ,Rz: " << atrlist2["Rz"].data<float>() << endmsg;
1558
1559 }
1560 }
1561 }
1562 else {
1563 ATH_MSG_ERROR("tweakGlobalFolder: cast fails for DBident " << DBident );
1564 return false;
1565 }
1566 }
1567 else {
1568 ATH_MSG_ERROR("tweakGlobalFolder: cannot retrieve CondAttrListCollection for key " << key );
1569 return false;
1570 }
1571
1572 return result;
1573}
#define endmsg
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 1437 of file InDetAlignDBTool.cxx.

1437 {
1438
1439 // find transform key, then set appropriate transform
1440 const CondAttrListCollection* atrlistcol1=nullptr;
1441 CondAttrListCollection* atrlistcol2=nullptr;
1442 bool result=false;
1443 if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol1,"/Indet/IBLDist")) {
1444 // loop over objects in collection
1445 atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1446 if (atrlistcol2!=nullptr){
1447 for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1448
1449 const coral::AttributeList& atrlist=citr->second;
1450 coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1451
1452 if(atrlist2["stave"].data<int>()!=stave) continue;
1453 else {
1454 msg(MSG::DEBUG) << "IBLDist DB -- channel before update: " << citr->first
1455 << " ,stave: " << atrlist2["stave"].data<int>()
1456 << " ,mag: " << atrlist2["mag"].data<float>()
1457 << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1458
1459 atrlist2["mag"].data<float>() += bowx;
1460 result = true;
1461 msg(MSG::DEBUG) << "IBLDist DB -- channel after update: " << citr->first
1462 << " ,stave: " << atrlist2["stave"].data<int>()
1463 << " ,mag: " << atrlist2["mag"].data<float>()
1464 << " ,base: " << atrlist2["base"].data<float>() << endmsg;
1465
1466 }
1467 }
1468 }
1469 else {
1470 ATH_MSG_ERROR("tweakIBLDist: cast fails for stave " << stave );
1471 return false;
1472 }
1473 }
1474 else {
1475 ATH_MSG_ERROR("tweakIBLDist: cannot retrieve CondAttrListCollection for key /Indet/IBLDist" );
1476 return false;
1477 }
1478
1479 return result;
1480}

◆ tweakTrans() [1/2]

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

Implements IInDetAlignDBTool.

Definition at line 1041 of file InDetAlignDBTool.cxx.

1042 {
1043
1044 bool result=false;
1045
1046 // New additions for new global folder structure
1047 // No ATs exist for levels 1 & 2 --> need alternative
1048 if (m_dynamicDB && level!=3){
1049 result=tweakGlobalFolder(ident, level, trans);
1050 if (!result ) ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
1051 }
1052 else {
1053 // find transform key, then set appropriate transform
1054 std::string key=dirkey(ident,level);
1055 const AlignableTransform* pat;
1056 AlignableTransform* pat2;
1057 if ((pat=cgetTransPtr(key))) {
1058 pat2=const_cast<AlignableTransform*>(pat);
1059 if (pat2!=nullptr) {
1060 result=pat2->tweak(ident,Amg::EigenTransformToCLHEP(trans));
1061 if (!result) ATH_MSG_ERROR(
1062 "Attempt to tweak non-existent transform for element "<<m_pixid->show_to_string(ident));
1063 } else {
1064 ATH_MSG_ERROR("tweakTrans: cast fails for key " << key );
1065 }
1066 } else {
1068 "tweakTrans: cannot retrieve AlignableTransform for key" << key );
1069 }
1070 }
1071
1072 return result;
1073}
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 1075 of file InDetAlignDBTool.cxx.

1077{
1078
1079 Amg::Translation3D newtranslation(translate);
1080 Amg::Transform3D newtrans = newtranslation * Amg::RotationMatrix3D::Identity();
1081 newtrans *= Amg::AngleAxis3D(gamma, Amg::Vector3D(0.,0.,1.));
1082 newtrans *= Amg::AngleAxis3D(beta, Amg::Vector3D(0.,1.,0.));
1083 newtrans *= Amg::AngleAxis3D(alpha, Amg::Vector3D(1.,0.,0.));
1084
1085 return tweakTrans(ident, level, newtrans);
1086}
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 617 of file InDetAlignDBTool.cxx.

618 {
619 std::ofstream* outfile=nullptr;
620 SmartIF<INTupleSvc> ntsvc{Gaudi::svcLocator()->service("NTupleSvc")};
621 if(!ntsvc.isValid()) ATH_MSG_ERROR("Cannot find NTupleSvc" );
622 const std::string path=file+"/9002";
623 NTuplePtr nt(ntsvc.get(),path);
624
625 if (ntuple) {
626 ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on ntuple 9002, path: " << file );
627 const int ntid=9002;
628 if (nt) {
629 ATH_MSG_DEBUG( "Ntuple " << path << " is already booked" );
630 } else {
631 ATH_MSG_DEBUG("Attempting to book ntuple " << path );
632 nt=ntsvc->book(file,ntid,CLID_ColumnWiseTuple,"AlignDB");
633 if (!nt) ATH_MSG_ERROR("Ntuple booking fails" );
634 }
636 sc=nt->addItem("MODPROP/DetType",nt_dettype);
637 sc=nt->addItem("MODPROP/Bec",nt_bec);
638 sc=nt->addItem("MODPROP/Layer",nt_layer);
639 sc=nt->addItem("MODPROP/Ring",nt_ring);
640 sc=nt->addItem("MODPROP/Sector",nt_sector);
641 sc=nt->addItem("MODPROP/Side",nt_side);
642 sc=nt->addItem("MODPROP/Level",nt_level);
643 sc=nt->addItem("MODPROP/Xofs",nt_xofs);
644 sc=nt->addItem("MODPROP/Yofs",nt_yofs);
645 sc=nt->addItem("MODPROP/Zofs",nt_zofs);
646 sc=nt->addItem("MODPROP/Phi",nt_phi);
647 sc=nt->addItem("MODPROP/Theta",nt_theta);
648 sc=nt->addItem("MODPROP/Psi",nt_psi);
649 sc=nt->addItem("MODPROP/Phi",nt_phi);
650 sc=nt->addItem("MODPROP/Theta",nt_theta);
651 sc=nt->addItem("MODPROP/Psi",nt_psi);
652 if (sc!=StatusCode::SUCCESS) ATH_MSG_ERROR(
653 "Error booking ntuple 9002 contents" );
654 } else {
655 ATH_MSG_DEBUG( "writeFile: Write AlignableTransforms on text file: " << file );
656 outfile=new std::ofstream(file.c_str());
657 }
658 int nobj=0;
659 int ntrans=0;
660 for (std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
661 iobj!=m_alignobjs.end();++iobj) {
662 const AlignableTransform* pat;
663 if ((pat=cgetTransPtr(*iobj))) {
664 ++nobj;
665 if (!ntuple) *outfile << *iobj << '\n';
667 cit!=pat->end();++cit) {
668 const Identifier& ident=cit->identify();
669 const Amg::Transform3D& trans=Amg::CLHEPTransformToEigen( cit->transform() );
670 int det,bec,layer,ring,sector,side;
671 float dx,dy,dz,phi,theta,psi;
672 if(!ident.is_valid()) ATH_MSG_FATAL("Attempting to write an Invalid ID!!!");
673 if (!idToDetSet(ident,det,bec,layer,ring,sector,side)) {
674 // can fail for testbeam whe identifier with all layer
675 // and wafer indices set to zero is not valid in the dictionary
676 // these transforms are not actually used by testbeam GeoModel anyway
677 ATH_MSG_WARNING( "Ident for unknown detector type in " << *iobj );
678 det=1;bec=0;layer=0;ring=0;sector=0;side=0;
679 }
680 Amg::Vector3D shift=trans.translation();
681 Amg::RotationMatrix3D rot=trans.rotation();
682 dx=shift.x();
683 dy=shift.y();
684 dz=shift.z();
685 double alpha, beta, gamma;
686 extractAlphaBetaGamma(trans, alpha, beta, gamma);
687
688 //ATH_MSG_WARNING("THIS NEEDS TO BE CHECKED --- InDetAlignDBTool.cxx:647");
689 // checked and appears all good, keep this in for now in case we have to recheck things
690 Amg::Vector3D ea = rot.eulerAngles(2, 0, 2);
691
692 phi= ea[0];
693 theta=ea[1];
694 psi=ea[2];
695 ++ntrans;
696 if (ntuple) {
698 nt_bec=bec;
700 nt_ring=ring;
701 nt_sector=sector;
702 nt_level=3;
703 // derive level by looking for objects ending in /ID, SCT or PIX
704 std::string r3=iobj->substr(iobj->size()-3,3);
705 if (r3=="/ID") nt_level=1;
706 if (r3=="SCT" || r3=="PIX") nt_level=2;
708 nt_xofs=dx;
709 nt_yofs=dy;
710 nt_zofs=dz;
711 nt_phi=phi;
713 nt_psi=psi;
717 if (StatusCode::SUCCESS!=nt->write()) ATH_MSG_ERROR("Problem filling ntuple 9002" );
718 } else {
719 *outfile << "2 " << det << " " << 2*bec << " " << layer << " " << sector <<
720 " " << ring << " " << side << " " << dx << " " << dy << " "
721 << dz << " " << alpha/CLHEP::mrad << " " << beta/CLHEP::mrad << " " << gamma/CLHEP::mrad << '\n';
722 ATH_MSG_VERBOSE("Found AlignableTransform for key "
723 << *iobj << " when writing output file");
724 }
725 }
726 } else {
727 ATH_MSG_ERROR("Cannot find AlignableTransform for key "
728 << *iobj << " when writing output file");
729 }
730 }
731 if (ntuple) {
732 } else {
733 outfile->close();
734 delete outfile;
735 }
736 ATH_MSG_DEBUG("Written " << nobj << " AlignableTransform objects" << " with " << ntrans << " transforms to text file" );
737}
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 772 of file InDetAlignDBTool.cxx.

773 {
774 std::ofstream* outfile=nullptr;
775
776 if (m_dynamicDB){
777 ATH_MSG_DEBUG( "writeFile: Write GlobalFolder DB in text file: " << file );
778 outfile=new std::ofstream(file.c_str());
779 std::vector<std::string> folder_list = {"/Indet/AlignL1/ID", "/Indet/AlignL2/PIX", "/Indet/AlignL2/SCT"};
780
781 for (std::vector<std::string>::iterator it = folder_list.begin(); it != folder_list.end(); ++it){
782
783 *outfile << *it << '\n';
784
785 const CondAttrListCollection* atrlistcol=nullptr;
786 if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,*it)) {
787 // loop over objects in collection
788 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
789
790 const coral::AttributeList& atrlist=citr->second;
791 *outfile << atrlist["subsystem"].data<int>()
792 << " " << atrlist["det"].data<int>()
793 << " " << atrlist["bec"].data<int>()
794 << " " << atrlist["layer"].data<int>()
795 << " " << atrlist["ring"].data<int>()
796 << " " << atrlist["sector"].data<int>()
797 << " " << atrlist["side"].data<int>()
798 << " " << atrlist["Tx"].data<float>()
799 << " " << atrlist["Ty"].data<float>()
800 << " " << atrlist["Tz"].data<float>()
801 << " " << atrlist["Rx"].data<float>()
802 << " " << atrlist["Ry"].data<float>()
803 << " " << atrlist["Rz"].data<float>() << '\n';
804 }
805 }
806 else {
807 if (msgLvl(MSG::INFO))
808 msg(MSG::INFO) << "Cannot find " << *it << " Container - cannot write DB in text file " << endmsg;
809 }
810 }
811 outfile->close();
812 delete outfile;
813 }
814 else {
815 ATH_MSG_DEBUG( "writeFile: No dynamic Run2 DB structure is present --> skipping writing file " << file );
816 }
817}

◆ writeIBLDistFile()

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

Implements IInDetAlignDBTool.

Definition at line 740 of file InDetAlignDBTool.cxx.

741 {
742 std::ofstream* outfile=nullptr;
743
744 ATH_MSG_DEBUG( "writeFile: Write IBLDist DB in text file: " << file );
745 outfile=new std::ofstream(file.c_str());
746 *outfile << "/Indet/IBLDist" << '\n';
747
748 const CondAttrListCollection* atrlistcol=nullptr;
749 if (StatusCode::SUCCESS==detStore()->retrieve(atrlistcol,"/Indet/IBLDist")) {
750 // loop over objects in collection
751 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
752
753 const coral::AttributeList& atrlist=citr->second;
754 *outfile << citr->first << " " << atrlist["stave"].data<int>()
755 << " " << atrlist["eta"].data<int>()
756 << " " << atrlist["mag"].data<float>()
757 << " " << atrlist["base"].data<float>() << '\n';
758 }
759 }
760 else {
761 if (msgLvl(MSG::INFO))
762 msg(MSG::INFO) << "Cannot find IBLDist Container - cannot write IBLDist DB in text file " << endmsg;
763 }
764
765 outfile->close();
766 delete outfile;
767
768}

Member Data Documentation

◆ m_alignchans

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

Definition at line 190 of file InDetAlignDBTool.h.

◆ m_alignobjs

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

Definition at line 189 of file InDetAlignDBTool.h.

◆ m_attrListCollection

CondAttrListCollection* InDetAlignDBTool::m_attrListCollection {}
private

Definition at line 192 of file InDetAlignDBTool.h.

192{};

◆ 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 207 of file InDetAlignDBTool.h.

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

◆ m_doStrip

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

Definition at line 208 of file InDetAlignDBTool.h.

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

◆ m_dynamicDB

bool InDetAlignDBTool::m_dynamicDB {false}
private

Definition at line 186 of file InDetAlignDBTool.h.

186{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 204 of file InDetAlignDBTool.h.

204{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 187 of file InDetAlignDBTool.h.

◆ m_par_condstream

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

Definition at line 199 of file InDetAlignDBTool.h.

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

◆ m_par_dbkey

std::string InDetAlignDBTool::m_par_dbkey
private

Definition at line 194 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 202 of file InDetAlignDBTool.h.

202{ 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 198 of file InDetAlignDBTool.h.

198{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 196 of file InDetAlignDBTool.h.

196{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 203 of file InDetAlignDBTool.h.

203{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 197 of file InDetAlignDBTool.h.

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

◆ m_pixid

const PixelID* InDetAlignDBTool::m_pixid {}
private

Definition at line 182 of file InDetAlignDBTool.h.

182{};

◆ m_pixman

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

Definition at line 184 of file InDetAlignDBTool.h.

184{};

◆ m_pixmanName

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

Definition at line 205 of file InDetAlignDBTool.h.

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

◆ m_sctid

const SCT_ID* InDetAlignDBTool::m_sctid {}
private

Definition at line 183 of file InDetAlignDBTool.h.

183{};

◆ m_sctman

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

Definition at line 185 of file InDetAlignDBTool.h.

185{};

◆ m_sctmanName

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

Definition at line 206 of file InDetAlignDBTool.h.

206{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: