CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
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 size () const
 
Trailer trailer () const
 

Private Attributes

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

Detailed Description

Definition at line 123 of file AMCSpec.h.

Constructor & Destructor Documentation

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

Definition at line 125 of file AMCSpec.h.

125 : block_header_(d) {};
BlockHeader block_header_
Definition: AMCSpec.h:143
tuple d
Definition: ztail.py:151
Packet::Packet ( unsigned int  amc,
unsigned int  board,
unsigned int  lv1id,
unsigned int  orbit,
unsigned int  bx,
const std::vector< uint64_t > &  load 
)

Definition at line 126 of file AMCSpec.cc.

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

126  :
127  block_header_(amc, board, load.size() + 3), // add 3 words for header (2) and trailer (1)
128  header_(amc, lv1id, bx, load.size() + 3, orbit, board, 0),
129  trailer_(0, lv1id, load.size() + 3)
130  {
131  auto hdata = header_.raw();
132  payload_.reserve(load.size() + 3);
133  payload_.insert(payload_.end(), hdata.begin(), hdata.end());
134  payload_.insert(payload_.end(), load.begin(), load.end());
135  payload_.insert(payload_.end(), trailer_.raw());
136 
137  auto ptr = payload_.data();
138  Trailer::writeCRC(ptr, ptr + payload_.size() - 1);
139  }
static void writeCRC(const uint64_t *start, uint64_t *end)
Definition: AMCSpec.cc:118
BlockHeader block_header_
Definition: AMCSpec.h:143
uint64_t raw() const
Definition: AMCSpec.h:107
double amc
Definition: hdecay.h:20
std::vector< uint64_t > raw() const
Definition: AMCSpec.h:74
Trailer trailer_
Definition: AMCSpec.h:148
Header header_
Definition: AMCSpec.h:147
void load(int perCUT=90)
Definition: getMaxPt.h:59
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150

Member Function Documentation

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

Definition at line 142 of file AMCSpec.cc.

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

143  {
144  payload_.insert(payload_.end(), data, data + size);
145  }
unsigned int size() const
Definition: AMCSpec.h:143
std::unique_ptr< uint64_t[]> data()
Definition: AMCSpec.cc:179
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150
std::vector< uint64_t > Packet::block ( unsigned int  id) const

Definition at line 167 of file AMCSpec.cc.

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

168  {
169  if (id == 0 and id == block_header_.getBlocks() - 1) {
170  return payload_;
171  } else if (id == block_header_.getBlocks() - 1) {
172  return std::vector<uint64_t>(payload_.begin() + id * split_block_size, payload_.end());
173  } else {
174  return std::vector<uint64_t>(payload_.begin() + id * split_block_size, payload_.begin() + (id + 1) * split_block_size);
175  }
176  }
BlockHeader block_header_
Definition: AMCSpec.h:143
unsigned int getBlocks() const
Definition: AMCSpec.cc:54
static const unsigned int split_block_size
Definition: AMCSpec.h:9
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150
BlockHeader amc::Packet::blockHeader ( unsigned int  block = 0) const
inline

Definition at line 137 of file AMCSpec.h.

References block_header_.

137 { return block_header_; };
BlockHeader block_header_
Definition: AMCSpec.h:143
unsigned int amc::Packet::blocks ( ) const
inline

Definition at line 141 of file AMCSpec.h.

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

141 { return block_header_.getBlocks(); };
BlockHeader block_header_
Definition: AMCSpec.h:143
unsigned int getBlocks() const
Definition: AMCSpec.cc:54
std::unique_ptr< uint64_t[]> Packet::data ( )

Definition at line 179 of file AMCSpec.cc.

References i, and payload_.

Referenced by cuy.FindIssue::__init__(), and addPayload().

180  {
181  // Remove 3 words: 2 for the header, 1 for the trailer
182  std::unique_ptr<uint64_t[]> res(new uint64_t[payload_.size() - 3]);
183  for (unsigned int i = 0; i < payload_.size() - 3; ++i)
184  res.get()[i] = payload_[i + 2];
185  return res;
186  }
int i
Definition: DBlmapReader.cc:9
unsigned long long uint64_t
Definition: Time.h:15
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150
void Packet::finalize ( unsigned int  lv1,
unsigned int  bx,
bool  legacy_mc = false 
)

Definition at line 148 of file AMCSpec.cc.

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

149  {
150  if (legacy_mc) {
152 
153  payload_.insert(payload_.begin(), {0, 0});
154  payload_.insert(payload_.end(), {0});
155  } else {
156  header_ = Header(payload_.data());
157  trailer_ = Trailer(&payload_.back());
158 
159  std::string check(reinterpret_cast<const char*>(payload_.data()), payload_.size() * 8 - 4);
160  auto crc = cms::CRC32Calculator(check).checksum();
161 
162  trailer_.check(crc, lv1, header_.getSize());
163  }
164  }
BlockHeader block_header_
Definition: AMCSpec.h:143
unsigned int getAMCNumber() const
Definition: AMCSpec.h:28
bool check(const std::string &)
Trailer trailer_
Definition: AMCSpec.h:148
unsigned int getSize() const
Definition: AMCSpec.h:30
unsigned int getSize() const
Definition: AMCSpec.h:71
unsigned int getBoardID() const
Definition: AMCSpec.h:29
Header header_
Definition: AMCSpec.h:147
std::uint32_t checksum()
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150
Header amc::Packet::header ( void  ) const
inline

Definition at line 138 of file AMCSpec.h.

References header_.

138 { return header_; };
Header header_
Definition: AMCSpec.h:147
unsigned int amc::Packet::size ( void  ) const
inline

Definition at line 143 of file AMCSpec.h.

References payload_.

Referenced by addPayload().

143 { return payload_.size() - 3; };
std::vector< uint64_t > payload_
Definition: AMCSpec.h:150
Trailer amc::Packet::trailer ( void  ) const
inline

Definition at line 139 of file AMCSpec.h.

References trailer_.

139 { return trailer_; };
Trailer trailer_
Definition: AMCSpec.h:148

Member Data Documentation

BlockHeader amc::Packet::block_header_
private

Definition at line 143 of file AMCSpec.h.

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

Header amc::Packet::header_
private

Definition at line 147 of file AMCSpec.h.

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

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

Definition at line 150 of file AMCSpec.h.

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

Trailer amc::Packet::trailer_
private

Definition at line 148 of file AMCSpec.h.

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