ATLAS Offline Software
Loading...
Searching...
No Matches
NRPC_RawDataProviderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9namespace Muon {
10
12
13 // Get ROBDataProviderSvc
14 ATH_CHECK(m_robDataProvider.retrieve());
15 ATH_CHECK(m_idHelperSvc.retrieve());
16 ATH_CHECK(m_rdoContainerKey.initialize());
17 ATH_CHECK(m_readKey.initialize());
18 return StatusCode::SUCCESS;
19}
20
22 const ROBFragmentList& vecRobs, const EventContext& ctx) const {
23
24 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
25 SG::WriteHandle rdoContainer(m_rdoContainerKey, ctx);
26 ATH_CHECK(rdoContainer.record(std::make_unique<xAOD::NRPCRDOContainer>(), std::make_unique<xAOD::NRPCRDOAuxContainer>()));
27
28 ATH_MSG_VERBOSE("convert(): " << vecRobs.size() << " ROBFragments.");
29
30 for (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment* frag : vecRobs) {
31 // convert only if data payload is delivered
32 if (frag->rod_ndata() != 0) {
33 ATH_CHECK(fillCollections(*frag, *rdoContainer).ignore() );
34 } else {
35 ATH_MSG_DEBUG(" ROB " << MSG::hex << frag->source_id() << " is delivered with an empty payload" );
36 }
37 }
38
39 return StatusCode::SUCCESS;
40}
41
42StatusCode NRPC_RawDataProviderTool::convert(const EventContext& ctx) const {
43 const RpcCablingMap* cabling{nullptr};
44 ATH_CHECK(SG::get(cabling, m_readKey, ctx));
45 return convert(cabling->getAllROBId(), ctx);
46}
47
48
49StatusCode NRPC_RawDataProviderTool::convert(const std::vector<IdentifierHash>& HashVec,
50 const EventContext& ctx) const {
51 const RpcCablingMap* cabling{nullptr};
52 ATH_CHECK(SG::get(cabling, m_readKey, ctx));
53 return convert(cabling->getROBId(HashVec, msgStream()), ctx);
54}
55
56StatusCode NRPC_RawDataProviderTool::convert(const std::vector<uint32_t>& robIds,
57 const EventContext& ctx) const {
58 ROBFragmentList vecOfRobf;
59 m_robDataProvider->getROBData(ctx, robIds, vecOfRobf);
60 return convertIntoContainer(vecOfRobf, ctx);
61}
62
63
65 xAOD::NRPCRDOContainer& rdoIdc) const {
66#define WARNING_WITH_LINE(msg) ATH_MSG_WARNING(__FILE__ << ":" << __LINE__<< " " << msg)
67 try {
68 robFrag.check();
69 } catch (eformat::Issue& ex) {
70 ATH_MSG_VERBOSE(ex.what());
71 return StatusCode::SUCCESS; // error in fragment
72 }
73
74 //uint32_t nstat = robFrag.nstatus();
75 uint32_t version = robFrag.rod_version();
76 uint32_t sourceId = robFrag.source_id();
77 uint32_t rod_sourceId = robFrag.rod_source_id();
78
79 // Unpack sub-detector and board sector from sourceId
80 uint16_t subDetector = sourceId >> 16;
81 uint16_t boardSector = (sourceId & 0x00ffff);
82
83 ATH_MSG_VERBOSE("ROD version: " << MSG::hex << version << MSG::dec << " ROB source ID: " << MSG::hex << sourceId << MSG::dec
84 << " ROD source ID: " << MSG::hex << rod_sourceId << MSG::dec << " Subdetector: " << MSG::hex
85 << subDetector << MSG::dec << " boardSector: " << std::hex
86 << boardSector << std::dec );
87
88
89
90 // get the pointer to the data
91 BS data;
92 robFrag.rod_data(data);
93
94 const unsigned int data_size = robFrag.rod_ndata();
95
96
97 // Loop on words
98 unsigned int idata=0;
99 while (idata<data_size) {
100 if (data[idata]==6 && data[idata+4]==0xa0 && data[idata+5]==0) {
101 ATH_MSG_DEBUG("NRPC: Empty board " << std::hex << data[idata+4] << std::dec << " for " << std::hex << data[idata+1] << std::dec );
102 } else if (data[idata]<6) {
103 WARNING_WITH_LINE("NRPC: Corrupted: Number of words from board " << std::hex << data[idata+4] << std::dec << " is <6 :" << data[idata] );
104 break;
105 } else if ( idata+data[idata] > data_size) {
106 WARNING_WITH_LINE("NRPC: Corrupted number of words from board " << std::hex << data[idata+4] << std::dec << " is too large :" << std::hex << data[idata] << std::dec );
107 break;
108 } else if ( (data[idata+data[idata]-2] & 0x000000ff) != 0xa0) {
109 WARNING_WITH_LINE("NRPC: Missing expected trailer a0" );
110 break;
111 } else {
112
113 // Bit inversion and manipulation needed to decode nominal BCID
114 uint32_t bcid12 = (data[idata+2] & 0xff000000) >> 24;
115 uint32_t bcid34 = (data[idata+2] & 0x00ff0000) >> 8;
116 uint32_t bcid56 = (data[idata+2] & 0x0000ff00) << 8;
117 uint32_t bcid78 = (data[idata+2] & 0x000000ff) << 24;
118 uint32_t bcid_nom = (bcid12 | bcid34 | bcid56 | bcid78) >> 4;
119
120 // Decode data
121 for (unsigned int i=0; i<data[idata]-6; i++) {
122 uint16_t board = (data[idata+4+i] & 0x000000ff) ;
123 uint16_t chan = (data[idata+4+i] & 0x0000ff00) >> 8 ;
124 float tot = ((data[idata+4+i] & 0x007f0000) >> 16)*0.4 ;
125 float time = ((data[idata+4+i] & 0x0f000000) >> 24)*1.6 ;
126 uint32_t bcid_hit = (data[idata+4+i] & 0xf0000000) >> 28 ;
127
128 // Compute the BCID of the hit combining the nominal BCID with the last 4 bits from the hit (bcid_hit)
129 uint32_t bcid_nom_4bits = (bcid_nom & 0x0000000f) ;
130 uint32_t bcid = 0 ;
131 if (bcid_hit >= bcid_nom_4bits) { // The BCID of the hit is subsequent to the nominal
132 bcid = ( (bcid_nom & 0xfffffff0) | bcid_hit );
133 } else {
134 bcid = ( (bcid_nom & 0xfffffff0) | bcid_hit ) + 0x00000010;
135 }
136
137 // Build the RDO
138 xAOD::NRPCRDO* NrpcRdo = rdoIdc.push_back(std::make_unique<xAOD::NRPCRDO>());
139 NrpcRdo->setBcid(bcid);
140 NrpcRdo->setTime(time);
141 NrpcRdo->setSubdetector(subDetector);
142 NrpcRdo->setBoardsector(boardSector);
143 NrpcRdo->setBoard(board);
144 NrpcRdo->setChannel(chan);
145 NrpcRdo->setTimeoverthr(tot);
146 }
147 }
148
149 idata+=data[idata];
150 }
151
152
153 return StatusCode::SUCCESS;
154
155} // end fillCollections
156
157
158
159
160} // namespace Muon
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
#define WARNING_WITH_LINE(msg)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
virtual StatusCode initialize() override
standard Athena-Algorithm method
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
virtual StatusCode fillCollections(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, xAOD::NRPCRDOContainer &rdoIdc) const
SG::WriteHandleKey< xAOD::NRPCRDOContainer > m_rdoContainerKey
virtual StatusCode convert() const
the new ones
OFFLINE_FRAGMENTS_NAMESPACE::PointerType BS
SG::ReadCondHandleKey< RpcCablingMap > m_readKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode convertIntoContainer(const ROBFragmentList &vecRobs, const EventContext &ctx) const
Convert method.
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.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
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.