ATLAS Offline Software
RpcCablingTestAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "RpcCablingTestAlg.h"
7 
8 
9 
10 RpcCablingTestAlg::RpcCablingTestAlg(const std::string& name, ISvcLocator* pSvcLocator):
11  AthAlgorithm(name,pSvcLocator) {}
12 
13 
15  ATH_CHECK(m_idHelperSvc.retrieve());
18  for (const std::string& statName : m_considStat) {
19  m_cabStat.insert(m_idHelperSvc->rpcIdHelper().stationNameIndex(statName));
20  }
21  return StatusCode::SUCCESS;
22 }
23 
25  const EventContext& ctx = Gaudi::Hive::currentContext();
26  ATH_MSG_INFO("Start validation of the Rpc cabling");
27 
29  if (!detectorMgr.isValid()){
30  ATH_MSG_FATAL("Failed to retrieve the Detector manager "<<m_DetectorManagerKey.fullKey());
31  return StatusCode::FAILURE;
32  }
33 
35  if (!cabling.isValid()) {
36  ATH_MSG_ERROR("Failed to retrieve the Rpc cabling "<<m_cablingKey.fullKey());
37  return StatusCode::FAILURE;
38  }
39  const RpcIdHelper& idHelper = m_idHelperSvc->rpcIdHelper();
40  unsigned int n_elements{0}, n_success{0};
41  for (auto det_itr = idHelper.detectorElement_begin(); det_itr != idHelper.detectorElement_end(); ++det_itr){
42 
43  const MuonGM::RpcReadoutElement* readEle = detectorMgr->getRpcReadoutElement(*det_itr);
44  if (!readEle) {
45  ATH_MSG_VERBOSE("Detector element does not exist. ");
46  continue;
47  }
48  if (!m_cabStat.empty() && !m_cabStat.count(m_idHelperSvc->stationName(readEle->identify()))){
49  ATH_MSG_VERBOSE("Do not test station "<<m_idHelperSvc->toString(readEle->identify()));
50  continue;
51  }
52  const Identifier station_id = idHelper.elementID(readEle->identify());
53  ATH_MSG_DEBUG("Check station "<<m_idHelperSvc->toString(station_id));
54 
55  for (bool measPhi : {true, false}) {
56  for (int gap = 1 ; gap <= readEle->numberOfLayers(measPhi); ++gap) {
57  for (int strip = 1; strip <= readEle->Nstrips(measPhi); ++strip) {
58  bool is_valid{false};
59  const Identifier chanId = idHelper.channelID(station_id,
60  readEle->getDoubletZ(),
61  readEle->getDoubletPhi(),
62  gap, measPhi, strip, is_valid);
63  if (!is_valid) {
64  ATH_MSG_VERBOSE("Invalid Identifier");
65  continue;
66  }
67  bool failure{false};
68 
69  ++n_elements;
70  CablingData cabl_data{};
71  if (!cabling->convert(chanId, cabl_data, false)){
72  ATH_MSG_ERROR("Invalid identifier "<<m_idHelperSvc->toString(chanId));
73  return StatusCode::FAILURE;
74  }
76  if (!cabling->getOnlineId(cabl_data, msgStream())){
77  return StatusCode::FAILURE;
78  }
79  ATH_MSG_DEBUG("Successfully converted offline -> online "<<cabl_data);
80  CablingData onl_data{};
82  onl_data.NrpcCablingOnlineID::operator=(cabl_data);
83  onl_data.channelId = cabl_data.channelId;
84  if (!cabling->getOfflineId(onl_data, msgStream())) {
85  return StatusCode::FAILURE;
86  }
87  if (onl_data != cabl_data){
88  ATH_MSG_FATAL("Back translation of the cabling failed for hit "<<m_idHelperSvc->toString(chanId)<<
89  std::endl<<" -- started with "<<cabl_data<<std::endl<<
90  " -- got back: "<<onl_data);
91  failure = true;
92  }
93  Identifier backChanId{0};
94  if (!cabling->convert(onl_data, backChanId, true)){
95  ATH_MSG_FATAL("Failed to translate back the cabling object"<<onl_data<<" to an Identifier");
96  return StatusCode::FAILURE;
97  }
98  if (backChanId != chanId) {
99  ATH_MSG_FATAL("Detected a silent messenger. Started with "<<m_idHelperSvc->toString(chanId)
100  <<" ended up with "<<m_idHelperSvc->toString(backChanId));
101  failure = true;
102  }
103  n_success += (!failure);
104  if (failure) return StatusCode::FAILURE;
105  }
106  }
107  }
108  }
109  ATH_MSG_INFO( n_success<<" out of "<<n_elements<<" channels were successfully validated.");
110  return n_success == n_elements ? StatusCode::SUCCESS : StatusCode::FAILURE;
111 }
112 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SiliconTech::strip
@ strip
MuonIdHelper::detectorElement_begin
const_id_iterator detectorElement_begin() const
Iterators over full set of ids.
Definition: MuonIdHelper.cxx:762
RpcCablingTestAlg::execute
virtual StatusCode execute() override
Definition: RpcCablingTestAlg.cxx:24
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RpcIdHelper::elementID
Identifier elementID(int stationName, int stationEta, int stationPhi, int doubletR) const
Definition: RpcIdHelper.cxx:802
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:54
MuonIdHelper::detectorElement_end
const_id_iterator detectorElement_end() const
Definition: MuonIdHelper.cxx:764
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RpcIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int doubletR, int doubletZ, int doubletPhi, int gasGap, int measuresPhi, int strip) const
Definition: RpcIdHelper.cxx:940
CaloSwCorrections.gap
def gap(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:212
RpcIdHelper
Definition: RpcIdHelper.h:51
ReadCondHandle.h
RpcCablingTestAlg.h
RpcCablingTestAlg::RpcCablingTestAlg
RpcCablingTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: RpcCablingTestAlg.cxx:10
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
NrpcCablingData
Cabling information shipped around the Digi <-> Rdo conversions.
Definition: NrpcCablingData.h:121
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonGM::RpcReadoutElement::getDoubletPhi
int getDoubletPhi() const
return DoubletPhi value for the given readout element, be aware that one RE can contain two DoubletPh...
AthAlgorithm
Definition: AthAlgorithm.h:47
RpcCablingTestAlg::m_cabStat
std::set< int > m_cabStat
Definition: RpcCablingTestAlg.h:38
RpcCablingTestAlg::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: RpcCablingTestAlg.h:30
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
RpcCablingTestAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: RpcCablingTestAlg.h:28
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
NrpcCablingData::channelId
uint8_t channelId
Definition: NrpcCablingData.h:124
MuonGM::RpcReadoutElement::numberOfLayers
virtual int numberOfLayers(bool measphi=true) const override final
number of layers in phi/eta projection, same for eta/phi planes
MuonGM::MuonReadoutElement::identify
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:184
RpcCablingTestAlg::m_cablingKey
SG::ReadCondHandleKey< MuonNRPC_CablingMap > m_cablingKey
Definition: RpcCablingTestAlg.h:33
MuonGM::RpcReadoutElement::Nstrips
int Nstrips(bool measphi) const
returns the number of strips for the phi or eta plane
RpcCablingTestAlg::m_considStat
Gaudi::Property< std::vector< std::string > > m_considStat
Definition: RpcCablingTestAlg.h:35
MuonGM::RpcReadoutElement::getDoubletZ
int getDoubletZ() const
return DoubletZ value for the given readout element
RpcCablingTestAlg::initialize
virtual StatusCode initialize() override
Definition: RpcCablingTestAlg.cxx:14
RpcReadoutElement.h