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

Helper class for applying LAr alignments either from LArDetectorToolNV or from LArAlignCondAlg. More...

#include <LArAlignHelper.h>

Inheritance diagram for LArAlignHelper:
Collaboration diagram for LArAlignHelper:

Public Member Functions

 LArAlignHelper ()
StatusCode applyAlignments (const ServiceHandle< StoreGateSvc > &detStore, const DetCondKeyTrans *detCondKeyTrans, GeoAlignmentStore *alignmentStore) const
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::vector< std::string > m_alignNames
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Helper class for applying LAr alignments either from LArDetectorToolNV or from LArAlignCondAlg.

Definition at line 24 of file LArAlignHelper.h.

Constructor & Destructor Documentation

◆ LArAlignHelper()

LArAlignHelper::LArAlignHelper ( )

Definition at line 15 of file LArAlignHelper.cxx.

16 : AthMessaging("LArAlignHelper")
17{
18}
AthMessaging()
Default constructor:

Member Function Documentation

◆ applyAlignments()

StatusCode LArAlignHelper::applyAlignments ( const ServiceHandle< StoreGateSvc > & detStore,
const DetCondKeyTrans * detCondKeyTrans,
GeoAlignmentStore * alignmentStore ) const

Definition at line 20 of file LArAlignHelper.cxx.

23{
24 ATH_MSG_DEBUG("Applying LAr Alignments to GeoModel");
25
26 // Special treatment for the HEC:
27 StoredAlignX *hec1AlxPos{nullptr};
28 StoredAlignX *hec2AlxPos{nullptr};
29 StoredAlignX *hec1AlxNeg{nullptr};
30 StoredAlignX *hec2AlxNeg{nullptr};
31 if (detStore->contains<StoredAlignX> ("HEC1_POS")) {
32 if (detStore->retrieve(hec1AlxPos,"HEC1_POS")!=StatusCode::SUCCESS) {
33 ATH_MSG_WARNING(" Unable to retrieve StoredAlignX for the key HEC1_POS");
34 }
35 }
36 if (detStore->contains<StoredAlignX> ("HEC1_NEG")) {
37 if (detStore->retrieve(hec1AlxNeg,"HEC1_NEG")!=StatusCode::SUCCESS) {
38 ATH_MSG_WARNING(" Unable to retrieve StoredAlignX for the key HEC1_NEG");
39 }
40 }
41 if (detStore->contains<StoredAlignX> ("HEC2_POS")) {
42 if (detStore->retrieve(hec2AlxPos,"HEC2_POS")!=StatusCode::SUCCESS) {
43 ATH_MSG_WARNING(" Unable to retrieve StoredAlignX for the key HEC2_POS");
44 }
45 }
46 if (detStore->contains<StoredAlignX> ("HEC2_NEG")) {
47 if (detStore->retrieve(hec2AlxNeg,"HEC2_NEG")!=StatusCode::SUCCESS) {
48 ATH_MSG_WARNING(" Unable to retrieve StoredAlignX for the key HEC2_NEG");
49 }
50 }
51 GeoAlignableTransform *hec1GatPos = hec1AlxPos ? hec1AlxPos->getAlignX(): nullptr;
52 GeoAlignableTransform *hec1GatNeg = hec1AlxPos ? hec1AlxNeg->getAlignX(): nullptr;
53 GeoAlignableTransform *hec2GatPos = hec2AlxPos ? hec2AlxPos->getAlignX(): nullptr;
54 GeoAlignableTransform *hec2GatNeg = hec2AlxPos ? hec2AlxNeg->getAlignX(): nullptr;
55
56 // Loop over align names and if a transform is present, then alter its delta
57 for(const std::string& alignName : m_alignNames) {
58 ATH_MSG_DEBUG("Working on align name " << alignName);
59 HepGeom::Transform3D newDelta;
60 // First try to retrieve StoredAlignX
61 if(detStore->contains<StoredAlignX>(alignName)) {
62 StoredAlignX* alignX{nullptr};
63 if(detStore->retrieve(alignX,alignName).isFailure()) {
64 ATH_MSG_ERROR(" Unable to retrieve StoredAlignX for the key " << alignName);
65 return StatusCode::FAILURE;
66 }
67
68 if(!alignX) {
69 ATH_MSG_ERROR("Null pointer to StoredAlignX for the key " << alignName);
70 return StatusCode::FAILURE;
71 }
72
73 GeoAlignableTransform* gat = alignX->getAlignX();
74 if(!gat) {
75 ATH_MSG_ERROR("Null pointer to GeoAlignableTransform for the key " << alignName);
76 return StatusCode::FAILURE;
77 }
78
79 // Check the existence of new delta in DetCondKeyTrans
80 if(detCondKeyTrans->getTransform(alignName,newDelta)) {
81 gat->setDelta(Amg::CLHEPTransformToEigen(newDelta),alignmentStore);
82 }
83 else {
84 gat->clearDelta(alignmentStore);
85 }
86 }
87 else if (alignName=="HEC_POS") {
88 if (hec1GatPos) {
89 if(detCondKeyTrans->getTransform(alignName,newDelta)) {
90 hec1GatPos->setDelta(Amg::CLHEPTransformToEigen(newDelta),alignmentStore);
91 }
92 else {
93 hec1GatPos->clearDelta(alignmentStore);
94 }
95 }
96 if (hec2GatPos) {
97 if(detCondKeyTrans->getTransform(alignName,newDelta)) {
98 hec2GatPos->setDelta(Amg::CLHEPTransformToEigen(newDelta),alignmentStore);
99 }
100 else {
101 hec2GatPos->clearDelta(alignmentStore);
102 }
103 }
104 }
105 else if (alignName=="HEC_NEG") {
106 if (hec1GatNeg) {
107 if(detCondKeyTrans->getTransform(alignName,newDelta)) {
108 hec1GatNeg->setDelta(Amg::CLHEPTransformToEigen(newDelta),alignmentStore);
109 }
110 else {
111 hec1GatNeg->clearDelta(alignmentStore);
112 }
113 }
114 if (hec2GatNeg) {
115 if(detCondKeyTrans->getTransform(alignName,newDelta)) {
116 hec2GatNeg->setDelta(Amg::CLHEPTransformToEigen(newDelta),alignmentStore);
117 }
118 else {
119 hec2GatNeg->clearDelta(alignmentStore);
120 }
121 }
122 }
123 else {
124 ATH_MSG_DEBUG(" No StoredAlignX for the key " << alignName);
125 }
126 } // Loop over Align Names
127
128 // Fill the caches of Full Physical Volumes
129 //
130 // !!! NB! The code assumes that StoredPhysVol-s are used only by LAr
131 // This has been true ever since the StorePhysVol-s were invented.
132 //
133 std::vector<std::string> keys;
134 detStore->keys<StoredPhysVol> (keys);
135 for(const std::string& key : keys) {
136 StoredPhysVol* storedPV = detStore->tryRetrieve<StoredPhysVol>(key);
137 ATH_MSG_DEBUG("Building position caches for StoredPhysVol :" << key);
138 if(storedPV) {
139 storedPV->getPhysVol()->getAbsoluteTransform(alignmentStore);
140 storedPV->getPhysVol()->getDefAbsoluteTransform(alignmentStore);
141 }
142 }
143
144 // Debug printout of global positions
145 if (msgLvl (MSG::DEBUG)) {
146 for(const std::string& alignName : m_alignNames) {
147 if(detStore->contains<StoredPhysVol>(alignName)) {
148 StoredPhysVol* storedPV{nullptr};
149 if(detStore->retrieve(storedPV,alignName).isSuccess()) {
150 const GeoIntrusivePtr<GeoFullPhysVol> fullPV = storedPV->getPhysVol();
151 const GeoTrf::Transform3D& xf = fullPV->getAbsoluteTransform(alignmentStore);
152 GeoTrf::Vector3D trans=xf.translation();
153 GeoTrf::RotationMatrix3D rot=xf.rotation();
154 ATH_MSG_DEBUG("Dump Absolute Transform: Key " << alignName
155 << " translation [" << trans.x() << "," << trans.y() << "," << trans.z()
156 << "] rotation (" << rot(0,0) << "," << rot(0,1) << "," << rot(0,2)
157 << "," << rot(1,0) << "," << rot(1,1) << "," << rot(1,2)
158 << "," << rot(2,0) << "," << rot(2,1) << "," << rot(2,2) << ")");
159 }
160 }
161 }
162 }
163
164 return StatusCode::SUCCESS;
165}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool msgLvl(const MSG::Level lvl) const
Test the output level.
bool getTransform(const std::string &key, HepGeom::Transform3D &result) const
std::vector< std::string > m_alignNames
GeoAlignableTransform * getAlignX()
GeoFullPhysVol * getPhysVol()
Destructor.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_alignNames

std::vector<std::string> LArAlignHelper::m_alignNames
private
Initial value:
{ "LARCRYO_B"
, "LARCRYO_EC_POS"
, "LARCRYO_EC_NEG"
, "PRESAMPLER_B_POS"
, "PRESAMPLER_B_NEG"
, "EMB_POS"
, "EMB_NEG"
, "PRESAMPLER_EC_POS"
, "PRESAMPLER_EC_NEG"
, "EMEC_POS"
, "EMEC_NEG"
, "HEC_POS"
, "HEC_NEG"
, "HEC1_POS"
, "HEC1_NEG"
, "HEC2_POS"
, "HEC2_NEG"
, "FCAL1_POS"
, "FCAL1_NEG"
, "FCAL2_POS"
, "FCAL2_NEG"
, "FCAL3_POS"
, "FCAL3_NEG"
, "SOLENOID"
}

Definition at line 34 of file LArAlignHelper.h.

34 { "LARCRYO_B"
35 , "LARCRYO_EC_POS"
36 , "LARCRYO_EC_NEG"
37 , "PRESAMPLER_B_POS"
38 , "PRESAMPLER_B_NEG"
39 , "EMB_POS"
40 , "EMB_NEG"
41 , "PRESAMPLER_EC_POS"
42 , "PRESAMPLER_EC_NEG"
43 , "EMEC_POS"
44 , "EMEC_NEG"
45 , "HEC_POS" // Policy: either HEC_POS is present or HEC1_POS and HEC2_POS. The same applies to HEC_NEG
46 , "HEC_NEG" // Now in recent releases if HEC_POS is found it will be applied to both HEC1 and HEC2...
47 , "HEC1_POS"
48 , "HEC1_NEG"
49 , "HEC2_POS"
50 , "HEC2_NEG"
51 , "FCAL1_POS"
52 , "FCAL1_NEG"
53 , "FCAL2_POS"
54 , "FCAL2_NEG"
55 , "FCAL3_POS"
56 , "FCAL3_NEG"
57 , "SOLENOID"
58 };

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.


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