ATLAS Offline Software
Loading...
Searching...
No Matches
NrpcDigitToNrpcRDO.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <algorithm>
8#include "GaudiKernel/PhysicalConstants.h"
15
16// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
17namespace Muon{
19 ATH_MSG_DEBUG(" in initialize()");
20
21 ATH_CHECK(m_idHelperSvc.retrieve());
22 ATH_CHECK( m_NrpcContainerKey.initialize() );
23
24 ATH_MSG_DEBUG("Tag info filled successfully");
25
26 ATH_CHECK(m_cablingKey.initialize());
27 ATH_MSG_DEBUG("Cabling info initialized");
28
29 ATH_CHECK(m_digitContainerKey.initialize());
30 ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_digitContainerKey);
31
32 for (const std::string& statName : m_convStat){
33 m_selectedStations.insert(m_idHelperSvc->rpcIdHelper().stationNameIndex(statName));
34 }
35 return StatusCode::SUCCESS;
36}
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
38StatusCode NrpcDigitToNrpcRDO::execute(const EventContext& ctx) const {
39 ATH_MSG_DEBUG("in execute()");
40
42 if (!container.isValid()) {
43 ATH_MSG_FATAL("Could not find RpcDigitContainer called " << container.name() << " in store " << container.store());
44 return StatusCode::FAILURE;
45 }
46 SG::ReadCondHandle cabling(m_cablingKey, ctx);
47 if (!cabling.isValid()) {
48 ATH_MSG_FATAL("Could not find MuonNRPC_CablingMap " );
49 return StatusCode::FAILURE;
50 }
51 ATH_MSG_DEBUG("Found MuonNRPC_CablingMap ");
52
54 SG::WriteHandle nrpcRdoData(m_NrpcContainerKey, ctx);
55 ATH_CHECK(nrpcRdoData.record(std::make_unique<xAOD::NRPCRDOContainer>(),
56 std::make_unique<xAOD::NRPCRDOAuxContainer>()));
57
58
59 const IdContext rpcContext = m_idHelperSvc->rpcIdHelper().module_context();
60
61 // loop over digit collections
62 for (const RpcDigitCollection* rpcCollection : *container) {
63 ATH_MSG_DEBUG("RPC Digit -> Pad loop :: digitCollection at " << rpcCollection);
64
65 IdentifierHash moduleHash = rpcCollection->identifierHash();
66 Identifier moduleId{0};
67
68 if (m_idHelperSvc->rpcIdHelper().get_id(moduleHash, moduleId, &rpcContext)) {
69 ATH_MSG_WARNING("Failed to translate the "<<moduleHash<<" to a valid identifier");
70 continue;
71 }
72 if (m_selectedStations.size() &&
73 !m_selectedStations.count(m_idHelperSvc->stationName(moduleId))) {
74 ATH_MSG_DEBUG("Detector element "<<m_idHelperSvc->toString(moduleId)
75 <<" is not considered to be a small gap RPC");
76 continue;
77 }
78
79 // loop over digit
80 for (const RpcDigit* rpcDigit : *rpcCollection) {
81 const Identifier channelId = rpcDigit->identify();
82
83 ATH_MSG_DEBUG("Convert RPC digit "<<m_idHelperSvc->toString(channelId));
84
85 RpcCablingData translateCache{};
87 if (!cabling->convert(channelId, translateCache, rpcDigit->stripSide())) {
88 ATH_MSG_FATAL("Found a non NRPC identifier " << m_idHelperSvc->toString(channelId));
89 return StatusCode::FAILURE;
90 }
91
92 if (!cabling->getOnlineId(translateCache, msgStream())) {
93 ATH_MSG_ERROR("Offline to Online Id conversion for NRPC chamber.");
94 return StatusCode::FAILURE;
95 }
97 const float rdo_time = rpcDigit->time();
98
99 const float the_timeoverthr = rpcDigit->ToT();
100 uint32_t the_bcid= rdo_time / 25.;
101
102 xAOD::NRPCRDO* NrpcRdo = nrpcRdoData->push_back(std::make_unique<xAOD::NRPCRDO>());
103 NrpcRdo->setBcid(the_bcid);
104 NrpcRdo->setTime(rdo_time);
105 NrpcRdo->setSubdetector(translateCache.subDetector);
106 NrpcRdo->setBoardsector(translateCache.boardSector);
107 NrpcRdo->setBoard(translateCache.board);
108 NrpcRdo->setChannel(translateCache.channelId);
109 NrpcRdo->setTimeoverthr(the_timeoverthr);
110 }
111 }
112 return StatusCode::SUCCESS;
113 }
114}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< xAOD::NRPCRDOContainer > m_NrpcContainerKey
SG::ReadHandleKey< RpcDigitContainer > m_digitContainerKey
ServiceHandle< IMuonIdHelperSvc > m_idHelperSvc
SG::ReadCondHandleKey< RpcCablingMap > m_cablingKey
std::unordered_set< int > m_selectedStations
virtual StatusCode initialize() override final
Gaudi::Property< std::vector< std::string > > m_convStat
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setBoardsector(uint16_t Boardsector)
Set the sector of the board within the subdetector.
void setBoard(uint16_t Board)
Set the number of the TDC channel.
void setTimeoverthr(float Timeoverthr)
Set the time over threshold.
void setSubdetector(uint16_t SubDet)
Set the sub detector.
void setChannel(uint16_t Channel)
Set the fire channel number.
void setTime(float Time)
Set the trigger time [ns].
void setBcid(uint32_t Bcid)
Set the bunch crossing identifier.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
NRPCRDO_v1 NRPCRDO
Define the version of the NRPC RDO class.
Definition NRPCRDO.h:13
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.