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

Service to manage TRT alignment data. More...

#include <TRT_AlignDbSvc.h>

Inheritance diagram for TRT_AlignDbSvc:

Public Member Functions

 TRT_AlignDbSvc (const std::string &name, ISvcLocator *pSvcLocator)
 constructor
virtual ~TRT_AlignDbSvc ()
 destructor
virtual StatusCode initialize ()
 tool initialize
virtual StatusCode finalize ()
 tool finalize
StatusCode IOVCallBack (IOVSVC_CALLBACK_ARGS)
 Call back function for alignment folders.
StatusCode writeAlignTextFile (const std::string &file) const
 write AlignableTransforms to flat text file
StatusCode writeStrawAlignTextFile (const std::string &file) const
StatusCode writeGlobalFolderFile (const std::string &file) const
StatusCode readAlignTextFile (const std::string &file)
 read AlignableTransforms from text file into TDS
StatusCode streamOutAlignObjects () const
 write the alignment objects to output
StatusCode registerAlignObjects (const std::string &tag, int run1, int event1, int run2, int event2) const
 register alignment objects with the IoV service
StatusCode setAlignTransform (Identifier ident, Amg::Transform3D trans, unsigned int level)
 set AlignableTransform for an identifier
StatusCode tweakAlignTransform (Identifier ident, Amg::Transform3D trans, unsigned int level)
 tweak AlignableTransform for an identifier
const Amg::Transform3D getAlignmentTransform (const Identifier &ident, unsigned int level) const
 get AlignableTransform for an identifier
const Amg::Transform3DgetAlignmentTransformPtr (const Identifier &ident, unsigned int level) const
 get Level L2 Transform for an identifier
StatusCode tweakGlobalFolder (Identifier ident, const Amg::Transform3D &trans)
 tweak L1 DB for global folders for an identifier

Private Member Functions

StatusCode setAlignTransformL1 (Identifier ident, const Amg::Transform3D &trans)
 set Level 1 AlignableTransform for an identifier
StatusCode setAlignTransformL2 (Identifier ident, Amg::Transform3D trans)
 set Level 2 AlignableTransform for an identifier
StatusCode setAlignTransformL3 (Identifier ident, Amg::Transform3D trans)
 set Level 3 AlignableTransform for an identifier
const Amg::Transform3D getAlignmentTransformL1 (Identifier const &ident) const
 get Level 1 AlignableTransform for an identifier
const Amg::Transform3DgetAlignmentTransformL1Ptr (Identifier const &ident) const
 get Level L1 Transform for an identifier
const Amg::Transform3D getAlignmentTransformL2 (Identifier const &ident) const
 get Level 2 AlignableTransform for an identifier
const Amg::Transform3DgetAlignmentTransformL2Ptr (Identifier const &ident) const
 get Level L2 Transform for an identifier
StatusCode tweakAlignTransformL1 (Identifier ident, const Amg::Transform3D &trans)
 tweak Level 1 AlignableTransform for an identifier
StatusCode tweakAlignTransformL2 (Identifier ident, const Amg::Transform3D &trans)
 tweak Level 2 AlignableTransform for an identifier
StatusCode tweakAlignTransformL3 (Identifier ident, Amg::Transform3D trans)
 tweak Level 3 AlignableTransform for an identifier
AlignableTransformgetTransPtr (const std::string &key) const
 get AlignableTransform pointer for an object key
const AlignableTransformcgetTransPtr (const std::string &key) const
 get const AlignableTransform pointer for an object key
bool isOldKey (const std::string &input) const
 Returns the true if the input key is from the old endcap scheme.
void printCondObjects () const
 Output the conditions objects currently in memory.
StatusCode createAlignObjects () const
 Create an empty set of AlignableTransforms for the GeoModel setup.
StatusCode createAlignObjectsWhichDoNotAlreadyExist ()
 Create an empty set of AlignableTransforms for the transforms which are not created by XXXXXXX from the conddb.
const AlignableTransformContainergetContainer () const
 Return the container.
std::string findkey (const Identifier &ident, const std::string &type) const
 Return the object key for a given identifier and data type.

Static Private Member Functions

static int getRingForStrawLayer (int strawlayer)
 Returns the ring for a given strawLayer.
static std::string prefixtag (const std::string &key)
 Return the prefix tag for a given calibration folder.
static std::string intToString (int input)
 Convert from an int to a string.
static void printTransform (const std::string &thisName, const Amg::Transform3D &transform)
 Output the transform to the cout, for debugging.

Private Attributes

ServiceHandle< StoreGateSvcm_detStore
ServiceHandle< ITRT_StrawAlignDbSvcm_trtStrawAlignDbSvc
const TRT_IDm_trtid
 trt id helper
const InDetDD::TRT_DetectorManagerm_trtman
 detector manager
std::string m_alignroot
 root alignment folder
std::string m_alignString
 alignment string searched for
std::string m_par_alitextfile
 input text file
std::vector< std::string > m_alignobjs
 folder names
std::vector< int > m_alignchans
 channels
const DataHandle< AlignableTransformContainerm_aligncontainerhandle
ToolHandle< IAthenaOutputStreamToolm_streamer
 OutputStreamTool.
std::vector< Amg::Transform3D * > m_amgTransformCache
std::string m_alignDBprefix
bool m_dynamicDB
bool m_forceUserDBConfig

Detailed Description

Service to manage TRT alignment data.

Definition at line 45 of file TRT_AlignDbSvc.h.

Constructor & Destructor Documentation

◆ TRT_AlignDbSvc()

TRT_AlignDbSvc::TRT_AlignDbSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

constructor

Definition at line 37 of file TRT_AlignDbSvc.cxx.

38 : base_class(name,pSvcLocator),
39 m_detStore("DetectorStore",name),
40 m_trtStrawAlignDbSvc("TRT_StrawAlignDbSvc",name),
41 m_trtid(nullptr),
42 m_trtman(nullptr),
43 m_alignroot("/TRT/Align"),
44 m_alignString("AL"),
46 m_streamer("AthenaOutputStreamTool/CondStream1"),
47 m_alignDBprefix("/TRT/Align/"),
48 m_dynamicDB(false),
50{
51 declareProperty("StreamTool",m_streamer);
52 declareProperty("alignroot",m_alignroot);
53 declareProperty("alignTextFile",m_par_alitextfile);
54 declareProperty("DetectorStore",m_detStore);
55 declareProperty("TrtStrawAlignDbSvc", m_trtStrawAlignDbSvc,"Service for interaction with the TRT straw alignment DB");
56 declareProperty("alignString",m_alignString);
57 declareProperty("alignDBprefix",m_alignDBprefix);
58 declareProperty("forceUserDBConfig",m_forceUserDBConfig, "Set to true to override any DB auto-configuration");
59}
const TRT_ID * m_trtid
trt id helper
ToolHandle< IAthenaOutputStreamTool > m_streamer
OutputStreamTool.
std::string m_alignString
alignment string searched for
ServiceHandle< ITRT_StrawAlignDbSvc > m_trtStrawAlignDbSvc
std::string m_par_alitextfile
input text file
const InDetDD::TRT_DetectorManager * m_trtman
detector manager
ServiceHandle< StoreGateSvc > m_detStore
std::string m_alignDBprefix
std::string m_alignroot
root alignment folder

◆ ~TRT_AlignDbSvc()

TRT_AlignDbSvc::~TRT_AlignDbSvc ( )
virtual

destructor

Definition at line 63 of file TRT_AlignDbSvc.cxx.

64{}

Member Function Documentation

◆ cgetTransPtr()

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

get const AlignableTransform pointer for an object key

Definition at line 1381 of file TRT_AlignDbSvc.cxx.

1381 {
1382 ATH_MSG_DEBUG( "In cgetTransPtr" );
1383 ATH_MSG_DEBUG( "Getting the poiter for key " << key );
1384
1385 // Retrieve AlignableTransform pointer for a given key - const version
1386 const AlignableTransform* pat=nullptr;
1388 // the retrieve is unnecessary. in fact, if patc==0, retrieve should
1389 // fail as well.
1390
1391 if( patc || StatusCode::SUCCESS==m_detStore->retrieve(patc,m_alignroot)) {
1392 for(DataVector<AlignableTransform>::const_iterator dva=patc->begin();dva!=patc->end();++dva) {
1393 if( (*dva)->tag()==key ) {
1394 pat = *dva;
1395 break;
1396 }
1397 }
1398 }
1399
1400 if(!pat){
1401 ATH_MSG_WARNING( "AlignableTransform poiter is NULL!!!!!" );
1402 ATH_MSG_WARNING( "Failed to get the AlignableTransform for key " << key );
1403 }
1404
1405 ATH_MSG_DEBUG( "leaving cgetTransPtr " );
1406 return pat;
1407}
CondMultChanCollection< AlignableTransform > AlignableTransformContainer
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
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.
const AlignableTransformContainer * getContainer() const
Return the container.

◆ createAlignObjects()

StatusCode TRT_AlignDbSvc::createAlignObjects ( ) const
private

Create an empty set of AlignableTransforms for the GeoModel setup.

create an empty set of AlignableTransforms for the GeoModel setup

Create empty alignment objects. Use when constants are read in from textfiles. Make sure that the objects are not read in by IOV before

check if collection already exists

Create the appropriate (empty) AlignableTransforms for this geometry

record it

Definition at line 1283 of file TRT_AlignDbSvc.cxx.

1283 {
1284
1289 ATH_MSG_DEBUG( "createAlignObjects method called" );
1290
1293 ATH_MSG_WARNING( "createAlignObjects: AlignableTransformContainer with name " << m_alignroot
1294 << " already exists." );
1295 return StatusCode::FAILURE;
1296 }
1297
1299 auto patc = std::make_unique<AlignableTransformContainer>();
1300
1301 for (unsigned int i=0;i<m_alignobjs.size();++i) {
1302 patc->push_back(std::make_unique<AlignableTransform>(m_alignobjs[i]));
1303 patc->add(m_alignchans[i]);
1304 ATH_MSG_INFO( " added empty AlignableTransform for key " << m_alignobjs[i] );
1305 }
1306
1308 ATH_CHECK( m_detStore->record(std::move(patc),m_alignroot) );
1309
1310 ATH_MSG_DEBUG( "Leaving createAlignObjects" );
1311 return StatusCode::SUCCESS;
1312}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
std::vector< std::string > m_alignobjs
folder names
std::vector< int > m_alignchans
channels

◆ createAlignObjectsWhichDoNotAlreadyExist()

StatusCode TRT_AlignDbSvc::createAlignObjectsWhichDoNotAlreadyExist ( )
private

Create an empty set of AlignableTransforms for the transforms which are not created by XXXXXXX from the conddb.

create an empty set of AlignableTransforms for the transforms which are not created by XXXXXXX from the conddb

Create empty alignment objects for the object which do do already exist

check if collection already exists

Get the alignabletransformcontainer

Need to cost cast b/c were are chaning it, Ugly but so be it.

Only create the new keys that dont exist

If the pointer doesnt exist

Definition at line 1316 of file TRT_AlignDbSvc.cxx.

1316 {
1317
1320 ATH_MSG_DEBUG( "createAlignObjectsWhichDoNotAlreadyExist method called" );
1321
1324
1327
1329 AlignableTransformContainer* patc_NonConst = const_cast<AlignableTransformContainer*>(patc);
1330
1331 for (unsigned int i=0;i<m_alignobjs.size();++i) {
1332
1334 if(m_alignString != "Alold" && !isOldKey(m_alignobjs[i] )){
1335
1337 if(!cgetTransPtr(m_alignobjs[i])){
1338
1339 AlignableTransform* pat=new AlignableTransform(m_alignobjs[i]);
1340 patc_NonConst->push_back(pat);
1341 patc_NonConst->add(m_alignchans[i]);
1342 ATH_MSG_INFO( " added empty AlignableTransform for key " << m_alignobjs[i] );
1343
1344 }
1345 }
1346 }
1347
1348 ATH_MSG_DEBUG( "Leaving createAlignObjectsWhichDoNotAlreadyExist" );
1349 return StatusCode::SUCCESS;
1350}
void add(ChanNum chanNum)
Adding in channel numbers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const AlignableTransform * cgetTransPtr(const std::string &key) const
get const AlignableTransform pointer for an object key
bool isOldKey(const std::string &input) const
Returns the true if the input key is from the old endcap scheme.

◆ finalize()

StatusCode TRT_AlignDbSvc::finalize ( )
virtual

tool finalize

Definition at line 172 of file TRT_AlignDbSvc.cxx.

173{
174 ATH_MSG_INFO( "TRT_AlignDbSvc finalize method called" );
175 for(std::vector<Amg::Transform3D*>::iterator it = m_amgTransformCache.begin(); it != m_amgTransformCache.end(); ++it){
176 delete *it;
177 }
178 return StatusCode::SUCCESS;
179}
std::vector< Amg::Transform3D * > m_amgTransformCache

◆ findkey()

std::string TRT_AlignDbSvc::findkey ( const Identifier & ident,
const std::string & type ) const
private

Return the object key for a given identifier and data type.

return the object key for a given identifier and data type

given a TRT identifier and a type ("RT", "T0", "DF" or "AL") return the key for the associated ArrayStore or AlignableTransForm in TDS

The keys in the old (Lisbon) scheme coincide with TDS folder names:

/Indet/Align/TRTB0 AlignableTransform for barrel layer 0. Etc /Indet/Align/TRT_DF_B0 Wire shift FloatArrayStore for barrel layer 0. Etc /Indet/Calib/TRT_T0_B0 T0 FloatArrayStore for barrel layer 0. Etc /Indet/Calib/TRT_RT_B0 R(t) FloatArrayStore for barrel layer 0. Etc

In the COOL scheme there is only one folder for AlignableTransforms and one for FloatArrayStores (/TRT/Align and /TRT/Calib). These contains collections of objects with the following keys:

/TRT/Align/L2A AlignableTransform for Endcap A. /TRT/Align/AX DEPRECATED! Old AlignableTransform for Endcap A wheel X where X is [0-13]. /TRT/Align/B0 AlignableTransform for barrel layer 0. /TRT/Align/B1 AlignableTransform for barrel layer 1. /TRT/Align/B2 AlignableTransform for Endcap C. /TRT/Align/L2C AlignableTransform for barrel layer 0. /TRT/Align/CX DEPRECATED! Old AlignableTransform for Endcap C wheel X where X is [0-13]. /TRT/Calib/DF_B0 Wire shift FloatArrayStore for barrel layer 0. Etc /TRT/Calib/T0_B0 T0 FloatArrayStore for barrel layer 0. Etc /TRT/Calib/RT_B0 R(t) FloatArrayStore for barrel layer 0. Etc

So the result is eg /Indet/Calib/TRT_T0_A6 in the Lisbon scheme and /TRT/Calib/T0_A6 in the COOL scheme

  • for the T0 folder for wheel 6 in endcap A

Definition at line 1147 of file TRT_AlignDbSvc.cxx.

1147 {
1173 std::ostringstream result;
1174 if (!m_trtid->is_trt(ident)) return result.str();
1175
1176 if(type=="AL" || type=="ALold") {
1177 // result << "/TRT/Align/";
1179 } else if(type=="DF") {
1180 result << "/TRT/Calib/DF";
1181 } else return result.str();
1182
1183 int bec=m_trtid->barrel_ec(ident);
1184
1185 if(type!="AL" && type!="ALold") result << "_";
1186
1187 if(type=="AL"){
1188 if(bec==2) {
1189 result << "L2A";
1190 } else if(bec==-2) {
1191 result << "L2C";
1192 } else {
1193 result << "B";
1194 int layer = m_trtid->layer_or_wheel(ident);
1195 result << layer;
1196 }
1197 }else if(type=="ALold"){
1198 if(bec==2) {
1199 result << "A";
1200 } else if(bec==-2) {
1201 result << "C";
1202 } else {
1203 result << "B";
1204 }
1205 int layer = m_trtid->layer_or_wheel(ident);
1206 result << layer;
1207 }
1208
1213
1214 return result.str();
1215}
@ layer
Definition HitInfo.h:79

◆ getAlignmentTransform()

const Amg::Transform3D TRT_AlignDbSvc::getAlignmentTransform ( const Identifier & ident,
unsigned int level ) const

get AlignableTransform for an identifier

get Level L2 Transform for an identifier

Definition at line 537 of file TRT_AlignDbSvc.cxx.

537 {
538 ATH_MSG_DEBUG( "In getAlignmentTransform" );
539
540 if(level != 1 && level != 2){
541 ATH_MSG_ERROR( "Call to trans wrong!" );
542 ATH_MSG_ERROR( "Level must be 1 or 2!" );
543 ATH_MSG_ERROR( "Returning NULL" );
544 return Amg::Transform3D();
545 }
546
547 return (level == 1) ? getAlignmentTransformL1(ident) : getAlignmentTransformL2(ident);
548}
#define ATH_MSG_ERROR(x)
const Amg::Transform3D getAlignmentTransformL2(Identifier const &ident) const
get Level 2 AlignableTransform for an identifier
const Amg::Transform3D getAlignmentTransformL1(Identifier const &ident) const
get Level 1 AlignableTransform for an identifier
Eigen::Affine3d Transform3D
@ ident
Definition HitInfo.h:77

◆ getAlignmentTransformL1()

const Amg::Transform3D TRT_AlignDbSvc::getAlignmentTransformL1 ( Identifier const & ident) const
private

get Level 1 AlignableTransform for an identifier

Definition at line 551 of file TRT_AlignDbSvc.cxx.

551 {
552 ATH_MSG_DEBUG( "In getAlignmentTransformL1" );
553 // return level 1 AlignableTransform for the TRT subdetector bec (+-1,+-2)
554 // or return null transform.
555
556 std::string key="/TRT/Align/TRT";
557 const AlignableTransform* pat=cgetTransPtr(key);
558 if (!pat) return Amg::Transform3D();
559
560 // get Amg::Transform3d via AlignTransMember
561 AlignableTransform::AlignTransMem_citr itr = pat->findIdent(ident);
562 return ( itr!=pat->end() ? Amg::CLHEPTransformToEigen(itr->transform()) : Amg::Transform3D() );
563}
std::vector< AlignTransMember >::const_iterator AlignTransMem_citr
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.

◆ getAlignmentTransformL1Ptr()

const Amg::Transform3D * TRT_AlignDbSvc::getAlignmentTransformL1Ptr ( Identifier const & ident) const
private

get Level L1 Transform for an identifier

Definition at line 611 of file TRT_AlignDbSvc.cxx.

611 {
612 ATH_MSG_DEBUG( "In getAlignmentTransformL1Ptr" );
613 // get level 1 (despite name, will change soon) AlignableTransform for the subdetector containing ident
614 const Amg::Transform3D* rc(nullptr) ;
615 if( m_trtid->is_trt(ident) ) {
616 const AlignableTransform* pat = cgetTransPtr( "/TRT/Align/TRT" ) ;
617 if( pat ) {
618 int bec=m_trtid->barrel_ec(ident);
619 Identifier mid=m_trtid->module_id(bec,0,0);
621 if(iter != pat->end() ) {
622 Amg::Transform3D* amgTransform = new Amg::Transform3D((Amg::CLHEPTransformToEigen(iter->transform())));
623 m_amgTransformCache.push_back(amgTransform);
624 rc = amgTransform;
625 }
626 }
627 }
628
629 ATH_MSG_DEBUG( "Leaving getAlignmentTransformL1Ptr" );
630 return rc ;
631}
static Double_t rc

◆ getAlignmentTransformL2()

const Amg::Transform3D TRT_AlignDbSvc::getAlignmentTransformL2 ( Identifier const & ident) const
private

get Level 2 AlignableTransform for an identifier

Definition at line 566 of file TRT_AlignDbSvc.cxx.

566 {
567 ATH_MSG_DEBUG( "In getAlignmentTransformL2" );
568 // return level 2 AlignableTransform for the module containing ident
569 // or return null transform.
570
571 std::string key=findkey(ident,m_alignString);
572 //does a key exist corresponding to this identifier?
573
574 const AlignableTransform* pat=cgetTransPtr(key);
575 if (!pat) return Amg::Transform3D();
576
577 // OK it exists
578 // get "module identifier" from identifier
579 int bec=m_trtid->barrel_ec(ident);
580 int layer=m_trtid->layer_or_wheel(ident);
581 int sector=m_trtid->phi_module(ident);
582 int strawLayer=m_trtid->straw_layer(ident);
583 int ring = getRingForStrawLayer(strawLayer);
584
585 Identifier mid;
586 if(key == (m_alignDBprefix+"L2A") || key == (m_alignDBprefix+"L2C") )
587 mid=m_trtid->layer_id(bec,0,layer,ring);
588 else
589 mid=m_trtid->module_id(bec,sector,layer);
590
591 // get Amg::Transform3d via AlignTransMember
592 AlignableTransform::AlignTransMem_citr itr = pat->findIdent(mid);
593 return ( itr!=pat->end() ? Amg::CLHEPTransformToEigen(itr->transform()) : Amg::Transform3D() );
594}
std::string findkey(const Identifier &ident, const std::string &type) const
Return the object key for a given identifier and data type.
static int getRingForStrawLayer(int strawlayer)
Returns the ring for a given strawLayer.
@ strawLayer
Definition HitInfo.h:81

◆ getAlignmentTransformL2Ptr()

const Amg::Transform3D * TRT_AlignDbSvc::getAlignmentTransformL2Ptr ( Identifier const & ident) const
private

get Level L2 Transform for an identifier

Definition at line 634 of file TRT_AlignDbSvc.cxx.

634 {
635 ATH_MSG_DEBUG( "In getAlignmentTransformL2Ptr" );
636 // set level 2 (despite name, will change soon) AlignableTransform for the module containing ident
637 // or add a new one.
638 const Amg::Transform3D* rc(nullptr) ;
639 //does a folder exist corresponding to this identifier?
640 if( m_trtid->is_trt(ident) ) {
641 std::string key=findkey(ident,m_alignString);
642 const AlignableTransform* pat=cgetTransPtr(key);
643 if(pat) {
644 // make sure the identifier is a "module identifier"
645 int bec=m_trtid->barrel_ec(ident);
646 int layer=m_trtid->layer_or_wheel(ident);
647 int sector=m_trtid->phi_module(ident);
648 int strawLayer=m_trtid->straw_layer(ident);
649 int ring = getRingForStrawLayer(strawLayer);
650 Identifier mid;
651 if(key == (m_alignDBprefix+"L2A") || key == (m_alignDBprefix+"L2C") ){
652 mid =m_trtid->layer_id(bec,0,layer,ring);
653 }else
654 mid =m_trtid->module_id(bec,sector,layer);
655
657 if(iter != pat->end() ){
659 Amg::Transform3D* amgTransform = new Amg::Transform3D((Amg::CLHEPTransformToEigen(iter->transform())));
660 m_amgTransformCache.push_back(amgTransform);
661 rc = amgTransform;
662 }
663
664 else
665 ATH_MSG_WARNING( "Did not find the transform for " << m_trtid->show_to_string(mid) );
666 }
667 }
668
669 ATH_MSG_DEBUG( "Leaving getAlignmentTransformL2Ptr" );
670 return rc ;
671}

◆ getAlignmentTransformPtr()

const Amg::Transform3D * TRT_AlignDbSvc::getAlignmentTransformPtr ( const Identifier & ident,
unsigned int level ) const

get Level L2 Transform for an identifier

Definition at line 597 of file TRT_AlignDbSvc.cxx.

597 {
598 ATH_MSG_DEBUG( "In getAlignmentTransformPtr" );
599
600 if(level != 1 && level != 2){
601 ATH_MSG_ERROR( "Call to trans wrong!" );
602 ATH_MSG_ERROR( "Level must be 1 or 2!" );
603 ATH_MSG_ERROR( "Returning NULL" );
604 return nullptr;
605 }
606
607 return (level == 1) ? getAlignmentTransformL1Ptr(ident) : getAlignmentTransformL2Ptr(ident);
608}
const Amg::Transform3D * getAlignmentTransformL2Ptr(Identifier const &ident) const
get Level L2 Transform for an identifier
const Amg::Transform3D * getAlignmentTransformL1Ptr(Identifier const &ident) const
get Level L1 Transform for an identifier

◆ getContainer()

const AlignableTransformContainer * TRT_AlignDbSvc::getContainer ( ) const
private

Return the container.

Definition at line 1599 of file TRT_AlignDbSvc.cxx.

1600{
1601 if (m_aligncontainerhandle.isValid())
1602 return m_aligncontainerhandle.cptr();
1603 const AlignableTransformContainer* ptr = nullptr;
1604 if (m_detStore->retrieve (ptr, m_alignroot).isFailure()) {
1605 ATH_MSG_ERROR ("Cannot retrieve " << m_alignroot << " from detStore ");
1606 }
1607 return ptr;
1608}
const DataHandle< AlignableTransformContainer > m_aligncontainerhandle
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ getRingForStrawLayer()

int TRT_AlignDbSvc::getRingForStrawLayer ( int strawlayer)
staticprivate

Returns the ring for a given strawLayer.

Definition at line 1411 of file TRT_AlignDbSvc.cxx.

1411 {
1412 return strawlayer / 4 * 4;
1413}

◆ getTransPtr()

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

get AlignableTransform pointer for an object key

Definition at line 1375 of file TRT_AlignDbSvc.cxx.

1375 {
1376 ATH_MSG_DEBUG( "In (and leaving) getTransPtr" );
1377 return const_cast<AlignableTransform*>(cgetTransPtr(key)) ;
1378}

◆ initialize()

StatusCode TRT_AlignDbSvc::initialize ( )
virtual

tool initialize

If the folder exists, register a callback, we read from the text file if it exists in the call back If the folder does not yet exist, create and record it.

This is the folder given by the conditions db.(Eg: from the global tag) One can block this via: conddb.blockFolder("/TRT/Align") in the jobOptions

This is the text files whence the constants.

register the callback

Reminder that the constants will be read from text file.

create alignment objects

Read the newly created objects

Definition at line 68 of file TRT_AlignDbSvc.cxx.

69{
70 ATH_MSG_INFO( " in initialize " );
71
72 ATH_CHECK( m_detStore.retrieve() );
73 ATH_CHECK (m_trtStrawAlignDbSvc.retrieve() );
74 ATH_MSG_INFO ("retrieved " << m_trtStrawAlignDbSvc);
75
76 // Get the geometry.
78 ATH_CHECK (m_detStore->retrieve(m_trtman,"TRT") );
79
80 // Get TRT manager and ID helper
81 itermin=m_trtman->getDetectorElementBegin();
82 itermax=m_trtman->getDetectorElementEnd();
83 ATH_CHECK( m_detStore->retrieve(m_trtid,"TRT_ID") );
84 ATH_MSG_INFO( "found all TRT services " );
85
86 if (m_trtman->m_alignfoldertype == InDetDD::timedependent_run2 && !m_forceUserDBConfig){
87 m_dynamicDB = true;
88 m_alignroot = "/TRT/AlignL2";
89 m_alignDBprefix = "/TRT/AlignL2/";
90 }
91 if (m_trtman->m_alignfoldertype == InDetDD::static_run1 && !m_forceUserDBConfig){
92 m_dynamicDB = false;
93 m_alignroot = "/TRT/Align";
94 m_alignDBprefix = "/TRT/Align/";
95 }
96
97
98 // setup list of TDS objects from geometry description
99 m_alignobjs.clear();
100 m_alignchans.clear();
101
102 // Include a level 1 alignment
103 int ichan(0) ;
104 if (!m_dynamicDB){
105 m_alignobjs.emplace_back("/TRT/Align/TRT");
106 ATH_MSG_INFO( "Adding key: /TRT/Align/TRT --> We are using static DB folder scheme" );
107 m_alignchans.push_back(ichan++);
108 }
109
110 //Check all detector elements in the present geometry setup
111 for (iter=itermin;iter!=itermax;++iter) {
112 const InDetDD::TRT_BaseElement* element=*iter;
113 if (element!=nullptr) {
114 const Identifier ident=element->identify();
115 if (m_trtid->is_trt(ident)) { //OK this Element is included
116 std::string key = findkey(ident,m_alignString);
117 std::vector<std::string>::const_iterator ix = find(m_alignobjs.begin(),m_alignobjs.end(),key);
118 if (ix==m_alignobjs.end()) {
119 m_alignobjs.push_back(key);
120 ATH_MSG_INFO( "Adding key: " << key );
121 m_alignchans.push_back(ichan++);
122 }
123 }
124 }
125 }
126
130
134 bool alignFolderExists = m_detStore->contains<AlignableTransformContainer>(m_alignroot) ;
135 if (m_dynamicDB) alignFolderExists = ( alignFolderExists && m_detStore->contains<CondAttrListCollection>("/TRT/AlignL1/TRT"));
136
139 bool alignTextFileExists = !m_par_alitextfile.empty();
140
141 if( alignFolderExists ) {
142
145
147 if( alignTextFileExists )
148 ATH_MSG_INFO( "AlignableTransformContainer with name " << m_alignroot
149 << " exists. Will read text file from callback function." );
150
151 } else if ( alignTextFileExists ) {
152
154 ATH_CHECK( this->createAlignObjects() );
155
158
159 } else {
160 ATH_MSG_ERROR( "AlignableTransformContainer not in IOV service and no textfile specified." );
161 }
162
163 ATH_MSG_DEBUG ("The TRT/Align keys and channels are:");
164 for (unsigned int i=0;i<m_alignobjs.size();++i)
165 ATH_MSG_DEBUG (" key " << m_alignobjs[i] << " chan " << m_alignchans[i]);
166
167 return StatusCode::SUCCESS;
168}
virtual Identifier identify() const override final
identifier of this detector element:
StatusCode createAlignObjects() const
Create an empty set of AlignableTransforms for the GeoModel setup.
StatusCode readAlignTextFile(const std::string &file)
read AlignableTransforms from text file into TDS
StatusCode IOVCallBack(IOVSVC_CALLBACK_ARGS)
Call back function for alignment folders.
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
@ timedependent_run2

◆ intToString()

std::string TRT_AlignDbSvc::intToString ( int input)
staticprivate

Convert from an int to a string.

Definition at line 1441 of file TRT_AlignDbSvc.cxx.

1441 {
1442 std::ostringstream stm;
1443 stm << input;
1444 return stm.str();
1445}

◆ IOVCallBack()

StatusCode TRT_AlignDbSvc::IOVCallBack ( IOVSVC_CALLBACK_ARGS )

Call back function for alignment folders.

By the time this gets called the alignment transforms have been created. Either by the create method in initialize, or from the align folder content from the cond db. (Its not clear to johnda where the alignable tracnsforms get created from the conddb)

If we read the constants from the db, there is a chance that they only contained the alignable transforms for the old endcap keys. In which case we need to create the transforms for the new endcap keys

Print the keys were setting

print out the objects we have

Definition at line 182 of file TRT_AlignDbSvc.cxx.

183{
184 ATH_MSG_DEBUG( "In IOVCallBack" );
185
194
197 for (std::list<std::string>::const_iterator itr=keys.begin(); itr!=keys.end(); ++itr)
198 ATH_MSG_INFO( "IOVCALLBACK for key " << *itr<< " number " << I );
199
200
201 if(!m_par_alitextfile.empty()){
203 }else{
204 ATH_MSG_INFO( "Text file " << m_par_alitextfile << " is empty" );
205 }
206
210
211 ATH_MSG_DEBUG( "Leaving IOVCallBack" );
212 return StatusCode::SUCCESS;
213}
#define I(x, y, z)
Definition MD5.cxx:116
void printCondObjects() const
Output the conditions objects currently in memory.
StatusCode createAlignObjectsWhichDoNotAlreadyExist()
Create an empty set of AlignableTransforms for the transforms which are not created by XXXXXXX from t...

◆ isOldKey()

bool TRT_AlignDbSvc::isOldKey ( const std::string & input) const
private

Returns the true if the input key is from the old endcap scheme.

Definition at line 1418 of file TRT_AlignDbSvc.cxx.

1418 {
1419
1420 for(unsigned int i=0; i<14; ++i){
1421 std::string testA = "A"+intToString(i);
1422 ATH_MSG_VERBOSE( " The testA is " << testA << " "
1423 << bool(input.find(testA)!=std::string::npos) );
1424 if(input.find(testA)!=std::string::npos){
1425 return true;
1426 }
1427
1428 std::string testC = "C"+intToString(i);
1429 ATH_MSG_VERBOSE( " The testC is " << testC << " "
1430 << bool(input.find(testC)!=std::string::npos) );
1431 if(input.find(testC)!=std::string::npos){
1432 return true;
1433 }
1434
1435 }
1436
1437 return false;
1438}
#define ATH_MSG_VERBOSE(x)
static std::string intToString(int input)
Convert from an int to a string.

◆ prefixtag()

std::string TRT_AlignDbSvc::prefixtag ( const std::string & key)
staticprivate

Return the prefix tag for a given calibration folder.

return the prefix tag for a given calibration folder

given a TRT calibration folder key, return the prefix tag for the associated (Float)ArrayStore or AlignableTransform.

This is used in version tags if big container is NOT used.

Prefixes are TrtDfB0_ Wire shift FloatArrayStore for barrel layer 0. Etc TrtT0B0_ T0 FloatArrayStore for barrel layer 0. Etc TrtRtB0_ R(t) FloatArrayStore for barrel layer 0. Etc TrtAlB0_ AlignableTransform for barrel layer 0. Etc TrtAlId_ AlignableTransform for TRT.

Definition at line 1218 of file TRT_AlignDbSvc.cxx.

1218 {
1231
1232 std::ostringstream result;
1233 std::string detector=key.substr(1,3);
1234
1235 std::string type,quantity;
1236 int ind,ind1;
1237 if(detector=="TRT") {
1238 type=key.substr(5,5);
1239 ind=11;
1240 ind1=11;
1241 quantity=key.substr(ind,2);
1242 } else if(detector=="Indet") {
1243 type=key.substr(7,5);
1244 ind=17;
1245 ind1=13;
1246 quantity="";
1247 if(type=="Align" && key.substr(ind1,2)!="ID") {
1248 if(key.substr(ind1+3,1)=="_") quantity="DF";
1249 }
1250 } else {
1251 return "";
1252 }
1253 if(type=="Calib") {
1254
1255 if(quantity=="DF") {
1256 result << "TrtDf";
1257 } else if (quantity=="RT") {
1258 result << "TrtRt";
1259 } else if (quantity=="T0") {
1260 result << "TrtT0";
1261 } else {
1262 return "TrtDe_";
1263 }
1264 std::string module=key.substr(ind+3,2);
1265 result << module;
1266 } else if(type=="Align") {
1267 std::string module=key.substr(ind1,2);
1268 if(module=="ID" || module=="TR") {
1269 return "TrtAl_";
1270 } else {
1271 result << "TrtAl";
1272 }
1273 module=key.substr(ind+3,2);
1274 result << module;
1275 } else {
1276 return "";
1277 }
1278 result << "_";
1279 return result.str();
1280}

◆ printCondObjects()

void TRT_AlignDbSvc::printCondObjects ( ) const
private

Output the conditions objects currently in memory.

Definition at line 1353 of file TRT_AlignDbSvc.cxx.

1353 {
1354 ATH_MSG_DEBUG( " In printCondObjects " );
1355 ATH_MSG_INFO( " TRT Conditions DB contains " << m_alignobjs.size() <<" AlignableTransforms: " );
1356
1357 const AlignableTransform *pat;
1358 std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
1359 std::vector<std::string>::const_iterator iobjE=m_alignobjs.end();
1360 for (;iobj!=iobjE;++iobj) {
1361 ATH_MSG_INFO( " " << *iobj );
1362 pat=cgetTransPtr(*iobj);
1363 if (pat) {
1364 pat->print2();
1365 } else {
1366 ATH_MSG_ERROR( " Could not find key: " << *iobj );
1367 }
1368 }
1369
1370 ATH_MSG_DEBUG( " Leaving printCondObjects" );
1371 return;
1372}

◆ printTransform()

void TRT_AlignDbSvc::printTransform ( const std::string & thisName,
const Amg::Transform3D & transform )
staticprivate

Output the transform to the cout, for debugging.

Out put the transfor to the cout, for debugging.

Definition at line 1448 of file TRT_AlignDbSvc.cxx.

1448 {
1449 std::cout << thisName << " " << transform(0,3) << " " << transform(1,3) << " " << transform(2,3) << std::endl;
1450 std::cout << thisName << " " << transform(0,0) << " " << transform(0,1) << " " << transform(0,2) << std::endl;
1451 std::cout << thisName << " " << transform(1,0) << " " << transform(1,1) << " " << transform(1,2) << std::endl;
1452 std::cout << thisName << " " << transform(2,1) << " " << transform(2,1) << " " << transform(2,2) << std::endl;
1453 return;
1454}
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ readAlignTextFile()

StatusCode TRT_AlignDbSvc::readAlignTextFile ( const std::string & file)

read AlignableTransforms from text file into TDS

first clean the alignment container: loop over all AlignableTransforms and empty them.

force a call back

Definition at line 350 of file TRT_AlignDbSvc.cxx.

350 {
351 ATH_MSG_DEBUG( " In readAlignTextFile " );
352 ATH_MSG_INFO( "Read alignment constants from text file: " << file );
353 std::ifstream infile;
354 infile.open(file.c_str());
355
359 const AlignableTransformContainer* container= getContainer();
360 if(container) {
361 AlignableTransformContainer* nccontainer = const_cast<AlignableTransformContainer*>(container) ;
362
365 for(;it!=itE;++it)
366 // there is no 'clear' function in alignable transform, so we do it with this hack
367 **it = AlignableTransform( (*it)->tag() ) ;
368 } else {
369 return StatusCode::FAILURE ;
370 }
371
372 // loop over file
373 int nobj=0;
374 int ntrans=0;
375 std::string atname;
376 AlignableTransform* pat(nullptr) ;
377 char line[512] ;
378
379 while( infile.getline(line,512) ) {
380 if(line[0] != '#') {
381
382 std::string linestring(line) ;
383 if( linestring.find('/') != std::string::npos) {
384 // this must be a line with a container name
385 atname = linestring ;
386 ATH_MSG_INFO( "now reading container: " << atname );
387 pat=getTransPtr(atname);
388 if (!pat) {
389 ATH_MSG_ERROR( "Cannot find AlignableTransform object for key " << atname );
390 return StatusCode::FAILURE;
391 } else {
392 nobj++;
393 }
394 } else if(pat!=nullptr) {
395 // this must be a line with constants
396 std::istringstream is(line) ;
397
398 int bec(0),layer(0),sector(0),strawLayer(0);
399 double dx,dy,dz,phi,theta,psi;
400
401 if(atname == (m_alignDBprefix+"L2A") || atname == (m_alignDBprefix+"L2C") ){
402 if( is >> bec >> layer >> strawLayer >> dx >> dy >> dz >> phi ) {
403 CLHEP::Hep3Vector translation(dx, dy, dz);
404 CLHEP::HepRotation rotation;
405 if (is >> theta >> psi) {
406 ATH_MSG_DEBUG ("read a line with euler angles!" << phi
407 << " " << theta << " " << psi);
408 rotation.set(phi, theta, psi);
409 }
410 //We have to give a phi sector, so we'll give 0.
411 Identifier ident=m_trtid->layer_id(bec,0,layer,strawLayer);
412 ATH_MSG_DEBUG( "The identifier is for bec " << bec
413 << " layer " << layer << " strawLayer " << strawLayer );
414 ATH_MSG_DEBUG( "The code is " << m_trtid->show_to_string(ident) );
415 if( pat->findIdent(ident)!=pat->end() ) {
416 ATH_MSG_WARNING ("WARNING: read module from file which was already in AlignableTransform. Will skip it."
417 << " bec,lay,sec,strawlay = " << bec << " " << layer << " " << sector << " " );
418 } else {
419 pat->add(ident,HepGeom::Transform3D(rotation, translation));
420 HepGeom::Transform3D testtrans = HepGeom::Transform3D(rotation, translation);
421 if(msgLvl(MSG::DEBUG)){
422 std::string thisMess = atname+" for "+file;
423 printTransform(thisMess,Amg::CLHEPTransformToEigen(testtrans));
424 }
425
426
427 ++ntrans;
428 ATH_MSG_DEBUG( "Set transform: "
429 << " [" << bec << "," << layer << "," << strawLayer
430 << "] key " << atname
431 << " rotation=(" << phi << "," << theta << "," << psi
432 << "), translation=(" << dx << "," << dy << "," << dz << "])"
433 );
434 }
435 } else if(!linestring.empty()) {
436 ATH_MSG_WARNING( "Read invalid line from textfile. Line=\'" << line << "\'" );
437 }
438 }//if endcap
439 else{
440 if( is >> bec >> layer >> sector >> dx >> dy >> dz >> phi ) {
441 CLHEP::Hep3Vector translation(dx,dy,dz) ;
442 CLHEP::HepRotation rotation;
443 if( is >> theta >> psi ) {
444 ATH_MSG_DEBUG( "read a line with euler angles!" << phi << " " << theta << " " << psi );
445 rotation.set(phi,theta,psi) ;
446
447 } else {
448 ATH_MSG_DEBUG( "read a line with angle in phi!" << phi );
449 rotation = CLHEP::HepRotationZ(phi) ;
450 }
451
452 Identifier ident=m_trtid->module_id(bec,sector,layer);
453 if( pat->findIdent(ident)!=pat->end() ) {
454 ATH_MSG_WARNING ("WARNING: read module from file which was already in AlignableTransform. Will skip it."
455 << " bec,lay,sec = " << bec << " " << layer << " " << sector);
456 } else {
457 pat->add(ident,HepGeom::Transform3D(rotation, translation));
458 ++ntrans ;
459 ATH_MSG_DEBUG( "Set transform: "
460 << " [" << bec << "," << layer << "," << sector
461 << "] key " << atname << " rotation=(" << phi << "," << theta << "," << psi
462 << "), translation=(" << dx << "," << dy << "," << dz << "])" );
463 }
464 } else if(!linestring.empty()) {
465 ATH_MSG_WARNING( "Read invalid line from textfile. Line=\'" << line << "\'" );
466 }
467 }//if not the endcap
468
469
470 }//if pat!=0
471 }//if line != "#"
472 }//while
473
474 infile.close() ;
475 ATH_MSG_INFO( "Read " << nobj << " objects from file with " << ntrans << " transforms."
476 << " Now forcing callback in detector manager." );
477
479 if((const_cast<InDetDD::TRT_DetectorManager*>(m_trtman))->align().isFailure()){
480 ATH_MSG_ERROR("Failed to force the alignment callback!" );
481 }
482
483 ATH_MSG_DEBUG( " Leaving readAlignTextFile " );
484 return StatusCode::SUCCESS;
485}
Scalar phi() const
phi method
Scalar theta() const
theta method
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
Definition DataVector.h:842
AlignableTransform * getTransPtr(const std::string &key) const
get AlignableTransform pointer for an object key
static void printTransform(const std::string &thisName, const Amg::Transform3D &transform)
Output the transform to the cout, for debugging.
TFile * file

◆ registerAlignObjects()

StatusCode TRT_AlignDbSvc::registerAlignObjects ( const std::string & tag,
int run1,
int event1,
int run2,
int event2 ) const

register alignment objects with the IoV service

Definition at line 514 of file TRT_AlignDbSvc.cxx.

514 {
515
516 ATH_MSG_INFO( "registerAlignObjects with IOV " );
517 ATH_MSG_INFO( "Run/evt1 [" << run1 << "," << event1 << "]" );
518 ATH_MSG_INFO( "Run/evt2 [" << run2 << "," << event2 << "]" );
519
520 // get pointer to registration svc
521 SmartIF<IIOVRegistrationSvc> regsvc(service("IOVRegistrationSvc"));
522 ATH_CHECK( regsvc.isValid() );
523
524 if (StatusCode::SUCCESS==regsvc->registerIOV("AlignableTransformContainer",m_alignroot,tag,run1,run2,event1,event2)){
525 ATH_MSG_INFO( " Register AlignableTransformContainer object "
526 << m_alignroot );
527 } else {
528 ATH_MSG_ERROR( " Failed to register AlignableTranformContainer "
529 << m_alignroot );
530 return StatusCode::FAILURE;
531 }
532
533 return StatusCode::SUCCESS;
534}

◆ setAlignTransform()

StatusCode TRT_AlignDbSvc::setAlignTransform ( Identifier ident,
Amg::Transform3D trans,
unsigned int level )

set AlignableTransform for an identifier

Definition at line 674 of file TRT_AlignDbSvc.cxx.

674 {
675 ATH_MSG_DEBUG( "In getAlignmentTransform" );
676
677 if(level != 1 && level != 2 && level != 3){
678 ATH_MSG_FATAL( "Call to setAlignTransform wrong!" );
679 ATH_MSG_FATAL( "Level must be 1,2 or 3!" );
680 return StatusCode::FAILURE;
681 }
682
683 switch (level) {
684
685 case 1:
686 ATH_CHECK( setAlignTransformL1(ident,trans) );
687 break;
688 case 2:
689 ATH_CHECK( setAlignTransformL2(ident,trans) );
690 break;
691 case 3:
692 ATH_CHECK( setAlignTransformL3(ident,trans) );
693 break;
694 }
695
696 return StatusCode::SUCCESS;
697}
#define ATH_MSG_FATAL(x)
StatusCode setAlignTransformL1(Identifier ident, const Amg::Transform3D &trans)
set Level 1 AlignableTransform for an identifier
StatusCode setAlignTransformL3(Identifier ident, Amg::Transform3D trans)
set Level 3 AlignableTransform for an identifier
StatusCode setAlignTransformL2(Identifier ident, Amg::Transform3D trans)
set Level 2 AlignableTransform for an identifier

◆ setAlignTransformL1()

StatusCode TRT_AlignDbSvc::setAlignTransformL1 ( Identifier ident,
const Amg::Transform3D & trans )
private

set Level 1 AlignableTransform for an identifier

AlignableTransform for the subdetector containing ident or add a new one.

Definition at line 700 of file TRT_AlignDbSvc.cxx.

700 {
704 ATH_MSG_DEBUG( "In setAlignTransformL1" );
705 if(msgLvl(MSG::DEBUG)){
706 printTransform("Transform in setAlignTransformL1",trans);
707 }
708
709 // New additions for new global folder structure
710 // No ATs exist for levels 1 & 2 --> need alternative
711 if (m_dynamicDB){
712 if(!tweakGlobalFolder(ident, trans)) {
713 ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
714 return StatusCode::FAILURE;
715 }
716 }
717 else {
718
719 //does a folder exist corresponding to this identifier?
720 AlignableTransform* pat=getTransPtr("/TRT/Align/TRT");
721 if (!pat){
722 ATH_MSG_FATAL( "The AlignableTransform for key " << "/TRT/Align/TRT" << " does not exist " );
723 ATH_MSG_FATAL( "Failing ... " );
724 return StatusCode::FAILURE;
725 }
726
727 // make sure the identifier is a "subdetector identifier"
728 if( !(m_trtid->is_trt(ident)) ){
729 ATH_MSG_FATAL( "The identifier " << ident << " is not from the TRT " );
730 ATH_MSG_FATAL( "Failing ... " );
731 return StatusCode::FAILURE;
732 }
733
734 int bec=m_trtid->barrel_ec(ident);
735 Identifier mid=m_trtid->module_id(bec,0,0);
736 // update or add (mid,trans) pair
737 HepGeom::Transform3D clhepTrans = Amg::EigenTransformToCLHEP(trans);
738 if( !(pat->update(mid,clhepTrans)) ) {
739 pat->add(mid,clhepTrans);
740 pat->sortv() ;
741 }
742 }
743
744 ATH_MSG_DEBUG( "Leaving setAlignTransformL1" );
745 return StatusCode::SUCCESS;
746}
StatusCode tweakGlobalFolder(Identifier ident, const Amg::Transform3D &trans)
tweak L1 DB for global folders for an identifier
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.

◆ setAlignTransformL2()

StatusCode TRT_AlignDbSvc::setAlignTransformL2 ( Identifier ident,
Amg::Transform3D trans )
private

set Level 2 AlignableTransform for an identifier

AlignableTransform for the module containing ident or add a new one.

Definition at line 749 of file TRT_AlignDbSvc.cxx.

749 {
750 ATH_MSG_DEBUG( "In setAlignTransformL2" );
754
755 //does a folder exist corresponding to this identifier?
756 std::string key=findkey(ident,m_alignString);
757 AlignableTransform* pat=getTransPtr(key);
758 if (!pat) return StatusCode::FAILURE;
759
760 // make sure the identifier is a "module identifier"
761 if( !(m_trtid->is_trt(ident)) ) return StatusCode::FAILURE;
762 int bec=m_trtid->barrel_ec(ident);
763 int layer=m_trtid->layer_or_wheel(ident);
764 int sector=m_trtid->phi_module(ident);
765 int strawLayer=m_trtid->straw_layer(ident);
766 int ring = getRingForStrawLayer(strawLayer);
767 Identifier ident2;
768
769 ATH_MSG_DEBUG( "Setting the L2 Alignment for: "
770 << " Bec= " << bec << " layer= " << layer << " sector= " << sector
771 << " strawLayer= " << strawLayer );
772 ATH_MSG_DEBUG( "The translations are: x= " << trans(0,3) << " y= "<<trans(1,3) << " z= "<<trans(2,3) );
773
774 if(key == (m_alignDBprefix+"L2A") || key == (m_alignDBprefix+"L2C"))
775 ident2=m_trtid->layer_id(bec,0,layer,ring);
776 else
777 ident2=m_trtid->module_id(bec,sector,layer);
778
779 // make sure the identifier is a TRT identifier
780 if( !(m_trtid->is_trt(ident2)) ){
781 ATH_MSG_FATAL( "The identifier " << ident2 << " is not from the TRT " );
782 ATH_MSG_FATAL( "Failing ... " );
783 return StatusCode::FAILURE;
784 }
785
786 // update or add (mid,trans) pair
787 HepGeom::Transform3D clhepTrans = Amg::EigenTransformToCLHEP(trans);
788 if( !(pat->update(ident2,clhepTrans)) ) {
789 pat->add(ident2,clhepTrans);
790 pat->sortv() ;
791 }
792
793 ATH_MSG_DEBUG( "Leaving setAlignTransformL2 " );
794 return StatusCode::SUCCESS;
795}

◆ setAlignTransformL3()

StatusCode TRT_AlignDbSvc::setAlignTransformL3 ( Identifier ident,
Amg::Transform3D trans )
private

set Level 3 AlignableTransform for an identifier

Definition at line 798 of file TRT_AlignDbSvc.cxx.

798 {
799 ATH_MSG_DEBUG( "In setAlignTransformL3" );
800
801 // make sure the identifier is a "module identifier"
802 if( !(m_trtid->is_trt(ident)) ) return StatusCode::FAILURE;
803 int bec=m_trtid->barrel_ec(ident);
804
805 //Only L3 in the barrel is currently supported
806 if(abs(bec) == 1){
807
808 // Currently at L3 only displacements in the plane of the straw layer can be stored.
809 // For tracks coming from the interaction point this coorisponds to the sensitive coordinate
810 ATH_MSG_INFO("Storing L3 Barrel constants, Only dx and rotz will be written to DB");
811 float dx = trans.translation().x();
812 float rotz = std::atan2(trans.rotation()(0,1),trans.rotation()(0,0));
813
814 // Need the length of the wires to translate the rotation to a translation.
815 const InDetDD::TRT_BaseElement* strawElement = m_trtman->getElement( ident );
816 double strawLenthOver2 = 0.5* strawElement->strawLength();
817
818 // The alignment frames are the same for straws on side A and side C (verrify this!!)
819 // but variables stored in the db are not. We'll calculate the dispacement of each end
820 // in the alignment frame and in a second step, convert to the values in the DB.
821 double delta_dx_atLargerZ = dx + strawLenthOver2 * std::sin(rotz);
822 double delta_dx_atSmallerZ = dx - strawLenthOver2 * std::sin(rotz);
823
824 // For the definition of dx1 and dx2 see TRT_ConditionsData/StrawDx.h
825 // Now we need to know the real meaning of dx1 and dx2. Alas, we
826 // are in the frame of either of the two barrel sides, but not
827 // both, so we need to know which one.
828 bool sideA = m_trtid->barrel_ec(ident) == 1;
829
830 // Straw position closest to the electronics
831 double dx1_new = sideA ? delta_dx_atLargerZ : delta_dx_atSmallerZ;
832
833 // Straw position away from the electronics
834 double dx2_new = sideA ? delta_dx_atSmallerZ : delta_dx_atLargerZ;
835
836 // Uncertianty on straw positions (Arbitrary for now)
837 double dxErr = 0.001;
838
839 m_trtStrawAlignDbSvc->setDx(ident, dx1_new, dx2_new, dxErr);
840 }else{
841 // Currently at L3 only displacements in the plane of the straw layer can be stored.
842 // For tracks coming from the interaction point this coorisponds to the sensitive coordinate
843 ATH_MSG_INFO("Storing L3 Endcap constants, Only dy and rotz will be written to DB");
844
845 // The expected transformation is in the local frame of the Endcap Straws
846 // In the local straw frame:
847 // - the z-axis is along the straw and points toward the beampipe
848 // - the x-axis is along global-z and away from the interaction point
849 // (locX = globZ A-side / locX = -1 *gobZ C-side)
850 // - the y-axis is along global phi_hat direction determined by the other 2.
851 // (clockwise C-side, counter clockwise A-Side)
852 float dy = trans.translation().y();
853 float rotx = std::atan2(trans.rotation()(1,2),trans.rotation()(2,2));
854
855 // Need the length of the wires to translate the rotation to a translation.
856 const InDetDD::TRT_BaseElement* strawElement = m_trtman->getElement( ident );
857 double strawLenthOver2 = 0.5* strawElement->strawLength();
858
859 // In the global frame, 'dx1' corresponds to the readout side and 'dx2'
860 // to the side closest the beampipe.
861 double delta_dx_nearBeamPipe = dy + strawLenthOver2 * std::sin(rotx);
862 double delta_dx_nearReadOut = dy - strawLenthOver2 * std::sin(rotx);
863
864 // Uncertianty on straw positions (Arbitrary for now)
865 double dxErr = 0.001;
866
867 m_trtStrawAlignDbSvc->setDx(ident, delta_dx_nearReadOut, delta_dx_nearBeamPipe, dxErr);
868 }
869
870 ATH_MSG_DEBUG( "Leaving setAlignTransformL3 " );
871 return StatusCode::SUCCESS;
872}
virtual const double & strawLength() const =0
Active straw length.
unsigned int constexpr sideA
Definition RPDUtils.h:16

◆ streamOutAlignObjects()

StatusCode TRT_AlignDbSvc::streamOutAlignObjects ( ) const

write the alignment objects to output

Definition at line 488 of file TRT_AlignDbSvc.cxx.

488 {
489 ATH_MSG_DEBUG( "In streamOutAlignObjects " );
490
491 // Get Output Stream tool for writing
492 ATH_CHECK( m_streamer.retrieve() );
493
494 IAthenaOutputStreamTool* streamer=const_cast<IAthenaOutputStreamTool*>(&(*m_streamer));
495
496 ATH_CHECK( streamer->connectOutput() );
497
499 IAthenaOutputStreamTool::TypeKeyPair arraypair("AlignableTransformContainer",m_alignroot);
500 typeKeys.push_back(arraypair);
502
503 ATH_CHECK( streamer->streamObjects(typeKeys) );
504 ATH_CHECK( streamer->commitOutput() );
505
506 ATH_MSG_INFO( " Streamed out and committed AlignableTransformContainer" );
508
509 ATH_MSG_DEBUG( "Leaving streamOutAlignObjects " );
510 return StatusCode::SUCCESS;
511}
virtual StatusCode streamObjects(const TypeKeyPairs &typeKeys, const std::string &outputName="")=0
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
virtual StatusCode connectOutput(const std::string &outputName="")=0
Connect to the output stream Must connectOutput BEFORE streaming Only specify "outputName" if one wan...
std::vector< TypeKeyPair > TypeKeyPairs
virtual StatusCode commitOutput(bool doCommit=false)=0
Commit the output stream after having streamed out objects Must commitOutput AFTER streaming.

◆ tweakAlignTransform()

StatusCode TRT_AlignDbSvc::tweakAlignTransform ( Identifier ident,
Amg::Transform3D trans,
unsigned int level )

tweak AlignableTransform for an identifier

Definition at line 875 of file TRT_AlignDbSvc.cxx.

875 {
876
877 ATH_MSG_DEBUG( "In tweakAlignTransform" );
878
879 if(level != 1 && level != 2 && level != 3){
880 ATH_MSG_FATAL( "Incorrect call to tweakTrans" );
881 ATH_MSG_FATAL( "level must be 1,2 or 3" );
882 return StatusCode::FAILURE;
883 }
884
885 if(level == 1){
886 if(tweakAlignTransformL1(ident,trans).isFailure()){
887
888 ATH_MSG_WARNING( "tweak failed...just setting it." );
889
890 if(setAlignTransformL1(ident,trans).isFailure()){
891 ATH_MSG_FATAL( "Set also failed!" );
892 ATH_MSG_FATAL( "Fail for real." );
893 return StatusCode::FAILURE;
894 }
895 }
896 }
897
898 else if(level == 2){
899 if(tweakAlignTransformL2(ident,trans).isFailure()){
900
901 ATH_MSG_WARNING( "tweak failed...just setting it." );
902
903 if(setAlignTransformL2(ident,trans).isFailure()){
904 ATH_MSG_FATAL( "Set also failed!" );
905 ATH_MSG_FATAL( "Fail for real." );
906 return StatusCode::FAILURE;
907 }
908 }
909 }
910
911 else if(level == 3){
912 if(tweakAlignTransformL3(ident,trans).isFailure()){
913
914 ATH_MSG_WARNING( "tweak failed...just setting it." );
915
916 if(setAlignTransformL3(ident,trans).isFailure()){
917 ATH_MSG_FATAL( "Set also failed!" );
918 ATH_MSG_FATAL( "Fail for real." );
919 return StatusCode::FAILURE;
920 }
921 }
922 }
923
924 ATH_MSG_DEBUG( "Leaving tweakAlignTransform" );
925 return StatusCode::SUCCESS;
926}
StatusCode tweakAlignTransformL1(Identifier ident, const Amg::Transform3D &trans)
tweak Level 1 AlignableTransform for an identifier
StatusCode tweakAlignTransformL3(Identifier ident, Amg::Transform3D trans)
tweak Level 3 AlignableTransform for an identifier
StatusCode tweakAlignTransformL2(Identifier ident, const Amg::Transform3D &trans)
tweak Level 2 AlignableTransform for an identifier

◆ tweakAlignTransformL1()

StatusCode TRT_AlignDbSvc::tweakAlignTransformL1 ( Identifier ident,
const Amg::Transform3D & trans )
private

tweak Level 1 AlignableTransform for an identifier

multiply level 1 AlignableTransform for the module containing ident by an additional transform.

does a folder exist corresponding to this identifier?

OK the key exists make sure the identifier is a "subdetector identifier"

multiply the additional transformation

Definition at line 929 of file TRT_AlignDbSvc.cxx.

929 {
933 ATH_MSG_DEBUG( "In tweakAlignTransformL1" );
934
935 // New additions for new global folder structure
936 // No ATs exist for levels 1 & 2 --> need alternative
937 if (m_dynamicDB){
938 if(!tweakGlobalFolder(ident, trans)) {
939 ATH_MSG_ERROR( "Attempt tweak GlobalDB folder failed" );
940 return StatusCode::FAILURE;
941 }
942 }
943 else {
944
946 AlignableTransform* pat=getTransPtr("/TRT/Align/TRT");
947 if (!pat){
948 ATH_MSG_WARNING( "The AlignableTransform for key " << "/TRT/Align/TRT" << " does not exist " );
949 ATH_MSG_WARNING( "Failing ... " );
950 return StatusCode::FAILURE;
951 }
952
956 if( !(m_trtid->is_trt(ident)) ){
957 ATH_MSG_WARNING( "The identifier " << ident << " is not from the TRT " );
958 ATH_MSG_WARNING( "Failing ... " );
959 return StatusCode::FAILURE;
960 }
961
962 int bec=m_trtid->barrel_ec(ident);
963 Identifier mid=m_trtid->module_id(bec,0,0);
964
966 if( !(pat->tweak(mid,Amg::EigenTransformToCLHEP(trans))) ){
967 ATH_MSG_WARNING( "The Alignable transfor tweek failed for " << mid );
968 ATH_MSG_WARNING( "Failing ... " );
969 return StatusCode::FAILURE;
970 }
971 }
972
973 ATH_MSG_DEBUG( "Leaving tweakAlignTransformL1" );
974 return StatusCode::SUCCESS;
975}

◆ tweakAlignTransformL2()

StatusCode TRT_AlignDbSvc::tweakAlignTransformL2 ( Identifier ident,
const Amg::Transform3D & trans )
private

tweak Level 2 AlignableTransform for an identifier

Definition at line 978 of file TRT_AlignDbSvc.cxx.

978 {
979 ATH_MSG_DEBUG( "In tweakAlignTransformL2" );
980 // multiply level 2 AlignableTransform for the module containing ident
981 // by an additional transform.
982
983 //does a folder exist corresponding to this identifier?
984 std::string key=findkey(ident,m_alignString);
985 AlignableTransform* pat=getTransPtr(key);
986 if (!pat){
987 ATH_MSG_WARNING( "The transfor for key: " << key << "Does not exist" );
988 ATH_MSG_WARNING( " Failing ... " );
989 return StatusCode::FAILURE;
990 }
991
992 //OK the key exists
993 // make sure the identifier is a "module identifier"
994 if( !(m_trtid->is_trt(ident)) ) return StatusCode::FAILURE;
995 int bec=m_trtid->barrel_ec(ident);
996 int layer=m_trtid->layer_or_wheel(ident);
997 int sector=m_trtid->phi_module(ident);
998 int strawLayer=m_trtid->straw_layer(ident);
999 int ring = getRingForStrawLayer(strawLayer);
1000 Identifier mid;
1001 if(key == (m_alignDBprefix+"L2A") || key == (m_alignDBprefix+"L2C"))
1002 mid = m_trtid->layer_id(bec,0,layer,ring);
1003 else
1004 mid = m_trtid->module_id(bec,sector,layer);
1005
1006 // multiply the additional transformation
1007 if( !(pat->tweak(mid,Amg::EigenTransformToCLHEP(trans))) ){
1008 ATH_MSG_WARNING( "Leaving tweakAlignTransformL2. TWEAK FAILED!!" );
1009 return StatusCode::FAILURE;
1010 }
1011
1012 ATH_MSG_DEBUG( "Leaving tweakAlignTransformL2" );
1013 return StatusCode::SUCCESS;
1014}

◆ tweakAlignTransformL3()

StatusCode TRT_AlignDbSvc::tweakAlignTransformL3 ( Identifier ident,
Amg::Transform3D trans )
private

tweak Level 3 AlignableTransform for an identifier

Definition at line 1017 of file TRT_AlignDbSvc.cxx.

1017 {
1018 ATH_MSG_DEBUG( "In tweakAlignTransformL3" );
1019
1020 // make sure the identifier is a "module identifier"
1021 if( !(m_trtid->is_trt(ident)) ) return StatusCode::FAILURE;
1022 int bec=m_trtid->barrel_ec(ident);
1023
1024 //Only L3 in the barrel is currently supported
1025 if(abs(bec) == 1){
1026
1027 // Currently at L3 only displacements in the plane of the straw layer can be stored.
1028 // For tracks coming from the interaction point this coorisponds to the sensitive coordinate
1029 ATH_MSG_INFO("Storing L3 constants, Only dx and rotz will be written to DB");
1030 float dx = trans.translation().x();
1031
1032 ATH_MSG_DEBUG("xx: " << trans.rotation()(0,0));
1033 ATH_MSG_DEBUG("xy: " << trans.rotation()(0,1));
1034 ATH_MSG_DEBUG("xz: " << trans.rotation()(0,2));
1035 ATH_MSG_DEBUG("yx: " << trans.rotation()(1,0));
1036 ATH_MSG_DEBUG("yy: " << trans.rotation()(1,1));
1037 ATH_MSG_DEBUG("yz: " << trans.rotation()(1,2));
1038 ATH_MSG_DEBUG("zx: " << trans.rotation()(2,0));
1039 ATH_MSG_DEBUG("zy: " << trans.rotation()(2,1));
1040 ATH_MSG_DEBUG("zz: " << trans.rotation()(2,2));
1041
1042 // For the definition of dx1 and dx2 see TRT_ConditionsData/StrawDx.h
1043 // Now we need to know the real meaning of dx1 and dx2. Alas, we
1044 // are in the frame of either of the two barrel sides, but not
1045 // both, so we need to know which one.
1046 bool sideA = m_trtid->barrel_ec(ident) == 1;
1047
1048 float rotz = std::atan2(trans.rotation()(0,2),trans.rotation()(0,0));
1049
1050 // Need the length of the wires to translate the rotation to a translation.
1051 const InDetDD::TRT_BaseElement* strawElement = m_trtman->getElement( ident );
1052 double strawLenthOver2 = 0.5* strawElement->strawLength();
1053
1054 // Old way (buggy)
1055 //double delta_dx_atLargerZ = dx + strawLenthOver2 * std::sin(rotz);
1056 //double delta_dx_atSmallerZ = dx - strawLenthOver2 * std::sin(rotz);
1057
1058 // New way - The rotation is opposite for side A as compared to side C
1059 double delta_dx_atLargerZ;
1060 double delta_dx_atSmallerZ;
1061 if (sideA){
1062 delta_dx_atLargerZ = dx - strawLenthOver2 * std::sin(rotz);
1063 delta_dx_atSmallerZ = dx + strawLenthOver2 * std::sin(rotz);
1064 }
1065 else{
1066 delta_dx_atLargerZ = dx + strawLenthOver2 * std::sin(rotz);
1067 delta_dx_atSmallerZ = dx - strawLenthOver2 * std::sin(rotz);
1068 }
1069
1070 // Straw position closest to the electronics
1071 double delta_dx1 = sideA ? delta_dx_atLargerZ : delta_dx_atSmallerZ;
1072
1073 // Straw position away from the electronics
1074 double delta_dx2 = sideA ? delta_dx_atSmallerZ : delta_dx_atLargerZ;
1075
1076 // Uncertianty on straw positions
1077 double dxErr = 0.001;
1078
1079 // now we do some gymnastics: because the strawdisplacement is
1080 // binned, we would rather not just 'add' the current change,
1081 // but rather 'set' the total change. note that this goes
1082 // wrong if there were other straw corrections
1083 // applied. We might have to worry about that at
1084 // some point.
1085 double dx1_current = m_trtStrawAlignDbSvc->getDx1(ident);
1086 double dx2_current = m_trtStrawAlignDbSvc->getDx2(ident) ;
1087 ATH_MSG_DEBUG("Current dx1 is: " << dx1_current);
1088 ATH_MSG_DEBUG("Current dx2 is: " << dx2_current);
1089
1090 double dx1_new = dx1_current + delta_dx1;
1091 double dx2_new = dx2_current + delta_dx2;
1092
1093 //ATH_MSG_INFO("New dx1 is: " << dx1_new);
1094 //ATH_MSG_INFO("New dx2 is: " << dx2_new);
1095
1096 m_trtStrawAlignDbSvc->setDx(ident, dx1_new, dx2_new, dxErr);
1097 }else{
1098
1099 // Currently at L3 only displacements in the plane of the straw layer can be stored.
1100 // For tracks coming from the interaction point this coorisponds to the sensitive coordinate
1101 ATH_MSG_INFO("Storing L3 Endcap constants, Only dy and rotz will be written to DB");
1102
1103 // The expected transformation is in the local frame of the Endcap Straws
1104 // In the local straw frame:
1105 // - the z-axis is along the straw and points toward the beampipe
1106 // - the x-axis is along global-z and away from the interaction point
1107 // (locX = globZ A-side / locX = -1 *gobZ C-side)
1108 // - the y-axis is along global phi_hat direction determined by the other 2.
1109 // (clockwise C-side, counter clockwise A-Side)
1110 float dy = trans.translation().y();
1111 float rotx = std::atan2(trans.rotation()(1,2),trans.rotation()(2,2));
1112
1113 // Need the length of the wires to translate the rotation to a translation.
1114 const InDetDD::TRT_BaseElement* strawElement = m_trtman->getElement( ident );
1115 double strawLenthOver2 = 0.5* strawElement->strawLength();
1116
1117 // In the global frame, 'dx1' corresponds to the readout side and 'dx2'
1118 // to the side closest the beampipe.
1119 double delta_dx_nearBeamPipe = dy + strawLenthOver2 * std::sin(rotx);
1120 double delta_dx_nearReadOut = dy - strawLenthOver2 * std::sin(rotx);
1121
1122 // Uncertianty on straw positions
1123 double dxErr = 0.001;
1124
1125 // now we do some gymnastics: because the strawdisplacement is
1126 // binned, we would rather not just 'add' the current change,
1127 // but rather 'set' the total change. note that this goes
1128 // wrong if there were other straw corrections
1129 // applied. We might have to worry about that at
1130 // some point.
1131 double dx1_current = m_trtStrawAlignDbSvc->getDx1(ident);
1132 double dx2_current = m_trtStrawAlignDbSvc->getDx2(ident) ;
1133 ATH_MSG_DEBUG("Current dx1 is: " << dx1_current);
1134 ATH_MSG_DEBUG("Current dx2 is: " << dx2_current);
1135
1136 double dx1_new = dx1_current + delta_dx_nearReadOut;
1137 double dx2_new = dx2_current + delta_dx_nearBeamPipe;
1138
1139 m_trtStrawAlignDbSvc->setDx(ident, dx1_new, dx2_new, dxErr);
1140 }
1141
1142 ATH_MSG_DEBUG( "Leaving tweakAlignTransformL3 " );
1143 return StatusCode::SUCCESS;
1144}

◆ tweakGlobalFolder()

StatusCode TRT_AlignDbSvc::tweakGlobalFolder ( Identifier ident,
const Amg::Transform3D & trans )

tweak L1 DB for global folders for an identifier

Definition at line 1506 of file TRT_AlignDbSvc.cxx.

1506 {
1507
1508 // find transform key, then set appropriate transform
1509 const CondAttrListCollection* atrlistcol1=nullptr;
1510 CondAttrListCollection* atrlistcol2=nullptr;
1511 bool result = false;
1512 std::string key="/TRT/AlignL1/TRT";
1513 ATH_MSG_DEBUG( " Identifier is valid: "<< ident.is_valid() );
1514 int bec=m_trtid->barrel_ec(ident);
1515 const unsigned int DBident=1000+bec*100;
1516 // so far not a very fancy DB identifier, but seems elaborate enough for this simple structure
1517
1518 if (StatusCode::SUCCESS==m_detStore->retrieve(atrlistcol1,key)) {
1519 // loop over objects in collection
1520 atrlistcol2 = const_cast<CondAttrListCollection*>(atrlistcol1);
1521 if (atrlistcol1!=nullptr){
1522 for (CondAttrListCollection::const_iterator citr=atrlistcol2->begin(); citr!=atrlistcol2->end();++citr) {
1523
1524 const coral::AttributeList& atrlist=citr->second;
1525 coral::AttributeList& atrlist2 = const_cast<coral::AttributeList&>(atrlist);
1526
1527 if(citr->first!=DBident){
1528 ATH_MSG_DEBUG( "tweakGlobalFolder fails due to identifier mismatch" );
1529 continue;
1530 }
1531 else {
1532 ATH_MSG_DEBUG( "Tweak Old global DB -- channel: " << citr->first
1533 << " ,bec: " << atrlist2["bec"].data<int>()
1534 << " ,layer: " << atrlist2["layer"].data<int>()
1535 << " ,sector: " << atrlist2["sector"].data<int>()
1536 << " ,Tx: " << atrlist2["Tx"].data<float>()
1537 << " ,Ty: " << atrlist2["Ty"].data<float>()
1538 << " ,Tz: " << atrlist2["Tz"].data<float>()
1539 << " ,phi: " << atrlist2["phi"].data<float>()
1540 << " ,theta: " << atrlist2["theta"].data<float>()
1541 << " ,psi: " << atrlist2["psi"].data<float>() );
1542
1543
1544 // Follow same definitions as in TRT_AlignDbSvc.cxx
1545 CLHEP::Hep3Vector oldtranslation(atrlist2["Tx"].data<float>(),atrlist2["Ty"].data<float>(),atrlist2["Tz"].data<float>());
1546 CLHEP::HepRotation oldrotation;
1547 oldrotation.set(atrlist["phi"].data<float>(),atrlist["theta"].data<float>(),atrlist["psi"].data<float>());
1548 HepGeom::Transform3D oldtransform(oldrotation, oldtranslation);
1549
1550 // get the new transform
1551 HepGeom::Transform3D newtrans = Amg::EigenTransformToCLHEP(trans)*oldtransform;
1552 Amg::Transform3D newtransAMG = trans*Amg::CLHEPTransformToEigen(oldtransform);
1553
1554 // Extract the values we need to write to DB
1555 Amg::Vector3D shift=newtransAMG.translation();
1556 CLHEP::HepRotation rot=newtrans.getRotation();
1557 Amg::Vector3D eulerangles;
1558 eulerangles[0] = rot.getPhi();
1559 eulerangles[1] = rot.getTheta();
1560 eulerangles[2] = rot.getPsi();
1561
1562 atrlist2["Tx"].data<float>() = shift.x();
1563 atrlist2["Ty"].data<float>() = shift.y();
1564 atrlist2["Tz"].data<float>() = shift.z();
1565 atrlist2["phi"].data<float>() = eulerangles[0] ;
1566 atrlist2["theta"].data<float>() = eulerangles[1] ;
1567 atrlist2["psi"].data<float>() = eulerangles[2] ;
1568
1569 result = true;
1570 ATH_MSG_DEBUG( "Tweak New global DB -- channel: " << citr->first
1571 << " ,bec: " << atrlist2["bec"].data<int>()
1572 << " ,layer: " << atrlist2["layer"].data<int>()
1573 << " ,sector: " << atrlist2["sector"].data<int>()
1574 << " ,Tx: " << atrlist2["Tx"].data<float>()
1575 << " ,Ty: " << atrlist2["Ty"].data<float>()
1576 << " ,Tz: " << atrlist2["Tz"].data<float>()
1577 << " ,phi: " << atrlist2["phi"].data<float>()
1578 << " ,theta: " << atrlist2["theta"].data<float>()
1579 << " ,psi: " << atrlist2["psi"].data<float>() );
1580
1581 }
1582 }
1583 }
1584 else {
1585 ATH_MSG_ERROR("tweakGlobalFolder: cast fails for DBident " << DBident );
1586 return StatusCode::FAILURE;
1587 }
1588 }
1589 else {
1590 ATH_MSG_ERROR("tweakGlobalFolder: cannot retrieve CondAttrListCollection for key " << key );
1591 return StatusCode::FAILURE;
1592 }
1593
1594 if (result) return StatusCode::SUCCESS;
1595 else return StatusCode::FAILURE;
1596}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
Eigen::Matrix< double, 3, 1 > Vector3D

◆ writeAlignTextFile()

StatusCode TRT_AlignDbSvc::writeAlignTextFile ( const std::string & file) const

write AlignableTransforms to flat text file

Loop over created AlignableTransforms

Only write out new keys unless explicitly ask for old keys

The object must exist in detector store

Keep track of total number of transforms

get the relavent identifing info

Get the translation and rotation

Definition at line 216 of file TRT_AlignDbSvc.cxx.

217{
218 ATH_MSG_DEBUG(" in writeAlignTextFile ");
219 ATH_MSG_INFO( " Write AlignableTransforms to text file: "<< file );
220 std::ofstream outfile(file);
221
222 int ntrans=0;
223 int nobj=0;
224
226 std::vector<std::string>::const_iterator iobj=m_alignobjs.begin();
227 std::vector<std::string>::const_iterator iobjE=m_alignobjs.end();
228 for (;iobj!=iobjE; ++iobj) {
229 const AlignableTransform* pat=cgetTransPtr(*iobj);
230 std::string key=*iobj;
231
233 if(isOldKey(key) && m_alignString != "ALold")
234 continue;
235
237 if (!pat){
238 ATH_MSG_ERROR( "Cannot find AlignableTransform for key "<< key );
239 ATH_MSG_ERROR( "Skipping it. " );
240 outfile << key << std::endl;
241 continue;
242 }
243
244 // first record is the name
245 ATH_MSG_INFO( " Write folder: " << key );
246 outfile << key << std::endl;
247 ++nobj;
248
249 // loop over all transforms in the AlignableTransform object
252 for (;cit!=citE;++cit) {
253
254 int bec(0);
255 int layer(0);
256 int sector(0);
257 int strawLayer(0);
258
260 ++ntrans;
261
263 const Identifier& ident=cit->identify();
264 bec=m_trtid->barrel_ec(ident);
265 layer=m_trtid->layer_or_wheel(ident);
266 sector=m_trtid->phi_module(ident);
267 strawLayer=m_trtid->straw_layer(ident);
268
270 const Amg::Transform3D& trans = Amg::CLHEPTransformToEigen(cit->transform());
271
272 if(msgLvl(MSG::DEBUG)){
273 std::string thisMess = key+" for "+file;
274 printTransform(thisMess,trans);
275 }
276
277
278 HepGeom::Transform3D transCLHEP = Amg::EigenTransformToCLHEP(trans);
279 CLHEP::HepRotation rot=transCLHEP.getRotation();
280 Amg::Vector3D eulerangles;
281 eulerangles[0] = rot.getPhi();
282 eulerangles[1] = rot.getTheta();
283 eulerangles[2] = rot.getPsi();
284
285 Amg::Vector3D shift=trans.translation();
286 //Matthias: was initially 2,1,2 --> this should be equivalent to complicated method above
287 //Amg::Vector3D eulerangles = trans.rotation().eulerAngles(2,0,2) ;
288
289 if(key == (m_alignDBprefix+"L2A") || key == (m_alignDBprefix+"L2C") ){
290
291 ATH_MSG_INFO( " Write member: "
292 << ident << " " << bec << " " << layer << " " << strawLayer << " " << key );
293
294 outfile << bec << " " << layer << " " << strawLayer << " "
295 << std::setprecision(10) << " "
296 << shift.x() << " " << shift.y() << " " << shift.z() << " "
297 << eulerangles[0] << " " << eulerangles[1] << " " << eulerangles[2]
298 << std::endl;
299
300 ATH_MSG_DEBUG( "Writing transform to log file " );
301 ATH_MSG_DEBUG( bec << " " << layer << " " << strawLayer << " "
302 << std::setprecision(10) << " "
303 << shift.x() << " " << shift.y() << " " << shift.z() << " "
304 << eulerangles[0] << " " << eulerangles[1] << " " << eulerangles[2]
305 );
306
307 }else{
308 //Need to validate this for writing out L1 Endcap alignments
309 ATH_MSG_INFO( " Write member: "
310 << ident << " " << bec << " " << layer << " " << sector << " " << key );
311
312 outfile << bec << " " << layer << " " << sector << " "
313 << std::setprecision(10) << " "
314 << shift.x() << " " << shift.y() << " " << shift.z() << " "
315 << eulerangles[0] << " " << eulerangles[1] << " " << eulerangles[2]
316 << std::endl;
317
318 ATH_MSG_DEBUG( "Writing transform to log file " );
319 ATH_MSG_DEBUG( bec << " " << layer << " " << sector << " "
320 << std::setprecision(10) << " "
321 << shift.x() << " " << shift.y() << " " << shift.z() << " "
322 << eulerangles[0] << " " << eulerangles[1] << " " << eulerangles[2]
323 );
324 }
325
326 }
327 }
328
329 outfile.close();
330
331 ATH_MSG_INFO( "Written " << nobj << " AlignableTransform objects" << " with " << ntrans
332 << " transforms to text file" );
333
334 ATH_MSG_DEBUG( " leaving writeAlignTextFile " );
335 return StatusCode::SUCCESS;
336}

◆ writeGlobalFolderFile()

StatusCode TRT_AlignDbSvc::writeGlobalFolderFile ( const std::string & file) const

Definition at line 1457 of file TRT_AlignDbSvc.cxx.

1458 {
1459
1460 if (m_dynamicDB){
1461 ATH_MSG_DEBUG( "writeFile: Write GlobalFolder DB in text file: " << file );
1462 std::ofstream outfile(file);
1463 std::vector<std::string> folder_list = {"/TRT/AlignL1/TRT"};
1464
1465 for (std::vector<std::string>::iterator it = folder_list.begin(); it != folder_list.end(); ++it){
1466
1467 outfile << *it << std::endl;
1468 const CondAttrListCollection* atrlistcol=nullptr;
1469 if (StatusCode::SUCCESS==m_detStore->retrieve(atrlistcol,*it)) {
1470 // loop over objects in collection
1471 for (CondAttrListCollection::const_iterator citr=atrlistcol->begin(); citr!=atrlistcol->end();++citr) {
1472
1473 const coral::AttributeList& atrlist=citr->second;
1474 outfile << atrlist["bec"].data<int>()
1475 << " " << atrlist["layer"].data<int>()
1476 << " " << atrlist["sector"].data<int>()
1477 << " " << atrlist["Tx"].data<float>()
1478 << " " << atrlist["Ty"].data<float>()
1479 << " " << atrlist["Tz"].data<float>()
1480 << " " << atrlist["phi"].data<float>()
1481 << " " << atrlist["theta"].data<float>()
1482 << " " << atrlist["psi"].data<float>() << std::endl;
1483 }
1484 }
1485 else {
1486 if (msgLvl(MSG::INFO)){
1487 ATH_MSG_INFO( "Cannot find " << *it << " Container - cannot write DB in text file " );
1488 return StatusCode::FAILURE;
1489 }
1490 }
1491 }
1492
1493 return StatusCode::SUCCESS;
1494 }
1495 else {
1496 ATH_MSG_DEBUG( "writeFile: No dynamic Run2 DB structure is present --> skipping writing file " << file );
1497 return StatusCode::SUCCESS;
1498 }
1499}

◆ writeStrawAlignTextFile()

StatusCode TRT_AlignDbSvc::writeStrawAlignTextFile ( const std::string & file) const

Definition at line 338 of file TRT_AlignDbSvc.cxx.

339{
340 ATH_MSG_DEBUG( " in writeAlignTextFile " );
341
342 ATH_MSG_INFO( "Writing the straw alignments " );
343 if( m_trtStrawAlignDbSvc -> writeTextFile(file) != StatusCode::SUCCESS )
344 ATH_MSG_ERROR("Cannot write to file "<< file );
345
346 return StatusCode::SUCCESS;
347}

Member Data Documentation

◆ m_alignchans

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

channels

Definition at line 166 of file TRT_AlignDbSvc.h.

◆ m_aligncontainerhandle

const DataHandle<AlignableTransformContainer> TRT_AlignDbSvc::m_aligncontainerhandle
private

Definition at line 167 of file TRT_AlignDbSvc.h.

◆ m_alignDBprefix

std::string TRT_AlignDbSvc::m_alignDBprefix
private

Definition at line 171 of file TRT_AlignDbSvc.h.

◆ m_alignobjs

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

folder names

Definition at line 165 of file TRT_AlignDbSvc.h.

◆ m_alignroot

std::string TRT_AlignDbSvc::m_alignroot
private

root alignment folder

Definition at line 162 of file TRT_AlignDbSvc.h.

◆ m_alignString

std::string TRT_AlignDbSvc::m_alignString
private

alignment string searched for

Definition at line 163 of file TRT_AlignDbSvc.h.

◆ m_amgTransformCache

std::vector<Amg::Transform3D*> TRT_AlignDbSvc::m_amgTransformCache
mutableprivate

Definition at line 169 of file TRT_AlignDbSvc.h.

◆ m_detStore

ServiceHandle<StoreGateSvc> TRT_AlignDbSvc::m_detStore
private

Definition at line 158 of file TRT_AlignDbSvc.h.

◆ m_dynamicDB

bool TRT_AlignDbSvc::m_dynamicDB
private

Definition at line 173 of file TRT_AlignDbSvc.h.

◆ m_forceUserDBConfig

bool TRT_AlignDbSvc::m_forceUserDBConfig
private

Definition at line 174 of file TRT_AlignDbSvc.h.

◆ m_par_alitextfile

std::string TRT_AlignDbSvc::m_par_alitextfile
private

input text file

Definition at line 164 of file TRT_AlignDbSvc.h.

◆ m_streamer

ToolHandle<IAthenaOutputStreamTool> TRT_AlignDbSvc::m_streamer
private

OutputStreamTool.

Definition at line 168 of file TRT_AlignDbSvc.h.

◆ m_trtid

const TRT_ID* TRT_AlignDbSvc::m_trtid
private

trt id helper

Definition at line 160 of file TRT_AlignDbSvc.h.

◆ m_trtman

const InDetDD::TRT_DetectorManager* TRT_AlignDbSvc::m_trtman
private

detector manager

Definition at line 161 of file TRT_AlignDbSvc.h.

◆ m_trtStrawAlignDbSvc

ServiceHandle<ITRT_StrawAlignDbSvc> TRT_AlignDbSvc::m_trtStrawAlignDbSvc
private

Definition at line 159 of file TRT_AlignDbSvc.h.


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