6#include "GaudiKernel/PhysicalConstants.h"
9 constexpr double inverseSpeedOfLight = 1 / Gaudi::Units::c_light;
17 ATH_MSG_ERROR(
"Neither legacy or xAOD::Rpcs shall be translated.");
18 return StatusCode::FAILURE;
28 return StatusCode::SUCCESS;
34 const size_t modHashMax{
m_idHelperSvc->rpcIdHelper().module_hash_max()};
40 if (
msgLvl(MSG::VERBOSE)) {
41 for (
const std::unique_ptr<RpcDigitCollection>& digitCollPtr : tempOut) {
47 return a->identify() < b->identify();
50 for (
const RpcDigit* digitPtr : *digitCollPtr) {
52 <<
" time: " << digitPtr->time()
53 <<
" ToT: " << digitPtr->ToT()
54 <<
" stripSide: " << digitPtr->stripSide());
60 ATH_CHECK(writeHandle.
record(std::make_unique<RpcDigitContainer>(modHashMax)));
62 for (
size_t coll_hash = 0; coll_hash < modHashMax; ++coll_hash) {
63 if (tempOut[coll_hash] && tempOut[coll_hash]->size()) {
64 ATH_CHECK(writeHandle->addCollection(tempOut[coll_hash].release(), coll_hash));
69 return StatusCode::SUCCESS;
75 return StatusCode::SUCCESS;
79 ATH_MSG_DEBUG(
"Retrieved " << rdoContainer->size() <<
" RPC RDOs.");
83 for (
const RpcPad* rdoColl : *rdoContainer) {
84 ATH_MSG_DEBUG(
" Number of CMs in this Pad " << rdoColl->size());
86 uint16_t padId = rdoColl->onlineId();
87 uint16_t sectorId = rdoColl->sector();
92 uint16_t cmaId = coinMatrix->onlineId();
96 std::vector<std::unique_ptr<RpcDigit>> digitVec{
m_rpcRdoDecoderTool->getDigit(rpcChan, sectorId,
100 if (digitVec.empty())
continue;
103 for (std::unique_ptr<RpcDigit>& newDigit : digitVec) {
105 std::unique_ptr<RpcDigitCollection>& digitColl =
container[collHash];
107 digitColl = std::make_unique<RpcDigitCollection>(
m_idHelperSvc->chamberId(newDigit->identify()),
110 digitColl->push_back(std::move(newDigit));
115 return StatusCode::SUCCESS;
120 return StatusCode::SUCCESS;
125 ATH_MSG_DEBUG(
"Retrieved " << rdoContainer->size() <<
" NRPC RDOs.");
127 if (!cabling.isValid()) {
129 return StatusCode::FAILURE;
134 return StatusCode::FAILURE;
140 ATH_MSG_VERBOSE(
"Convert RDO boardSector: "<<
static_cast<int>(rdo->boardsector())<<
", board:"
141 <<
static_cast<int>(rdo->board())<<
" channel: "<<
static_cast<int>(rdo->channel()) <<
", time: "
142 <<rdo->time()<<
", ToT: "<<rdo->timeoverthr());
148 convObj.
board = rdo->board();
151 if (!cabling->getOfflineId(convObj, msgStream())) {
153 return StatusCode::FAILURE;
156 if (!cabling->convert(convObj, chanId)) {
157 return StatusCode::FAILURE;
161 std::unique_ptr<RpcDigitCollection>& coll = digit_map[modHash];
164 coll = std::make_unique<RpcDigitCollection>(id_helper.
elementID(chanId), modHash);
168 const double timeOfFlight = inverseSpeedOfLight * (muonDetMgr->getRpcReadoutElement(chanId)->stripPos(chanId)).mag();
169 const float digit_time = rdo->time() - timeOfFlight;
170 const float ToT =
m_patch_for_rpc_time ? rdo->timeoverthr() + timeOfFlight : rdo->timeoverthr() ;
171 std::unique_ptr<RpcDigit> digit = std::make_unique<RpcDigit>(chanId, digit_time, ToT, convObj.
stripSide());
172 coll->push_back(std::move(digit));
174 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
bool msgLvl(const MSG::Level lvl) const
This is a "hash" representation of an Identifier.
Gaudi::Property< bool > m_decodeNrpcRDO
Gaudi::Property< bool > m_decodeLegacyRDO
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadHandleKey< xAOD::NRPCRDOContainer > m_nRpcRdoKey
ToolHandle< IRPC_RDO_Decoder > m_rpcRdoDecoderTool
SG::ReadCondHandleKey< RpcCablingCondData > m_rpcReadKey
Gaudi::Property< bool > m_patch_for_rpc_time
StatusCode decodeNRpc(const EventContext &ctx, TempDigitContainer &container) const
SG::ReadCondHandleKey< RpcCablingMap > m_nRpcCablingKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
StatusCode decodeLegacyRdo(const EventContext &ctx, TempDigitContainer &container) const
: Decode the legacy RpcRdo format
ServiceHandle< IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override final
SG::WriteHandleKey< RpcDigitContainer > m_rpcDigitKey
SG::ReadHandleKey< RpcPadContainer > m_rpcRdoKey
std::vector< std::unique_ptr< RpcDigitCollection > > TempDigitContainer
Identifier elementID(int stationName, int stationEta, int stationPhi, int doubletR) const
const DataObjID & fullKey() const
bool isPresent() const
Is the referenced object present in SG?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
NRPCRDO_v1 NRPCRDO
Define the version of the NRPC RDO class.
Helper struct that is parsed to the cabling map to translate between the offline & online Identifiers...
uint8_t channelId
Online board channel number.
bool stripSide() const
: Is the strip readout on the opposite side
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.