ATLAS Offline Software
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 
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 
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 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Muon::nsw::NSWCommonDecoder::~NSWCommonDecoder
virtual ~NSWCommonDecoder()
Definition: NSWCommonDecoder.cxx:73
Muon::nsw::NSWCommonDecoder::m_channels
std::vector< Muon::nsw::VMMChannel * > m_channels
Definition: NSWCommonDecoder.h:34
Muon::nsw::NSWCommonDecoder::m_has_error
bool m_has_error
Definition: NSWCommonDecoder.h:28
Muon::nsw::NSWCommonDecoder::m_elinks
std::vector< Muon::nsw::NSWElink * > m_elinks
Definition: NSWCommonDecoder.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
VMMChannel.h
NSWCommonDecoder.h
Muon::nsw::NSWElinkROCHeaderException
NSWElinkROCHeaderException
Definition: NSWDecodeExceptions.h:22
NSWDecodeExceptions.h
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
Muon::nsw::NSWCommonDecoder::NSWCommonDecoder
NSWCommonDecoder(const eformat::read::ROBFragment &rob)
Definition: NSWCommonDecoder.cxx:12