test
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, unsigned fmt_version)
13  : format_version_(fmt_version&0xF)
14  , source_id_(sourceId)
15  , bxnum_(bx)
16  , lvl1num_(l1num)
17 {
18  bzero(this, sizeInWords()*2);
19  source_id_ = sourceId;
20  bxnum_ = bx;
21  lvl1num_ = l1num;
22  format_version_ = fmt_version & 0xF;
23  init();
24 }
25 
26 
28 {
29  bit64_ = 5;
30  header2_2_ = 0x0001;
31  header2_1_ = header2_3_ = 0x8000;
32 }
33 
34 
35 void CSCDDUHeader::setDMBDAV(int dduInput)
36 {
37  // Set appropriate bit in dmb_dav_
38 
39  dmb_dav_ |= ((1 << dduInput) & 0x7FFF); // dduInput is 0-14
40 
41  live_cscs_ |= ((1 << dduInput) & 0x7FFF); // Set DDU Inputs Connected to "Live" CSCs
42 
43  // Count bits set in dmb_dav_... for the trick used see
44  // http://en.wikipedia.org/wiki/Hamming_weight or http://graphics.stanford.edu/~seander/bithacks.html
45 
46  ncsc_ = 0;
47  unsigned short dmbdav = dmb_dav_;
48  for( ; dmbdav; ++ncsc_ )
49  {
50  dmbdav &= dmbdav - 1;
51  }
52 }
53 
54 bool CSCDDUHeader::check() const
55 {
56  //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl;
57  return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000
58  && header2_2_ == 0x0001;
59 }
60 
unsigned source_id_
Definition: CSCDDUHeader.h:56
unsigned dmb_dav_
Definition: CSCDDUHeader.h:74
unsigned lvl1num_
Definition: CSCDDUHeader.h:59
bool check() const
Definition: CSCDDUHeader.cc:54
void setDMBDAV(int dduInput)
Definition: CSCDDUHeader.cc:35
unsigned header2_3_
Definition: CSCDDUHeader.h:68
unsigned header2_2_
Definition: CSCDDUHeader.h:67
unsigned ncsc_
Definition: CSCDDUHeader.h:71
unsigned header2_1_
Definition: CSCDDUHeader.h:66
unsigned live_cscs_
Definition: CSCDDUHeader.h:76
unsigned format_version_
Definition: CSCDDUHeader.h:55
unsigned bit64_
should always be 5
Definition: CSCDDUHeader.h:62
void init()
initializes constants
Definition: CSCDDUHeader.cc:27
static unsigned sizeInWords()
Definition: CSCDDUHeader.h:32
unsigned bxnum_
Definition: CSCDDUHeader.h:57