ATLAS Offline Software
Loading...
Searching...
No Matches
Nsw_CablingMap.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7std::ostream& operator<<(std::ostream& ostr,
8 const NswZebraData& connector) {
9 ostr << "First channel: " << connector.firstChannel
10 << ", last channel: " << connector.lastChannel
11 << " shift: " << connector.shiftChannel;
12 return ostr;
13}
14
15
18
19std::optional<Identifier> Nsw_CablingMap::correctChannel(const Identifier& id,
20 MsgStream& msg) const {
21 bool debug = msg.level() <= MSG::DEBUG;
22
23 const MmIdHelper& mmHelper{m_idHelperSvc->mmIdHelper()};
24 const sTgcIdHelper& sTgcHelper{m_idHelperSvc->stgcIdHelper()};
25 LookUpMap::const_iterator itr = m_cablingMap.find(m_idHelperSvc->layerId(id));
26 if (itr == m_cablingMap.end()) {
27 if (debug)
28 msg << MSG::DEBUG << "The gas gap " << m_idHelperSvc->toString(id)
29 << " has no known cabling correction" << endmsg;
30 return std::make_optional<Identifier>(id);
31 }
32 const NswZebraSet& correctionSet{itr->second};
33 const int channel = m_idHelperSvc->isMM(id) ? mmHelper.channel(id) :
34 sTgcHelper.channel(id);
35 NswZebraSet::const_iterator zebra_conn = correctionSet.find(channel);
36 if (zebra_conn == correctionSet.end()) {
37 if (debug)
38 msg << MSG::DEBUG << "The zebra connector associated to "
39 << m_idHelperSvc->toString(id)
40 << " was mounted correctly -> no correction needed " << endmsg;
41 return std::make_optional<Identifier>(id);
42 }
43 const int newChannel = channel + zebra_conn->shiftChannel;
44 if (newChannel < zebra_conn->firstChannel ||
45 newChannel > zebra_conn->lastChannel) {
46 if (debug)
47 msg << MSG::DEBUG << "The associated channel "
48 << m_idHelperSvc->toString(id)
49 << " is shifted outside of the zebra connector range: "
50 << newChannel << ". Mask the channel." << endmsg;
51 return std::nullopt;
52 }
53 if (m_idHelperSvc->isMM(id)) {
54 const Identifier newId = mmHelper.channelID(id,
55 mmHelper.multilayer(id),
56 mmHelper.gasGap(id),
57 newChannel);
58 if (debug)
59 msg << MSG::DEBUG << "The input identifier "
60 << m_idHelperSvc->toString(id) << " is shifted to a new one "
61 << m_idHelperSvc->toString(newId) << endmsg;
62 return std::make_optional<Identifier>(std::move(newId));
63 }
64 const Identifier newId = sTgcHelper.channelID(id,
65 sTgcHelper.multilayer(id),
66 sTgcHelper.gasGap(id),
67 sTgcHelper.channelType(id),
68 newChannel);
69 if (debug)
70 msg << MSG::DEBUG << "The input identifier "
71 << m_idHelperSvc->toString(id) << " is shifted to a new one "
72 << m_idHelperSvc->toString(newId) << endmsg;
73
74 return std::make_optional<Identifier>(std::move(newId));
75}
77 const NswZebraData& connector,
78 MsgStream& msg) {
79 if (connector.firstChannel >= connector.lastChannel ||
80 !connector.shiftChannel) {
81 msg << MSG::ERROR << "Invalid zebra definition has been parsed for "
82 << m_idHelperSvc->toString(gapID) << ". " << connector << endmsg;
83 return false;
84 }
85 NswZebraSet& correctionSet = m_cablingMap[gapID];
86 if (correctionSet.count(connector.firstChannel) ||
87 correctionSet.count(connector.lastChannel)) {
88 msg << MSG::ERROR << "Zebra " << m_idHelperSvc->toString(gapID)
89 << " is already partially covered " << connector << endmsg;
90 return false;
91 }
92 msg << MSG::DEBUG << "Add new zebra connector " << connector << " to "
93 << m_idHelperSvc->toString(gapID) << "." << endmsg;
94 correctionSet.insert(connector);
95 return true;
96}
#define endmsg
const bool debug
std::set< NswZebraData, std::less<> > NswZebraSet
std::ostream & operator<<(std::ostream &ostr, const NswZebraData &connector)
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Nsw_CablingMap(const Muon::IMuonIdHelperSvc *svc)
const Muon::IMuonIdHelperSvc * m_idHelperSvc
bool addConnector(const Identifier &gapID, const NswZebraData &connector, MsgStream &msg)
LookUpMap m_cablingMap
std::optional< Identifier > correctChannel(const Identifier &id, MsgStream &msg) const
int multilayer(const Identifier &id) const
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
int16_t lastChannel
int16_t firstChannel
int16_t shiftChannel
MsgStream & msg
Definition testRead.cxx:32