CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/EventFilter/CSCRawToDigi/src/CSCDDUHeader.cc

Go to the documentation of this file.
00001 #include "EventFilter/CSCRawToDigi/interface/CSCDDUHeader.h"
00002 #include <string.h> // for bzero
00003 #include <iostream>
00004 
00005 CSCDDUHeader::CSCDDUHeader() 
00006 {
00007   bzero(this, sizeInWords()*2);
00008   init();
00009 }
00010 
00011 
00012 CSCDDUHeader::CSCDDUHeader(unsigned bx, unsigned l1num, unsigned sourceId) 
00013   : source_id_(sourceId), bxnum_(bx), lvl1num_(l1num)
00014 {
00015   bzero(this, sizeInWords()*2);
00016   source_id_ = sourceId;
00017   bxnum_ = bx;
00018   lvl1num_ = l1num;
00019   init();
00020 }
00021 
00022 
00023 void CSCDDUHeader::init() 
00024 {
00025   bit64_ = 5;
00026   header2_2_ = 0x0001;
00027   header2_1_ = header2_3_ = 0x8000;
00028 }
00029 
00030 
00031 void CSCDDUHeader::setDMBDAV(int dduInput) 
00032 {
00033   // Set appropriate bit in dmb_dav_
00034 
00035   dmb_dav_ |= (1 << dduInput);  // dduInput is 0-14
00036 
00037   // Count bits set in dmb_dav_... for the trick used see
00038   // https://en.wikipedia.org/wiki/Hamming_weight or https://graphics.stanford.edu/~seander/bithacks.html
00039 
00040   ncsc_ = 0;
00041   unsigned short dmbdav = dmb_dav_;
00042   for( ; dmbdav; ++ncsc_ )
00043   {
00044     dmbdav &= dmbdav - 1;
00045   }
00046 }
00047 
00048 bool CSCDDUHeader::check() const 
00049 {
00050   //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl;
00051   return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000
00052   && header2_2_ == 0x0001;
00053 }
00054