20 return StatusCode::SUCCESS;
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;
32 for (
unsigned i = 0 ; i < staggering.size(); ++i){
33 staggering[i] = (staggering.size() -1) -i;
35 for (
unsigned i = 0 ; i < staggering.size() ; i+=2){
36 std::swap(staggering[i], staggering[i+1]);
38 for (
unsigned nLay : {3,4}){
43 for (
unsigned ch = 0 ; ch < staggering.size() ; ++ch) {
44 OffChnl off = testCard.
offlineTube(ch, msgStream());
46 ATH_MSG_FATAL(
"Failed to load tube & layer for channel "<<ch);
47 return StatusCode::FAILURE;
49 unsigned back_ch = testCard.
tdcChannel(off.layer, off.tube +1 , msgStream());
52 <<
static_cast<int>(off.layer)<<
","
53 <<
static_cast<int>(off.tube +1)<<
" and then back to "
55 return StatusCode::FAILURE;
59 for (
unsigned lay = 1 ; lay <= nLay ; ++lay) {
61 const unsigned ch1 = testCard.
tdcChannel(lay,tube,msgStream());
66 <<
" leads to 2 different answers "<<ch1<<
" vs. "<<ch2);
67 return StatusCode::FAILURE;
77 return StatusCode::FAILURE;
81 if (!cabling.isValid()) {
83 return StatusCode::FAILURE;
89 if (!deadChanHandle.
isValid()) {
91 return StatusCode::FAILURE;
93 deadChan = deadChanHandle.
cptr();
98 unsigned int n_elements{0}, n_success{0};
113 for (
int layer = 1 ; layer <= readEle->
getNLayers(); ++layer){
115 bool is_valid{
false};
121 if (deadChan && !deadChan->
isGood(tube_id)) {
128 cabling->convert(tube_id,cabling_data);
130 if (!cabling->getOnlineId(cabling_data,msgStream())){
135 if (f_dump) (*f_dump)<<cabling_data<<std::endl;
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));
148 if (!cabling->convert(cabling_data, test_id,
true)){
149 ATH_MSG_ERROR(
"The extracted offline identifier "<<cabling_data<<
" does not make sense");
153 if (test_id != tube_id){
163 cabling_data.tdcId = 0xff;
164 cabling_data.channelId =0xff;
165 if (!cabling->getOfflineId(cabling_data, msgStream()) || !cabling->convert(cabling_data, test_id,
true)) {
171 if (!cabling->getOnlineId(mrod_module,msgStream())){
184 ATH_MSG_INFO( n_success<<
" out of "<<n_elements<<
" channels were successfully validated.");
185 return failure ? StatusCode::FAILURE: StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_ALWAYS(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_dumpFile
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
MdtCablingTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< MdtCondDbData > m_deadChanKey
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_cablingKey
virtual StatusCode execute() override
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
MdtMezzanineCard - Helper struct to represent the structure of a mezzanine card in a consistent way E...
bool checkConsistency(MsgStream &msg) const
checks whether the tdc mapping is complete.
OfflineCh offlineTube(uint8_t tdc, MsgStream &msg) const
uint8_t numTubesPerLayer() const
returns the number of tubes per layer;
uint8_t tdcChannel(uint8_t tubeLay, uint8_t tube, MsgStream &msg) const
returns the tdc channel number
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)
Split the offline part of the cabling apart to use it later for sorting.
Helper struct to pipe the result from the tdc -> offline channel translation.