ATLAS Offline Software
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 
5 #include "NrpcDigitToNrpcRDO.h"
6 
7 #include <algorithm>
8 #include "GaudiKernel/PhysicalConstants.h"
12 #include "StoreGate/StoreGateSvc.h"
15 
16 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
17 namespace 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 
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
38 StatusCode NrpcDigitToNrpcRDO::execute(const EventContext& ctx) const {
39  ATH_MSG_DEBUG("in execute()");
40 
41  SG::ReadHandle container(m_digitContainerKey, ctx);
42  if (!container.isValid()) {
43  ATH_MSG_FATAL("Could not find RpcDigitContainer called " << container.name() << " in store " << container.store());
44  return StatusCode::FAILURE;
45  }
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 }
Muon::NrpcDigitToNrpcRDO::m_NrpcContainerKey
SG::WriteHandleKey< xAOD::NRPCRDOContainer > m_NrpcContainerKey
Definition: NrpcDigitToNrpcRDO.h:38
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
RpcDigit
Definition: RpcDigit.h:16
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
RpcDigitCollection
Definition: RpcDigitCollection.h:17
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
xAOD::NRPCRDO_v1::setBoardsector
void setBoardsector(uint16_t Boardsector)
Set the sector of the board within the subdetector.
xAOD::NRPCRDO_v1
Definition: NRPCRDO_v1.h:14
Muon::NrpcDigitToNrpcRDO::m_digitContainerKey
SG::ReadHandleKey< RpcDigitContainer > m_digitContainerKey
Definition: NrpcDigitToNrpcRDO.h:35
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
ShowData.h
xAOD::NRPCRDO_v1::setBoard
void setBoard(uint16_t Board)
Set the number of the TDC channel.
NrpcDigitToNrpcRDO.h
xAOD::NRPCRDO_v1::setChannel
void setChannel(uint16_t Channel)
Set the fire channel number.
Muon::NrpcDigitToNrpcRDO::m_cablingKey
SG::ReadCondHandleKey< RpcCablingMap > m_cablingKey
Definition: NrpcDigitToNrpcRDO.h:33
RpcDigit.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RpcDigitCollection.h
xAOD::NRPCRDO_v1::setSubdetector
void setSubdetector(uint16_t SubDet)
Set the sub detector.
Muon::NrpcDigitToNrpcRDO::initialize
virtual StatusCode initialize() override final
Definition: NrpcDigitToNrpcRDO.cxx:18
Muon::NrpcDigitToNrpcRDO::m_idHelperSvc
ServiceHandle< IMuonIdHelperSvc > m_idHelperSvc
Definition: NrpcDigitToNrpcRDO.h:40
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
xAOD::NRPCRDO_v1::setBcid
void setBcid(uint32_t Bcid)
Set the bunch crossing identifier.
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition: StoreGate/src/VarHandleBase.cxx:382
Muon::NrpcDigitToNrpcRDO::m_convStat
Gaudi::Property< std::vector< std::string > > m_convStat
Definition: NrpcDigitToNrpcRDO.h:30
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
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:121
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Muon::RpcCablingData
Helper struct that is parsed to the cabling map to translate between the offline & online Identifiers...
Definition: RpcCablingData.h:96
NRPCRDOAuxContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Muon::NrpcDigitToNrpcRDO::m_selectedStations
std::unordered_set< int > m_selectedStations
Definition: NrpcDigitToNrpcRDO.h:42
Muon::NrpcDigitToNrpcRDO::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: NrpcDigitToNrpcRDO.cxx:38
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
StoreGateSvc.h
xAOD::NRPCRDO_v1::setTime
void setTime(float Time)
Set the trigger time [ns].
xAOD::NRPCRDO_v1::setTimeoverthr
void setTimeoverthr(float Timeoverthr)
Set the time over threshold.
RpcReadoutElement.h
Identifier
Definition: IdentifierFieldParser.cxx:14