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:
Collaboration 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
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 44 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 1377 of file TRT_AlignDbSvc.cxx.

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

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

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

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

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

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

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

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

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

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

◆ getAlignmentTransformPtr()

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

get Level L2 Transform for an identifier

Definition at line 593 of file TRT_AlignDbSvc.cxx.

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

1596{
1597 const AlignableTransformContainer* ptr = nullptr;
1598 if (m_detStore->retrieve (ptr, m_alignroot).isFailure()) {
1599 ATH_MSG_ERROR ("Cannot retrieve " << m_alignroot << " from detStore ");
1600 }
1601 return ptr;
1602}
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 1407 of file TRT_AlignDbSvc.cxx.

1407 {
1408 return strawlayer / 4 * 4;
1409}

◆ getTransPtr()

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

get AlignableTransform pointer for an object key

Definition at line 1371 of file TRT_AlignDbSvc.cxx.

1371 {
1372 ATH_MSG_DEBUG( "In (and leaving) getTransPtr" );
1373 return const_cast<AlignableTransform*>(cgetTransPtr(key)) ;
1374}

◆ 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.

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 if( alignTextFileExists )
144 ATH_MSG_INFO( "AlignableTransformContainer with name " << m_alignroot
145 << " exists. Will read text file from callback function." );
146
147 } else if ( alignTextFileExists ) {
148
150 ATH_CHECK( this->createAlignObjects() );
151
154
155 } else {
156 ATH_MSG_ERROR( "AlignableTransformContainer not in IOV service and no textfile specified." );
157 }
158
159 ATH_MSG_DEBUG ("The TRT/Align keys and channels are:");
160 for (unsigned int i=0;i<m_alignobjs.size();++i)
161 ATH_MSG_DEBUG (" key " << m_alignobjs[i] << " chan " << m_alignchans[i]);
162
163 return StatusCode::SUCCESS;
164}
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 1437 of file TRT_AlignDbSvc.cxx.

1437 {
1438 std::ostringstream stm;
1439 stm << input;
1440 return stm.str();
1441}

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

179{
180 ATH_MSG_DEBUG( "In IOVCallBack" );
181
190
193// for (std::list<std::string>::const_iterator itr=keys.begin(); itr!=keys.end(); ++itr)
194// ATH_MSG_INFO( "IOVCALLBACK for key " << *itr<< " number " << I );
195
196
197 if(!m_par_alitextfile.empty()){
199 }else{
200 ATH_MSG_INFO( "Text file " << m_par_alitextfile << " is empty" );
201 }
202
206
207 ATH_MSG_DEBUG( "Leaving IOVCallBack" );
208 return StatusCode::SUCCESS;
209}
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 1414 of file TRT_AlignDbSvc.cxx.

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

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

◆ printCondObjects()

void TRT_AlignDbSvc::printCondObjects ( ) const
private

Output the conditions objects currently in memory.

Definition at line 1349 of file TRT_AlignDbSvc.cxx.

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

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

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

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

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

◆ setAlignTransform()

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

set AlignableTransform for an identifier

Definition at line 670 of file TRT_AlignDbSvc.cxx.

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

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

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

◆ setAlignTransformL3()

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

set Level 3 AlignableTransform for an identifier

Definition at line 794 of file TRT_AlignDbSvc.cxx.

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

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

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

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

◆ tweakAlignTransformL2()

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

tweak Level 2 AlignableTransform for an identifier

Definition at line 974 of file TRT_AlignDbSvc.cxx.

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

◆ tweakAlignTransformL3()

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

tweak Level 3 AlignableTransform for an identifier

Definition at line 1013 of file TRT_AlignDbSvc.cxx.

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

◆ tweakGlobalFolder()

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

tweak L1 DB for global folders for an identifier

Definition at line 1502 of file TRT_AlignDbSvc.cxx.

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

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

◆ writeGlobalFolderFile()

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

Definition at line 1453 of file TRT_AlignDbSvc.cxx.

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

◆ writeStrawAlignTextFile()

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

Definition at line 334 of file TRT_AlignDbSvc.cxx.

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

Member Data Documentation

◆ m_alignchans

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

channels

Definition at line 165 of file TRT_AlignDbSvc.h.

◆ m_alignDBprefix

std::string TRT_AlignDbSvc::m_alignDBprefix
private

Definition at line 169 of file TRT_AlignDbSvc.h.

◆ m_alignobjs

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

folder names

Definition at line 164 of file TRT_AlignDbSvc.h.

◆ m_alignroot

std::string TRT_AlignDbSvc::m_alignroot
private

root alignment folder

Definition at line 161 of file TRT_AlignDbSvc.h.

◆ m_alignString

std::string TRT_AlignDbSvc::m_alignString
private

alignment string searched for

Definition at line 162 of file TRT_AlignDbSvc.h.

◆ m_amgTransformCache

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

Definition at line 167 of file TRT_AlignDbSvc.h.

◆ m_detStore

ServiceHandle<StoreGateSvc> TRT_AlignDbSvc::m_detStore
private

Definition at line 157 of file TRT_AlignDbSvc.h.

◆ m_dynamicDB

bool TRT_AlignDbSvc::m_dynamicDB
private

Definition at line 171 of file TRT_AlignDbSvc.h.

◆ m_forceUserDBConfig

bool TRT_AlignDbSvc::m_forceUserDBConfig
private

Definition at line 172 of file TRT_AlignDbSvc.h.

◆ m_par_alitextfile

std::string TRT_AlignDbSvc::m_par_alitextfile
private

input text file

Definition at line 163 of file TRT_AlignDbSvc.h.

◆ m_streamer

ToolHandle<IAthenaOutputStreamTool> TRT_AlignDbSvc::m_streamer
private

OutputStreamTool.

Definition at line 166 of file TRT_AlignDbSvc.h.

◆ m_trtid

const TRT_ID* TRT_AlignDbSvc::m_trtid
private

trt id helper

Definition at line 159 of file TRT_AlignDbSvc.h.

◆ m_trtman

const InDetDD::TRT_DetectorManager* TRT_AlignDbSvc::m_trtman
private

detector manager

Definition at line 160 of file TRT_AlignDbSvc.h.

◆ m_trtStrawAlignDbSvc

ServiceHandle<ITRT_StrawAlignDbSvc> TRT_AlignDbSvc::m_trtStrawAlignDbSvc
private

Definition at line 158 of file TRT_AlignDbSvc.h.


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