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 dmbId) 00032 { 00033 dmb_dav_ |= (1 << dmbId); 00034 // use Ritchie algo to count bits 00035 ncsc_ = 0; 00036 unsigned short dmbdav = dmb_dav_; 00037 for( ; dmbdav; ++ncsc_) 00038 { 00039 dmbdav &= dmbdav - 1; 00040 } 00041 } 00042 00043 bool CSCDDUHeader::check() const 00044 { 00045 //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl; 00046 return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000 00047 && header2_2_ == 0x0001; 00048 } 00049