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 ()
 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 36 of file TRT_AlignDbSvc.cxx.

37 : base_class(name,pSvcLocator),
38 m_detStore("DetectorStore",name),
39 m_trtStrawAlignDbSvc("TRT_StrawAlignDbSvc",name),
40 m_trtid(nullptr),
41 m_trtman(nullptr),
42 m_alignroot("/TRT/Align"),
43 m_alignString("AL"),
45 m_streamer("AthenaOutputStreamTool/CondStream1"),
46 m_alignDBprefix("/TRT/Align/"),
47 m_dynamicDB(false),
49{
50 declareProperty("StreamTool",m_streamer);
51 declareProperty("alignroot",m_alignroot);
52 declareProperty("alignTextFile",m_par_alitextfile);
53 declareProperty("DetectorStore",m_detStore);
54 declareProperty("TrtStrawAlignDbSvc", m_trtStrawAlignDbSvc,"Service for interaction with the TRT straw alignment DB");
55 declareProperty("alignString",m_alignString);
56 declareProperty("alignDBprefix",m_alignDBprefix);
57 declareProperty("forceUserDBConfig",m_forceUserDBConfig, "Set to true to override any DB auto-configuration");
58}
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 62 of file TRT_AlignDbSvc.cxx.

63{}

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 1380 of file TRT_AlignDbSvc.cxx.

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

1282 {
1283
1288 ATH_MSG_DEBUG( "createAlignObjects method called" );
1289
1292 ATH_MSG_WARNING( "createAlignObjects: AlignableTransformContainer with name " << m_alignroot
1293 << " already exists." );
1294 return StatusCode::FAILURE;
1295 }
1296
1298 auto patc = std::make_unique<AlignableTransformContainer>();
1299
1300 for (unsigned int i=0;i<m_alignobjs.size();++i) {
1301 patc->push_back(std::make_unique<AlignableTransform>(m_alignobjs[i]));
1302 patc->add(m_alignchans[i]);
1303 ATH_MSG_INFO( " added empty AlignableTransform for key " << m_alignobjs[i] );
1304 }
1305
1307 ATH_CHECK( m_detStore->record(std::move(patc),m_alignroot) );
1308
1309 ATH_MSG_DEBUG( "Leaving createAlignObjects" );
1310 return StatusCode::SUCCESS;
1311}
#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 1315 of file TRT_AlignDbSvc.cxx.

1315 {
1316
1319 ATH_MSG_DEBUG( "createAlignObjectsWhichDoNotAlreadyExist method called" );
1320
1323
1326
1328 AlignableTransformContainer* patc_NonConst = const_cast<AlignableTransformContainer*>(patc);
1329
1330 for (unsigned int i=0;i<m_alignobjs.size();++i) {
1331
1333 if(m_alignString != "Alold" && !isOldKey(m_alignobjs[i] )){
1334
1336 if(!cgetTransPtr(m_alignobjs[i])){
1337
1338 AlignableTransform* pat=new AlignableTransform(m_alignobjs[i]);
1339 patc_NonConst->push_back(pat);
1340 patc_NonConst->add(m_alignchans[i]);
1341 ATH_MSG_INFO( " added empty AlignableTransform for key " << m_alignobjs[i] );
1342
1343 }
1344 }
1345 }
1346
1347 ATH_MSG_DEBUG( "Leaving createAlignObjectsWhichDoNotAlreadyExist" );
1348 return StatusCode::SUCCESS;
1349}
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 171 of file TRT_AlignDbSvc.cxx.

172{
173 ATH_MSG_INFO( "TRT_AlignDbSvc finalize method called" );
174 for(std::vector<Amg::Transform3D*>::iterator it = m_amgTransformCache.begin(); it != m_amgTransformCache.end(); ++it){
175 delete *it;
176 }
177 return StatusCode::SUCCESS;
178}
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 1146 of file TRT_AlignDbSvc.cxx.

1146 {
1172 std::ostringstream result;
1173 if (!m_trtid->is_trt(ident)) return result.str();
1174
1175 if(type=="AL" || type=="ALold") {
1176 // result << "/TRT/Align/";
1178 } else if(type=="DF") {
1179 result << "/TRT/Calib/DF";
1180 } else return result.str();
1181
1182 int bec=m_trtid->barrel_ec(ident);
1183
1184 if(type!="AL" && type!="ALold") result << "_";
1185
1186 if(type=="AL"){
1187 if(bec==2) {
1188 result << "L2A";
1189 } else if(bec==-2) {
1190 result << "L2C";
1191 } else {
1192 result << "B";
1193 int layer = m_trtid->layer_or_wheel(ident);
1194 result << layer;
1195 }
1196 }else if(type=="ALold"){
1197 if(bec==2) {
1198 result << "A";
1199 } else if(bec==-2) {
1200 result << "C";
1201 } else {
1202 result << "B";
1203 }
1204 int layer = m_trtid->layer_or_wheel(ident);
1205 result << layer;
1206 }
1207
1212
1213 return result.str();
1214}
@ 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 536 of file TRT_AlignDbSvc.cxx.

536 {
537 ATH_MSG_DEBUG( "In getAlignmentTransform" );
538
539 if(level != 1 && level != 2){
540 ATH_MSG_ERROR( "Call to trans wrong!" );
541 ATH_MSG_ERROR( "Level must be 1 or 2!" );
542 ATH_MSG_ERROR( "Returning NULL" );
543 return Amg::Transform3D();
544 }
545
546 return (level == 1) ? getAlignmentTransformL1(ident) : getAlignmentTransformL2(ident);
547}
#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 550 of file TRT_AlignDbSvc.cxx.

550 {
551 ATH_MSG_DEBUG( "In getAlignmentTransformL1" );
552 // return level 1 AlignableTransform for the TRT subdetector bec (+-1,+-2)
553 // or return null transform.
554
555 std::string key="/TRT/Align/TRT";
556 const AlignableTransform* pat=cgetTransPtr(key);
557 if (!pat) return Amg::Transform3D();
558
559 // get Amg::Transform3d via AlignTransMember
560 AlignableTransform::AlignTransMem_citr itr = pat->findIdent(ident);
561 return ( itr!=pat->end() ? Amg::CLHEPTransformToEigen(itr->transform()) : Amg::Transform3D() );
562}
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 610 of file TRT_AlignDbSvc.cxx.

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

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

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

◆ getAlignmentTransformPtr()

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

get Level L2 Transform for an identifier

Definition at line 596 of file TRT_AlignDbSvc.cxx.

596 {
597 ATH_MSG_DEBUG( "In getAlignmentTransformPtr" );
598
599 if(level != 1 && level != 2){
600 ATH_MSG_ERROR( "Call to trans wrong!" );
601 ATH_MSG_ERROR( "Level must be 1 or 2!" );
602 ATH_MSG_ERROR( "Returning NULL" );
603 return nullptr;
604 }
605
606 return (level == 1) ? getAlignmentTransformL1Ptr(ident) : getAlignmentTransformL2Ptr(ident);
607}
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 1598 of file TRT_AlignDbSvc.cxx.

1599{
1600 if (m_aligncontainerhandle.isValid())
1601 return m_aligncontainerhandle.cptr();
1602 const AlignableTransformContainer* ptr = nullptr;
1603 if (m_detStore->retrieve (ptr, m_alignroot).isFailure()) {
1604 ATH_MSG_ERROR ("Cannot retrieve " << m_alignroot << " from detStore ");
1605 }
1606 return ptr;
1607}
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 1410 of file TRT_AlignDbSvc.cxx.

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

◆ getTransPtr()

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

get AlignableTransform pointer for an object key

Definition at line 1374 of file TRT_AlignDbSvc.cxx.

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

◆ 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 67 of file TRT_AlignDbSvc.cxx.

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

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

◆ IOVCallBack()

StatusCode TRT_AlignDbSvc::IOVCallBack ( )

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 181 of file TRT_AlignDbSvc.cxx.

182{
183 ATH_MSG_DEBUG( "In IOVCallBack" );
184
193
196// for (std::list<std::string>::const_iterator itr=keys.begin(); itr!=keys.end(); ++itr)
197// ATH_MSG_INFO( "IOVCALLBACK for key " << *itr<< " number " << I );
198
199
200 if(!m_par_alitextfile.empty()){
202 }else{
203 ATH_MSG_INFO( "Text file " << m_par_alitextfile << " is empty" );
204 }
205
209
210 ATH_MSG_DEBUG( "Leaving IOVCallBack" );
211 return StatusCode::SUCCESS;
212}
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 1417 of file TRT_AlignDbSvc.cxx.

1417 {
1418
1419 for(unsigned int i=0; i<14; ++i){
1420 std::string testA = "A"+intToString(i);
1421 ATH_MSG_VERBOSE( " The testA is " << testA << " "
1422 << bool(input.find(testA)!=std::string::npos) );
1423 if(input.find(testA)!=std::string::npos){
1424 return true;
1425 }
1426
1427 std::string testC = "C"+intToString(i);
1428 ATH_MSG_VERBOSE( " The testC is " << testC << " "
1429 << bool(input.find(testC)!=std::string::npos) );
1430 if(input.find(testC)!=std::string::npos){
1431 return true;
1432 }
1433
1434 }
1435
1436 return false;
1437}
#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 1217 of file TRT_AlignDbSvc.cxx.

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

◆ printCondObjects()

void TRT_AlignDbSvc::printCondObjects ( ) const
private

Output the conditions objects currently in memory.

Definition at line 1352 of file TRT_AlignDbSvc.cxx.

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

◆ 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 1447 of file TRT_AlignDbSvc.cxx.

1447 {
1448 std::cout << thisName << " " << transform(0,3) << " " << transform(1,3) << " " << transform(2,3) << std::endl;
1449 std::cout << thisName << " " << transform(0,0) << " " << transform(0,1) << " " << transform(0,2) << std::endl;
1450 std::cout << thisName << " " << transform(1,0) << " " << transform(1,1) << " " << transform(1,2) << std::endl;
1451 std::cout << thisName << " " << transform(2,1) << " " << transform(2,1) << " " << transform(2,2) << std::endl;
1452 return;
1453}
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 349 of file TRT_AlignDbSvc.cxx.

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

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

◆ setAlignTransform()

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

set AlignableTransform for an identifier

Definition at line 673 of file TRT_AlignDbSvc.cxx.

673 {
674 ATH_MSG_DEBUG( "In getAlignmentTransform" );
675
676 if(level != 1 && level != 2 && level != 3){
677 ATH_MSG_FATAL( "Call to setAlignTransform wrong!" );
678 ATH_MSG_FATAL( "Level must be 1,2 or 3!" );
679 return StatusCode::FAILURE;
680 }
681
682 switch (level) {
683
684 case 1:
685 ATH_CHECK( setAlignTransformL1(ident,trans) );
686 break;
687 case 2:
688 ATH_CHECK( setAlignTransformL2(ident,trans) );
689 break;
690 case 3:
691 ATH_CHECK( setAlignTransformL3(ident,trans) );
692 break;
693 }
694
695 return StatusCode::SUCCESS;
696}
#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 699 of file TRT_AlignDbSvc.cxx.

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

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

◆ setAlignTransformL3()

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

set Level 3 AlignableTransform for an identifier

Definition at line 797 of file TRT_AlignDbSvc.cxx.

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

487 {
488 ATH_MSG_DEBUG( "In streamOutAlignObjects " );
489
490 // Get Output Stream tool for writing
491 ATH_CHECK( m_streamer.retrieve() );
492
493 IAthenaOutputStreamTool* streamer=const_cast<IAthenaOutputStreamTool*>(&(*m_streamer));
494
495 ATH_CHECK( streamer->connectOutput() );
496
498 IAthenaOutputStreamTool::TypeKeyPair arraypair("AlignableTransformContainer",m_alignroot);
499 typeKeys.push_back(arraypair);
501
502 ATH_CHECK( streamer->streamObjects(typeKeys) );
503 ATH_CHECK( streamer->commitOutput() );
504
505 ATH_MSG_INFO( " Streamed out and committed AlignableTransformContainer" );
507
508 ATH_MSG_DEBUG( "Leaving streamOutAlignObjects " );
509 return StatusCode::SUCCESS;
510}
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 874 of file TRT_AlignDbSvc.cxx.

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

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

◆ tweakAlignTransformL2()

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

tweak Level 2 AlignableTransform for an identifier

Definition at line 977 of file TRT_AlignDbSvc.cxx.

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

◆ tweakAlignTransformL3()

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

tweak Level 3 AlignableTransform for an identifier

Definition at line 1016 of file TRT_AlignDbSvc.cxx.

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

◆ tweakGlobalFolder()

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

tweak L1 DB for global folders for an identifier

Definition at line 1505 of file TRT_AlignDbSvc.cxx.

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

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

◆ writeGlobalFolderFile()

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

Definition at line 1456 of file TRT_AlignDbSvc.cxx.

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

◆ writeStrawAlignTextFile()

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

Definition at line 337 of file TRT_AlignDbSvc.cxx.

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

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: