CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Block.cc
Go to the documentation of this file.
1 #include <iomanip>
2 
4 
6 
7 #define EDM_ML_DEBUG 1
8 
9 namespace l1t {
10  uint32_t
12  {
13  if (type_ == MP7) {
14  LogTrace("L1T") << "Writing MP7 link header";
15  return ((id_ & ID_mask) << ID_shift) | ((size_ & size_mask) << size_shift) | ((capID_ & capID_mask) << capID_shift);
16  }
17  LogTrace("L1T") << "Writing CTP7 link header";
18  return ((id_ & CTP7_mask) << CTP7_shift);
19  }
20 
21  std::auto_ptr<Block>
23  {
24  if (end_ - data_ < getHeaderSize()) {
25  LogDebug("L1T") << "Reached end of payload";
26  return std::auto_ptr<Block>();
27  }
28 
29  if (data_[0] == 0xffffffff) {
30  LogDebug("L1T") << "Skipping padding word";
31  ++data_;
32  return getBlock();
33  }
34 
35  auto header = getHeader();
36 
37  if (end_ - data_ < header.getSize()) {
38  edm::LogError("L1T")
39  << "Expecting a block size of " << header.getSize()
40  << " but only " << (end_ - data_) << " words remaining";
41  return std::auto_ptr<Block>();
42  }
43 
44  LogTrace("L1T") << "Creating block with size " << header.getSize();
45 
46  auto res = std::auto_ptr<Block>(new Block(header, data_, data_ + header.getSize()));
47  data_ += header.getSize();
48  return res;
49  }
50 
51  MP7Payload::MP7Payload(const uint32_t * data, const uint32_t * end, bool legacy_mc) : Payload(data, end)
52  {
53  // For legacy MC (74 first MC campaigns) skip one empty word that was
54  // reserved for the header. With data, read out infrastructure
55  // version and algorithm version.
56  if (legacy_mc) {
57  LogTrace("L1T") << "Skipping " << std::hex << *data_;
58  ++data_;
59  } else {
60  infra_ = data_[0];
61  algo_ = data_[1];
62  data_ += 2;
63  }
64  }
65 
68  {
69  LogTrace("L1T") << "Getting header from " << std::hex << std::setw(8) << *data_;
70 
71  return BlockHeader(data_++);
72  }
73 
74  CTP7Payload::CTP7Payload(const uint32_t * data, const uint32_t * end) : Payload(data, end)
75  {
76  ++data_;
77  size_ = (*data >> size_shift) & size_mask;
78  ++data_;
79  }
80 
83  {
84  return BlockHeader(data_++, size_);
85  }
86 }
#define LogDebug(id)
uint32_t raw(block_t type=MP7) const
Definition: Block.cc:11
type
Definition: HCALResponse.h:21
static const unsigned int capID_mask
Definition: Block.h:37
static const unsigned int size_shift
Definition: Block.h:105
virtual BlockHeader getHeader() override
Definition: Block.cc:82
static const unsigned int CTP7_mask
Definition: Block.h:31
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
Definition: Block.cc:51
std::auto_ptr< Block > getBlock()
Definition: Block.cc:22
Definition: Block.h:10
static const unsigned int ID_shift
Definition: Block.h:32
block_t type_
Definition: Block.h:42
const uint32_t * end_
Definition: Block.h:84
static const unsigned int ID_mask
Definition: Block.h:33
unsigned size_
Definition: Block.h:107
virtual BlockHeader getHeader()=0
block_t
Definition: Block.h:10
CTP7Payload(const uint32_t *data, const uint32_t *end)
Definition: Block.cc:74
virtual unsigned getHeaderSize() const =0
static const unsigned int size_mask
Definition: Block.h:35
#define end
Definition: vmac.h:37
unsigned infra_
Definition: Block.h:87
unsigned int size_
Definition: Block.h:40
#define LogTrace(id)
unsigned int capID_
Definition: Block.h:41
const uint32_t * data_
Definition: Block.h:83
virtual BlockHeader getHeader() override
Definition: Block.cc:67
static const unsigned int size_mask
Definition: Block.h:104
static const unsigned int CTP7_shift
Definition: Block.h:30
unsigned int id_
Definition: Block.h:39
static const unsigned int capID_shift
Definition: Block.h:36
static const unsigned int size_shift
Definition: Block.h:34
unsigned algo_
Definition: Block.h:86