ATLAS Offline Software
Loading...
Searching...
No Matches
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"
7
8#include <format>
9
10namespace 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
77 ATH_CHECK(m_inputKeyPad.initialize(!m_inputKeyPad.empty()));
78 ATH_CHECK(m_inputKeyRdo.initialize(!m_inputKeyRdo.empty()));
79 ATH_CHECK(m_cablingKey.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};
164 ATH_CHECK(SG::get(cabling, m_cablingKey, ctx));
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading from StoreGate.
Header file for AthHistogramAlgorithm.
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
virtual StatusCode initialize() override final
std::vector< RdoHistoSet > m_rdoHistos
SG::ReadHandleKey< xAOD::NRPCRDOContainer > m_inputKeyRdo
SG::ReadHandleKey< RpcPadContainer > m_inputKeyPad
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Service handle of the IdHelperSvc.
Gaudi::Property< std::string > m_path
SG::ReadCondHandleKey< Muon::RpcCablingMap > m_cablingKey
std::vector< PadHistoSet > m_padHistos
Muon::MuonStationIndex::ChIndex ChIdx_t
virtual StatusCode execute() override final
Use IdentifiableContainer with RpcPad.
Class to store array like branches into the n-tuples.
Definition HitValAlg.cxx:19
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
constexpr int toInt(const EnumType enumVal)
const std::string & chName(ChIndex index)
convert ChIndex into a string
LayerIndex toLayerIndex(ChIndex index)
convert ChIndex into LayerIndex
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
NRPCRDO_v1 NRPCRDO
Define the version of the NRPC RDO class.
Definition NRPCRDO.h:13
NRPCRDOContainer_v1 NRPCRDOContainer
Define the version of the NRPC RDO container.
PadHistoSet(const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const ChIdx_t chIndex)
Constructor instantiating the monitoring histograms.
RdoHistoSet(const ServiceHandle< ITHistSvc > &histSvc, const std::string &basePath, const ChIdx_t chIndex)
Constructor instantiating the monitoring histograms.
TH1 * h_tOverThr
Time over threshold.
Helper struct that is parsed to the cabling map to translate between the offline & online Identifiers...
uint8_t channelId
Online board channel number.
int16_t & board
Unique identifier of the tdc chip.
int16_t & boardSector
Unique Identifier of the Rpc chamber from an online perspective.
int16_t & subDetector
Identifier of the subdetector region in the readout BA / BC etc.