ATLAS Offline Software
Loading...
Searching...
No Matches
BCM_RodDecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// BCM_RodDecoder.cxx
7// Implementation file for class BCM_RodDecoder
11// Version 00-00-01 12/05/2008 Daniel Dobos
12// Version 00-00-11 05/02/2009 Daniel Dobos
14
15#include "BCM_RodDecoder.h"
16
17#include <cinttypes>
18
19static const InterfaceID IID_IBCM_RodDecoder("BCM_RodDecoder", 1, 0);
20const InterfaceID& BCM_RodDecoder::interfaceID()
21{
23}
24
26// destructor
31
33// initialize() -
36{
37#ifdef BCM_DEBUG
38 ATH_MSG_VERBOSE( "in BCM_RodDecoder::initialize" );
39#endif
40
41 ATH_CHECK( AthAlgTool::initialize() );
42
45 m_hit_number = 0;
46
47 return StatusCode::SUCCESS;
48}
49
51// finalize() -
54{
55#ifdef BCM_DEBUG
56 ATH_MSG_VERBOSE( "in BCM_RodDecoder::finalize" );
57#endif
58
59 ATH_MSG_INFO( "Bytestream summary: " << m_fragment_number << " fragments found" );
60 ATH_MSG_INFO( "Bytestream summary: " << m_LVL1A_number << " LVL1As found" );
61 ATH_MSG_INFO( "Bytestream summary: " << m_hit_number << " hits found" );
62
63 return StatusCode::SUCCESS;
64}
65
67// fillCollection() -
69StatusCode BCM_RodDecoder::fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, BCM_RDO_Container* rdoCont, std::vector<unsigned int>* /*vecHash*/) const
70{
71#ifdef BCM_DEBUG
72 ATH_MSG_INFO( "in BCM_RodDecoder::fillCollection" );
73#endif
74
75 StatusCode sc = StatusCode::SUCCESS;
76
77 BCM_RDO_Collection* coll = nullptr;
78
79 // set the data pointer type
81 robFrag->rod_data(vint);
82
83 // get source ID
84 int ROD_source_ID = robFrag->rod_source_id();
85
86 // get LVL1 ID
87 int ROD_LVL1_ID = robFrag->rod_lvl1_id();
88
89 // get BC ID
90 //int m_ROD_BC_ID = robFrag->rod_bc_id();
91
92 // get number of data words in the fragment
93 uint32_t dataword_it_end = robFrag->rod_ndata();
94
95 unsigned int Channel = 0;
96 unsigned int Pulse1Position = 0;
97 unsigned int Pulse1Width = 0;
98 unsigned int Pulse2Position = 0;
99 unsigned int Pulse2Width = 0;
100 unsigned int LVL1A = 0;
101 unsigned int BCID = 0;
102 unsigned int Error = 0;
103 uint32_t rawDataWord_buffer = 0;
104
106
107 // loop over the data words in the fragment
108 for (uint32_t dataword_it = 0; dataword_it < dataword_it_end; ++dataword_it) {
109 uint32_t rawDataWord = vint[dataword_it]; // set the dataword to investigate
110 unsigned int dataword_position = dataword_it%6;
111 switch(dataword_position) {
112 case 0:
113 if (dataword_it + 5 <=dataword_it_end) {
114 uint32_t lastDataWord = vint[dataword_it+5];
115 Error = (lastDataWord & 0x0000000f);
116 } else {
117 Error = 15;
118 }
119 BCID = (rawDataWord & 0xfff00000) >> 20;
120 LVL1A = dataword_it / 6;
122 Channel = getChannelID(ROD_source_ID, 0);
123 coll = getCollection(Channel,rdoCont);
124 Pulse1Position = (rawDataWord & 0x000fc000) >> 14;
125 Pulse1Width = (rawDataWord & 0x00003e00) >> 9;
126 Pulse2Position = (rawDataWord & 0x000001f8) >> 3;
127 rawDataWord_buffer = (rawDataWord & 0x00000007);
128 break;
129 case 1:
130 Pulse2Width = ((rawDataWord & 0xc0000000) >> 30) | (rawDataWord_buffer << 2);
131#ifdef BCM_DEBUG
132 if (Pulse1Width != 0 || Pulse2Width != 0) {
133 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
134 }
135 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
136#endif
137 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
138 m_hit_number++;
139 Channel = getChannelID(ROD_source_ID, 1);
140 coll = getCollection(Channel,rdoCont);
141 Pulse1Position = (rawDataWord & 0x3f000000) >> 24;
142 Pulse1Width = (rawDataWord & 0x00f80000) >> 19;
143 Pulse2Position = (rawDataWord & 0x0007e000) >> 13;
144 Pulse2Width = (rawDataWord & 0x00001f00) >> 8;
145#ifdef BCM_DEBUG
146 if (Pulse1Width != 0 || Pulse2Width != 0) {
147 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
148 }
149 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
150#endif
151 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
152 m_hit_number++;
153 Channel = getChannelID(ROD_source_ID, 2);
154 coll = getCollection(Channel,rdoCont);
155 Pulse1Position = (rawDataWord & 0x000000fc) >> 2;
156 rawDataWord_buffer = (rawDataWord & 0x00000003);
157 break;
158 case 2:
159 Pulse1Width = ((rawDataWord & 0xe0000000) >> 29) | (rawDataWord_buffer << 3);
160 Pulse2Position = (rawDataWord & 0x1f800000) >> 23;
161 Pulse2Width = (rawDataWord & 0x007c0000) >> 18;
162#ifdef BCM_DEBUG
163 if (Pulse1Width != 0 || Pulse2Width != 0) {
164 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
165 }
166 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
167#endif
168 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
169 m_hit_number++;
170 Channel = getChannelID(ROD_source_ID, 3);
171 coll = getCollection(Channel,rdoCont);
172 Pulse1Position = (rawDataWord & 0x0003f000) >> 12;
173 Pulse1Width = (rawDataWord & 0x00000f80) >> 7;
174 Pulse2Position = (rawDataWord & 0x0000007e) >> 1;
175 rawDataWord_buffer = (rawDataWord & 0x00000001);
176 break;
177 case 3:
178 Pulse2Width = ((rawDataWord & 0xf0000000) >> 28) | (rawDataWord_buffer << 4);
179#ifdef BCM_DEBUG
180 if (Pulse1Width != 0 || Pulse2Width != 0) {
181 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
182 }
183 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
184#endif
185 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
186 m_hit_number++;
187 Channel = getChannelID(ROD_source_ID, 4);
188 coll = getCollection(Channel,rdoCont);
189 Pulse1Position = (rawDataWord & 0x0fc00000) >> 22;
190 Pulse1Width = (rawDataWord & 0x003e0000) >> 17;
191 Pulse2Position = (rawDataWord & 0x0001f800) >> 11;
192 Pulse2Width = (rawDataWord & 0x000007c0) >> 6;
193#ifdef BCM_DEBUG
194 if (Pulse1Width != 0 || Pulse2Width != 0) {
195 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
196 }
197 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width);
198#endif
199 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
200 m_hit_number++;
201 Channel = getChannelID(ROD_source_ID, 5);
202 coll = getCollection(Channel,rdoCont);
203 Pulse1Position = (rawDataWord & 0x0000003f);
204 break;
205 case 4:
206 Pulse1Width = (rawDataWord & 0xf8000000) >> 27;
207 Pulse2Position = (rawDataWord & 0x07e00000) >> 21;
208 Pulse2Width = (rawDataWord & 0x001f0000) >> 16;
209#ifdef BCM_DEBUG
210 if (Pulse1Width != 0 || Pulse2Width != 0) {
211 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width);
212 }
213 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
214#endif
215 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
216 m_hit_number++;
217 Channel = getChannelID(ROD_source_ID, 6);
218 coll = getCollection(Channel,rdoCont);
219 Pulse1Position = (rawDataWord & 0x0000fc00) >> 10;
220 Pulse1Width = (rawDataWord & 0x000003e0) >> 5;
221 rawDataWord_buffer = (rawDataWord & 0x0000001f);
222 break;
223 case 5:
224 Pulse2Position = ((rawDataWord & 0x80000000) >> 31) | (rawDataWord_buffer << 1);
225 Pulse2Width = (rawDataWord & 0x7c000000) >> 26;
226#ifdef BCM_DEBUG
227 if (Pulse1Width != 0 || Pulse2Width != 0) {
228 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
229 }
230 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
231#endif
232 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
233 m_hit_number++;
234 Channel = getChannelID(ROD_source_ID, 7);
235 coll = getCollection(Channel,rdoCont);
236 Pulse1Position = (rawDataWord & 0x03f00000) >> 20;
237 Pulse1Width = (rawDataWord & 0x000f8000) >> 15;
238 Pulse2Position = (rawDataWord & 0x00007e00) >> 9;
239 Pulse2Width = (rawDataWord & 0x000001f0) >> 4;
240#ifdef BCM_DEBUG
241 if (Pulse1Width != 0 || Pulse2Width != 0) {
242 ATH_MSG_ERROR( "BCM-ISSUE L1ID: " << ROD_LVL1_ID << " Ch: " << Channel << " L1A: " << LVL1A << " BCID: " << BCID << " Hit: " << Pulse1Position << " " << Pulse1Width << " " << Pulse2Position << " " << Pulse2Width );
243 }
244 ATH_MSG_DEBUG( "Decoded ROD 0x"<< std::hex<<ROD_source_ID<<std::dec <<" channel: "<< Channel <<" - BCID: "<< BCID <<" : "<< Pulse1Position <<"-"<< Pulse1Width <<" "<< Pulse2Position <<"-"<< Pulse2Width );
245#endif
246 coll->push_back(new RDO(Channel,Pulse1Position,Pulse1Width,Pulse2Position,Pulse2Width,LVL1A,BCID,ROD_LVL1_ID,Error));
247 m_hit_number++;
248 break;
249 }
250 }
251
252 return sc;
253}
254
256// getChannelID() - convert ROD source ID, dataword position combination into ChannelID number
258unsigned int BCM_RodDecoder::getChannelID(int ROD_source_ID, unsigned int dataword_position) const
259{
260 switch(ROD_source_ID) {
261 // Run-1 Fragment
262 case 0x0081000A:
263 switch(dataword_position) {
264 case 0:
265 return 0;
266 case 1:
267 return 9;
268 case 2:
269 return 2;
270 case 3:
271 return 11;
272 case 4:
273 return 4;
274 case 5:
275 return 13;
276 case 6:
277 return 6;
278 case 7:
279 return 15;
280 default:
281 return 0xffffffff;
282 }
283 // Run-2 Fragment
284 case 0x0081004A:
285 switch(dataword_position) {
286 case 0:
287 return 0;
288 case 1:
289 return 9;
290 case 2:
291 return 2;
292 case 3:
293 return 11;
294 case 4:
295 return 4;
296 case 5:
297 return 13;
298 case 6:
299 return 6;
300 case 7:
301 return 15;
302 default:
303 return 0xffffffff;
304 }
305 // Run-1 Fragment
306 case 0x0081000C:
307 switch(dataword_position) {
308 case 0:
309 return 8;
310 case 1:
311 return 1;
312 case 2:
313 return 10;
314 case 3:
315 return 3;
316 case 4:
317 return 12;
318 case 5:
319 return 5;
320 case 6:
321 return 14;
322 case 7:
323 return 7;
324 default:
325 return 0xffffffff;
326 }
327 // Run-2 fragment
328 case 0x0081004C:
329 switch(dataword_position) {
330 case 0:
331 return 8;
332 case 1:
333 return 1;
334 case 2:
335 return 10;
336 case 3:
337 return 3;
338 case 4:
339 return 12;
340 case 5:
341 return 5;
342 case 6:
343 return 14;
344 case 7:
345 return 7;
346 default:
347 return 0xffffffff;
348 }
349 default:
350 return 0xffffffff;
351 }
352}
353
355// getCollection() - return collection corresponding to a particular channel
356// if it exists in container, or create it if it doesn't
359{
360 BCM_RDO_Collection* coll;
362 bool collExists = false;
364 BCM_RDO_Container::iterator itE= cont->end();
365 for (; it!=itE; ++it) {
366 if ((*it)->getChannel() == chan) {
367 collExists = true;
368 cont_it = it;
369 }
370 }
371 if (collExists) {
372 coll = *cont_it;
373 } else { // if collection does not exist create it
374 coll = new BCM_RDO_Collection(chan);
375 cont->push_back(coll); // add collection to container
376 }
377 return coll;
378}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static const InterfaceID IID_IBCM_RodDecoder("BCM_RodDecoder", 1, 0)
static Double_t sc
virtual StatusCode initialize() override
unsigned int getChannelID(int ROD_source_ID, unsigned int dataword_position) const
BCM_RawData RDO
virtual ~BCM_RodDecoder()
static const InterfaceID & interfaceID()
virtual StatusCode finalize() override
std::atomic< unsigned int > m_LVL1A_number
StatusCode fillCollection(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFrag, BCM_RDO_Container *rdoCont, std::vector< unsigned int > *vecHash=NULL) const
BCM_RDO_Collection * getCollection(unsigned int chan, BCM_RDO_Container *cont) const
std::atomic< unsigned int > m_hit_number
std::atomic< unsigned int > m_fragment_number
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const DataType * PointerType
Definition RawEvent.h:25
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27