ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCablings
MuonCablingData
src
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
5
#include <
MuonCablingData/Nsw_CablingMap.h
>
6
7
std::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
16
Nsw_CablingMap::Nsw_CablingMap
(
const
Muon::IMuonIdHelperSvc
* svc)
17
:
m_idHelperSvc
{svc} {}
18
19
std::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
}
76
bool
Nsw_CablingMap::addConnector
(
const
Identifier
& gapID,
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
debug
const bool debug
Definition
MakeUncertaintyPlots.cxx:53
NswZebraSet
std::set< NswZebraData, std::less<> > NswZebraSet
Definition
NswZebraData.h:38
operator<<
std::ostream & operator<<(std::ostream &ostr, const NswZebraData &connector)
Definition
Nsw_CablingMap.cxx:7
Nsw_CablingMap.h
MmIdHelper
Definition
MmIdHelper.h:54
MmIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition
MmIdHelper.cxx:768
MmIdHelper::channel
int channel(const Identifier &id) const override
Definition
MmIdHelper.cxx:832
MmIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition
MmIdHelper.cxx:830
MmIdHelper::multilayer
int multilayer(const Identifier &id) const
Definition
MmIdHelper.cxx:828
Muon::IMuonIdHelperSvc
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
Definition
IMuonIdHelperSvc.h:27
Nsw_CablingMap::Nsw_CablingMap
Nsw_CablingMap(const Muon::IMuonIdHelperSvc *svc)
Definition
Nsw_CablingMap.cxx:16
Nsw_CablingMap::m_idHelperSvc
const Muon::IMuonIdHelperSvc * m_idHelperSvc
Definition
Nsw_CablingMap.h:38
Nsw_CablingMap::addConnector
bool addConnector(const Identifier &gapID, const NswZebraData &connector, MsgStream &msg)
Definition
Nsw_CablingMap.cxx:76
Nsw_CablingMap::m_cablingMap
LookUpMap m_cablingMap
Definition
Nsw_CablingMap.h:44
Nsw_CablingMap::correctChannel
std::optional< Identifier > correctChannel(const Identifier &id, MsgStream &msg) const
Definition
Nsw_CablingMap.cxx:19
sTgcIdHelper
Definition
sTgcIdHelper.h:55
sTgcIdHelper::multilayer
int multilayer(const Identifier &id) const
Definition
sTgcIdHelper.cxx:1025
sTgcIdHelper::channelType
int channelType(const Identifier &id) const
Definition
sTgcIdHelper.cxx:1030
sTgcIdHelper::channel
int channel(const Identifier &id) const override
Definition
sTgcIdHelper.cxx:1035
sTgcIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition
sTgcIdHelper.cxx:1028
sTgcIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
Definition
sTgcIdHelper.cxx:894
Identifier
Definition
IdentifierFieldParser.cxx:14
NswZebraData
Definition
NswZebraData.h:18
NswZebraData::lastChannel
int16_t lastChannel
Definition
NswZebraData.h:21
NswZebraData::firstChannel
int16_t firstChannel
Definition
NswZebraData.h:20
NswZebraData::shiftChannel
int16_t shiftChannel
Definition
NswZebraData.h:22
msg
MsgStream & msg
Definition
testRead.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0