CMS 3D CMS Logo

pos::PixelTrimAllPixels Class Reference

#include <CalibFormats/SiPixelObjects/interface/PixelTrimAllPixels.h>

Inheritance diagram for pos::PixelTrimAllPixels:

pos::PixelTrimBase pos::PixelConfigBase

List of all members.

Public Member Functions

void generateConfiguration (PixelFECConfigInterface *pixelFEC, PixelNameTranslation *trans, const PixelMaskBase &pixelMask) const
PixelROCTrimBitsgetTrimBits (PixelROCName name)
PixelROCTrimBits getTrimBits (int ROCId) const
 PixelTrimAllPixels (std::vector< std::vector< std::string > > &tableMat)
 PixelTrimAllPixels (std::string filename)
void writeASCII (std::string filename) const
void writeBinary (std::string filename) const
virtual void writeXML (std::ofstream *out) const
void writeXML (pos::PixelConfigKey key, int version, std::string path) const
virtual void writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out) const
virtual void writeXMLTrailer (std::ofstream *out) const

Private Attributes

std::vector< std::string > rocname_
std::vector< PixelROCTrimBitstrimbits_


Detailed Description

Definition at line 31 of file PixelTrimAllPixels.h.


Constructor & Destructor Documentation

PixelTrimAllPixels::PixelTrimAllPixels ( std::string  filename  ) 

Definition at line 107 of file PixelTrimAllPixels.cc.

References c, i, in, pos::PixelROCTrimBits::read(), pos::PixelROCTrimBits::readBinary(), s1, s2, tmp, and trimbits_.

00107                                                         :
00108   PixelTrimBase("","",""){
00109 
00110     if (filename[filename.size()-1]=='t'){
00111 
00112       std::ifstream in(filename.c_str());
00113         
00114       //        std::cout << "filename =" << filename << std::endl;
00115 
00116       std::string s1;
00117       in >> s1; 
00118 
00119       trimbits_.clear();
00120 
00121 
00122       while (in.good()){
00123           
00124         std::string s2;
00125         in>>s2;
00126 
00127         //          std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<< " s2:" << s2 << std::endl;
00128 
00129         assert( s1 == "ROC:" );
00130 
00131         PixelROCName rocid(s2);
00132 
00133         //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
00134             
00135         PixelROCTrimBits tmp;
00136       
00137         tmp.read(rocid, in);
00138 
00139         trimbits_.push_back(tmp);
00140 
00141         in >> s1;
00142 
00143       }
00144 
00145       in.close();
00146 
00147     }
00148     else{
00149 
00150       std::ifstream in(filename.c_str(),std::ios::binary);
00151 
00152       char nchar;
00153 
00154       in.read(&nchar,1);
00155 
00156       std::string s1;
00157 
00158       //wrote these lines of code without ref. needs to be fixed
00159       for(int i=0;i< nchar; i++){
00160         char c;
00161         in >>c;
00162         s1.push_back(c);
00163       }
00164 
00165       //std::cout << "READ ROC name:"<<s1<<std::endl;
00166 
00167       trimbits_.clear();
00168 
00169 
00170       while (!in.eof()){
00171 
00172         //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read s1:"<<s1<<std::endl;
00173 
00174         PixelROCName rocid(s1);
00175 
00176         //std::cout << "PixelTrimAllPixels::PixelTrimAllPixels read rocid:"<<rocid<<std::endl;
00177             
00178         PixelROCTrimBits tmp;
00179       
00180         tmp.readBinary(rocid, in);
00181 
00182         trimbits_.push_back(tmp);
00183 
00184 
00185         in.read(&nchar,1);
00186 
00187         s1.clear();
00188 
00189         if (in.eof()) continue;
00190 
00191         //wrote these lines of code without ref. needs to be fixed
00192         for(int i=0;i< nchar; i++){
00193           char c;
00194           in >>c;
00195           s1.push_back(c);
00196         }
00197 
00198 
00199       }
00200 
00201       in.close();
00202 
00203 
00204 
00205     }
00206 
00207     //std::cout << "Read trimbits for "<<trimbits_.size()<<" ROCs"<<std::endl;
00208 
00209   }

PixelTrimAllPixels::PixelTrimAllPixels ( std::vector< std::vector< std::string > > &  tableMat  ) 

View's name: CONF_KEY_ROC_TRIMS_MV

Name Null? Type ----------------------------------------- -------- ---------------------------- CONFIG_KEY_ID NUMBER(38) CONFG_KEY VARCHAR2(80) VERSION VARCHAR2(40) KIND_OF_COND VARCHAR2(40) ROC_NAME VARCHAR2(187) HUB_ADDRS NUMBER(38) PORT_NUMBER NUMBER(10) ROC_I2C_ADDR NUMBER GEOM_ROC_NUM NUMBER(10) DATA_FILE VARCHAR2(200) TRIM_CLOB CLOB

Definition at line 22 of file PixelTrimAllPixels.cc.

References bits, c, TestMuL1L2Filter_cff::cerr, lat::endl(), n, r, pos::PixelROCTrimBits::read(), tmp, and trimbits_.

00022                                                                                   :
00023   PixelTrimBase("","","")
00024 {
00025 
00026     std::stringstream currentRocName;
00027     std::map<std::string , int > colM;
00028     std::vector<std::string > colNames;
00047     colNames.push_back("CONFIG_KEY_ID"  );
00048     colNames.push_back("CONFG_KEY"      );
00049     colNames.push_back("VERSION"        );
00050     colNames.push_back("KIND_OF_COND"   );
00051     colNames.push_back("ROC_NAME"       );
00052     colNames.push_back("HUB_ADDRS"      );
00053     colNames.push_back("PORT_NUMBER"    );
00054     colNames.push_back("ROC_I2C_ADDR"   );
00055     colNames.push_back("GEOM_ROC_NUM"   );
00056     colNames.push_back("DATA_FILE"      );
00057     colNames.push_back("TRIM_CLOB"      );
00058  
00059 
00060     for(unsigned int c = 0 ; c < tableMat[0].size() ; c++)
00061       {
00062         for(unsigned int n=0; n<colNames.size(); n++)
00063           {
00064             if(tableMat[0][c] == colNames[n])
00065               {
00066                 colM[colNames[n]] = c;
00067                 break;
00068               }
00069           }
00070       }//end for
00071     for(unsigned int n=0; n<colNames.size(); n++)
00072       {
00073       if(colM.find(colNames[n]) == colM.end())
00074         {
00075           std::cerr << "[PixelTrimAllPixels::PixelTrimAllPixels()]\tCouldn't find in the database the column with name " << colNames[n] << std::endl;
00076           assert(0);
00077         }
00078       }
00079     
00080     //unsigned char *bits ;        /// supose to be " unsigned  char bits[tableMat[1][colM["TRIM_BLOB"]].size()] ;  "
00081     //char c[2080];
00082     std::string bits;
00083         
00084     for(unsigned int r = 1 ; r < tableMat.size() ; r++)    //Goes to every row of the Matrix
00085       {
00086         PixelROCName rocid( tableMat[r][colM["ROC_NAME"]] );
00087         // tableMat[r][colM["TRIM_BLOB"]].copy(c , 2080 );
00088         // unsigned char *bits = (unsigned char* )(tableMat[r][colM["TRIM_BLOB"]].c_str());
00089         //bits = (unsigned char)(tableMat[r][colM["TRIM_BLOB"]].c_str());
00090         PixelROCTrimBits tmp;     // Have to add like this  PixelROCTrimBits tmp(rocid , bits ); 
00091         std::istringstream istring ;
00092         istring.str(tableMat[r][colM["TRIM_CLOB"]]) ;
00093         tmp.read(rocid, istring) ;
00094 //      bits = tableMat[r][colM["TRIM_CLOB"]];
00095         //std::cout<<rocid<<std::endl;
00096         // std::cout<<bits.size()<<std::endl;
00097 //      tmp.setROCTrimBits(rocid, bits);
00098         trimbits_.push_back(tmp);
00099         //std::cout<<"Pase por aqui:"<<r<<std::endl;
00100         // dacValue = atoi(tableMat[r][colM["VALUE"]].c_str());
00101         // pDSM.insert(pair<string,pair<string,int> >(currentRocName.str(),pair<string,int>(dacName,dacValue)));
00102       }//end for r 
00103     //std::cout<<trimbits_.size()<<std::endl;
00104 } //end contructor with databasa table


Member Function Documentation

void PixelTrimAllPixels::generateConfiguration ( PixelFECConfigInterface pixelFEC,
PixelNameTranslation trans,
const PixelMaskBase pixelMask 
) const [virtual]

Implements pos::PixelTrimBase.

Definition at line 237 of file PixelTrimAllPixels.cc.

References parsecf::pyparsing::col(), pos::PixelNameTranslation::getHdwAddress(), pos::PixelMaskBase::getMaskBits(), pos::PixelHdwAddress::hubaddress(), i, pos::PixelROCMaskBits::mask(), pos::PixelHdwAddress::mfec(), pos::PixelHdwAddress::mfecchannel(), name, pos::PixelHdwAddress::portaddress(), pos::PixelHdwAddress::rocid(), pos::PixelFECConfigInterface::roctrimload(), row, tmp, and trimbits_.

00239                                                                                     {
00240 
00241   for(unsigned int i=0;i<trimbits_.size();i++){
00242 
00243     std::vector<unsigned char> trimAndMasks(4160);
00244 
00245     const PixelROCMaskBits& maskbits=pixelMask.getMaskBits(i);
00246 
00247     for (unsigned int col=0;col<52;col++){
00248       for (unsigned int row=0;row<80;row++){
00249         unsigned char tmp=trimbits_[i].trim(col,row);
00250         if (maskbits.mask(col,row)!=0) tmp|=0x80;
00251         trimAndMasks[col*80+row]=tmp;
00252       }
00253     }
00254 
00255     // the slow way, one pixel at a time
00256     //pixelFEC->setMaskAndTrimAll(*(trans->getHdwAddress(trimbits_[i].name())),trimAndMasks);
00257     // the fast way, a full roc in column mode (& block xfer)
00258     const PixelHdwAddress* theROC = trans->getHdwAddress(trimbits_[i].name());
00259     pixelFEC->roctrimload(theROC->mfec(),
00260                           theROC->mfecchannel(),
00261                           theROC->hubaddress(),
00262                           theROC->portaddress(),
00263                           theROC->rocid(),
00264                           trimAndMasks);
00265   }
00266 }

PixelROCTrimBits * PixelTrimAllPixels::getTrimBits ( PixelROCName  name  )  [virtual]

Implements pos::PixelTrimBase.

Definition at line 225 of file PixelTrimAllPixels.cc.

References i, name, and trimbits_.

00225                                                                   {
00226 
00227   for(unsigned int i=0;i<trimbits_.size();i++){
00228     if (trimbits_[i].name()==name) return &(trimbits_[i]);
00229   }
00230 
00231   return 0;
00232 
00233 }

PixelROCTrimBits PixelTrimAllPixels::getTrimBits ( int  ROCId  )  const [virtual]

Implements pos::PixelTrimBase.

Definition at line 219 of file PixelTrimAllPixels.cc.

References trimbits_.

00219                                                                 {
00220 
00221   return trimbits_[ROCId];
00222 
00223 }

void PixelTrimAllPixels::writeASCII ( std::string  filename  )  const [virtual]

Implements pos::PixelTrimBase.

Definition at line 281 of file PixelTrimAllPixels.cc.

References EgammaValidation_cff::filename, i, module(), pos::PixelModuleName::modulename(), name, out, and trimbits_.

00281                                                       {
00282 
00283   if (dir!="") dir+="/";
00284   PixelModuleName module(trimbits_[0].name().rocname());
00285   std::string filename=dir+"ROC_Trims_module_"+module.modulename()+".dat";
00286   
00287 
00288   std::ofstream out(filename.c_str());
00289 
00290   for(unsigned int i=0;i<trimbits_.size();i++){
00291     trimbits_[i].writeASCII(out);
00292   }
00293 
00294 
00295 }

void PixelTrimAllPixels::writeBinary ( std::string  filename  )  const [virtual]

Implements pos::PixelTrimBase.

Definition at line 268 of file PixelTrimAllPixels.cc.

References i, out, and trimbits_.

00268                                                             {
00269 
00270   
00271   std::ofstream out(filename.c_str(),std::ios::binary);
00272 
00273   for(unsigned int i=0;i<trimbits_.size();i++){
00274     trimbits_[i].writeBinary(out);
00275   }
00276 
00277 
00278 }

virtual void pos::PixelTrimAllPixels::writeXML ( std::ofstream *  out  )  const [inline, virtual]

Reimplemented from pos::PixelTrimBase.

Definition at line 50 of file PixelTrimAllPixels.h.

00050 {;}

void pos::PixelTrimAllPixels::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const [inline, virtual]

Reimplemented from pos::PixelTrimBase.

Definition at line 48 of file PixelTrimAllPixels.h.

00048 {;}

virtual void pos::PixelTrimAllPixels::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out 
) const [inline, virtual]

Reimplemented from pos::PixelTrimBase.

Definition at line 49 of file PixelTrimAllPixels.h.

00049 {;}

virtual void pos::PixelTrimAllPixels::writeXMLTrailer ( std::ofstream *  out  )  const [inline, virtual]

Reimplemented from pos::PixelTrimBase.

Definition at line 51 of file PixelTrimAllPixels.h.

00051 {;}


Member Data Documentation

std::vector<std::string> pos::PixelTrimAllPixels::rocname_ [private]

Definition at line 60 of file PixelTrimAllPixels.h.

std::vector<PixelROCTrimBits> pos::PixelTrimAllPixels::trimbits_ [private]

Definition at line 61 of file PixelTrimAllPixels.h.

Referenced by generateConfiguration(), getTrimBits(), PixelTrimAllPixels(), writeASCII(), and writeBinary().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:50:37 2009 for CMSSW by  doxygen 1.5.4