CMS 3D CMS Logo

Functions

bitset_utilities Namespace Reference

this file contains additional dynamic_bitset methods More...

Functions

boost::dynamic_bitset append (const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
 this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1
void bitsetToChar (const boost::dynamic_bitset<> &bs, unsigned char *result)
 this method takes bitset obj and returns char * array
void printWords (const boost::dynamic_bitset<> &bs)
boost::dynamic_bitset ushortToBitset (const unsigned int numberOfBits, unsigned short *buf)
 this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj.

Detailed Description

this file contains additional dynamic_bitset methods


Function Documentation

boost::dynamic_bitset bitset_utilities::append ( const boost::dynamic_bitset<> &  bs1,
const boost::dynamic_bitset<> &  bs2 
)

this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1

Definition at line 10 of file bitset_append.cc.

References i, and query::result.

  {
    boost::dynamic_bitset<> result(bs1.size()+bs2.size());
    unsigned size1 = bs1.size();
    for(unsigned i = 0; i < size1; ++i)
      {
        result[i] = bs1[i];
      }
    for(unsigned i = 0; i < bs2.size(); ++i)
      {
        result[size1+i] = bs2[i];
      }
    return result;
  }
void bitset_utilities::bitsetToChar ( const boost::dynamic_bitset<> &  bs,
unsigned char *  result 
)

this method takes bitset obj and returns char * array

Definition at line 40 of file bitset_append.cc.

References i.

Referenced by CSCDigiToRaw::createFedBuffers(), cscClassPackerCompare(), cscPackAndUnpack(), and printWords().

  {
    for(unsigned i = 0; i < bs.size(); ++i)
      {
        result[i/8] =  (bs[i+7]<<7)+
          (bs[i+6]<<6)+
          (bs[i+5]<<5)+
          (bs[i+4]<<4)+ 
          (bs[i+3]<<3)+
          (bs[i+2]<<2)+
          (bs[i+1]<<1)+
          bs[i];
        i+=7;
      }
  }
void bitset_utilities::printWords ( const boost::dynamic_bitset<> &  bs)

Definition at line 56 of file bitset_append.cc.

References bitsetToChar(), and i.

Referenced by cscClassPackerCompare().

  {
    unsigned char words[60000];
    bitsetToChar(bs, words);
    unsigned short * buf= (unsigned short *) words;
    for (int unsigned i=0;i<bs.size()/16;++i) {
      printf("%04x %04x %04x %04x\n",buf[i+3],buf[i+2],buf[i+1],buf[i]);
      i+=3;
    }
  }
boost::dynamic_bitset bitset_utilities::ushortToBitset ( const unsigned int  numberOfBits,
unsigned short *  buf 
)

this method takes numberOfBits bits from unsigned short * array and returns them in the bitset obj.

Definition at line 27 of file bitset_append.cc.

References i, and query::result.

Referenced by CSCTMBData::pack(), CSCEventData::pack(), CSCDDUEventData::pack(), CSCDCCEventData::pack(), and CSCALCTHeader::pack().

  {
    boost::dynamic_bitset<> result(numberOfBits);
    for(unsigned i = 0; i < result.size(); ++i)
      {
        result[i] = (buf[i/16]>>(i%16)) & 0x1;
      }
    return result;
  }