23 {
24 const EventContext& ctx = Gaudi::Hive::currentContext();
25 std::unique_ptr<std::fstream> f_dump = !
m_dumpFile.value().empty() ?
26 std::make_unique<std::fstream>(
m_dumpFile, std::fstream::out) : nullptr;
28 {
30 using OffChnl = MdtMezzanineCard::OfflineCh;
31 Mapping staggering{};
32 for (
unsigned i = 0 ;
i < staggering.size(); ++
i){
33 staggering[
i] = (staggering.size() -1) -
i;
34 }
35 for (
unsigned i = 0 ;
i < staggering.size() ;
i+=2){
36 std::swap(staggering[i], staggering[i+1]);
37 }
38 for (unsigned nLay : {3,4}){
39 MdtMezzanineCard testCard(staggering, nLay , 0);
40 if (!testCard.checkConsistency(msgStream())) return StatusCode::FAILURE;
43 for (
unsigned ch = 0 ;
ch < staggering.size() ; ++
ch) {
44 OffChnl off = testCard.offlineTube(ch, msgStream());
45 if (!off.isValid) {
46 ATH_MSG_FATAL(
"Failed to load tube & layer for channel "<<ch);
47 return StatusCode::FAILURE;
48 }
49 unsigned back_ch = testCard.tdcChannel(off.layer, off.tube +1 , msgStream());
50 if (ch != back_ch) {
52 <<static_cast<int>(off.layer)<<","
53 <<static_cast<int>(off.tube +1)<<" and then back to "
54 <<back_ch);
55 return StatusCode::FAILURE;
56 }
57 }
59 for (unsigned lay = 1 ; lay <= nLay ; ++lay) {
60 for (
unsigned int tube = 1 ;
tube <= testCard.numTubesPerLayer() ; ++
tube) {
61 const unsigned ch1 = testCard.tdcChannel(lay,tube,msgStream());
62 const unsigned ch2 = testCard.tdcChannel(lay,tube + testCard.numTubesPerLayer(),msgStream());
63
64 if(ch1 != ch2) {
66 <<" leads to 2 different answers "<<ch1<<" vs. "<<ch2);
67 return StatusCode::FAILURE;
68 }
69 }
70 }
71 }
72 }
73
77 return StatusCode::FAILURE;
78 }
79
83 return StatusCode::FAILURE;
84 }
85
86 const MdtCondDbData* deadChan{nullptr};
88 SG::ReadCondHandle<MdtCondDbData> deadChanHandle{
m_deadChanKey,ctx};
89 if (!deadChanHandle.
isValid()) {
91 return StatusCode::FAILURE;
92 }
93 deadChan = deadChanHandle.
cptr();
94
95 }
96
98 unsigned int n_elements{0}, n_success{0};
99 bool failure{false};
100
102 const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr);
103
104 if (!readEle) {
106 continue;
107 }
110 continue;
111 }
115 bool is_valid{false};
117 if (!is_valid){
119 continue;
120 }
121 if (deadChan && !deadChan->
isGood(tube_id)) {
123 continue;
124 }
125 ++n_elements;
128 cabling->convert(tube_id,cabling_data);
130 if (!
cabling->getOnlineId(cabling_data,msgStream())){
132 failure = true;
133 continue;
134 }
137
139 const MdtCablingOffData off_data{};
140 static_cast<MdtCablingOffData&
> (
cabling_data) = off_data;
141 if (!
cabling->getOfflineId(cabling_data, msgStream())){
142 ATH_MSG_ERROR(
"Could not convert the online cabling "<<cabling_data<<
" to an offline identifier. Initial identifier "<<
m_idHelperSvc->toString(tube_id));
143 failure = true;
144 continue;
145 }
146
147 Identifier test_id{};
148 if (!
cabling->convert(cabling_data, test_id,
true)){
149 ATH_MSG_ERROR(
"The extracted offline identifier "<<cabling_data<<
" does not make sense");
150 failure = true;
151 continue;
152 }
153 if (test_id != tube_id){
155 failure = true;
156 continue;
157 }
158
160 static_cast<MdtCablingOffData&
>(
cabling_data) = off_data;
161
165 if (!
cabling->getOfflineId(cabling_data, msgStream()) || !
cabling->convert(cabling_data, test_id,
true)) {
167 failure = true;
168 continue;
169 }
171 if (!
cabling->getOnlineId(mrod_module,msgStream())){
173 failure = true;
174 continue;
175 }
177 if (idHelper.
elementID(test_id) != idHelper.
elementID(readEle->
identify()) &&
static_cast<const MdtCablingOnData&
>(mrod_module)!=(cabling_data)) {
179 failure = true;
180 } else ++n_success;
181 }
182 }
183 }
184 ATH_MSG_INFO( n_success<<
" out of "<<n_elements<<
" channels were successfully validated.");
185 return failure ? StatusCode::FAILURE: StatusCode::SUCCESS;
186}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_ALWAYS(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Gaudi::Property< std::string > m_dumpFile
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
SG::ReadCondHandleKey< MdtCondDbData > m_deadChanKey
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_cablingKey
bool isGood(const Identifier &Id) const
Returns if the identifier (tube/multiLayer/chamber) is masked in the conditions database.
bool isGoodChamber(const Identifier &Id) const
Returns true if the complete chamber has not dead channels.
Identifier elementID(int stationName, int stationEta, int stationPhi) const
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int tubeLayer, int tube) const
std::array< uint8_t, 24 > Mapping
int getNLayers() const
Returns the number of tube layers inside the multilayer.
int getMultilayer() const
Returns the multilayer represented by the readout element.
int getNtubesperlayer() const
Returns the number of tubes in each tube layer.
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
const_id_iterator detectorElement_end() const
const_pointer_type cptr()
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)