Execute method.
23 {
24 std::unique_ptr<std::fstream> f_dump = !
m_dumpFile.value().empty() ?
25 std::make_unique<std::fstream>(
m_dumpFile, std::fstream::out) : nullptr;
27 {
29 using OffChnl = MdtMezzanineCard::OfflineCh;
30 Mapping staggering{};
31 for (
unsigned i = 0 ;
i < staggering.size(); ++
i){
32 staggering[
i] = (staggering.size() -1) -
i;
33 }
34 for (
unsigned i = 0 ;
i < staggering.size() ;
i+=2){
35 std::swap(staggering[i], staggering[i+1]);
36 }
37 for (unsigned nLay : {3,4}){
38 MdtMezzanineCard testCard(staggering, nLay , 0);
39 if (!testCard.checkConsistency(msgStream())) return StatusCode::FAILURE;
42 for (
unsigned ch = 0 ;
ch < staggering.size() ; ++
ch) {
43 OffChnl off = testCard.offlineTube(ch, msgStream());
44 if (!off.isValid) {
45 ATH_MSG_FATAL(
"Failed to load tube & layer for channel "<<ch);
46 return StatusCode::FAILURE;
47 }
48 unsigned back_ch = testCard.tdcChannel(off.layer, off.tube +1 , msgStream());
49 if (ch != back_ch) {
51 <<static_cast<int>(off.layer)<<","
52 <<static_cast<int>(off.tube +1)<<" and then back to "
53 <<back_ch);
54 return StatusCode::FAILURE;
55 }
56 }
58 for (unsigned lay = 1 ; lay <= nLay ; ++lay) {
59 for (
unsigned int tube = 1 ;
tube <= testCard.numTubesPerLayer() ; ++
tube) {
60 const unsigned ch1 = testCard.tdcChannel(lay,tube,msgStream());
61 const unsigned ch2 = testCard.tdcChannel(lay,tube + testCard.numTubesPerLayer(),msgStream());
62
63 if(ch1 != ch2) {
65 <<" leads to 2 different answers "<<ch1<<" vs. "<<ch2);
66 return StatusCode::FAILURE;
67 }
68 }
69 }
70 }
71 }
72
76 return StatusCode::FAILURE;
77 }
78
82 return StatusCode::FAILURE;
83 }
84
85 const MdtCondDbData* deadChan{nullptr};
87 SG::ReadCondHandle<MdtCondDbData> deadChanHandle{
m_deadChanKey,ctx};
88 if (!deadChanHandle.
isValid()) {
90 return StatusCode::FAILURE;
91 }
92 deadChan = deadChanHandle.
cptr();
93
94 }
95
97 unsigned int n_elements{0}, n_success{0};
98 bool failure{false};
99
101 const MuonGM::MdtReadoutElement* readEle = detectorMgr->getMdtReadoutElement(*det_itr);
102
103 if (!readEle) {
105 continue;
106 }
109 continue;
110 }
114 bool is_valid{false};
116 if (!is_valid){
118 continue;
119 }
120 if (deadChan && !deadChan->
isGood(tube_id)) {
122 continue;
123 }
124 ++n_elements;
127 cabling->convert(tube_id,cabling_data);
129 if (!
cabling->getOnlineId(cabling_data,msgStream())){
131 failure = true;
132 continue;
133 }
136
138 const MdtCablingOffData off_data{};
139 static_cast<MdtCablingOffData&
> (
cabling_data) = off_data;
140 if (!
cabling->getOfflineId(cabling_data, msgStream())){
141 ATH_MSG_ERROR(
"Could not convert the online cabling "<<cabling_data<<
" to an offline identifier. Initial identifier "<<
m_idHelperSvc->toString(tube_id));
142 failure = true;
143 continue;
144 }
145
146 Identifier test_id{};
147 if (!
cabling->convert(cabling_data, test_id,
true)){
148 ATH_MSG_ERROR(
"The extracted offline identifier "<<cabling_data<<
" does not make sense");
149 failure = true;
150 continue;
151 }
152 if (test_id != tube_id){
154 failure = true;
155 continue;
156 }
157
159 static_cast<MdtCablingOffData&
>(
cabling_data) = off_data;
160
164 if (!
cabling->getOfflineId(cabling_data, msgStream()) || !
cabling->convert(cabling_data, test_id,
true)) {
166 failure = true;
167 continue;
168 }
170 if (!
cabling->getOnlineId(mrod_module,msgStream())){
172 failure = true;
173 continue;
174 }
176 if (idHelper.
elementID(test_id) != idHelper.
elementID(readEle->
identify()) &&
static_cast<const MdtCablingOnData&
>(mrod_module)!=(cabling_data)) {
178 failure = true;
179 } else ++n_success;
180 }
181 }
182 }
183 ATH_MSG_INFO( n_success<<
" out of "<<n_elements<<
" channels were successfully validated.");
184 return failure ? StatusCode::FAILURE: StatusCode::SUCCESS;
185}
#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)