ATLAS Offline Software
NrpcDigitToNrpcRDO.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 
18 
19 NrpcDigitToNrpcRDO::NrpcDigitToNrpcRDO(const std::string& name, ISvcLocator* pSvcLocator) :
20  AthReentrantAlgorithm(name, pSvcLocator){}
21 
22 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
23 
25  ATH_MSG_DEBUG(" in initialize()");
26 
27  ATH_CHECK(m_idHelperSvc.retrieve());
28  ATH_CHECK( m_NrpcContainerKey.initialize() );
29 
30  ATH_MSG_DEBUG("Tag info filled successfully");
31 
33  ATH_MSG_DEBUG("Cabling info initialized");
34 
36  ATH_MSG_VERBOSE("Initialized ReadHandleKey: " << m_digitContainerKey);
37 
38  for (const std::string& statName : m_convStat){
39  m_selectedStations.insert(m_idHelperSvc->rpcIdHelper().stationNameIndex(statName));
40  }
41  return StatusCode::SUCCESS;
42 }
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44 StatusCode NrpcDigitToNrpcRDO::execute(const EventContext& ctx) const {
45  ATH_MSG_DEBUG("in execute()");
46 
48  if (!container.isValid()) {
49  ATH_MSG_FATAL("Could not find RpcDigitContainer called " << container.name() << " in store " << container.store());
50  return StatusCode::FAILURE;
51  }
53  if (!readHandle_Cabling.isValid()) {
54  ATH_MSG_FATAL("Could not find MuonNRPC_CablingMap " );
55  return StatusCode::FAILURE;
56  }
57  const MuonNRPC_CablingMap* cabling_ptr = readHandle_Cabling.cptr();
58  ATH_MSG_DEBUG("Found MuonNRPC_CablingMap ");
59 
62  ATH_CHECK(nrpcRdoData.record(std::make_unique<xAOD::NRPCRDOContainer>(),
63  std::make_unique<xAOD::NRPCRDOAuxContainer>()));
64 
65 
66  const IdContext rpcContext = m_idHelperSvc->rpcIdHelper().module_context();
67 
68  // loop over digit collections
69  for (const RpcDigitCollection* rpcCollection : *container) {
70  ATH_MSG_DEBUG("RPC Digit -> Pad loop :: digitCollection at " << rpcCollection);
71 
72  IdentifierHash moduleHash = rpcCollection->identifierHash();
73  Identifier moduleId{0};
74 
75  if (m_idHelperSvc->rpcIdHelper().get_id(moduleHash, moduleId, &rpcContext)) {
76  ATH_MSG_WARNING("Failed to translate the "<<moduleHash<<" to a valid identifier");
77  continue;
78  }
79  if (m_selectedStations.size() &&
80  !m_selectedStations.count(m_idHelperSvc->stationName(moduleId))) {
81  ATH_MSG_DEBUG("Detector element "<<m_idHelperSvc->toString(moduleId)
82  <<" is not considered to be a small gap RPC");
83  continue;
84  }
85 
86  // loop over digit
87  for (const RpcDigit* rpcDigit : *rpcCollection) {
88  const Identifier channelId = rpcDigit->identify();
89 
90  ATH_MSG_DEBUG("Convert RPC digit "<<m_idHelperSvc->toString(channelId));
91 
94  if (!cabling_ptr->convert(channelId, cabling_data, rpcDigit->stripSide())) {
95  ATH_MSG_FATAL("Found a non NRPC identifier " << m_idHelperSvc->toString(channelId));
96  return StatusCode::FAILURE;
97  }
98 
99  bool cabling = cabling_ptr->getOnlineId(cabling_data, msgStream());
100  if (!cabling) {
101  ATH_MSG_ERROR("Offline to Online Id conversion for NRPC chamber.");
102  return StatusCode::FAILURE;
103  }
105  const float rdo_time = rpcDigit->time();
106 
107  const float the_timeoverthr = rpcDigit->ToT();
108  uint32_t the_bcid= rdo_time / 25.;
109 
110  xAOD::NRPCRDO* NrpcRdo = nrpcRdoData->push_back(std::make_unique<xAOD::NRPCRDO>());
111  NrpcRdo->setBcid(the_bcid);
112  NrpcRdo->setTime(rdo_time);
113  NrpcRdo->setSubdetector(cabling_data.subDetector);
114  NrpcRdo->setTdcsector(cabling_data.tdcSector);
115  NrpcRdo->setTdc(cabling_data.tdc);
116  NrpcRdo->setChannel(cabling_data.channelId);
117  NrpcRdo->setTimeoverthr(the_timeoverthr);
118  }
119  }
120  return StatusCode::SUCCESS;
121 }
xAOD::NRPCRDO_v1::setTdcsector
void setTdcsector(uint16_t Tdcsector)
Set the sector of the tdc within the subdetector.
NrpcDigitToNrpcRDO::NrpcDigitToNrpcRDO
NrpcDigitToNrpcRDO(const std::string &name, ISvcLocator *pSvcLocator)
Definition: NrpcDigitToNrpcRDO.cxx:19
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
RpcDigit
Definition: RpcDigit.h:16
NrpcDigitToNrpcRDO::m_NrpcContainerKey
SG::WriteHandleKey< xAOD::NRPCRDOContainer > m_NrpcContainerKey
Definition: NrpcDigitToNrpcRDO.h:36
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
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
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
createCablingJSON.cabling_data
dictionary cabling_data
Definition: createCablingJSON.py:18
xAOD::NRPCRDO_v1
Definition: NRPCRDO_v1.h:14
NrpcDigitToNrpcRDO::m_convStat
Gaudi::Property< std::vector< std::string > > m_convStat
Definition: NrpcDigitToNrpcRDO.h:28
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonNRPC_CablingMap
Definition: MuonNRPC_CablingMap.h:21
ShowData.h
NrpcDigitToNrpcRDO::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: NrpcDigitToNrpcRDO.h:38
MuonNRPC_CablingMap::getOnlineId
bool getOnlineId(NrpcCablingData &cabling_data, MsgStream &log) const
return the online id given the offline id
Definition: MuonNRPC_CablingMap.cxx:85
NrpcDigitToNrpcRDO.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
xAOD::NRPCRDO_v1::setChannel
void setChannel(uint16_t Channel)
Set the fire channel number.
NrpcDigitToNrpcRDO::m_digitContainerKey
SG::ReadHandleKey< RpcDigitContainer > m_digitContainerKey
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.
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
NrpcCablingData
Cabling information shipped around the Digi <-> Rdo conversions.
Definition: NrpcCablingData.h:121
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:379
NrpcDigitToNrpcRDO::m_cablingKey
SG::ReadCondHandleKey< MuonNRPC_CablingMap > m_cablingKey
Definition: NrpcDigitToNrpcRDO.h:31
xAOD::NRPCRDO_v1::setTdc
void setTdc(uint16_t Tdc)
Set the number of the TDC channel.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
NrpcDigitToNrpcRDO::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: NrpcDigitToNrpcRDO.cxx:44
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:122
NrpcDigitToNrpcRDO::m_selectedStations
std::set< int > m_selectedStations
Definition: NrpcDigitToNrpcRDO.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
NRPCRDOAuxContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
NrpcDigitToNrpcRDO::initialize
virtual StatusCode initialize() override final
Definition: NrpcDigitToNrpcRDO.cxx:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IdentifierHash
Definition: IdentifierHash.h:38
IdContext
class IdContext
Definition: IdContext.h:34
StoreGateSvc.h
xAOD::NRPCRDO_v1::setTime
void setTime(float Time)
Set the trigger time [ns].
MuonNRPC_CablingMap::convert
bool convert(const NrpcCablingData &cabling_data, Identifier &id, bool check_valid=true) const
converts the cabling data into an identifier.
Definition: MuonNRPC_CablingMap.cxx:31
xAOD::NRPCRDO_v1::setTimeoverthr
void setTimeoverthr(float Timeoverthr)
Set the time over threshold.
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67
RpcReadoutElement.h