CMS 3D CMS Logo

Public Member Functions | Private Attributes | Friends

pos::PixelROCMaskBits Class Reference

This class implements.. More...

#include <interface/PixelROCMaskBits.h>

List of all members.

Public Member Functions

unsigned int mask (unsigned int col, unsigned int row) const
PixelROCName name () const
 PixelROCMaskBits ()
int read (const PixelROCName &rocid, std::ifstream &in)
int read (const PixelROCName &rocid, std::istringstream &in)
int read (const PixelROCName &rocid, std::string in)
int readBinary (const PixelROCName &rocid, std::ifstream &in)
void setMask (unsigned int col, unsigned int row, unsigned int mask)
void setROCMaskBits (PixelROCName &rocid, std::string bits)
void writeASCII (std::ofstream &out) const
void writeBinary (std::ofstream &out) const
void writeXML (std::ofstream *out) const

Private Attributes

unsigned char bits_ [520]
PixelROCName rocid_

Friends

std::ostream & operator<< (std::ostream &s, const PixelROCMaskBits &maskbits)

Detailed Description

This class implements..

A longer explanation will be placed here later

Definition at line 20 of file PixelROCMaskBits.h.


Constructor & Destructor Documentation

PixelROCMaskBits::PixelROCMaskBits ( )

Definition at line 18 of file PixelROCMaskBits.cc.

                                  {
}

Member Function Documentation

unsigned int PixelROCMaskBits::mask ( unsigned int  col,
unsigned int  row 
) const

Definition at line 173 of file PixelROCMaskBits.cc.

References bits_, and tmp.

Referenced by pos::PixelCalibConfiguration::enablePixels(), pos::PixelTrimAllPixels::generateConfiguration(), pos::PixelTrimCommon::generateConfiguration(), and writeASCII().

                                                                           {

  unsigned int tmp=bits_[col*10+row/8];
//   std::cout << "c =  " << col << "\tr = " << row << "\tbits_[" << (col*10+row/8) << "]=" << bits_[col*10+row/8] << std::endl ;
//   std::cout << "[PixelROCMaskBits::mask()] tmp iniziale " << tmp      << std::endl ;
  tmp=tmp>>(row%8);                                             
//   std::cout << "[PixelROCMaskBits::mask()] tmp finale   " << tmp      << std::endl ;
//   unsigned int res = tmp&0x01 ;                                      
//   std::cout << "[PixelROCMaskBits::mask()] return value " << res      << std::endl ;
  return tmp&0x01;

}
PixelROCName pos::PixelROCMaskBits::name ( ) const [inline]

Definition at line 43 of file PixelROCMaskBits.h.

References rocid_.

{return rocid_;}
int PixelROCMaskBits::read ( const PixelROCName rocid,
std::istringstream &  in 
)

Definition at line 101 of file PixelROCMaskBits.cc.

References bits_, INSTR::byte, runTheMatrix::data, i, j, rocid_, and GlobalPosition_Frontier_DevDB_cff::tag.

{
  rocid_=rocid;
  std::string tag;
  for (int i=0;i<52;i++)
    {
      in >> tag;
      //std::cout << "Now reading col:"<<tag<<std::endl;
      std::string data;
      in >> data;
      //std::cout <<"data.size()" <<data.size()<<std::endl;
      unsigned char byte=0;
      for(int j=0;j<80;j++)
        {
        if (data[j]=='1') byte+=128;
        if ((j+1)%8==0) 
          {
            //std::cout << "Writing byte:"<<(int)byte<<std::endl;
            bits_[i*10+(j+1)/8-1]=byte;
            byte=0; 
          }
        else
          {
            byte/=2;
          }
      }
    }
  return 1;
}
int PixelROCMaskBits::read ( const PixelROCName rocid,
std::string  in 
)

Definition at line 47 of file PixelROCMaskBits.cc.

References bits_, i, and rocid_.

Referenced by pos::PixelMaskAllPixels::PixelMaskAllPixels().

                                                                 {
 rocid_=rocid;
 for( int i=0; i<(int)sizeof(bits_); i++)
 {
  bits_[i] = in.at(i) ;
 }
 return 1 ;
}
int PixelROCMaskBits::read ( const PixelROCName rocid,
std::ifstream &  in 
)

Definition at line 57 of file PixelROCMaskBits.cc.

References bits_, INSTR::byte, runTheMatrix::data, i, j, rocid_, and GlobalPosition_Frontier_DevDB_cff::tag.

                                                                    {

    rocid_=rocid;

    std::string tag;

    for (int i=0;i<52;i++){
    
      in >> tag;
      
      //std::cout << "Now reading col:"<<tag<<std::endl;

      std::string data;

      in >> data;

      //std::cout <<"data.size()" <<data.size()<<std::endl;

      unsigned char byte=0;

      for(int j=0;j<80;j++){
         
        if (data[j]=='1') byte+=128;
        
        if ((j+1)%8==0) {
            //std::cout << "Writing byte:"<<(int)byte<<std::endl;
          bits_[i*10+(j+1)/8-1]=byte;
          byte=0; 
        }
        else{
          byte/=2;
        }
        

      }

    }

    return 1;

}
int PixelROCMaskBits::readBinary ( const PixelROCName rocid,
std::ifstream &  in 
)

Definition at line 132 of file PixelROCMaskBits.cc.

References bits_, and rocid_.

Referenced by pos::PixelMaskAllPixels::PixelMaskAllPixels().

                                                                          {

    rocid_=rocid;


    in.read((char*)bits_,520);


    return 1;
}
void PixelROCMaskBits::setMask ( unsigned int  col,
unsigned int  row,
unsigned int  mask 
)

Definition at line 187 of file PixelROCMaskBits.cc.

References bits_.

                                                                                   {

  assert(mask==0||mask==1);  

  unsigned int bit=1<<(row%8);
  if (mask) bits_[col*10+row/8]=bits_[col*10+row/8]|bit;  
  if (!mask) bits_[col*10+row/8]=bits_[col*10+row/8]&(0xff^bit);

}
void PixelROCMaskBits::setROCMaskBits ( PixelROCName rocid,
std::string  bits 
)

Definition at line 23 of file PixelROCMaskBits.cc.

References bits_, gather_cfg::cout, i, and rocid_.

{
  std::string mthn = "[PixelROCMaskBits::setROCMaskBits()]\t\t\t    " ;
try
  {
    rocid_=rocid;
    char cpt[520] ;
    bits.copy( cpt , 520);
    for(unsigned int i = 0 ; i < bits.size(); i++)
      {
        bits_[i] = (unsigned char)cpt[i];
        //      std::cout<< "bits_[" << i << "]\t" << bits_[i] <<std::endl;
        //      std::cout<<rocid_<<std::endl;
        //      std::cout.flags(std::ios::hex)
      }
  }
 catch(std::bad_cast)
   {
     std::cout << __LINE__ << "]\t" << mthn << "Error casting variable." << std::endl;
   }
}
void PixelROCMaskBits::writeASCII ( std::ofstream &  out) const

Definition at line 156 of file PixelROCMaskBits.cc.

References mask(), rocid_, and pos::PixelROCName::rocname().

                                                       {

    out << "ROC:    "<<rocid_.rocname()<<std::endl;
 
    for(unsigned int col=0;col<52;col++){
        out << "col";
        if (col<10) out << "0";
        out <<col<<":  ";
        for (int row=0;row<80;row++){
            out << mask(col,row);
        }
        out << std::endl;
    }

}
void PixelROCMaskBits::writeBinary ( std::ofstream &  out) const

Definition at line 144 of file PixelROCMaskBits.cc.

References bits_, i, rocid_, and pos::PixelROCName::rocname().

                                                        {

    out << (char)rocid_.rocname().size();
    out.write(rocid_.rocname().c_str(),rocid_.rocname().size());

    for(unsigned int i=0;i<520;i++){
        out << bits_[i];
    }

}
void PixelROCMaskBits::writeXML ( std::ofstream *  out) const

Definition at line 225 of file PixelROCMaskBits.cc.

References base64_encode(), bits_, rocid_, and pos::PixelROCName::rocname().

{
  std::string mthn = "[PixelROCMaskBits::writeXML()]\t\t\t\t" ;

  std::string encoded = base64_encode(bits_, sizeof(bits_));

  *out << "  <DATA>"                                             << std::endl ;
  *out << "   <ROC_NAME>"  << rocid_.rocname() << "</ROC_NAME>"  << std::endl ;
  *out << "   <KILL_MASK>" << encoded          << "</KILL_MASK>" << std::endl ;
  *out << "  </DATA>"                                            << std::endl ;
  *out << " "                                                    << std::endl ;
      
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const PixelROCMaskBits maskbits 
) [friend]

Member Data Documentation

unsigned char pos::PixelROCMaskBits::bits_[520] [private]

Definition at line 50 of file PixelROCMaskBits.h.

Referenced by mask(), read(), readBinary(), setMask(), setROCMaskBits(), writeBinary(), and writeXML().