Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:26

0001 #include "EventFilter/CSCRawToDigi/interface/CSCDDUHeader.h"
0002 #include <cstring>  // for bzero
0003 #include <iostream>
0004 
0005 CSCDDUHeader::CSCDDUHeader() {
0006   bzero(this, sizeInWords() * 2);
0007   init();
0008 }
0009 
0010 CSCDDUHeader::CSCDDUHeader(unsigned bx, unsigned l1num, unsigned sourceId, unsigned fmt_version)
0011     : format_version_(fmt_version & 0xF), source_id_(sourceId), bxnum_(bx), lvl1num_(l1num) {
0012   bzero(this, sizeInWords() * 2);
0013   source_id_ = sourceId;
0014   bxnum_ = bx;
0015   lvl1num_ = l1num;
0016   format_version_ = fmt_version & 0xF;
0017   init();
0018 }
0019 
0020 void CSCDDUHeader::init() {
0021   bit64_ = 5;
0022   header2_2_ = 0x0001;
0023   header2_1_ = header2_3_ = 0x8000;
0024 }
0025 
0026 void CSCDDUHeader::setDMBDAV(int dduInput) {
0027   // Set appropriate bit in dmb_dav_
0028 
0029   dmb_dav_ |= ((1 << dduInput) & 0x7FFF);  // dduInput is 0-14
0030 
0031   live_cscs_ |= ((1 << dduInput) & 0x7FFF);  // Set DDU Inputs Connected to "Live" CSCs
0032 
0033   // Count bits set in dmb_dav_... for the trick used see
0034   // http://en.wikipedia.org/wiki/Hamming_weight or http://graphics.stanford.edu/~seander/bithacks.html
0035 
0036   ncsc_ = 0;
0037   unsigned short dmbdav = dmb_dav_;
0038   for (; dmbdav; ++ncsc_) {
0039     dmbdav &= dmbdav - 1;
0040   }
0041 }
0042 
0043 bool CSCDDUHeader::check() const {
0044   //std::cout <<"SANDRIK"<<std::hex <<header2_1_<<" "<<header2_2_ <<" "<<header2_3_<<std::endl;
0045   return bit64_ == 5 && header2_1_ == 0x8000 && header2_3_ == 0x8000 && header2_2_ == 0x0001;
0046 }