CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDDUHeader.cc
Go to the documentation of this file.
2 #include <string.h> // for bzero
3 #include <iostream>
4 
6 {
7  bzero(this, sizeInWords()*2);
8  init();
9 }
10 
11 
12 CSCDDUHeader::CSCDDUHeader(unsigned bx, unsigned l1num, unsigned sourceId)
13  : source_id_(sourceId), bxnum_(bx), lvl1num_(l1num)
14 {
15  bzero(this, sizeInWords()*2);
16  source_id_ = sourceId;
17  bxnum_ = bx;
18  lvl1num_ = l1num;
19  init();
20 }
21 
22 
24 {
25  bit64_ = 5;
26  header2_2_ = 0x0001;
27  header2_1_ = header2_3_ = 0x8000;
28 }
29 
30 
31 void CSCDDUHeader::setDMBDAV(int dduInput)
32 {
33  // Set appropriate bit in dmb_dav_
34 
35  dmb_dav_ |= (1 << dduInput); // dduInput is 0-14
36 
37  // Count bits set in dmb_dav_... for the trick used see
38  // http://en.wikipedia.org/wiki/Hamming_weight or http://graphics.stanford.edu/~seander/bithacks.html
39 
40  ncsc_ = 0;
41  unsigned short dmbdav = dmb_dav_;
42  for( ; dmbdav; ++ncsc_ )
43  {
44  dmbdav &= dmbdav - 1;
45  }
46 }
47 
48 bool CSCDDUHeader::check() const
49 {
50  //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl;
51  return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000
52  && header2_2_ == 0x0001;
53 }
54 
unsigned source_id_
Definition: CSCDDUHeader.h:44
unsigned dmb_dav_
Definition: CSCDDUHeader.h:62
unsigned lvl1num_
Definition: CSCDDUHeader.h:47
bool check() const
Definition: CSCDDUHeader.cc:48
void setDMBDAV(int dduInput)
Definition: CSCDDUHeader.cc:31
unsigned header2_3_
Definition: CSCDDUHeader.h:56
unsigned header2_2_
Definition: CSCDDUHeader.h:55
unsigned ncsc_
Definition: CSCDDUHeader.h:59
unsigned header2_1_
Definition: CSCDDUHeader.h:54
unsigned bit64_
should always be 5
Definition: CSCDDUHeader.h:50
void init()
initializes constants
Definition: CSCDDUHeader.cc:23
static unsigned sizeInWords()
Definition: CSCDDUHeader.h:31
unsigned bxnum_
Definition: CSCDDUHeader.h:45