16 base_class(name, svc) {}
28 using AllHelperArray = std::array<const MuonIdHelper*, 6>;
31 AllHelperArray::const_iterator itr = std::ranges::find_if(allHelpers,
33 if (itr == allHelpers.end()){
34 ATH_MSG_WARNING(
"No MuonIdHelper has been created before. Please do not setup the service if no muon layout is loaded");
35 return StatusCode::SUCCESS;
39 std::stringstream techStr{};
41 for (
int tech = 0; tech <=
m_primaryHelper->technologyNameIndexMax(); ++tech) {
50 techStr<<
", " << tech <<
" " << name;
54 unsigned int nstationsNames =
m_primaryHelper->stationNameIndexMax() + 1;
62 data.stationName = std::move(name);
67 if (
data.stationName[1] ==
'1')
68 data.chIndex = ChIdx::EML;
69 else if (
data.stationName[1] ==
'2')
70 data.chIndex = ChIdx::EML;
71 else if (
data.stationName[1] ==
'3')
72 data.chIndex = ChIdx::EML;
73 else if (
data.stationName[1] ==
'4')
74 data.chIndex = ChIdx::EIL;
76 if (
data.stationName[1] ==
'O') {
77 if (
data.stationName[2] ==
'L')
78 data.chIndex = ChIdx::EOL;
80 data.chIndex = ChIdx::EOS;
81 }
else if (
data.stationName[1] ==
'M') {
82 if (
data.stationName[2] ==
'L')
83 data.chIndex = ChIdx::EML;
85 data.chIndex = ChIdx::EMS;
86 }
else if (
data.stationName[1] ==
'I') {
87 if (
data.stationName[2] ==
'L')
88 data.chIndex = ChIdx::EIL;
90 data.chIndex = ChIdx::EIS;
91 }
else if (
data.stationName[1] ==
'E') {
92 if (
data.stationName[0] ==
'B') {
93 data.chIndex = ChIdx::BEE;
95 if (
data.stationName[2] ==
'L')
96 data.chIndex = ChIdx::EEL;
98 data.chIndex = ChIdx::EES;
100 }
else if (
data.stationName[0] ==
'C') {
101 if (
data.stationName[2] ==
'L')
102 data.chIndex = ChIdx::CSL;
104 data.chIndex = ChIdx::CSS;
106 if (
data.stationName[0] ==
'S' ||
data.stationName[0] ==
'M') {
108 data.chIndex = ChIdx::EIS;
110 data.chIndex = ChIdx::EIL;
114 if (
data.stationName[1] ==
'O') {
115 if (
data.stationName[2] ==
'L')
116 data.chIndex = ChIdx::BOL;
118 data.chIndex = ChIdx::BOS;
119 }
else if (
data.stationName[1] ==
'M') {
120 if (
data.stationName[2] ==
'L' ||
data.stationName[2] ==
'E')
121 data.chIndex = ChIdx::BML;
123 data.chIndex = ChIdx::BMS;
124 }
else if (
data.stationName[1] ==
'I') {
125 if (
data.stationName[2] ==
'L' ||
data.stationName[2] ==
'M' ||
data.stationName[2] ==
'R')
126 data.chIndex = ChIdx::BIL;
128 data.chIndex = ChIdx::BIS;
131 if (
data.chIndex == ChIdx::ChUnknown) {
132 ATH_MSG_ERROR(
"data.chIndex is negative in MuonIdHelperSvc::initialize ");
133 return StatusCode::FAILURE;
137 if (msgLvl(MSG::DEBUG)) {
138 msg(MSG::DEBUG) <<
"Adding station " << i <<
" " <<
data.stationName <<
" ";
140 msg(MSG::DEBUG) <<
" Endcap, ";
142 msg(MSG::DEBUG) <<
" Barrel, ";
144 msg(MSG::DEBUG) <<
" Small, ";
146 msg(MSG::DEBUG) <<
" Large, ";
171 std::ranges::for_each(allHelpers, [
this](
const MuonIdHelper* idHelper){
172 if (!idHelper)
return;
176 if (idx == StIndex::StUnknown)
continue;
183 return StatusCode::SUCCESS;
189 }
else if (
isTgc(
id)) {
191 }
else if (
isCsc(
id)) {
195 }
else if (
isMM(
id)) {
227 const std::set<TechnologyIndex>&
252 }
else if (
isTgc(
id)) {
254 }
else if (
isCsc(
id)) {
272 if (!
id.is_valid() || !
isMuon(
id)) {
274 return ChIdx::ChUnknown;
280 if (!
id.is_valid() || !
isMuon(
id)) {
282 return StIdx::StUnknown;
288 if (!
id.is_valid() || !
isMuon(
id)) {
290 return PhiIdx::PhiUnknown;
294 return PhiIdx::PhiUnknown;
298 if (stIndex == StIdx::BI) {
300 }
else if (stIndex == StIdx::BM) {
302 }
else if (stIndex == StIdx::BO) {
304 }
else if (stIndex == StIdx::EI) {
307 }
else if (
isTgc(
id)) {
310 index = PhiIdx::STGC1;
312 index = PhiIdx::STGC2;
314 }
else if (stIndex == StIdx::EM) {
316 if (chamberName[1] ==
'1')
318 else if (chamberName[1] ==
'2')
327 if (
isEndcap(
id))
return stationEta(
id) < 0 ? DetectorRegionIndex::EndcapC : DetectorRegionIndex::EndcapA;
328 return DetectorRegionIndex::Barrel;
336 if (
isMdt(
id))
return TechIdx::MDT;
337 else if (
isCsc(
id))
return TechIdx::CSC;
338 else if (
isTgc(
id))
return TechIdx::TGC;
339 else if (
isRpc(
id))
return TechIdx::RPC;
340 else if (
issTgc(
id))
return TechIdx::STGC;
341 else if (
isMM(
id))
return TechIdx::MM;
342 return TechIdx::TechnologyUnknown;
345 if (!
id.is_valid())
return " Invalid Identifier";
349 const std::string_view phiStr{
measuresPhi(
id) ?
"phi" :
"eta"};
352 }
else if (
isTgc(
id)) {
354 }
else if (
isCsc(
id)) {
356 }
else if (
isMM(
id)) {
362 channelType == sTgcType::Strip ?
"eta" : channelType == sTgcType::Wire ?
"phi" :
"pad" ,
379 if (!
id.is_valid()) {
380 return " Invalid Identifier";
390 if (!
id.is_valid())
return " Invalid Identifier";
393 }
else if (
isRpc(
id)) {
395 }
else if (
isTgc(
id)) {
401 }
else if (
isMM(
id)) {
410 if (!
id.is_valid())
return " Invalid Identifier";
424 }
else if (
isRpc(
id)) {
426 }
else if (
isMM(
id)) {
430 }
else if (
isCsc(
id)) {
432 }
else if (
isMdt(
id)) {
442 }
else if (
isRpc(
id)) {
444 }
else if (
isCsc(
id)) {
448 }
else if (
isMM(
id)) {
458 }
else if (
isRpc(
id)) {
461 }
else if (
isCsc(
id)) {
464 }
else if (
isMM(
id)) {
479 }
else if (
isRpc(
id)) {
483 }
else if (
isCsc(
id)) {
485 }
else if (
isMM(
id)) {
497 if (!
id.is_valid()) {
503 }
else if (
isTgc(
id)) {
505 }
else if (
isMdt(
id)) {
507 }
else if (
isCsc(
id)) {
511 }
else if (
isMM(
id)) {
518 if (!
id.is_valid()) {
524 }
else if (
isTgc(
id)) {
526 }
else if (
isMdt(
id)) {
528 }
else if (
isCsc(
id)) {
532 }
else if (
isMM(
id)) {
539 if (!
id.is_valid()) {
545 }
else if (
isTgc(
id)) {
547 }
else if (
isMdt(
id)) {
549 }
else if (
isCsc(
id)) {
553 }
else if (
isMM(
id)) {
560 if (!
id.is_valid()) {
566 }
else if (
isTgc(
id)) {
568 }
else if (
isMdt(
id)) {
570 }
else if (
isCsc(
id)) {
574 }
else if (
isMM(
id)) {
583 auto initTgcSectorMapping = [&]() -> std::vector<int>* {
584 std::vector<int>* mapping =
nullptr;
585 StatusCode
sc =
m_detStore->retrieve(mapping,
"TGC_SectorMapping");
586 if (
sc.isFailure() || !mapping) {
590 ATH_MSG_DEBUG(
"sector: retrieve TGC sector mapping " << mapping->size());
593 static const std::vector<int> tgcSectorMapping = *initTgcSectorMapping();
597 if (hash >= tgcSectorMapping.size()) {
601 return tgcSectorMapping[hash];
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
char data[hepevt_bytes_allocation_ATLAS]
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
MuonStationIndex::PhiIndex PhiIdx
virtual StatusCode initialize() override
AlgTool initilize.
virtual bool isMM(const Identifier &id) const override
returns whether this is a MM Identifier or not
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
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
virtual int stationRegion(const Identifier &id) const override
Return stationRegion for all technologies.
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
MuonStationIndex::StIndex StIdx
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
virtual int stationName(const Identifier &id) const override
Return stationName for all technologies.
MuonStationIndex::TechnologyIndex TechIdx
const RpcIdHelper * m_rpcIdHelper
Sub detector specific IdHelpers.
virtual std::string toString(const Identifier &id) const override
print all fields to string
virtual bool measuresPhi(const Identifier &id) const override
returns whether channel measures phi or not
const sTgcIdHelper * m_stgcIdHelper
virtual MuonStationIndex::ChIndex chamberIndex(const Identifier &id) const override
calculate chamber index from Identifier
virtual std::string stationNameString(const Identifier &id) const override
Return the station name string for all technologies.
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
virtual int stationPhi(const Identifier &id) const override
Return stationPhi for all technologies.
const MuonIdHelper * m_primaryHelper
std::array< std::set< TechIdx >, static_cast< int >(StIdx::StIndexMax)> m_techPerStation
Array holding which technologies are there per station.
virtual int stationEta(const Identifier &id) const override
Return stationEta for all technologies.
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)
MuonIdHelperSvc(const std::string &name, ISvcLocator *svc)
default AlgService constructor
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
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)
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
LayerIndex
enum to classify the different layers in the muon spectrometer
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.