ATLAS Offline Software
RpcRDOAnalysis.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "RpcRDOAnalysis.h"
5 #include "StoreGate/ReadHandle.h"
7 
8 #include <format>
9 
10 namespace MuonVal{
12  const std::string& basePath,
13  const ChIdx_t chIndex):
14  chIdx{chIndex} {
15 
16  auto createHisto = [&histSvc, &basePath, chIndex](const std::string& hName,
17  const std::string& hTitle,
18  const unsigned nBins,
19  const float xLow,
20  const float xHigh) {
21  TH1* h = new TH1F(hName.c_str(), hTitle.c_str(), nBins, xLow, xHigh);
22  h->Sumw2();
23  histSvc->regHist(std::format("/{}/PAD/Chamber_{}/{}",
24  basePath,
25  chIndex != ChIdx_t::ChUnknown ? chName(chIndex) : "Inclusive",
26  hName), h).ignore();
27  return h;
28  };
29  h_status = createHisto("status", "RPC Pad Status", 100, 0, 10);
30  h_err = createHisto("error", "RPC Pad error code", 100, 0, 10);
31  h_onlineID = createHisto("onlineID", "RPC pad online ID", 100, 0, 10);
32  h_lvl1ID = createHisto("lvl1ID", "RPC Pad online ID", 100, 0, 10);
33  h_bcID = createHisto("bcid", "RPC Pad BCID", 100,0, 10);
34  h_sector = createHisto("sector", "RPC Pad Sector", 100, 0, 75);
35 
36  h_coinOnID = createHisto("coinOnID", "CM Online ID", 100, 0, 10);
37  h_coinCrc = createHisto("coinCrc", "CM CRC", 100, 0 , 300);
38  h_coinFel1ID = createHisto("coinFel1ID", "CM FEL1ID", 100, 0, 10);
39  h_coinFebcID = createHisto("coinFebcID", "CM FEBCID", 100, 0, 10);
40  h_firedBcID = createHisto("h_firedBcID", "Fired Channel BCID", 100, 0, 10);
41  h_firedTime = createHisto("h_firedTime", "Fired Channel time", 100, 0, 10);
42  h_firedChan = createHisto("h_firedChan", "Fired Channel number", 100, 0, 35);
43  h_firedIjk = createHisto("h_firedIjk", "Fired Channel ijk", 100, 0, 10);
44 
45  h_firedOvl = createHisto("h_firedOvl", "Fired Channel overlap", 100, 0, 10);
46  h_firedThr = createHisto("h_firedThr", "Fired Channel threshold", 100, 0, 5);
47  }
49  const std::string& basePath,
50  const ChIdx_t chIndex):
51  chIdx{chIndex} {
52 
53  auto createHisto = [&histSvc, &basePath, chIndex](const std::string& hName,
54  const std::string& hTitle,
55  const unsigned nBins,
56  const float xLow,
57  const float xHigh) {
58  TH1* h = new TH1F(hName.c_str(), hTitle.c_str(), nBins, xLow, xHigh);
59  h->Sumw2();
60  histSvc->regHist(std::format("/{}/RDO/Chamber_{}/{}",
61  basePath,
62  chIndex != ChIdx_t::ChUnknown ? chName(chIndex) : "Inclusive",
63  hName), h).ignore();
64  return h;
65  };
66  h_bcid = createHisto("bcid", "Bunch Crossing ID", 5,10,100);
67  h_time = createHisto("time", "Recorded time", 45, 10, 100);
68  h_tOverThr = createHisto("tot", "Time over threshold", 0, 30 , 30);
69  h_subDet = createHisto("subdet", "Subdetector ID", 50, 0, 100);
70  h_boardSec = createHisto("boardsector", "Board sector ID", 50, 0, 100);
71  h_board = createHisto("boardID", "Board identifier", 50, 0, 100);
72  h_channelId = createHisto("channelID", "Channel identifier", 50,0 , 100);
73 
74  }
75 
78  ATH_CHECK(m_inputKeyRdo.initialize(!m_inputKeyRdo.empty()));
80  ATH_CHECK(m_idHelperSvc.retrieve());
81  for (int8_t ch = toInt(ChIdx_t::ChUnknown); ch != toInt(ChIdx_t::BEE); ++ch) {
82  using namespace Muon::MuonStationIndex;
83  auto chIdx = ChIdx_t{ch};
84  if (!m_inputKeyPad.empty() && toLayerIndex(chIdx) != LayerIndex::Inner) {
85  m_padHistos.emplace_back(histSvc(), m_path, chIdx);
86  }
87  if (m_inputKeyRdo.empty()) {
88  continue;
89  }
90  // If RpcPads are active, only the BIS78 NRPC ROs exist
91  if (!m_inputKeyPad.empty() && chIdx != ChIdx_t::BIS) {
92  continue;
93  }
94  m_rdoHistos.emplace_back(histSvc(), m_path, chIdx);
95  }
96 
97  return StatusCode::SUCCESS;
98  }
99 
101  const EventContext& ctx{Gaudi::Hive::currentContext()};
102  const RpcPadContainer* rpcPads{nullptr};
103  const xAOD::NRPCRDOContainer* rpcRdos{nullptr};
104  ATH_CHECK(SG::get(rpcPads, m_inputKeyPad, ctx));
105  ATH_CHECK(SG::get(rpcRdos, m_inputKeyRdo, ctx));
106 
107  if (rpcPads){
108  for (const RpcPad* pad : *rpcPads){
109  const ChIdx_t chIdx = m_idHelperSvc->chamberIndex(pad->identify());
110  std::vector<unsigned> fillMe{};
111  for (unsigned h = 0 ; h < m_padHistos.size(); ++h) {
112  if (m_padHistos[h].chIdx == ChIdx_t::ChUnknown ||
113  m_padHistos[h].chIdx == chIdx){
114  fillMe.push_back(h);
115  }
116  }
117 
118  const uint16_t padStat = pad->status();
119  const uint16_t padErr = pad->errorCode();
120  const uint16_t padOnID = pad->onlineId();
121  const uint16_t padLVL1ID = pad->lvl1Id();
122  const uint16_t padBCID = pad->bcId();
123  const int padSec = pad->sector();
124  for (unsigned h : fillMe) {
125  m_padHistos[h].h_status->Fill(padStat);
126  m_padHistos[h].h_err->Fill(padErr);
127  m_padHistos[h].h_onlineID->Fill(padOnID);
128  m_padHistos[h].h_lvl1ID->Fill(padLVL1ID);
129  m_padHistos[h].h_bcID->Fill(padBCID);
130  m_padHistos[h].h_sector->Fill(padSec);
131  }
132  for (const RpcCoinMatrix* coinMat : *pad) {
133  const uint16_t coinOnID = coinMat->onlineId();
134  const uint16_t coinCrc = coinMat->crc();
135  const uint16_t coinFel1ID = coinMat->fel1Id();
136  const uint16_t coinFebcID = coinMat->febcId();
137  for (unsigned h : fillMe) {
138  m_padHistos[h].h_coinOnID->Fill(coinOnID);
139  m_padHistos[h].h_coinCrc->Fill(coinCrc);
140  m_padHistos[h].h_coinFel1ID->Fill(coinFel1ID);
141  m_padHistos[h].h_coinFebcID->Fill(coinFebcID);
142  }
143 
144  for (const RpcFiredChannel* firedCh : *coinMat) {
145  const uint16_t firedBcID = firedCh->bcid();
146  const uint16_t firedTime = firedCh->time();
147  const uint16_t firedIjk = firedCh->ijk();
148  const uint16_t firedChan = firedCh->channel();
149  const uint16_t firedOvl = firedCh->ovl();
150  const uint16_t firedThr = firedCh->thr();
151  for (unsigned h : fillMe) {
152  m_padHistos[h].h_firedBcID->Fill(firedBcID);
153  m_padHistos[h].h_firedTime->Fill(firedTime);
154  m_padHistos[h].h_firedIjk->Fill(firedIjk);
155  m_padHistos[h].h_firedChan->Fill(firedChan);
156  m_padHistos[h].h_firedOvl->Fill(firedOvl);
157  m_padHistos[h].h_firedThr->Fill(firedThr);
158  }
159  }
160  }
161  }
162  if (rpcRdos) {
163  const Muon::RpcCablingMap* cabling{nullptr};
165  for (const xAOD::NRPCRDO* rdo : *rpcRdos) {
166  Muon::RpcCablingData convObj{};
167  convObj.subDetector = rdo->subdetector();
168  convObj.boardSector = rdo->boardsector();
169  convObj.board = rdo->board();
170  convObj.channelId = rdo->channel();
171 
172  if (!cabling->getOfflineId(convObj, msgStream())) {
173  ATH_MSG_FATAL("Failed to convert online -> offline");
174  return StatusCode::FAILURE;
175  }
176  Identifier chanId{};
177  if (!cabling->convert(convObj, chanId)) {
178  return StatusCode::FAILURE;
179  }
180  const ChIdx_t chIdx = m_idHelperSvc->chamberIndex(chanId);
181 
182  std::vector<unsigned> fillMe{};
183  for (unsigned h = 0 ; h < m_padHistos.size(); ++h) {
184  if (m_rdoHistos[h].chIdx == ChIdx_t::ChUnknown ||
185  m_rdoHistos[h].chIdx == chIdx){
186  fillMe.push_back(h);
187  }
188  }
189 
190  for (unsigned h : fillMe) {
191  m_rdoHistos[h].h_bcid->Fill(rdo->bcid());
192  m_rdoHistos[h].h_time->Fill(rdo->time());
193  m_rdoHistos[h].h_tOverThr->Fill(rdo->timeoverthr());
194  m_rdoHistos[h].h_subDet->Fill(rdo->subdetector());
195  m_rdoHistos[h].h_boardSec->Fill(rdo->boardsector());
196  m_rdoHistos[h].h_board->Fill(rdo->board());
197  m_rdoHistos[h].h_channelId->Fill(rdo->channel());
198  }
199  }
200  }
201  }
202  return StatusCode::SUCCESS;
203  }
204 
205 }
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
MuonVal::RpcRDOAnalysis::m_inputKeyRdo
SG::ReadHandleKey< xAOD::NRPCRDOContainer > m_inputKeyRdo
Definition: RpcRDOAnalysis.h:32
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
vtune_athena.format
format
Definition: vtune_athena.py:14
Muon::RpcCablingOnlineID::subDetector
int16_t & subDetector
Identifier of the subdetector region in the readout BA / BC etc.
Definition: RpcCablingData.h:82
MuonVal::RpcRDOAnalysis::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
Definition: RpcRDOAnalysis.h:39
Muon::MuonStationIndex
Definition: MuonStationIndex.h:13
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
Muon::MuonStationIndex::LayerIndex::Inner
@ Inner
MuonVal::RpcRDOAnalysis::m_rdoHistos
std::vector< RdoHistoSet > m_rdoHistos
Definition: RpcRDOAnalysis.h:106
xAOD::NRPCRDO_v1
Definition: NRPCRDO_v1.h:14
MuonVal::RpcRDOAnalysis::m_inputKeyPad
SG::ReadHandleKey< RpcPadContainer > m_inputKeyPad
Definition: RpcRDOAnalysis.h:31
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
RpcCoinMatrix
Definition: RpcCoinMatrix.h:20
RpcRDOAnalysis.h
ReadCondHandle.h
RpcFiredChannel
Definition: RpcFiredChannel.h:20
MuonVal::RpcRDOAnalysis::m_cablingKey
SG::ReadCondHandleKey< Muon::RpcCablingMap > m_cablingKey
Definition: RpcRDOAnalysis.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
Muon::MuonStationIndex::ChIndex::BIS
@ BIS
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
h
Muon::MuonStationIndex::chIndex
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
Definition: MuonStationIndex.cxx:11
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Muon::MuonStationIndex::chName
const std::string & chName(ChIndex index)
convert ChIndex into a string
Definition: MuonStationIndex.cxx:119
extractSporadic.h
list h
Definition: extractSporadic.py:96
MuonVal::RpcRDOAnalysis::RdoHistoSet::RdoHistoSet
RdoHistoSet(const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const ChIdx_t chIndex)
Constructor instantiating the monitoring histograms.
Definition: RpcRDOAnalysis.cxx:48
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
MuonVal::RpcRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: RpcRDOAnalysis.cxx:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Muon::RpcCablingMap
Definition: RpcCablingMap.h:27
Muon::MuonStationIndex::ChIndex::BEE
@ BEE
MuonVal
Class to store array like branches into the n-tuples.
Definition: HitValAlg.cxx:19
dumpTgcDigiJitter.nBins
list nBins
Definition: dumpTgcDigiJitter.py:29
Muon::RpcCablingData
Helper struct that is parsed to the cabling map to translate between the offline & online Identifiers...
Definition: RpcCablingData.h:96
MuonVal::RpcRDOAnalysis::m_padHistos
std::vector< PadHistoSet > m_padHistos
Definition: RpcRDOAnalysis.h:105
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
RpcPad
Definition: RpcPad.h:21
h
MuonVal::RpcRDOAnalysis::PadHistoSet::PadHistoSet
PadHistoSet(const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const ChIdx_t chIndex)
Constructor instantiating the monitoring histograms.
Definition: RpcRDOAnalysis.cxx:11
Muon::MuonStationIndex::toLayerIndex
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
Muon::MuonStationIndex::ChIndex
ChIndex
enum to classify the different chamber layers in the muon spectrometer
Definition: MuonStationIndex.h:15
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
ReadHandle.h
Handle class for reading from StoreGate.
MuonVal::RpcRDOAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition: RpcRDOAnalysis.h:42
MuonVal::RpcRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: RpcRDOAnalysis.cxx:76
Muon::MuonStationIndex::toInt
constexpr int toInt(const EnumType enumVal)
Definition: MuonStationIndex.h:61
ServiceHandle< ITHistSvc >
RpcPadContainer
Use IdentifiableContainer with RpcPad.
Definition: RpcPadContainer.h:23
Identifier
Definition: IdentifierFieldParser.cxx:14