ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGMR4::MuonDetectorManager Class Reference

#include <MuonDetectorManager.h>

Inheritance diagram for MuonGMR4::MuonDetectorManager:
Collaboration diagram for MuonGMR4::MuonDetectorManager:

Classes

struct  MSEnvelopeSorter
 Helper struct to ensure that the spectrometer sectors & chambers are sorted. More...

Public Types

using ChIndex = Muon::MuonStationIndex::ChIndex
template<class MuonDetectorType>
using ElementPtr_t = std::unique_ptr<MuonDetectorType>
 : Abrivation of the smart pointer holding the readout element
template<class MuonDetectorType>
using ElementStorage_t = std::vector<ElementPtr_t<MuonDetectorType>>
 : Abbrivation of the container holding all readout elements of a technology.
using MuonSectorSet = std::vector<const SpectrometerSector*>
using MuonChamberSet = std::vector<const Chamber*>

Public Member Functions

 MuonDetectorManager ()
 ~MuonDetectorManager ()
unsigned int getNumTreeTops () const override final
 Declaration of the readout element getters & setter function as described above.
PVConstLink getTreeTop (unsigned int i) const override final
 Returns the i-the tree top GeoModel volume.
void addTreeTop (PVConstLink pv)
 Adds a new GeoModelVolume with its children as a new top node of the muon system.
void clearTreeTops ()
 Clears all tree tops helds by the manager.
const Muon::IMuonIdHelperSvcidHelperSvc () const
 Returns a pointer to the central MuonIdHelperSvc.
std::vector< const MuonReadoutElement * > getAllReadoutElements () const
 Returns the list of all detector elements.
std::vector< MuonReadoutElement * > getAllReadoutElements ()
const MuonReadoutElementgetReadoutElement (const Identifier &id) const
 Returns a generic Muon readout element.
MuonReadoutElementgetReadoutElement (const Identifier &id)
void addSpectrometerSector (ElementPtr_t< SpectrometerSector > &&chSector)
 Add a spectrometer enevelope object to the manager.
const SpectrometerSectorgetSectorEnvelope (const Identifier &channelId) const
 Retrieves the spectrometer envelope enclosing the channel's readout element.
const SpectrometerSectorgetSectorEnvelope (const Muon::MuonStationIndex::ChIndex chIdx, const unsigned sector, const int side) const
 Retrieves the spectrometer envelope from a generic identifier as it's used by e.g., the xAOD::MuonSegment.
const ChambergetChamber (const Identifier &channelId) const
 Retrieves the chamber enclosing the channel's readout element.
MuonSectorSet getAllSectors () const
 : Returns all MuonChambers associated with the readout geometry
MuonChamberSet getAllChambers () const
std::vector< ActsTrk::DetectorTypegetDetectorTypes () const
 Returns a list of all detector types.
template<>
void linkElements (ElementStorage_t< MdtReadoutElement > &detStore, MdtReadoutElement *refEle)
template<>
void linkElements (ElementStorage_t< MdtReadoutElement > &detStore, MdtReadoutElement *refEle)
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 Types

using EnvelopeMap_t = std::unordered_map<unsigned, const SpectrometerSector*>
 Abbrivation to find the sector envelopes sorted by the generic MS identifier.

Private Member Functions

template<class MuonDetectorType>
void linkElements (ElementStorage_t< MuonDetectorType > &allStore, MuonDetectorType *readOutEle)
 Method that connects the same elements from the station with the parsed readout Element and vice versa.
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc
ElementStorage_t< SpectrometerSectorm_secEnvelopes {}
EnvelopeMap_t m_envelopesById {}
ElementStorage_t< MdtReadoutElementm_mdtEles {}
ElementStorage_t< TgcReadoutElementm_tgcEles {}
ElementStorage_t< RpcReadoutElementm_rpcEles {}
ElementStorage_t< sTgcReadoutElementm_sTgcEles {}
ElementStorage_t< MmReadoutElementm_mmEles {}
std::vector< PVConstLink > m_treeTopVector {}
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

Member Typedef Documentation

◆ ChIndex

◆ ElementPtr_t

template<class MuonDetectorType>
using MuonGMR4::MuonDetectorManager::ElementPtr_t = std::unique_ptr<MuonDetectorType>

: Abrivation of the smart pointer holding the readout element

Definition at line 70 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

◆ ElementStorage_t

template<class MuonDetectorType>
using MuonGMR4::MuonDetectorManager::ElementStorage_t = std::vector<ElementPtr_t<MuonDetectorType>>

: Abbrivation of the container holding all readout elements of a technology.

The index of the vector entry corresponds to the IdentifierHash of the readout element.

Definition at line 73 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

◆ EnvelopeMap_t

using MuonGMR4::MuonDetectorManager::EnvelopeMap_t = std::unordered_map<unsigned, const SpectrometerSector*>
private

Abbrivation to find the sector envelopes sorted by the generic MS identifier.

Definition at line 148 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

◆ MuonChamberSet

◆ MuonSectorSet

Constructor & Destructor Documentation

◆ MuonDetectorManager()

MuonGMR4::MuonDetectorManager::MuonDetectorManager ( )

Definition at line 137 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

138 : AthMessaging{"MuonDetectorManagerR4"} {
139 if (!m_idHelperSvc.retrieve().isSuccess()) {
140 THROW_EXCEPTION(__func__<< "() -- Failed to retrieve the Identifier service");
141 }
142 setName("MuonR4");
143}
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ ~MuonDetectorManager()

MuonGMR4::MuonDetectorManager::~MuonDetectorManager ( )

Definition at line 132 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

132 {
133#ifndef SIMULATIONBASE
134 m_secEnvelopes.clear();
135#endif
136}

Member Function Documentation

◆ addSpectrometerSector()

void MuonGMR4::MuonDetectorManager::addSpectrometerSector ( ElementPtr_t< SpectrometerSector > && chSector)

Add a spectrometer enevelope object to the manager.

Parameters
chSectorUnique_ptr to the sector

Definition at line 179 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

179 {
180 const unsigned hash = msSectorIdHash(chSector->chamberIndex(), chSector->sector(), chSector->side());
181 ATH_MSG_DEBUG("Add new sector "<<(*chSector)<<", hash: "<<hash);
182 const auto [element, isNew] = m_envelopesById.insert(std::make_pair(hash, chSector.get()));
183 if (!isNew) {
184 THROW_EXCEPTION("Conflicting hash: "<<hash<<", inserted: \n"<<(*element->second)
185 <<",\n tried to insert:\n "<<(*chSector));
186 }
187 m_secEnvelopes.push_back(std::move(chSector));
188 }
#define ATH_MSG_DEBUG(x)

◆ addTreeTop()

void MuonGMR4::MuonDetectorManager::addTreeTop ( PVConstLink pv)

Adds a new GeoModelVolume with its children as a new top node of the muon system.

Definition at line 162 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

◆ clearTreeTops()

void MuonGMR4::MuonDetectorManager::clearTreeTops ( )

Clears all tree tops helds by the manager.

Definition at line 160 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

160{ m_treeTopVector.clear(); }

◆ getAllChambers()

MuonChamberSet MuonGMR4::MuonDetectorManager::getAllChambers ( ) const

Definition at line 213 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

213 {
214 MuonChamberSet chambers{};
215 std::ranges::for_each(m_secEnvelopes,
216 [&chambers](const ElementPtr_t<SpectrometerSector>& ms){
217 std::ranges::transform(ms->chambers(), std::back_inserter(chambers),
218 [](const SpectrometerSector::ChamberPtr& ch){
219 return ch.get();
220 });
221 });
222 return chambers;
223 }
std::unique_ptr< MuonDetectorType > ElementPtr_t
: Abrivation of the smart pointer holding the readout element
GeoModel::TransientConstSharedPtr< Chamber > ChamberPtr

◆ getAllReadoutElements() [1/2]

std::vector< MuonReadoutElement * > MuonGMR4::MuonDetectorManager::getAllReadoutElements ( )

◆ getAllReadoutElements() [2/2]

std::vector< const MuonReadoutElement * > MuonGMR4::MuonDetectorManager::getAllReadoutElements ( ) const

Returns the list of all detector elements.

◆ getAllSectors()

MuonSectorSet MuonGMR4::MuonDetectorManager::getAllSectors ( ) const

: Returns all MuonChambers associated with the readout geometry

Definition at line 210 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

210 {
211 return Acts::unpackConstSmartPointers(m_secEnvelopes);
212 }

◆ getChamber()

const Chamber * MuonGMR4::MuonDetectorManager::getChamber ( const Identifier & channelId) const

Retrieves the chamber enclosing the channel's readout element.

Parameters
channelIdIdentifier of a muon channel of interest

Definition at line 206 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

206 {
207 return getReadoutElement(channelId)->chamber();
208 }
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Returns a generic Muon readout element.
const Chamber * chamber() const
Returns the pointer to the chamber enclosing this readout element.

◆ getDetectorTypes()

std::vector< ActsTrk::DetectorType > MuonGMR4::MuonDetectorManager::getDetectorTypes ( ) const

Returns a list of all detector types.

Definition at line 168 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

168 {
169 std::vector<ActsTrk::DetectorType> types{};
170 if (!m_mdtEles.empty()) types.push_back(ActsTrk::DetectorType::Mdt);
171 if (!m_tgcEles.empty()) types.push_back(ActsTrk::DetectorType::Tgc);
172 if (!m_rpcEles.empty()) types.push_back(ActsTrk::DetectorType::Rpc);
173 if (!m_sTgcEles.empty()) types.push_back(ActsTrk::DetectorType::sTgc);
174 if (!m_mmEles.empty()) types.push_back(ActsTrk::DetectorType::Mm);
175 return types;
176}
static const std::vector< std::string > types
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ sTgc
Micromegas (NSW)
@ Rpc
Monitored Drift Tubes.
@ Mdt
MuonSpectrometer.

◆ getNumTreeTops()

unsigned int MuonGMR4::MuonDetectorManager::getNumTreeTops ( ) const
finaloverride

Declaration of the readout element getters & setter function as described above.

Returns the number of tree top nodes describing the muon system

Definition at line 153 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

153 {
154 return m_treeTopVector.size();
155}

◆ getReadoutElement() [1/2]

MuonReadoutElement * MuonGMR4::MuonDetectorManager::getReadoutElement ( const Identifier & id)

◆ getReadoutElement() [2/2]

const MuonReadoutElement * MuonGMR4::MuonDetectorManager::getReadoutElement ( const Identifier & id) const

Returns a generic Muon readout element.

◆ getSectorEnvelope() [1/2]

const SpectrometerSector * MuonGMR4::MuonDetectorManager::getSectorEnvelope ( const Identifier & channelId) const

Retrieves the spectrometer envelope enclosing the channel's readout element.

Parameters
channelIdIdentifier of a muon channel of interest

Definition at line 201 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

201 {
202 return getReadoutElement(channelId)->msSector();
203 }
const SpectrometerSector * msSector() const
Returns the pointer to the envelope volume enclosing all chambers in the sector.

◆ getSectorEnvelope() [2/2]

const SpectrometerSector * MuonGMR4::MuonDetectorManager::getSectorEnvelope ( const Muon::MuonStationIndex::ChIndex chIdx,
const unsigned sector,
const int side ) const

Retrieves the spectrometer envelope from a generic identifier as it's used by e.g., the xAOD::MuonSegment.

Parameters
chIdxChamber index indicating where the envelope is residing (BIL, BIS, etc.)
sectorGlobal sector of the envelope (1-16)
sideInteger indicating whether, the envelope is in the positive or negative hemisphere

Definition at line 189 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

191 {
192 const unsigned hash = msSectorIdHash(chIdx, sector, side);
193 EnvelopeMap_t::const_iterator itr = m_envelopesById.find(hash);
194 if (itr != m_envelopesById.end()) {
195 return itr->second;
196 }
197 ATH_MSG_WARNING("Failed to fetch valid envelope for "<<Muon::MuonStationIndex::chName(chIdx)
198 <<", sector: "<<sector<<", side: "<<side);
199 return nullptr;
200 }
#define ATH_MSG_WARNING(x)
const std::string & chName(ChIndex index)
convert ChIndex into a string

◆ getTreeTop()

PVConstLink MuonGMR4::MuonDetectorManager::getTreeTop ( unsigned int i) const
finaloverride

Returns the i-the tree top GeoModel volume.

Definition at line 156 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

156 {
157 assert(i < m_treeTopVector.size());
158 return m_treeTopVector[i];
159}

◆ idHelperSvc()

const Muon::IMuonIdHelperSvc * MuonGMR4::MuonDetectorManager::idHelperSvc ( ) const

Returns a pointer to the central MuonIdHelperSvc.

Definition at line 165 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

165 {
166 return m_idHelperSvc.get();
167}

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

◆ linkElements() [1/3]

template<>
void MuonGMR4::MuonDetectorManager::linkElements ( ElementStorage_t< MdtReadoutElement > & detStore,
MdtReadoutElement * refEle )

◆ linkElements() [2/3]

template<>
void MuonGMR4::MuonDetectorManager::linkElements ( ElementStorage_t< MdtReadoutElement > & detStore,
MdtReadoutElement * refEle )

The complementary detector element has not yet been parsed.

Definition at line 230 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

231 {
232 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
233 const int complMl = refEle->multilayer() == 2 ? 1 : idHelper.multilayerMax(refEle->identify());
234 const Identifier complMlId = idHelper.multilayerID(refEle->identify(), complMl);
235 const unsigned mlHash =static_cast<unsigned>(m_idHelperSvc->detElementHash(complMlId));
237 if (mlHash >= detStore.size() || !detStore[mlHash]) {
238 return;
239 }
240 detStore[mlHash]->setComplementaryReadoutEle(refEle);
241 refEle->setComplementaryReadoutEle(detStore[mlHash].get());
242
243}
Identifier multilayerID(const Identifier &channeldID) const
static int multilayerMax()
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ linkElements() [3/3]

template<class MuonDetectorType>
void MuonGMR4::MuonDetectorManager::linkElements ( ElementStorage_t< MuonDetectorType > & allStore,
MuonDetectorType * readOutEle )
private

Method that connects the same elements from the station with the parsed readout Element and vice versa.

The way how they are inter-linked depends on the detector technology For the moment, only link Mdts from the same multilayer against each other.

Parameters
allStoreStorage of all detector element that are cached up to this point
readOutEleParticular readout element to link against the existing elements

Definition at line 226 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

227 {
228 ATH_MSG_VERBOSE("No inter-linking for "<<ActsTrk::to_string(reEle->detectorType())<<" "<<detStore.size());
229}
#define ATH_MSG_VERBOSE(x)
std::string to_string(const DetectorType &type)

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

EnvelopeMap_t MuonGMR4::MuonDetectorManager::m_envelopesById {}
private

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonGMR4::MuonDetectorManager::m_idHelperSvc
private
Initial value:
{"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
"MuonDetectorManager"}

Definition at line 143 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

143 {"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
144 "MuonDetectorManager"};

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

ElementStorage_t<MdtReadoutElement> MuonGMR4::MuonDetectorManager::m_mdtEles {}
private

◆ m_mmEles

ElementStorage_t<MmReadoutElement> MuonGMR4::MuonDetectorManager::m_mmEles {}
private

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

ElementStorage_t<RpcReadoutElement> MuonGMR4::MuonDetectorManager::m_rpcEles {}
private

◆ m_secEnvelopes

ElementStorage_t<SpectrometerSector> MuonGMR4::MuonDetectorManager::m_secEnvelopes {}
private

◆ m_sTgcEles

ElementStorage_t<sTgcReadoutElement> MuonGMR4::MuonDetectorManager::m_sTgcEles {}
private

◆ m_tgcEles

ElementStorage_t<TgcReadoutElement> MuonGMR4::MuonDetectorManager::m_tgcEles {}
private

◆ m_treeTopVector

std::vector<PVConstLink> MuonGMR4::MuonDetectorManager::m_treeTopVector {}
private

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