ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::TRTTrkAlignDBTool Class Reference

#include <TRTTrkAlignDBTool.h>

Inheritance diagram for InDet::TRTTrkAlignDBTool:
Collaboration diagram for InDet::TRTTrkAlignDBTool:

Public Member Functions

 TRTTrkAlignDBTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TRTTrkAlignDBTool ()
StatusCode initialize ()
StatusCode finalize ()
void writeAlignPar ()
 Writes alignment parameters.
void setNtuple (TFile *file)
 sets ntuple to be used to write output
virtual void setLogStream (std::ostream *os)
 sets the output stream for the logfile
virtual StatusCode preSolve ()
 sets up initial alignment constants before solving
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

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

Protected Attributes

std::ostream * m_logStream = nullptr
 logfile output stream

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void printTransform (const Amg::Transform3D &tr) const
 print translation to stdout
void updateDB ()
 updates alignment constants in the DB
bool containsTRT (Trk::AlignModule *module) const
 checks whether the AlignModule contains TRT detector elements
void updateL0asL1 (Identifier idL0, const Amg::Transform3D &transform)
 updates level 0 transform as level 1 constants in the DB
bool checkAlignLevel ()
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const TRT_IDm_trtHelper
const PixelIDm_pixHelper
std::string m_outputAlignFile
std::string m_outputStrawAlignFile
std::string m_oldAlignFile
std::string m_oldStrawAlignFile
bool m_writeTextFile
bool m_writeOldConstants
bool m_updateConstants
ServiceHandle< ITRT_AlignDbSvcm_trtAlignDbSvc
ToolHandle< Trk::IAlignModuleToolm_alignModuleTool
ToolHandle< Trk::IGeometryManagerToolm_trtGeoManager
int m_trtAlignLevel
int m_trtAlignLevelBarrel
int m_trtAlignLevelEndcaps
TFile * m_ntuple
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 40 of file TRTTrkAlignDBTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TRTTrkAlignDBTool()

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

Definition at line 29 of file TRTTrkAlignDBTool.cxx.

30 : AthAlgTool(type,name,parent)
31 , m_trtHelper(nullptr)
32 , m_pixHelper(nullptr)
33 , m_outputAlignFile("OutputTRTAlignment.txt")
34 , m_outputStrawAlignFile("OutputTRTStrawAlignment.txt")
35 , m_oldAlignFile("OldTRTAlignment.txt")
36 , m_oldStrawAlignFile("OldTRTStrawAlignment.txt")
37 , m_writeTextFile(true)
38 , m_writeOldConstants(false)
39 , m_updateConstants(true)
40 , m_trtAlignDbSvc("TRT_AlignDbSvc",name)
41 , m_alignModuleTool("Trk::AlignModuleTool/AlignModuleTool")
42 , m_trtGeoManager("")
43 , m_trtAlignLevel(-1)
46 , m_ntuple{}
47{
48 declareInterface<ITrkAlignDBTool>(this);
49
50 declareProperty("OutputTextFile", m_outputAlignFile, "Text file to write the final alignment constants");
51 declareProperty("OutputStrawTextFile", m_outputStrawAlignFile, "Text file to write the final straw alignment constants");
52 declareProperty("WriteTextFile", m_writeTextFile, "Whether or not to write the final/new alignment constants to text file");
53 declareProperty("WriteOldConstants", m_writeOldConstants, "Whether or not to write the initial/old alignment constants to text file");
54 declareProperty("OldAlignFile", m_oldAlignFile, "Text file to write the initial/old alignment constants");
55 declareProperty("OldStrawAlignFile", m_oldStrawAlignFile, "Text file to write the initial/old straw alignment constants");
56 declareProperty("TrtAlignDbSvc", m_trtAlignDbSvc, "Service for interaction with the TRT alignment DB");
57 declareProperty("AlignModuleTool", m_alignModuleTool, "Tool for handling of align module collections");
58 declareProperty("TRTGeometryManager", m_trtGeoManager, "Tool for handling the TRT alignment geometry");
59 declareProperty("UpdateConstants", m_updateConstants, "Whether or no to update the alignment constants");
60
61 m_logStream = nullptr;
62}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< Trk::IGeometryManagerTool > m_trtGeoManager
ToolHandle< Trk::IAlignModuleTool > m_alignModuleTool
ServiceHandle< ITRT_AlignDbSvc > m_trtAlignDbSvc
std::ostream * m_logStream
logfile output stream

◆ ~TRTTrkAlignDBTool()

InDet::TRTTrkAlignDBTool::~TRTTrkAlignDBTool ( )
virtual

Definition at line 65 of file TRTTrkAlignDBTool.cxx.

66{}

Member Function Documentation

◆ checkAlignLevel()

bool InDet::TRTTrkAlignDBTool::checkAlignLevel ( )
private

Definition at line 130 of file TRTTrkAlignDBTool.cxx.

131{
132 if(m_trtAlignLevel == 0)
133 return true;
134
135 m_trtAlignLevel = -1;
136
137 bool ok=false;
138
139 switch(m_trtAlignLevelBarrel) {
140 case 1: case 2: case 3:
141 ok = true;
142 break;
143 default:
144 ATH_MSG_ERROR(" Storing of alignment constants for level "<<m_trtAlignLevelBarrel<<" for TRT Barrel is not implemented.");
146 ok = false;
147 break;
148 }
149
150 switch(m_trtAlignLevelEndcaps) {
151 case 1: case 2: case 3:
152 ok = ok && true;
153 break;
154 default:
155 ATH_MSG_ERROR(" Storing of alignment constants for level "<<m_trtAlignLevelEndcaps<<" for TRT Endcaps is not implemented.");
157 ok = false;
158 break;
159 }
160
161 return ok;
162}
#define ATH_MSG_ERROR(x)

◆ containsTRT()

bool InDet::TRTTrkAlignDBTool::containsTRT ( Trk::AlignModule * module) const
private

checks whether the AlignModule contains TRT detector elements

Definition at line 408 of file TRTTrkAlignDBTool.cxx.

409{
410 ATH_MSG_DEBUG("in containsTRT()");
411 const Trk::AlignModule::DetElementCollection * coll = module->detElementCollection(Trk::AlignModule::TRT);
412 if(!coll || coll->size()==0)
413 return false;
414
415 return true;
416}
#define ATH_MSG_DEBUG(x)
std::vector< const TrkDetElementBase * > DetElementCollection
typedefs to contain detector element pointers and transforms
Definition AlignModule.h:60

◆ declareGaudiProperty()

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

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

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

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

Definition at line 145 of file AthCommonDataStore.h.

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

◆ detStore()

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

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

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

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

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

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

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

Add StoreName to extra input/output deps as needed.

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

◆ finalize()

StatusCode InDet::TRTTrkAlignDBTool::finalize ( )
virtual

Implements Trk::ITrkAlignDBTool.

Definition at line 122 of file TRTTrkAlignDBTool.cxx.

123{
124 ATH_MSG_DEBUG("finalize() of TRTTrkAlignDBTool");
125
126 return StatusCode::SUCCESS;
127}

◆ initialize()

StatusCode InDet::TRTTrkAlignDBTool::initialize ( )
virtual

Implements Trk::ITrkAlignDBTool.

Definition at line 69 of file TRTTrkAlignDBTool.cxx.

70{
71 ATH_MSG_DEBUG("initialize() of TRTTrkAlignDBTool");
72
74 ATH_MSG_WARNING("Not updating TRT constants!");
75 return StatusCode::SUCCESS;
76 }
77 // get TRT db service
78 ATH_CHECK( m_trtAlignDbSvc.retrieve() );
79 // get AlignModuleTool
80 ATH_CHECK( m_alignModuleTool.retrieve());
81 // get TRT ID Helper
82 ATH_CHECK( detStore()->retrieve(m_trtHelper, "TRT_ID"));
83 // get Pixel ID Helper
85
86 // get TRTGeometryManagerTool
87 if( !m_trtGeoManager.empty() ) {
88 ATH_CHECK( m_trtGeoManager.retrieve());
89 ATH_MSG_DEBUG("retrieved " << m_trtGeoManager);
90 m_trtAlignLevel = m_trtGeoManager->alignLevel();
91 m_trtAlignLevelBarrel = m_trtGeoManager->alignLevelBarrel();
92 m_trtAlignLevelEndcaps = m_trtGeoManager->alignLevelEndcaps();
93 ATH_MSG_DEBUG("Retrieved TRT Global alignment level: "<<m_trtAlignLevel);
94 ATH_MSG_DEBUG("Retrieved TRT Barrel alignment level: "<<m_trtAlignLevelBarrel);
95 ATH_MSG_DEBUG("Retrieved TRT Endcap alignment level: "<<m_trtAlignLevelEndcaps);
96 if(m_trtAlignLevelEndcaps==200) {
97 ATH_MSG_WARNING("Requested update of TRT Endcap constants for the old scheme.");
98 ATH_MSG_WARNING("This will only work with \'alignString = \"ALold\"\' option of TRT_AlignDbSvc.");
100 }
101 }
102
103 if(m_trtAlignLevel == 0)
104 ATH_MSG_INFO(" Requested update of Level "<<m_trtAlignLevel<<" alignment constants for TRT");
105 else {
106 ATH_MSG_INFO(" Requested update of Level "<<m_trtAlignLevelBarrel<<" alignment constants for TRT Barrel");
107 ATH_MSG_INFO(" Requested update of Level "<<m_trtAlignLevelEndcaps<<" alignment constants for TRT Endcaps");
108 }
109
110 // check alignment level but don't stop on error
111 // if unknown level given, set to -1
112 if(!checkAlignLevel()) {
113 ATH_MSG_FATAL( " No geometry manager available or alignment level not given. " );
114 // we don't want to stop if there's errors
115 // so we comment out the return statement
116// return StatusCode::FAILURE;
117 }
118 return StatusCode::SUCCESS;
119}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

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

Return this algorithm's input handles.

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

◆ interfaceID()

const InterfaceID & ITrkAlignDBTool::interfaceID ( )
inlinestaticinherited

Definition at line 58 of file ITrkAlignDBTool.h.

static const InterfaceID IID_TRKALIGNINTERFACES_ITrkAlignDBTool("ITrkAlignDBTool", 1, 0)

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

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

Definition at line 30 of file AthCommonMsg.h.

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

◆ outputHandles()

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

Return this algorithm's output handles.

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

◆ preSolve()

virtual StatusCode Trk::ITrkAlignDBTool::preSolve ( )
inlinevirtualinherited

sets up initial alignment constants before solving

Definition at line 52 of file ITrkAlignDBTool.h.

52{ return StatusCode::SUCCESS; }

◆ printTransform()

void InDet::TRTTrkAlignDBTool::printTransform ( const Amg::Transform3D & tr) const
private

print translation to stdout

Definition at line 397 of file TRTTrkAlignDBTool.cxx.

398{
399 ATH_MSG_DEBUG(" - translation: "<<tr.translation().x()<<" "<<tr.translation().y()<<" "<<tr.translation().z());
400 ATH_MSG_DEBUG(" - rotation:");
401 ATH_MSG_DEBUG(" "<<tr(0,0)<<" "<<tr(0,1)<<" "<<tr(0,2));
402 ATH_MSG_DEBUG(" "<<tr(1,0)<<" "<<tr(1,1)<<" "<<tr(1,2));
403 ATH_MSG_DEBUG(" "<<tr(2,0)<<" "<<tr(2,1)<<" "<<tr(2,2));
404 return;
405}

◆ renounce()

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

Definition at line 380 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setLogStream()

virtual void Trk::ITrkAlignDBTool::setLogStream ( std::ostream * os)
inlinevirtualinherited

sets the output stream for the logfile

Definition at line 49 of file ITrkAlignDBTool.h.

◆ setNtuple()

void InDet::TRTTrkAlignDBTool::setNtuple ( TFile * file)
inlinevirtual

sets ntuple to be used to write output

Reimplemented from Trk::ITrkAlignDBTool.

Definition at line 54 of file TRTTrkAlignDBTool.h.

55 { m_ntuple=file; }
TFile * file

◆ sysInitialize()

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

Perform system initialization for an algorithm.

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

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

◆ sysStart()

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

Handle START transition.

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

◆ updateDB()

void InDet::TRTTrkAlignDBTool::updateDB ( )
private

updates alignment constants in the DB

Definition at line 204 of file TRTTrkAlignDBTool.cxx.

205{
206 ATH_MSG_DEBUG(" in TRTTrkAlignDBTool::updateDB()");
207
208 // There are 3 sets of alignment constants in the DB for the TRT
209 // L0 : whole TRT
210 // L1 : barrel + 2 endcaps
211 // L2 : barrel modules and endcap discs
212 //
213 // If we're doing alignment of the level between these, the constants
214 // of the closest higher level have to be updated.
215 // This is not allways necessary for all alignmodules since some of them
216 // can be defined to be identical with modules at lower alignment level,
217 // but we keep it like this for the moment.
218
219 // updating level 0, level 1 or level 2 constants in the DB
220 ATH_MSG_DEBUG("Global alignment level: "<<m_trtAlignLevel);
221 ATH_MSG_DEBUG("Barrel alignment level: "<<m_trtAlignLevelBarrel);
222 ATH_MSG_DEBUG("Endcap alignment level: "<<m_trtAlignLevelEndcaps);
223
225 ATH_MSG_ERROR(" No geometry manager available or alignment level not given.");
226 ATH_MSG_ERROR(" DB not updated.");
227 return;
228 }
229
230 ATH_MSG_INFO("-------------------------------------------------------");
231 if(m_trtAlignLevel>=0)
232 ATH_MSG_INFO("updating Level "<<m_trtAlignLevel<<" alignment constants for modules");
233 else {
234 ATH_MSG_INFO("updating Level "<<m_trtAlignLevelBarrel<<" alignment constants for Barrel modules");
235 ATH_MSG_INFO("updating Level "<<m_trtAlignLevelEndcaps<<" alignment constants for Endcap modules");
236 }
237
238 Amg::Transform3D dbtransform;
239
240 // loop over all AlignModules
241 std::vector<Trk::AlignModule *>::const_iterator imod = m_alignModuleTool->getAlignModuleCollection()->begin();
242 std::vector<Trk::AlignModule *>::const_iterator imod_end = m_alignModuleTool->getAlignModuleCollection()->end();
243 for( ; imod != imod_end; ++imod ) {
244
245 Trk::AlignModule * module = *imod;
246
247 ATH_MSG_DEBUG("-------------------------------------------------------");
248 ATH_MSG_DEBUG("Alignment corrections for module: "<<module->name());
249
250 // the identifier of the module for the DB
251 Identifier modID = module->identify();
252
253 // The TRT AlignModules of levels 1 and 2 use the TRT Identifier.
254 // For level 0 the Identifier can be either TRT of Pixel but we have to check
255 // that the AlignModule contains the TRT detector elements
256 // (there can also be L0 without TRT in which case we don't want to do anything)
257 if(!m_trtHelper->is_trt(modID) && (m_trtAlignLevel!=0 || !containsTRT(module)) ) {
258 ATH_MSG_DEBUG("Module with ID: "<<modID<<" is not a TRT module. Skipping.");
259 continue;
260 }
261
262 // get active alignment parameters for the module
263 DataVector<Trk::AlignPar> * alignPars = m_alignModuleTool->getAlignPars(module);
264 if(alignPars->size() == 0) {
265 ATH_MSG_INFO("Alignment for module "<<module->name()<<" not available.");
266 continue;
267 }
268
269 // get final alignment parameters
270 DataVector<Trk::AlignPar> * fullAlignPars = m_alignModuleTool->getFullAlignPars(module);
271 double apTraX = fullAlignPars->at(Trk::AlignModule::TransX)->par();
272 double apTraY = fullAlignPars->at(Trk::AlignModule::TransY)->par();
273 double apTraZ = fullAlignPars->at(Trk::AlignModule::TransZ)->par();
274 double apRotX = fullAlignPars->at(Trk::AlignModule::RotX)->par();
275 double apRotY = fullAlignPars->at(Trk::AlignModule::RotY)->par();
276 double apRotZ = fullAlignPars->at(Trk::AlignModule::RotZ)->par();
277
278 // construct the alignment transform
279 Amg::Translation3D translation( apTraX, apTraY, apTraZ );
280 Amg::Transform3D transform = translation * Amg::RotationMatrix3D::Identity();
281 transform *= Amg::AngleAxis3D(apRotZ, Amg::Vector3D(0.,0.,1.));
282 transform *= Amg::AngleAxis3D(apRotY, Amg::Vector3D(0.,1.,0.));
283 transform *= Amg::AngleAxis3D(apRotX, Amg::Vector3D(1.,0.,0.));
284
285
286
287 ATH_MSG_DEBUG(" - translation X = "<<apTraX);
288 ATH_MSG_DEBUG(" - translation Y = "<<apTraY);
289 ATH_MSG_DEBUG(" - translation Z = "<<apTraZ);
290 ATH_MSG_DEBUG(" - rotation X = "<<apRotX);
291 ATH_MSG_DEBUG(" - rotation Y = "<<apRotY);
292 ATH_MSG_DEBUG(" - rotation Z = "<<apRotZ);
293
294 // update TRT level 0 constants
295 if(m_trtAlignLevel == 0) {
296 updateL0asL1(modID,dbtransform);
297 continue;
298 }
299
300 int level;
301 if(m_trtHelper->is_barrel(modID))
303 else
305
306 // update the constants in memory
307 ATH_MSG_DEBUG("updating level "<<level<<" constants for module "<<module->name()<<" with ID "<<modID);
308 switch(level) {
309 case 1: case 2: {
310 // for levels 1 and 2 alignment the DB frame equals to the global frame but the align
311 // frame does not, so we have to apply an additional transform
312 Amg::Transform3D dbFrameToAlignFrame = module->globalFrameToAlignFrame();
313
314 ATH_MSG_DEBUG("DB to align");
315 printTransform(dbFrameToAlignFrame);
316
317 dbtransform = dbFrameToAlignFrame.inverse() * transform * dbFrameToAlignFrame;
318
319 break;
320 }
321
322 case 3:
323 // for level 3 alignment the DB frame and the align frame equals to the local frame
324 // so we don't apply any additional transform
325
326 // if we are in the Endcap we need to rotate about global Z
327 //if(abs(m_trtHelper->barrel_ec_id(modID.get_identifier32().get_compact()).get_compact()) == 2) { # Bug!
328 if( abs(m_trtHelper->barrel_ec(modID)) == 2) {
329 ATH_MSG_DEBUG("L3 module in TRT end-cap A so we apply additional rotation about global Z (" << M_PI << ")");
330 Amg::Translation3D newtranslation( 0,0,0 );
331 Amg::Transform3D newtransform = newtranslation * Amg::AngleAxis3D( M_PI, Amg::Vector3D(0.,0.,1.));
332 dbtransform = newtransform * transform;
333 }
334 else
335 // otherwise we don't do anything
336 dbtransform = transform;
337
338 break;
339
340 default:
341 // otherwise we don't know what to do
342 // so we do nothing for the module
343 ATH_MSG_WARNING("Unknown level "<<level<<". Skipping the module.");
344 continue;
345 }
346
347 ATH_MSG_DEBUG("DB transform");
348 printTransform(dbtransform);
349
350 // tweak applies the transform onto already existing transform in the DB
351 // or sets it if it doesn't exist yet
352 if(m_trtAlignDbSvc->tweakAlignTransform(modID,dbtransform,level).isFailure())
353 ATH_MSG_ERROR("Error setting constants for module \'"<<module->name()<<"\'");
354 else
355 ATH_MSG_DEBUG("Module \'"<<module->name()<<"\': Level "<<level<<" constants updated.");
356 }
357 ATH_MSG_INFO("-------------------------------------------------------");
358
359}
#define M_PI
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
bool containsTRT(Trk::AlignModule *module) const
checks whether the AlignModule contains TRT detector elements
void printTransform(const Amg::Transform3D &tr) const
print translation to stdout
void updateL0asL1(Identifier idL0, const Amg::Transform3D &transform)
updates level 0 transform as level 1 constants in the DB
Eigen::AngleAxisd AngleAxis3D
Eigen::Affine3d Transform3D
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D

◆ updateL0asL1()

void InDet::TRTTrkAlignDBTool::updateL0asL1 ( Identifier idL0,
const Amg::Transform3D & transform )
private

updates level 0 transform as level 1 constants in the DB

Definition at line 362 of file TRTTrkAlignDBTool.cxx.

363{
364 // splitting the whole TRT into barrel and two endcaps
365 // or the whole Inner Detector into TRT and the rest
366 // the Identifier has to be equal to:
367 // - L1 TRT barrel Identifier for TRT level 0 update
368 // - L1 Pixel Identifier for Inner Detector level 0 update
369 if( idL0 != m_pixHelper->wafer_id(0,0,0,0) && idL0 != m_trtHelper->barrel_ec_id(-1) ) {
370 ATH_MSG_ERROR("wrong identifier for L0 TRT in updateL0asL1() : "<<idL0);
371 ATH_MSG_ERROR("allowed are "<<m_trtHelper->barrel_ec_id(-1)<<" for TRT L0");
372 ATH_MSG_ERROR(" and "<<m_pixHelper->wafer_id(0,0,0,0)<<" for InDet L0");
373 return;
374 }
375
376 // for both L0 and L1 the global frame is equal to the DB frame
377 // for L0 it is also equal to align frame so no additional transform is needed
378
379 ATH_MSG_INFO("Splitting TRT into L1 modules and updating in the DB");
380
381 std::vector<Identifier> ids;
382 ids.push_back(m_trtHelper->barrel_ec_id(-1)); // barrel
383 ids.push_back(m_trtHelper->barrel_ec_id(-2)); // endcap A
384 ids.push_back(m_trtHelper->barrel_ec_id(2)); // endcap C
385
386 ATH_MSG_INFO("Updating L1 constants for TRT");
387 for(unsigned int i=0; i<ids.size(); ++i) {
388 // tweak applies the transform onto already existing transform in the DB
389 if(m_trtAlignDbSvc->tweakAlignTransform(ids[i],transform,1).isFailure())
390 ATH_MSG_ERROR("Error setting constants.");
391 else
392 ATH_MSG_INFO("Module "<<i<<". - id "<<ids[i]<<": Constants updated.");
393 }
394}

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

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

◆ writeAlignPar()

void InDet::TRTTrkAlignDBTool::writeAlignPar ( )
virtual

Writes alignment parameters.

Reimplemented from Trk::ITrkAlignDBTool.

Definition at line 165 of file TRTTrkAlignDBTool.cxx.

166{
167 ATH_MSG_DEBUG("in TRTTrkAlignDBTool::writeAlignPar()");
168
169 // do we want to update the DB?
170 if(!m_updateConstants) {
171 ATH_MSG_INFO("Update of TRT constants not requested!");
172 return;
173 }
174
175 // write initial alignment constants
177 ATH_MSG_INFO("Writing old TRT alignment constants to file "<<m_oldAlignFile);
178 if( m_trtAlignDbSvc -> writeAlignTextFile(m_oldAlignFile) != StatusCode::SUCCESS )
179 ATH_MSG_ERROR("Cannot write to file "<<m_oldAlignFile);
180 if( m_trtAlignDbSvc -> writeStrawAlignTextFile(m_oldStrawAlignFile) != StatusCode::SUCCESS )
181 ATH_MSG_ERROR("Cannot write to file "<<m_oldStrawAlignFile);
182 }
183
184 // now update the DB
185 updateDB();
186
187 // and write the final alignment constants
188 if(m_writeTextFile) {
189 if( m_trtAlignDbSvc->writeAlignTextFile(m_outputAlignFile) != StatusCode::SUCCESS )
190 ATH_MSG_ERROR("Cannot write to file "<<m_outputAlignFile);
191 else
192 ATH_MSG_INFO("Wrote final TRT alignment constants into "<<m_outputAlignFile);
193
194 if( m_trtAlignDbSvc->writeStrawAlignTextFile(m_outputStrawAlignFile) != StatusCode::SUCCESS )
195 ATH_MSG_ERROR("Cannot write to file "<<m_outputStrawAlignFile);
196 else
197 ATH_MSG_INFO("Wrote final TRT Straw alignment constants into "<<m_outputStrawAlignFile);
198 }
199
200 return;
201}
void updateDB()
updates alignment constants in the DB

Member Data Documentation

◆ m_alignModuleTool

ToolHandle<Trk::IAlignModuleTool> InDet::TRTTrkAlignDBTool::m_alignModuleTool
private

Definition at line 85 of file TRTTrkAlignDBTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_logStream

std::ostream* Trk::ITrkAlignDBTool::m_logStream = nullptr
protectedinherited

logfile output stream

Definition at line 55 of file ITrkAlignDBTool.h.

◆ m_ntuple

TFile* InDet::TRTTrkAlignDBTool::m_ntuple
private

Definition at line 92 of file TRTTrkAlignDBTool.h.

◆ m_oldAlignFile

std::string InDet::TRTTrkAlignDBTool::m_oldAlignFile
private

Definition at line 78 of file TRTTrkAlignDBTool.h.

◆ m_oldStrawAlignFile

std::string InDet::TRTTrkAlignDBTool::m_oldStrawAlignFile
private

Definition at line 79 of file TRTTrkAlignDBTool.h.

◆ m_outputAlignFile

std::string InDet::TRTTrkAlignDBTool::m_outputAlignFile
private

Definition at line 76 of file TRTTrkAlignDBTool.h.

◆ m_outputStrawAlignFile

std::string InDet::TRTTrkAlignDBTool::m_outputStrawAlignFile
private

Definition at line 77 of file TRTTrkAlignDBTool.h.

◆ m_pixHelper

const PixelID* InDet::TRTTrkAlignDBTool::m_pixHelper
private

Definition at line 74 of file TRTTrkAlignDBTool.h.

◆ m_trtAlignDbSvc

ServiceHandle<ITRT_AlignDbSvc> InDet::TRTTrkAlignDBTool::m_trtAlignDbSvc
private

Definition at line 84 of file TRTTrkAlignDBTool.h.

◆ m_trtAlignLevel

int InDet::TRTTrkAlignDBTool::m_trtAlignLevel
private

Definition at line 88 of file TRTTrkAlignDBTool.h.

◆ m_trtAlignLevelBarrel

int InDet::TRTTrkAlignDBTool::m_trtAlignLevelBarrel
private

Definition at line 89 of file TRTTrkAlignDBTool.h.

◆ m_trtAlignLevelEndcaps

int InDet::TRTTrkAlignDBTool::m_trtAlignLevelEndcaps
private

Definition at line 90 of file TRTTrkAlignDBTool.h.

◆ m_trtGeoManager

ToolHandle<Trk::IGeometryManagerTool> InDet::TRTTrkAlignDBTool::m_trtGeoManager
private

Definition at line 86 of file TRTTrkAlignDBTool.h.

◆ m_trtHelper

const TRT_ID* InDet::TRTTrkAlignDBTool::m_trtHelper
private

Definition at line 73 of file TRTTrkAlignDBTool.h.

◆ m_updateConstants

bool InDet::TRTTrkAlignDBTool::m_updateConstants
private

Definition at line 82 of file TRTTrkAlignDBTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_writeOldConstants

bool InDet::TRTTrkAlignDBTool::m_writeOldConstants
private

Definition at line 81 of file TRTTrkAlignDBTool.h.

◆ m_writeTextFile

bool InDet::TRTTrkAlignDBTool::m_writeTextFile
private

Definition at line 80 of file TRTTrkAlignDBTool.h.


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