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 ActsTrk::DetectorType type=ActsTrk::DetectorType::UnDefined) const
 Returns all readout elements.
std::vector< MuonReadoutElement * > getAllReadoutElements (const ActsTrk::DetectorType type=ActsTrk::DetectorType::UnDefined)
 Returns all readout elements.
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 153 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

◆ MuonChamberSet

◆ MuonSectorSet

Constructor & Destructor Documentation

◆ MuonDetectorManager()

MuonGMR4::MuonDetectorManager::MuonDetectorManager ( )

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

155 : AthMessaging{"MuonDetectorManagerR4"} {
156 if (!m_idHelperSvc.retrieve().isSuccess()) {
157 THROW_EXCEPTION(__func__<< "() -- Failed to retrieve the Identifier service");
158 }
159 setName("MuonR4");
160}
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ ~MuonDetectorManager()

MuonGMR4::MuonDetectorManager::~MuonDetectorManager ( )

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

149 {
150#ifndef SIMULATIONBASE
151 m_secEnvelopes.clear();
152#endif
153}

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 196 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

196 {
197 const unsigned hash = msSectorIdHash(chSector->chamberIndex(), chSector->sector(), chSector->side());
198 ATH_MSG_DEBUG("Add new sector "<<(*chSector)<<", hash: "<<hash);
199 const auto [element, isNew] = m_envelopesById.insert(std::make_pair(hash, chSector.get()));
200 if (!isNew) {
201 THROW_EXCEPTION("Conflicting hash: "<<hash<<", inserted: \n"<<(*element->second)
202 <<",\n tried to insert:\n "<<(*chSector));
203 }
204 m_secEnvelopes.push_back(std::move(chSector));
205 }
#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 179 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

◆ clearTreeTops()

void MuonGMR4::MuonDetectorManager::clearTreeTops ( )

Clears all tree tops helds by the manager.

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

177{ m_treeTopVector.clear(); }

◆ getAllChambers()

MuonChamberSet MuonGMR4::MuonDetectorManager::getAllChambers ( ) const

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

230 {
231 MuonChamberSet chambers{};
232 std::ranges::for_each(m_secEnvelopes,
233 [&chambers](const ElementPtr_t<SpectrometerSector>& ms){
234 std::ranges::transform(ms->chambers(), std::back_inserter(chambers),
235 [](const SpectrometerSector::ChamberPtr& ch){
236 return ch.get();
237 });
238 });
239 return chambers;
240 }
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 ( const ActsTrk::DetectorType type = ActsTrk::DetectorType::UnDefined)

Returns all readout elements.

Parameters
typeThe detector type of readout elements to be fetched. If it is UnDefined all registered elements are fetched. Otherwise all of the specified muon technology

◆ getAllReadoutElements() [2/2]

std::vector< const MuonReadoutElement * > MuonGMR4::MuonDetectorManager::getAllReadoutElements ( const ActsTrk::DetectorType type = ActsTrk::DetectorType::UnDefined) const

Returns all readout elements.

Parameters
typeThe detector type of readout elements to be fetched. If it is UnDefined all registered elements are fetched. Otherwise all of the specified muon technology

◆ getAllSectors()

MuonSectorSet MuonGMR4::MuonDetectorManager::getAllSectors ( ) const

: Returns all MuonChambers associated with the readout geometry

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

227 {
228 return Acts::unpackConstSmartPointers(m_secEnvelopes);
229 }

◆ 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 223 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

223 {
224 return getReadoutElement(channelId)->chamber();
225 }
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 185 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

185 {
186 std::vector<ActsTrk::DetectorType> types{};
187 if (!m_mdtEles.empty()) types.push_back(ActsTrk::DetectorType::Mdt);
188 if (!m_tgcEles.empty()) types.push_back(ActsTrk::DetectorType::Tgc);
189 if (!m_rpcEles.empty()) types.push_back(ActsTrk::DetectorType::Rpc);
190 if (!m_sTgcEles.empty()) types.push_back(ActsTrk::DetectorType::sTgc);
191 if (!m_mmEles.empty()) types.push_back(ActsTrk::DetectorType::Mm);
192 return types;
193}
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 170 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

170 {
171 return m_treeTopVector.size();
172}

◆ 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 218 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

218 {
219 return getReadoutElement(channelId)->msSector();
220 }
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 206 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

208 {
209 const unsigned hash = msSectorIdHash(chIdx, sector, side);
210 EnvelopeMap_t::const_iterator itr = m_envelopesById.find(hash);
211 if (itr != m_envelopesById.end()) {
212 return itr->second;
213 }
214 ATH_MSG_WARNING("Failed to fetch valid envelope for "<<Muon::MuonStationIndex::chName(chIdx)
215 <<", sector: "<<sector<<", side: "<<side);
216 return nullptr;
217 }
#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 173 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

173 {
174 assert(i < m_treeTopVector.size());
175 return m_treeTopVector[i];
176}

◆ idHelperSvc()

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

Returns a pointer to the central MuonIdHelperSvc.

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

182 {
183 return m_idHelperSvc.get();
184}

◆ 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 247 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

248 {
249 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
250 const int complMl = refEle->multilayer() == 2 ? 1 : idHelper.multilayerMax(refEle->identify());
251 const Identifier complMlId = idHelper.multilayerID(refEle->identify(), complMl);
252 const unsigned mlHash =static_cast<unsigned>(m_idHelperSvc->detElementHash(complMlId));
254 if (mlHash >= detStore.size() || !detStore[mlHash]) {
255 return;
256 }
257 detStore[mlHash]->setComplementaryReadoutEle(refEle);
258 refEle->setComplementaryReadoutEle(detStore[mlHash].get());
259
260}
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 243 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonDetectorManager.cxx.

244 {
245 ATH_MSG_VERBOSE("No inter-linking for "<<ActsTrk::to_string(reEle->detectorType())<<" "<<detStore.size());
246}
#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 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}

◆ 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 148 of file MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h.

148 {"Muon::MuonIdHelperSvc/MuonIdHelperSvc",
149 "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: