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

The Detector manager has methods to retrieve the Identifier helper and methods to retrieve the detector elements, as well as the relevant physical volumes. More...

#include <HGTD_DetectorManager.h>

Inheritance diagram for HGTD_DetectorManager:
Collaboration diagram for HGTD_DetectorManager:

Public Member Functions

 HGTD_DetectorManager (StoreGateSvc *detStore)
 Constructor.
 ~HGTD_DetectorManager ()
 Destructor.
virtual unsigned int getNumTreeTops () const override
 Access to raw geometry:
virtual PVConstLink getTreeTop (unsigned int i) const override
void addTreeTop (PVConstLink treeTop)
 Add a Tree top:
const InDetDD::HGTD_DetectorElementgetDetectorElement (const Identifier &id) const
 access to individual elements : via Identifier
const InDetDD::HGTD_DetectorElementgetDetectorElement (const IdentifierHash &idHash) const
 access to individual elements : via IdentifierHash
const InDetDD::HGTD_DetectorElementgetDetectorElement (int endcap, int layer, int phi_module, int eta_module) const
 access to individual elements : via element identification
const InDetDD::HGTD_DetectorElementCollectiongetDetectorElementCollection () const
 Get the collection of element that is held.
void addDetectorElement (InDetDD::HGTD_DetectorElement *element)
 Add elememts.
void addAlignableTransform (int level, const Identifier &id, GeoAlignableTransform *transform, const GeoVFullPhysVol *child)
 Register alignable transform.
bool setAlignableTransformDelta (int level, const Identifier &id, const Amg::Transform3D &delta, GeoVAlignmentStore *alignStore) const
 Apply alignment correction.
StatusCode align (const AlignableTransformContainer *container, GeoVAlignmentStore *alignStore) const
 Apply alignment constants from an AlignableTransformContainer.
void invalidateAll ()
 Invalidate cache for all detector elements.
void updateAll () const
 Update all caches.
void setCommonItems (std::unique_ptr< const InDetDD::SiCommonItems > &&commonItems)
 Set SiCommonItems.
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

const HGTD_DetectorManageroperator= (const HGTD_DetectorManager &right)
 Prevent copy and assignment.
 HGTD_DetectorManager (const HGTD_DetectorManager &right)
const HGTD_IDgetIdHelper () const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::vector< PVConstLink > m_volume
InDetDD::HGTD_DetectorElementCollection m_elementCollection
const HGTD_IDm_idHelper
std::vector< std::unique_ptr< InDetDD::ExtendedAlignableTransform > > m_alignableTransforms
std::unique_ptr< const InDetDD::SiCommonItemsm_commonItems
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

The Detector manager has methods to retrieve the Identifier helper and methods to retrieve the detector elements, as well as the relevant physical volumes.

Definition at line 42 of file HGTD_DetectorManager.h.

Constructor & Destructor Documentation

◆ HGTD_DetectorManager() [1/2]

HGTD_DetectorManager::HGTD_DetectorManager ( StoreGateSvc * detStore)

Constructor.

Definition at line 19 of file HGTD_DetectorManager.cxx.

20 : AthMessaging("HGTD_DetectorManager"),
21 m_idHelper(0)
22{
23 setName("HGTD");
24
25 //
26 // Initialize the Identifier helper
27 //
28 StatusCode sc = detStore->retrieve(m_idHelper,"HGTD_ID");
29 if (sc.isFailure() ) {
30 ATH_MSG_ERROR ("Could not retrieve HGTD id helper");
31 }
32
33 // Initialize the collections
34 if (m_idHelper) {
35 m_elementCollection.resize(m_idHelper->wafer_hash_max());
36 m_alignableTransforms.resize(m_idHelper->wafer_hash_max());
37 }
38 ATH_MSG_INFO("HGTD_DetectorManager initialized");
39}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static Double_t sc
AthMessaging()
Default constructor:
std::vector< std::unique_ptr< InDetDD::ExtendedAlignableTransform > > m_alignableTransforms
InDetDD::HGTD_DetectorElementCollection m_elementCollection
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ ~HGTD_DetectorManager()

HGTD_DetectorManager::~HGTD_DetectorManager ( )
default

Destructor.

◆ HGTD_DetectorManager() [2/2]

HGTD_DetectorManager::HGTD_DetectorManager ( const HGTD_DetectorManager & right)
private

Member Function Documentation

◆ addAlignableTransform()

void HGTD_DetectorManager::addAlignableTransform ( int level,
const Identifier & id,
GeoAlignableTransform * transform,
const GeoVFullPhysVol * child )

Register alignable transform.

Definition at line 96 of file HGTD_DetectorManager.cxx.

100{
101 (void)level;
102
103 if (!m_idHelper) return;
104
105 IdentifierHash idHash = m_idHelper->wafer_hash(id);
106
107 if (!idHash.is_valid()) {
108 ATH_MSG_WARNING("Invalid idHash for alignable transform");
109 return;
110 }
111
112 ATH_MSG_DEBUG("STORE ALIGNABLE:"
113 << " hash=" << idHash
114 << " transform ptr=" << transform
115 << " child ptr=" << child);
116
117 m_alignableTransforms[idHash] =
118 std::make_unique<InDetDD::ExtendedAlignableTransform>(transform, child);
119
120 ATH_MSG_DEBUG("Alignable container size = "
121 << m_alignableTransforms.size());
122
123 ATH_MSG_DEBUG("HGTD ALIGNABLE ADDED: idHash = " << idHash);
124
125 int count = 0;
126 for (const auto& t : m_alignableTransforms) {
127 if (t) count++;
128 }
129
130 ATH_MSG_DEBUG("HGTD alignable transforms registered: " << count);
131}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
constexpr bool is_valid() const
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148

◆ addDetectorElement()

void HGTD_DetectorManager::addDetectorElement ( InDetDD::HGTD_DetectorElement * element)

Add elememts.

Definition at line 84 of file HGTD_DetectorManager.cxx.

85{
86 IdentifierHash idHash = element->identifyHash();
87 if (idHash >= m_elementCollection.size()) {
88 throw std::runtime_error(
89 "HGTD_DetectorManager: Error adding detector element."
90 );
91 }
92 m_elementCollection[idHash] = element;
93}
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)

◆ addTreeTop()

void HGTD_DetectorManager::addTreeTop ( PVConstLink treeTop)

Add a Tree top:

Definition at line 53 of file HGTD_DetectorManager.cxx.

53 {
54 m_volume.push_back(vol);
55}
std::vector< PVConstLink > m_volume

◆ align()

StatusCode HGTD_DetectorManager::align ( const AlignableTransformContainer * container,
GeoVAlignmentStore * alignStore ) const

Apply alignment constants from an AlignableTransformContainer.

Definition at line 172 of file HGTD_DetectorManager.cxx.

175{
176 ATH_MSG_DEBUG("Applying HGTD alignment");
177
178 ATH_MSG_DEBUG("Entered align()");
179 if (!container) {
180 ATH_MSG_ERROR("Null AlignableTransformContainer");
181 return StatusCode::FAILURE;
182 }
183 ATH_MSG_DEBUG("Container pointer = " << container);
184 ATH_MSG_DEBUG("Container size = " << container->size());
185
186 if (container->empty()) {
187 ATH_MSG_WARNING("AlignableTransformContainer is empty");
188 return StatusCode::SUCCESS;
189 }
190
191 ATH_MSG_DEBUG("AlignableTransformContainer has "
192 << container->size()
193 << " AlignableTransform collection(s)");
194
195 // Use only the last tag of each AlignableTransform, exactly like InDet
196 std::map<std::string,const AlignableTransform*> transforms;
197
198 for (const auto* pat : *container) {
199
200 if (!pat) {
201 ATH_MSG_WARNING("Null AlignableTransform pointer");
202 continue;
203 }
204
205 ATH_MSG_DEBUG("--------------------------------");
206 ATH_MSG_DEBUG("Collection tag = " << pat->tag());
207 ATH_MSG_DEBUG("Collection size = " << pat->size());
208 transforms[pat->tag()] = pat;
209
210 }
211
212 for (const auto& entry : transforms) {
213
214 const AlignableTransform* transformCollection = entry.second;
215
216 ATH_MSG_DEBUG("Processing tag " << entry.first);
217
219 transformCollection->begin();
220 transIter != transformCollection->end();
221 ++transIter)
222 {
223
224 Identifier id = transIter->identify();
225
226 ATH_MSG_DEBUG("--------------------------------");
227 ATH_MSG_DEBUG("Identifier = " << id.get_compact());
228
229 Amg::Transform3D delta =
230 Amg::CLHEPTransformToEigen(transIter->transform());
231
232 ATH_MSG_DEBUG("Translation = ("
233 << delta.translation().x() << ", "
234 << delta.translation().y() << ", "
235 << delta.translation().z() << ")");
236
237 bool ok =
239 0,
240 id,
241 delta,
242 alignStore);
243
244 ATH_MSG_DEBUG("setAlignableTransformDelta returned "
245 << std::boolalpha << ok);
246
247 if (!ok) {
248 ATH_MSG_WARNING("Failed to apply alignment for identifier "
249 << id.get_compact());
250 }
251 }
252 }
253
254 return StatusCode::SUCCESS;
255}
std::vector< AlignTransMember >::const_iterator AlignTransMem_citr
AlignTransMem_citr end() const
AlignTransMem_citr begin() const
bool setAlignableTransformDelta(int level, const Identifier &id, const Amg::Transform3D &delta, GeoVAlignmentStore *alignStore) const
Apply alignment correction.
Amg::Transform3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
Eigen::Affine3d Transform3D
const SG::AuxVectorData * container() const
Return the container holding this element.

◆ getDetectorElement() [1/3]

const HGTD_DetectorElement * HGTD_DetectorManager::getDetectorElement ( const Identifier & id) const

access to individual elements : via Identifier

Definition at line 57 of file HGTD_DetectorManager.cxx.

58{
59 // Make sure it is a wafer Id
60 Identifier waferId = m_idHelper->wafer_id(id);
61 IdentifierHash idHash = m_idHelper->wafer_hash(waferId);
62 if (idHash.is_valid()) {
63 return m_elementCollection[idHash];
64 } else {
65 return 0;
66 }
67}

◆ getDetectorElement() [2/3]

const HGTD_DetectorElement * HGTD_DetectorManager::getDetectorElement ( const IdentifierHash & idHash) const

access to individual elements : via IdentifierHash

Definition at line 69 of file HGTD_DetectorManager.cxx.

70{
71 return m_elementCollection[idHash];
72}

◆ getDetectorElement() [3/3]

const HGTD_DetectorElement * HGTD_DetectorManager::getDetectorElement ( int endcap,
int layer,
int phi_module,
int eta_module ) const

access to individual elements : via element identification

Definition at line 74 of file HGTD_DetectorManager.cxx.

75{
76 return getDetectorElement(m_idHelper->wafer_id(endcap, layer, phi_module, eta_module));
77}
const InDetDD::HGTD_DetectorElement * getDetectorElement(const Identifier &id) const
access to individual elements : via Identifier

◆ getDetectorElementCollection()

const HGTD_DetectorElementCollection * HGTD_DetectorManager::getDetectorElementCollection ( ) const

Get the collection of element that is held.

Definition at line 79 of file HGTD_DetectorManager.cxx.

80{
81 return &m_elementCollection;
82}

◆ getIdHelper()

const HGTD_ID * HGTD_DetectorManager::getIdHelper ( ) const
private

Definition at line 257 of file HGTD_DetectorManager.cxx.

258{
259 return m_idHelper;
260}

◆ getNumTreeTops()

unsigned int HGTD_DetectorManager::getNumTreeTops ( ) const
overridevirtual

Access to raw geometry:

Definition at line 43 of file HGTD_DetectorManager.cxx.

44{
45 return m_volume.size();
46}

◆ getTreeTop()

PVConstLink HGTD_DetectorManager::getTreeTop ( unsigned int i) const
overridevirtual

Definition at line 48 of file HGTD_DetectorManager.cxx.

49{
50 return m_volume[i];
51}

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

◆ invalidateAll()

void HGTD_DetectorManager::invalidateAll ( )

Invalidate cache for all detector elements.

Definition at line 262 of file HGTD_DetectorManager.cxx.

263{
264 for (HGTD_DetectorElement* element : m_elementCollection) {
265 if (element) {
266 element->invalidate();
267 }
268 }
269}

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

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
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 182 of file AthMessaging.h.

183{ 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 user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ operator=()

const HGTD_DetectorManager & HGTD_DetectorManager::operator= ( const HGTD_DetectorManager & right)
private

Prevent copy and assignment.

◆ setAlignableTransformDelta()

bool HGTD_DetectorManager::setAlignableTransformDelta ( int level,
const Identifier & id,
const Amg::Transform3D & delta,
GeoVAlignmentStore * alignStore ) const

Apply alignment correction.

Definition at line 133 of file HGTD_DetectorManager.cxx.

137{
138 (void)level;
139
140 IdentifierHash idHash = m_idHelper->wafer_hash(id);
141
142 if (!idHash.is_valid()) return false;
143
144 ATH_MSG_DEBUG("idHash = " << idHash);
145
146 auto* transform = m_alignableTransforms[idHash].get();
147 ATH_MSG_DEBUG("RETRIEVE ALIGNABLE:"
148 << " hash=" << idHash
149 << " ext transform ptr=" << transform
150 << " geo alignable ptr="
151 << (transform ? transform->alignableTransform() : nullptr));
152
153 ATH_MSG_DEBUG("transform ptr = " << transform);
154
155 if (!transform){
156 ATH_MSG_ERROR("NO ALIGNABLE FOUND");
157 return false;
158 }
159 ATH_MSG_DEBUG("SETTING DELTA dx="
160 << delta.translation().x()
161 << " dy="
162 << delta.translation().y()
163 << " dz="
164 << delta.translation().z());
165
166 alignStore->setDelta(transform->alignableTransform(), delta);
167
168 return true;
169
170}
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ setCommonItems()

void HGTD_DetectorManager::setCommonItems ( std::unique_ptr< const InDetDD::SiCommonItems > && commonItems)

Set SiCommonItems.

Definition at line 280 of file HGTD_DetectorManager.cxx.

281{
282 m_commonItems = std::move(commonItems);
283}
std::unique_ptr< const InDetDD::SiCommonItems > m_commonItems

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

◆ updateAll()

void HGTD_DetectorManager::updateAll ( ) const

Update all caches.

Definition at line 271 of file HGTD_DetectorManager.cxx.

272{
273 for (const HGTD_DetectorElement* element : m_elementCollection) {
274 if (element) {
275 element->updateCache();
276 }
277 }
278}

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_alignableTransforms

std::vector<std::unique_ptr<InDetDD::ExtendedAlignableTransform> > HGTD_DetectorManager::m_alignableTransforms
private

Definition at line 120 of file HGTD_DetectorManager.h.

◆ m_commonItems

std::unique_ptr<const InDetDD::SiCommonItems> HGTD_DetectorManager::m_commonItems
private

Definition at line 122 of file HGTD_DetectorManager.h.

◆ m_elementCollection

InDetDD::HGTD_DetectorElementCollection HGTD_DetectorManager::m_elementCollection
private

Definition at line 116 of file HGTD_DetectorManager.h.

◆ m_idHelper

const HGTD_ID* HGTD_DetectorManager::m_idHelper
private

Definition at line 117 of file HGTD_DetectorManager.h.

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

◆ m_volume

std::vector<PVConstLink> HGTD_DetectorManager::m_volume
private

Definition at line 114 of file HGTD_DetectorManager.h.


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