ATLAS Offline Software
Loading...
Searching...
No Matches
NSWCommonDecoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4#include "ers/ers.h"
5#include "eformat/eformat.h"
6
11
12Muon::nsw::NSWCommonDecoder::NSWCommonDecoder (const eformat::read::ROBFragment &robFrag)
13 : m_has_error (false)
14{
15 static const uint32_t s_min_packet_size = 3; // felix header + null ROC header
16
17 robFrag.check ();
18
19 uint32_t nw = robFrag.rod_ndata ();
20 const uint32_t *bs = robFrag.rod_data (); // point directly to the first data element
21 const uint32_t *current_data_pointer = const_cast <uint32_t *> (bs);
22
23 uint32_t wcount(0); // data-element (32-bit word) counter
24
25 ERS_DEBUG (1, "NDATA FROM ROB HEADER: " << nw);
26
27 uint32_t remaining = nw;
28
29 while (remaining >= s_min_packet_size)
30 {
31 try
32 {
33 Muon::nsw::NSWElink *elink = new Muon::nsw::NSWElink (current_data_pointer, remaining);
34 m_elinks.push_back (elink);
35
36 // Append pointers to elink channels to a local channel vector
37
38 const std::vector <Muon::nsw::VMMChannel *> vchan = elink->get_channels ();
39 for (auto i = vchan.begin (); i != vchan.end (); ++i)
40 m_channels.push_back (*i);
41
42 wcount += elink->nwords ();
43 current_data_pointer += elink->nwords ();
44
45 ERS_DEBUG (1, "NDATA: " << nw << " WORD COUNTER: " << wcount);
46 ERS_DEBUG (1, "NPACKETS: " << m_elinks.size ());
47
48 remaining = nw - wcount;
49 }
50
51 catch (Muon::nsw::MuonNSWCommonDecoder::NSWElinkFelixHeaderException &e)
52 {
53 m_has_error = true;
54 ERS_DEBUG (1, e.what());
55 break;
56 }
57
58 catch (Muon::nsw::MuonNSWCommonDecoder::NSWElinkROCHeaderException &e)
59 {
60 m_has_error = true;
61 ERS_DEBUG (1, e.what());
62
63 // Try to move to next link
64
65 wcount += s_min_packet_size;
66 current_data_pointer += s_min_packet_size;
67 remaining = nw - wcount;
68 continue;
69 }
70 }
71}
72
74{
75 for (auto i = m_elinks.begin (); i != m_elinks.end (); ++i)
76 delete *i;
77}
NSWCommonDecoder(const eformat::read::ROBFragment &rob)
std::vector< Muon::nsw::NSWElink * > m_elinks
std::vector< Muon::nsw::VMMChannel * > m_channels