ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

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

Private Attributes

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

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 }

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 }

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ 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 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ 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 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ 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_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

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

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
StoredAlignX
Definition: StoredAlignX.h:23
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
StoredPhysVol
Definition: StoredPhysVol.h:27
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
StoredPhysVol::getPhysVol
GeoFullPhysVol * getPhysVol()
Destructor.
Definition: StoredPhysVol.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
DetCondKeyTrans::getTransform
bool getTransform(const std::string &key, HepGeom::Transform3D &result) const
Definition: DetCondKeyTrans.cxx:14
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Amg::CLHEPTransformToEigen
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Definition: CLHEPtoEigenConverter.h:38
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
DEBUG
#define DEBUG
Definition: page_access.h:11
LArAlignHelper::m_alignNames
std::vector< std::string > m_alignNames
Definition: LArAlignHelper.h:34
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37