CMS 3D CMS Logo

CSCDDUHeader.cc
Go to the documentation of this file.
2 #include <cstring> // for bzero
3 #include <iostream>
4 
6  bzero(this, sizeInWords() * 2);
7  init();
8 }
9 
10 CSCDDUHeader::CSCDDUHeader(unsigned bx, unsigned l1num, unsigned sourceId, unsigned fmt_version)
11  : format_version_(fmt_version & 0xF), source_id_(sourceId), bxnum_(bx), lvl1num_(l1num) {
12  bzero(this, sizeInWords() * 2);
14  bxnum_ = bx;
15  lvl1num_ = l1num;
16  format_version_ = fmt_version & 0xF;
17  init();
18 }
19 
21  bit64_ = 5;
22  header2_2_ = 0x0001;
23  header2_1_ = header2_3_ = 0x8000;
24 }
25 
26 void CSCDDUHeader::setDMBDAV(int dduInput) {
27  // Set appropriate bit in dmb_dav_
28 
29  dmb_dav_ |= ((1 << dduInput) & 0x7FFF); // dduInput is 0-14
30 
31  live_cscs_ |= ((1 << dduInput) & 0x7FFF); // Set DDU Inputs Connected to "Live" CSCs
32 
33  // Count bits set in dmb_dav_... for the trick used see
34  // http://en.wikipedia.org/wiki/Hamming_weight or http://graphics.stanford.edu/~seander/bithacks.html
35 
36  ncsc_ = 0;
37  unsigned short dmbdav = dmb_dav_;
38  for (; dmbdav; ++ncsc_) {
39  dmbdav &= dmbdav - 1;
40  }
41 }
42 
43 bool CSCDDUHeader::check() const {
44  //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl;
45  return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000 && header2_2_ == 0x0001;
46 }
unsigned source_id_
Definition: CSCDDUHeader.h:56
unsigned dmb_dav_
Definition: CSCDDUHeader.h:73
unsigned lvl1num_
Definition: CSCDDUHeader.h:59
void setDMBDAV(int dduInput)
Definition: CSCDDUHeader.cc:26
unsigned header2_3_
Definition: CSCDDUHeader.h:68
unsigned header2_2_
Definition: CSCDDUHeader.h:67
unsigned ncsc_
Definition: CSCDDUHeader.h:70
unsigned header2_1_
Definition: CSCDDUHeader.h:66
unsigned live_cscs_
Definition: CSCDDUHeader.h:75
unsigned format_version_
Definition: CSCDDUHeader.h:55
unsigned bit64_
should always be 5
Definition: CSCDDUHeader.h:62
void init()
initializes constants
Definition: CSCDDUHeader.cc:20
static unsigned sizeInWords()
Definition: CSCDDUHeader.h:31
unsigned bxnum_
Definition: CSCDDUHeader.h:57
bool check() const
Definition: CSCDDUHeader.cc:43