CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
amc::Packet Class Reference

#include <AMCSpec.h>

Public Member Functions

void addPayload (const uint64_t *, unsigned int)
 
std::vector< uint64_t > block (unsigned int id) const
 
BlockHeader blockHeader (unsigned int block=0) const
 
unsigned int blocks () const
 
std::unique_ptr< uint64_t[]> data ()
 
void finalize (unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
 
Header header () const
 
 Packet (const uint64_t *d)
 
 Packet (unsigned int amc, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load, unsigned int user=0)
 
unsigned int size () const
 
Trailer trailer () const
 

Private Attributes

BlockHeader block_header_
 
Header header_
 
std::vector< uint64_t > payload_
 
Trailer trailer_
 

Detailed Description

Definition at line 128 of file AMCSpec.h.

Constructor & Destructor Documentation

◆ Packet() [1/2]

amc::Packet::Packet ( const uint64_t *  d)
inline

Definition at line 130 of file AMCSpec.h.

130 : block_header_(d){};
BlockHeader block_header_
Definition: AMCSpec.h:154
d
Definition: ztail.py:151

◆ Packet() [2/2]

Packet::Packet ( unsigned int  amc,
unsigned int  board,
unsigned int  lv1id,
unsigned int  orbit,
unsigned int  bx,
const std::vector< uint64_t > &  load,
unsigned int  user = 0 
)

Definition at line 101 of file AMCSpec.cc.

References header_, svgfig::load(), payload_, amc::Header::raw(), amc::Trailer::raw(), trailer_, and amc::Trailer::writeCRC().

108  : block_header_(amc, board, load.size() + 3), // add 3 words for header (2) and trailer (1)
109  header_(amc, lv1id, bx, load.size() + 3, orbit, board, user),
110  trailer_(0, lv1id, load.size() + 3) {
111  auto hdata = header_.raw();
112  payload_.reserve(load.size() + 3);
113  payload_.insert(payload_.end(), hdata.begin(), hdata.end());
114  payload_.insert(payload_.end(), load.begin(), load.end());
115  payload_.insert(payload_.end(), trailer_.raw());
116 
117  auto ptr = payload_.data();
118  Trailer::writeCRC(ptr, ptr + payload_.size() - 1);
119  }
static void writeCRC(const uint64_t *start, uint64_t *end)
Definition: AMCSpec.cc:94
BlockHeader block_header_
Definition: AMCSpec.h:154
std::vector< uint64_t > raw() const
Definition: AMCSpec.h:79
uint64_t raw() const
Definition: AMCSpec.h:112
Trailer trailer_
Definition: AMCSpec.h:159
def load(fileName)
Definition: svgfig.py:547
Header header_
Definition: AMCSpec.h:158
Definition: AMCSpec.h:8
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

Member Function Documentation

◆ addPayload()

void Packet::addPayload ( const uint64_t *  data,
unsigned int  size 
)

Definition at line 121 of file AMCSpec.cc.

References data(), payload_, and size().

121  {
122  payload_.insert(payload_.end(), data, data + size);
123  }
std::unique_ptr< uint64_t[]> data()
Definition: AMCSpec.cc:154
unsigned int size() const
Definition: AMCSpec.h:154
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

◆ block()

std::vector< uint64_t > Packet::block ( unsigned int  id) const

Definition at line 143 of file AMCSpec.cc.

References block_header_, amc::BlockHeader::getBlocks(), payload_, and amc::split_block_size.

143  {
144  if (id == 0 and id == block_header_.getBlocks() - 1) {
145  return payload_;
146  } else if (id == block_header_.getBlocks() - 1) {
147  return std::vector<uint64_t>(payload_.begin() + id * split_block_size, payload_.end());
148  } else {
149  return std::vector<uint64_t>(payload_.begin() + id * split_block_size,
150  payload_.begin() + (id + 1) * split_block_size);
151  }
152  }
BlockHeader block_header_
Definition: AMCSpec.h:154
unsigned int getBlocks() const
Definition: AMCSpec.cc:47
static const unsigned int split_block_size
Definition: AMCSpec.h:9
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

◆ blockHeader()

BlockHeader amc::Packet::blockHeader ( unsigned int  block = 0) const
inline

Definition at line 148 of file AMCSpec.h.

References block_header_.

148 { return block_header_; };
BlockHeader block_header_
Definition: AMCSpec.h:154

◆ blocks()

unsigned int amc::Packet::blocks ( ) const
inline

Definition at line 152 of file AMCSpec.h.

References block_header_, and amc::BlockHeader::getBlocks().

152 { return block_header_.getBlocks(); };
BlockHeader block_header_
Definition: AMCSpec.h:154
unsigned int getBlocks() const
Definition: AMCSpec.cc:47

◆ data()

std::unique_ptr< uint64_t[]> Packet::data ( )

Definition at line 154 of file AMCSpec.cc.

References mps_fire::i, and payload_.

Referenced by addPayload().

154  {
155  // Remove 3 words: 2 for the header, 1 for the trailer
156  std::unique_ptr<uint64_t[]> res(new uint64_t[payload_.size() - 3]);
157  for (unsigned int i = 0; i < payload_.size() - 3; ++i)
158  res.get()[i] = payload_[i + 2];
159  return res;
160  }
Definition: Electron.h:6
unsigned long long uint64_t
Definition: Time.h:13
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

◆ finalize()

void Packet::finalize ( unsigned int  lv1,
unsigned int  bx,
bool  legacy_mc = false,
bool  mtf7_mode = false 
)

Definition at line 125 of file AMCSpec.cc.

References block_header_, nano_mu_digi_cff::bx, RPCNoise_example::check, amc::Trailer::check(), cms::CRC32Calculator::checksum(), amc::BlockHeader::getAMCNumber(), amc::BlockHeader::getBoardID(), amc::BlockHeader::getSize(), amc::Header::getSize(), header_, payload_, AlCaHLTBitMon_QueryRunRegistry::string, and trailer_.

125  {
126  if (legacy_mc) {
127  header_ =
129 
130  payload_.insert(payload_.begin(), {0, 0});
131  payload_.insert(payload_.end(), {0});
132  } else {
133  header_ = Header(payload_.data());
134  trailer_ = Trailer(&payload_.back());
135 
136  std::string check(reinterpret_cast<const char *>(payload_.data()), payload_.size() * 8 - 4);
137  auto crc = cms::CRC32Calculator(check).checksum();
138 
139  trailer_.check(crc, lv1, header_.getSize(), mtf7_mode);
140  }
141  }
BlockHeader block_header_
Definition: AMCSpec.h:154
bool check(unsigned int crc, unsigned int lv1_id, unsigned int size, bool mtf7_mode=false) const
Definition: AMCSpec.cc:82
unsigned int getAMCNumber() const
Definition: AMCSpec.h:28
Trailer trailer_
Definition: AMCSpec.h:159
unsigned int getBoardID() const
Definition: AMCSpec.h:29
unsigned int getSize() const
Definition: AMCSpec.h:30
unsigned int getSize() const
Definition: AMCSpec.h:76
Header header_
Definition: AMCSpec.h:158
std::uint32_t checksum()
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

◆ header()

Header amc::Packet::header ( void  ) const
inline

Definition at line 149 of file AMCSpec.h.

References header_.

149 { return header_; };
Header header_
Definition: AMCSpec.h:158

◆ size()

unsigned int amc::Packet::size ( void  ) const
inline

Definition at line 154 of file AMCSpec.h.

References payload_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and addPayload().

154 { return payload_.size() - 3; };
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161

◆ trailer()

Trailer amc::Packet::trailer ( void  ) const
inline

Definition at line 150 of file AMCSpec.h.

References trailer_.

150 { return trailer_; };
Trailer trailer_
Definition: AMCSpec.h:159

Member Data Documentation

◆ block_header_

BlockHeader amc::Packet::block_header_
private

Definition at line 154 of file AMCSpec.h.

Referenced by block(), blockHeader(), blocks(), and finalize().

◆ header_

Header amc::Packet::header_
private

Definition at line 158 of file AMCSpec.h.

Referenced by finalize(), header(), and Packet().

◆ payload_

std::vector<uint64_t> amc::Packet::payload_
private

Definition at line 161 of file AMCSpec.h.

Referenced by addPayload(), block(), data(), finalize(), Packet(), and size().

◆ trailer_

Trailer amc::Packet::trailer_
private

Definition at line 159 of file AMCSpec.h.

Referenced by finalize(), Packet(), and trailer().