36 using AllHelperArray = std::array<const MuonIdHelper*, 6>;
39 AllHelperArray::const_iterator itr = std::ranges::find_if(allHelpers,
41 if (itr == allHelpers.end()){
42 ATH_MSG_WARNING(
"No MuonIdHelper has been created before. Please do not setup the service if no muon layout is loaded");
43 return StatusCode::SUCCESS;
47 std::stringstream techStr{};
49 for (
int tech = 0; tech <=
m_primaryHelper->technologyNameIndexMax(); ++tech) {
58 techStr<<
", " << tech <<
" " << name;
62 unsigned int nstationsNames =
m_primaryHelper->stationNameIndexMax() + 1;
70 data.stationName = std::move(name);
75 if (
data.stationName[1] ==
'1')
76 data.chIndex = ChIdx::EML;
77 else if (
data.stationName[1] ==
'2')
78 data.chIndex = ChIdx::EML;
79 else if (
data.stationName[1] ==
'3')
80 data.chIndex = ChIdx::EML;
81 else if (
data.stationName[1] ==
'4')
82 data.chIndex = ChIdx::EIL;
84 if (
data.stationName[1] ==
'O') {
85 if (
data.stationName[2] ==
'L')
86 data.chIndex = ChIdx::EOL;
88 data.chIndex = ChIdx::EOS;
89 }
else if (
data.stationName[1] ==
'M') {
90 if (
data.stationName[2] ==
'L')
91 data.chIndex = ChIdx::EML;
93 data.chIndex = ChIdx::EMS;
94 }
else if (
data.stationName[1] ==
'I') {
95 if (
data.stationName[2] ==
'L')
96 data.chIndex = ChIdx::EIL;
98 data.chIndex = ChIdx::EIS;
99 }
else if (
data.stationName[1] ==
'E') {
100 if (
data.stationName[0] ==
'B') {
101 data.chIndex = ChIdx::BEE;
103 if (
data.stationName[2] ==
'L')
104 data.chIndex = ChIdx::EEL;
106 data.chIndex = ChIdx::EES;
108 }
else if (
data.stationName[0] ==
'C') {
109 if (
data.stationName[2] ==
'L')
110 data.chIndex = ChIdx::CSL;
112 data.chIndex = ChIdx::CSS;
114 if (
data.stationName[0] ==
'S' ||
data.stationName[0] ==
'M') {
116 data.chIndex = ChIdx::EIS;
118 data.chIndex = ChIdx::EIL;
122 if (
data.stationName[1] ==
'O') {
123 if (
data.stationName[2] ==
'L')
124 data.chIndex = ChIdx::BOL;
126 data.chIndex = ChIdx::BOS;
127 }
else if (
data.stationName[1] ==
'M') {
128 if (
data.stationName[2] ==
'L' ||
data.stationName[2] ==
'E')
129 data.chIndex = ChIdx::BML;
131 data.chIndex = ChIdx::BMS;
132 }
else if (
data.stationName[1] ==
'I') {
133 if (
data.stationName[2] ==
'L' ||
data.stationName[2] ==
'M' ||
data.stationName[2] ==
'R')
134 data.chIndex = ChIdx::BIL;
136 data.chIndex = ChIdx::BIS;
139 if (
data.chIndex == ChIdx::ChUnknown) {
140 ATH_MSG_ERROR(
"data.chIndex is negative in MuonIdHelperSvc::initialize ");
141 return StatusCode::FAILURE;
145 if (msgLvl(MSG::DEBUG)) {
146 msg(MSG::DEBUG) <<
"Adding station " << i <<
" " <<
data.stationName <<
" ";
148 msg(MSG::DEBUG) <<
" Endcap, ";
150 msg(MSG::DEBUG) <<
" Barrel, ";
152 msg(MSG::DEBUG) <<
" Small, ";
154 msg(MSG::DEBUG) <<
" Large, ";
179 std::ranges::for_each(allHelpers, [
this](
const MuonIdHelper* idHelper){
180 if (!idHelper)
return;
184 if (idx == StIndex::StUnknown)
continue;
191 return StatusCode::SUCCESS;
239 const std::set<TechnologyIndex>&
270 if (!
id.is_valid() || !
isMuon(
id)) {
272 return ChIdx::ChUnknown;
278 if (!
id.is_valid() || !
isMuon(
id)) {
280 return StIdx::StUnknown;
287 if (!
id.is_valid() || !
isMuon(
id)) {
289 return PhiIdx::PhiUnknown;
293 return PhiIdx::PhiUnknown;
298 return m_rpcIdHelper->doubletR(
id) == 1 ? PhiIdx::BI1 : PhiIdx::BI2;
299 }
case StIndex::BM: {
300 return m_rpcIdHelper->doubletR(
id) == 1 ? PhiIdx::BM1 : PhiIdx::BM2;
301 }
case StIndex::BO: {
302 return m_rpcIdHelper->doubletR(
id) == 1 ? PhiIdx::BO1 : PhiIdx::BO2;
303 }
case StIndex::EI: {
310 return m_stgcIdHelper->multilayer(
id) == 1 ? PhiIdx::STGC1 : PhiIdx::STGC2;
315 }
case StIndex::EM: {
317 if (chamberName[1] ==
'1') {
319 }
else if (chamberName[1] ==
'2') {
327 return PhiIdx::PhiUnknown;
331 if (
isEndcap(
id))
return stationEta(
id) < 0 ? DetectorRegionIndex::EndcapC : DetectorRegionIndex::EndcapA;
332 return DetectorRegionIndex::Barrel;
340 if (
isMdt(
id))
return TechIdx::MDT;
341 else if (
issTgc(
id))
return TechIdx::STGC;
342 else if (
isMM(
id))
return TechIdx::MM;
343 else if (
isTgc(
id))
return TechIdx::TGC;
344 else if (
isRpc(
id))
return TechIdx::RPC;
345 else if (
isCsc(
id))
return TechIdx::CSC;
346 return TechIdx::TechnologyUnknown;
349 if (!
id.is_valid())
return " Invalid Identifier";
367 channelType == sTgcType::Strip ?
"eta" : channelType == sTgcType::Wire ?
"phi" :
"pad" ,
390 if (!
id.is_valid()) {
391 return " Invalid Identifier";
417 return "Invalid detector element";
424 return std::format(
"{:} lay {:1d} tube {:1d}",
toStringDetEl(
id),
436 return "invalid gas gap Id";
529 auto initTgcSectorMapping = [&]() -> std::vector<int>* {
530 std::vector<int>* mapping =
nullptr;
531 StatusCode
sc =
m_detStore->retrieve(mapping,
"TGC_SectorMapping");
532 if (
sc.isFailure() || !mapping) {
536 ATH_MSG_DEBUG(
"sector: retrieve TGC sector mapping " << mapping->size());
539 static const std::vector<int> tgcSectorMapping = *initTgcSectorMapping();
543 if (hash >= tgcSectorMapping.size()) {
547 return tgcSectorMapping[hash];
633 #define IMPL_FIELDGETTER(fieldName, retType) \
634 retType MuonIdHelperSvc::fieldName(const Identifier& id) const { \
635 switch (technologyIndex(id)) { \
636 using enum TechnologyIndex; \
638 return m_mdtIdHelper->fieldName(id); \
640 return m_rpcIdHelper->fieldName(id); \
642 return m_tgcIdHelper->fieldName(id); \
644 return m_cscIdHelper->fieldName(id); \
646 return m_stgcIdHelper->fieldName(id); \
648 return m_mmIdHelper->fieldName(id); \
660 #undef IMPL_FIELDGETTER
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
bool isValid() const
Test to see if the link can be dereferenced.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
#define IMPL_FIELDGETTER(fieldName, retType)
Header file for AthHistogramAlgorithm.
This is a "hash" representation of an Identifier.
static int stationEtaMax(bool barrel)
static int stationEtaMin(bool barrel)
Access to min and max of level ranges.
const_id_iterator module_end() const
const_id_iterator module_begin() const
Iterators over full set of ids.
virtual int get_detectorElement_hash(const Identifier &id, IdentifierHash &hash_id) const
static const std::string BAD_NAME
virtual int get_module_hash(const Identifier &id, IdentifierHash &hash_id) const
size_type module_hash_max() const
the maximum hash value
size_type detectorElement_hash_max() const
virtual StatusCode initialize() override
AlgTool initilize.
virtual bool isMM(const Identifier &id) const override
returns whether this is a MM Identifier or not
virtual int stationName(const Identifier &id) const override
Return stationName for all technologies.
const TgcIdHelper * m_tgcIdHelper
virtual std::string chamberNameString(const Identifier &id) const override
print chamber name to string
const MdtIdHelper * m_mdtIdHelper
virtual Identifier detElId(const Identifier &id) const override
create a detector element ID
virtual bool isTgc(const Identifier &id) const override
returns whether this is a TGC Identifier or not
virtual MuonStationIndex::TechnologyIndex technologyIndex(const Identifier &id) const override
calculate layer index from Identifier
virtual IdentifierHash detElementHash(const Identifier &id) const override
Returns the detector element hash associated to an Identifier.
virtual bool isMdt(const Identifier &id) const override
returns whether this is a MDT Identifier or not
ServiceHandle< StoreGateSvc > m_detStore
bool hasCSC() const override
virtual int gasGap(const Identifier &id) const override
returns gas gap: gasGap for RPC + TGC, wireLayer for CSC, tube for MDT
virtual MuonStationIndex::DetectorRegionIndex regionIndex(const Identifier &id) const override
calculate detector region index from Identifier
Gaudi::Property< bool > m_hasMDT
virtual std::string toStringGasGap(const Identifier &id) const override
print all fields up to gas gap to string
virtual bool measuresPhi(const Identifier &id) const override
returns whether channel measures phi or not
std::unordered_set< Identifier > m_smdt_stat
virtual bool issTgc(const Identifier &id) const override
returns whether this is a sTGC Identifier or not
virtual bool issMdt(const Identifier &id) const override
returns whether this is a sMDT Identifier or not
bool hasMDT() const override
virtual std::string toStringDetEl(const Identifier &id) const override
print all fields up to detector element to string
Gaudi::Property< bool > m_hasMM
std::vector< TechIdx > m_technologies
virtual std::string toStringChamber(const Identifier &id) const override
print all fields up to chamber to string
virtual bool isSmallChamber(const Identifier &id) const override
returns whether this is a small chamber, always returns true for TGCs
MuonStationIndex::TechnologyIndex TechIdx
virtual int stationEta(const Identifier &id) const override
Return stationEta for all technologies.
const RpcIdHelper * m_rpcIdHelper
Sub detector specific IdHelpers.
virtual std::string toString(const Identifier &id) const override
print all fields to string
virtual int stationPhi(const Identifier &id) const override
Return stationPhi for all technologies.
const sTgcIdHelper * m_stgcIdHelper
virtual MuonStationIndex::ChIndex chamberIndex(const Identifier &id) const override
calculate chamber index from Identifier
virtual const std::set< MuonStationIndex::TechnologyIndex > & technologiesInStation(MuonStationIndex::StIndex stIndex) const override
Recieve all technologies in a station.
bool hasSTGC() const override
virtual MuonStationIndex::PhiIndex phiIndex(const Identifier &id) const override
calculate phi index from Identifier (not supported for MDT hits)
virtual std::string toStringTech(const Identifier &id) const override
print all fields up to technology to string
const MmIdHelper * m_mmIdHelper
const MuonIdHelper * m_primaryHelper
std::array< std::set< TechIdx >, static_cast< int >(StIdx::StIndexMax)> m_techPerStation
Array holding which technologies are there per station.
Gaudi::Property< bool > m_hasRPC
virtual bool isTrigger(const Identifier &id) const override
returns whether trigger chamber id or not
std::vector< StationNameData > m_stationNameData
bool hasMM() const override
virtual Identifier gasGapId(const Identifier &id) const override
create a gasGap ID (will return layer Id for MDTs)
virtual bool isRpc(const Identifier &id) const override
returns whether this is a RPC Identifier or not
Gaudi::Property< bool > m_hasSTGC
Gaudi::Property< bool > m_hasTGC
bool hasRPC() const override
virtual bool isEndcap(const Identifier &id) const override
returns whether this is an endcap Identifier or not
const CscIdHelper * m_cscIdHelper
virtual MuonStationIndex::StIndex stationIndex(const Identifier &id) const override
calculate station index from Identifier
virtual bool isCsc(const Identifier &id) const override
returns whether this is a CSC Identifier or not
virtual std::string toStringStation(const Identifier &id) const override
print all fields up to stationName to string
virtual std::string stationNameString(const Identifier &id) const override
Return the station name string for all technologies.
Gaudi::Property< bool > m_hasCSC
virtual bool isMuon(const Identifier &id) const override
returns whether this is a Muon Identifier or not
virtual MuonStationIndex::LayerIndex layerIndex(const Identifier &id) const override
calculate layer index from Identifier
virtual Identifier layerId(const Identifier &id) const override
create a layer ID, returns tube id for the MDTs
virtual bool hasHPTDC(const Identifier &id) const override
returns whether this Identifier belongs to an MDT with HPTDC or not NOTE that in Run4,...
virtual int sector(const Identifier &id) const override
return sector number 1-16, odd=large, even=small
virtual Identifier chamberId(const Identifier &id) const override
create a chamber ID
virtual IdentifierHash moduleHash(const Identifier &id) const override
Returns the module hash associated to an Identifier.
bool hasTGC() const override
StIndex
enum to classify the different station layers in the muon spectrometer
TechnologyIndex
enum to classify the different layers in the muon spectrometer
DetectorRegionIndex
enum to classify the different layers in the muon spectrometer
PhiIndex
enum to classify the different phi layers in the muon spectrometer
StIndex toStationIndex(ChIndex index)
convert ChIndex into StIndex
constexpr int toInt(const EnumType enumVal)
LayerIndex
enum to classify the different layers in the muon spectrometer
const std::string & stName(StIndex index)
convert StIndex into a string
const std::string & technologyName(TechnologyIndex index)
convert LayerIndex into a string
const std::string & chName(ChIndex index)
convert ChIndex into a string
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.