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){};

◆ 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.

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  }

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

Member Function Documentation

◆ addPayload()

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

Definition at line 121 of file AMCSpec.cc.

121  {
122  payload_.insert(payload_.end(), data, data + size);
123  }

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

◆ block()

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

Definition at line 143 of file AMCSpec.cc.

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  }

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

◆ blockHeader()

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

Definition at line 148 of file AMCSpec.h.

148 { return block_header_; };

References block_header_.

◆ blocks()

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

Definition at line 152 of file AMCSpec.h.

152 { return block_header_.getBlocks(); };

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

◆ data()

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

Definition at line 154 of file AMCSpec.cc.

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  }

References mps_fire::i, and payload_.

Referenced by addPayload().

◆ 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.

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  }

References block_header_, l1GtPatternGenerator_cfi::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_.

◆ header()

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

Definition at line 149 of file AMCSpec.h.

149 { return header_; };

References header_.

◆ size()

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

Definition at line 154 of file AMCSpec.h.

154 { return payload_.size() - 3; };

References payload_.

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

◆ trailer()

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

Definition at line 150 of file AMCSpec.h.

150 { return trailer_; };

References trailer_.

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().

mps_fire.i
i
Definition: mps_fire.py:355
Header
Definition: MsgHeader.h:6
amc::Trailer::writeCRC
static void writeCRC(const uint64_t *start, uint64_t *end)
Definition: AMCSpec.cc:94
amc::Packet::trailer_
Trailer trailer_
Definition: AMCSpec.h:159
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
cms::CRC32Calculator
Definition: CRC32Calculator.h:62
cms::CRC32Calculator::checksum
std::uint32_t checksum()
Definition: CRC32Calculator.h:66
amc::Trailer::check
bool check(unsigned int crc, unsigned int lv1_id, unsigned int size, bool mtf7_mode=false) const
Definition: AMCSpec.cc:82
amc::split_block_size
static const unsigned int split_block_size
Definition: AMCSpec.h:9
amc::Packet::payload_
std::vector< uint64_t > payload_
Definition: AMCSpec.h:161
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
amc::BlockHeader::getBlocks
unsigned int getBlocks() const
Definition: AMCSpec.cc:47
amc::Trailer::raw
uint64_t raw() const
Definition: AMCSpec.h:112
svgfig.load
def load(fileName)
Definition: svgfig.py:547
amc::Packet::header_
Header header_
Definition: AMCSpec.h:158
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
amc::Header::raw
std::vector< uint64_t > raw() const
Definition: AMCSpec.h:79
res
Definition: Electron.h:6
amc::BlockHeader::getAMCNumber
unsigned int getAMCNumber() const
Definition: AMCSpec.h:28
EnviromentSettings.user
user
Definition: EnviromentSettings.py:30
amc::BlockHeader::getBoardID
unsigned int getBoardID() const
Definition: AMCSpec.h:29
amc::Header::getSize
unsigned int getSize() const
Definition: AMCSpec.h:76
amc::BlockHeader::getSize
unsigned int getSize() const
Definition: AMCSpec.h:30
amc
Definition: AMCSpec.h:8
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
amc::Packet::block_header_
BlockHeader block_header_
Definition: AMCSpec.h:154
ztail.d
d
Definition: ztail.py:151
amc::Packet::data
std::unique_ptr< uint64_t[]> data()
Definition: AMCSpec.cc:154
amc::Packet::size
unsigned int size() const
Definition: AMCSpec.h:154