CMS 3D CMS Logo

Public Member Functions | Private Attributes | Friends

pos::PixelROCTrimBits Class Reference

This class implements.. More...

#include <interface/PixelROCTrimBits.h>

List of all members.

Public Member Functions

PixelROCName name () const
 PixelROCTrimBits ()
int read (PixelROCName rocid, std::ifstream &in)
int read (PixelROCName rocid, std::istringstream &in)
int read (PixelROCName rocid, std::string in)
int readBinary (PixelROCName rocid, std::ifstream &in)
void setROCTrimBits (PixelROCName rocid, std::string bits)
void setTrim (unsigned int col, unsigned int row, unsigned int trim)
unsigned int trim (unsigned int col, unsigned int row) const
void writeASCII (std::ofstream &out) const
void writeBinary (std::ofstream &out) const
void writeXML (std::ofstream *out) const

Private Attributes

unsigned char bits_ [2080]
PixelROCName rocid_

Friends

std::ostream & operator<< (std::ostream &s, const PixelROCTrimBits &trimbits)

Detailed Description

This class implements..

A longer explanation will be placed here later

Definition at line 20 of file PixelROCTrimBits.h.


Constructor & Destructor Documentation

PixelROCTrimBits::PixelROCTrimBits ( )

Definition at line 18 of file PixelROCTrimBits.cc.

{
}

Member Function Documentation

PixelROCName pos::PixelROCTrimBits::name ( ) const [inline]

Definition at line 45 of file PixelROCTrimBits.h.

References rocid_.

{return rocid_;}
int PixelROCTrimBits::read ( PixelROCName  rocid,
std::string  in 
)

Definition at line 41 of file PixelROCTrimBits.cc.

References bits_, i, and rocid_.

Referenced by pos::PixelTrimAllPixels::PixelTrimAllPixels().

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

Definition at line 98 of file PixelROCTrimBits.cc.

References bits_, INSTR::byte, data, i, j, rocid_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and tmp.

{
  std::string tag;
  //std::cout << "PixelROCTrimBits::read rocid:"<<rocid<<std::endl;
  rocid_=rocid;
  //std::cout << "PixelROCTrimBits::read rocid_:"<<rocid_<<std::endl;
  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: " <<data<<std::endl;
      unsigned char byte=0;
      for(int j=0;j<80;j++)
        {
          unsigned char tmp=toupper(data[j])-48;
          if (tmp>9) tmp-=7;  //FIXME this is so ugly
          byte+=tmp;
          if ((j+1)%2==0) 
            {
              //std::cout << "Writing byte:"<<(int)byte<<std::endl;
              bits_[i*40+(j+1)/2-1]=byte;
              byte=0; 
            }
          else
            {
              byte*=16;
            }
        }
    }
  return 1;
}
int PixelROCTrimBits::read ( PixelROCName  rocid,
std::ifstream &  in 
)

Definition at line 50 of file PixelROCTrimBits.cc.

References bits_, INSTR::byte, data, i, j, rocid_, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and tmp.

                                                            {
    
  std::string tag;

  //std::cout << "PixelROCTrimBits::read rocid:"<<rocid<<std::endl;

  rocid_=rocid;
  
  //std::cout << "PixelROCTrimBits::read rocid_:"<<rocid_<<std::endl;

  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++){

      unsigned char tmp=toupper(data[j])-48;
      if (tmp>9) tmp-=7;  //FIXME this is so ugly

      byte+=tmp;
      
      if ((j+1)%2==0) {
          //std::cout << "Writing byte:"<<(int)byte<<std::endl;
        bits_[i*40+(j+1)/2-1]=byte;
        byte=0; 
      }
      else{
        byte*=16;
      }
        

    }

  }
  return 1;

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

Definition at line 265 of file PixelROCDACSettings.cc.

Referenced by pos::PixelTrimAllPixels::PixelTrimAllPixels().

                                                                          {
    
    rocid_=rocid;

    in.read((char*)&Vdd_,1);
    in.read((char*)&Vana_,1);
    in.read((char*)&Vsf_,1);
    in.read((char*)&Vcomp_,1);
    in.read((char*)&Vleak_,1);
    in.read((char*)&VrgPr_,1);
    in.read((char*)&VwllPr_,1);
    in.read((char*)&VrgSh_,1);
    in.read((char*)&VwllSh_,1);
    in.read((char*)&VHldDel_,1);
    in.read((char*)&Vtrim_,1);
    in.read((char*)&VcThr_,1);
    in.read((char*)&VIbias_bus_,1);
    in.read((char*)&VIbias_sf_,1);
    in.read((char*)&VOffsetOp_,1);
    in.read((char*)&VbiasOp_,1);
    in.read((char*)&VOffsetRO_,1);
    in.read((char*)&VIon_,1);
    in.read((char*)&VIbias_PH_,1);
    in.read((char*)&VIbias_DAC_,1);
    in.read((char*)&VIbias_roc_,1);
    in.read((char*)&VIColOr_,1);
    in.read((char*)&Vnpix_,1);
    in.read((char*)&VsumCol_,1);
    in.read((char*)&Vcal_,1);
    in.read((char*)&CalDel_,1);
    in.read((char*)&TempRange_,1);
    in.read((char*)&WBC_,1);
    in.read((char*)&ChipContReg_,1);    
    
    return 1;

}
void PixelROCTrimBits::setROCTrimBits ( PixelROCName  rocid,
std::string  bits 
)

Definition at line 22 of file PixelROCTrimBits.cc.

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

{

try{
  rocid_=rocid;
  char cpt[2080] ;
  bits.copy( cpt , 2080);
  for(unsigned int i = 0 ; i < bits.size(); i++)
        bits_[i] = (unsigned char)cpt[i];
}catch(std::bad_cast){

std::cout << "Error casting variable." << std::endl;

}       
  
}
void PixelROCTrimBits::setTrim ( unsigned int  col,
unsigned int  row,
unsigned int  trim 
)

Definition at line 189 of file PixelROCTrimBits.cc.

References bits_, and tmp.

                                                                                   {

  assert(trim<16);

  unsigned int mask=0xf0;
  if (row%2==0) {
    trim<<=4;
    mask>>=4;
  }
  unsigned int tmp=bits_[col*40+row/2];
  bits_[col*40+row/2]=(tmp&mask)|trim;

}
unsigned int PixelROCTrimBits::trim ( unsigned int  col,
unsigned int  row 
) const

Definition at line 181 of file PixelROCTrimBits.cc.

References bits_, and tmp.

Referenced by pos::PixelCalibConfiguration::disablePixels(), pos::PixelCalibConfiguration::enablePixels(), and writeASCII().

                                                                           {

  unsigned int tmp=bits_[col*40+row/2];
  if (row%2==0) tmp/=16;
  return tmp&0x0F;

}
void PixelROCTrimBits::writeASCII ( std::ofstream &  out) const

Definition at line 159 of file PixelROCTrimBits.cc.

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

                                                       {

    //std::cout << " PixelROCTrimBits::writeASCII rocid_.rocname():"<<rocid_.rocname()<<std::endl;


    out << "ROC:     "<<rocid_.rocname()<<std::endl;

    //std::cout << "PixelROCTrimBits::writeBinary:"<<rocid_.rocname().size()
    //   << " " <<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 << std::hex<<std::uppercase<<trim(col,row)<<std::dec;
        }
        out << std::endl;
    }

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

Definition at line 145 of file PixelROCTrimBits.cc.

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

                                                        {

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

    //std::cout << "PixelROCTrimBits::writeBinary:"<<rocid_.rocname().size()
    // << " " <<rocid_.rocname()<<std::endl;

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

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

Definition at line 230 of file PixelROCTrimBits.cc.

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

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

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

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

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const PixelROCTrimBits trimbits 
) [friend]

Member Data Documentation

unsigned char pos::PixelROCTrimBits::bits_[2080] [private]

Definition at line 49 of file PixelROCTrimBits.h.

Referenced by read(), setROCTrimBits(), setTrim(), trim(), writeBinary(), and writeXML().

Definition at line 50 of file PixelROCTrimBits.h.

Referenced by name(), read(), setROCTrimBits(), writeASCII(), writeBinary(), and writeXML().