CMS 3D CMS Logo

Public Member Functions | Private Attributes

pos::PixelMaskAllPixels Class Reference

This is the documentation about PixelMaskAllPixels... More...

#include <interface/PixelMaskAllPixels.h>

Inheritance diagram for pos::PixelMaskAllPixels:
pos::PixelMaskBase pos::PixelMaskBase pos::PixelConfigBase pos::PixelConfigBase

List of all members.

Public Member Functions

void addROCMaskBits (PixelROCMaskBits)
const PixelROCMaskBitsgetMaskBits (int ROCId) const
PixelROCMaskBitsgetMaskBits (PixelROCName name)
 PixelMaskAllPixels (std::vector< std::vector< std::string > > &tableMat)
 PixelMaskAllPixels (std::string filename)
 PixelMaskAllPixels ()
 PixelMaskCommon (std::string filename)
void writeASCII (std::string dir) const
void writeASCII (std::string filename) const
void writeBinary (std::string filename) const
void writeBinary (std::string filename) const
void writeXML (pos::PixelConfigKey key, int version, std::string path) const
virtual void writeXML (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) 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 writeXMLHeader (pos::PixelConfigKey key, int version, std::string path, std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLTrailer (std::ofstream *out, std::ofstream *out1=NULL, std::ofstream *out2=NULL) const
virtual void writeXMLTrailer (std::ofstream *out) const

Private Attributes

std::vector< PixelROCMaskBitsmaskbits_
std::vector< bool > maskbits_
std::vector< PixeROCName > rocname_

Detailed Description

This is the documentation about PixelMaskAllPixels...

This class implements..

" "

A longer explanation will be placed here later

Definition at line 23 of file PixelMaskAllPixels.h.


Constructor & Destructor Documentation

PixelMaskAllPixels::PixelMaskAllPixels ( std::string  filename)

Definition at line 95 of file PixelMaskAllPixels.cc.

References trackerHits::c, gather_cfg::cout, i, recoMuon::in, maskbits_, pos::PixelROCMaskBits::read(), pos::PixelROCMaskBits::readBinary(), GlobalPosition_Frontier_DevDB_cff::tag, and tmp.

                                                        :
  PixelMaskBase("","",""){

    std::string mthn = "[PixelMaskAllPixels::PixelMaskAllPixels()]\t\t    " ;

    if (filename[filename.size()-1]=='t'){


        std::ifstream in(filename.c_str());

        if (!in.good()){
            std::cout << __LINE__ << "]\t" << mthn << "Could not open: " << filename << std::endl;
            throw std::runtime_error("Failed to open file "+filename);
        }
        
        std::string tag;
        in >> tag;

        maskbits_.clear();

        while (!in.eof()) {

            PixelROCName rocid(in);

            PixelROCMaskBits tmp;
            
            tmp.read(rocid,in);
            
            maskbits_.push_back(tmp);
            
            in >> tag;
            
        }
        
        in.close();

    }
    else{

        std::ifstream in(filename.c_str(),std::ios::binary);

        char nchar;

        in.read(&nchar,1);

        //in >> nchar;

        std::string s1;

        //wrote these lines of code without ref. needs to be fixed
        for(int i=0;i< nchar; i++){
            char c;
            in >>c;
            s1.push_back(c);
        }

        //std::cout << __LINE__ << "]\t" << mthn << "READ ROC name: "  << s1    << std::endl;
        
        maskbits_.clear();


        while (!in.eof()){

            //std::cout << __LINE__ << "]\t" << mthn << "read s1: "    << s1    << std::endl;

            PixelROCName rocid(s1);

            //std::cout << __LINE__ << "]\t" << mthn << "read rocid: " << rocid << std::endl;
            
            PixelROCMaskBits tmp;
      
            tmp.readBinary(rocid, in);

            maskbits_.push_back(tmp);


            in.read(&nchar,1);

            s1.clear();

            if (in.eof()) continue;
            
            //std::cout << __LINE__ << "]\t" << mthn << "Will read: " << (int)nchar << " characters." <<std::endl;

            //wrote these lines of code without ref. needs to be fixed
            for(int i=0;i< nchar; i++){
                char c;
                in >>c;
                //std::cout << " " <<c;
                s1.push_back(c);
            }
            //std::cout << std::endl;


        }

        in.close();



    }


    //std::cout << __LINE__ << "]\t" << mthn << "Read maskbits for " << maskbits_.size() << " ROCs" << std::endl;
        
    }
PixelMaskAllPixels::PixelMaskAllPixels ( std::vector< std::vector< std::string > > &  tableMat)

Definition at line 27 of file PixelMaskAllPixels.cc.

References base64_decode, trackerHits::c, dtNoiseDBValidation_cfg::cerr, maskbits_, n, alignCSCRings::r, pos::PixelROCMaskBits::read(), and tmp.

                                                                                  : PixelMaskBase("","","")
{
 std::string mthn = "[PixelMaskAllPixels::PixelMaskAllPixels()]\t\t    " ;
 //std::cout << __LINE__ << "]\t" << mthn << "Table Size in const: " << tableMat.size() << std::endl;

 std::vector< std::string > ins = tableMat[0];
 std::map<std::string , int > colM;
 std::vector<std::string > colNames;

/*
 EXTENSION_TABLE_NAME: ROC_MASKS (VIEW: CONF_KEY_ROC_MASKS_V)

 CONFIG_KEY                                NOT NULL VARCHAR2(80)
 KEY_TYPE                                  NOT NULL VARCHAR2(80)
 KEY_ALIAS                                 NOT NULL VARCHAR2(80)
 VERSION                                            VARCHAR2(40)
 KIND_OF_COND                              NOT NULL VARCHAR2(40)
 ROC_NAME                                  NOT NULL VARCHAR2(200)
 KILL_MASK                                 NOT NULL VARCHAR2(4000) colNames.push_back("CONFIG_KEY_ID" );
*/
 colNames.push_back("CONFIG_KEY"  );
 colNames.push_back("KEY_TYPE"    );
 colNames.push_back("KEY_ALIAS"   );
 colNames.push_back("VERSION"     );
 colNames.push_back("KIND_OF_COND");
 colNames.push_back("ROC_NAME"    );
 colNames.push_back("KILL_MASK"   );
  
 for(unsigned int c = 0 ; c < ins.size() ; c++)
   {
     for(unsigned int n=0; n<colNames.size(); n++)
       {
         if(tableMat[0][c] == colNames[n])
           {
             colM[colNames[n]] = c;
             break;
           }
       }
   }//end for
 for(unsigned int n=0; n<colNames.size(); n++)
   {
     if(colM.find(colNames[n]) == colM.end())
       {
         std::cerr << mthn << "Couldn't find in the database the column with name " << colNames[n] << std::endl;
         assert(0);
       }
   }
  maskbits_.clear() ;
  for(unsigned int r = 1 ; r < tableMat.size() ; r++){   //Goes to every row of the Matrix
    std::string currentRocName = tableMat[r][colM["ROC_NAME"]]  ;               
    PixelROCName rocid(currentRocName);
    PixelROCMaskBits tmp;
    tmp.read(rocid,base64_decode(tableMat[r][colM["KILL_MASK"]])) ; // decode back from specially base64-encoded data for XML 
    maskbits_.push_back(tmp);
  }                                                      //end for r 
}
PixelMaskAllPixels::PixelMaskAllPixels ( )

Definition at line 86 of file PixelMaskAllPixels.cc.

:PixelMaskBase("","",""){;}

Member Function Documentation

void PixelMaskAllPixels::addROCMaskBits ( PixelROCMaskBits  bits)

Definition at line 89 of file PixelMaskAllPixels.cc.

References maskbits_.

{
  maskbits_.push_back(bits);
}
const PixelROCMaskBits & PixelMaskAllPixels::getMaskBits ( int  ROCId) const [virtual]

Implements pos::PixelMaskBase.

Definition at line 203 of file PixelMaskAllPixels.cc.

References maskbits_.

                                                                       {

  return maskbits_[ROCId];

}
PixelROCMaskBits * PixelMaskAllPixels::getMaskBits ( PixelROCName  name) [virtual]

Implements pos::PixelMaskBase.

Definition at line 210 of file PixelMaskAllPixels.cc.

References i, maskbits_, and mergeVDriftHistosByStation::name.

                                                                   {

  for(unsigned int i=0;i<maskbits_.size();i++){
    if (maskbits_[i].name()==name) return &(maskbits_[i]);
  }

  return 0;

}
pos::PixelMaskAllPixels::PixelMaskCommon ( std::string  filename)
void PixelMaskAllPixels::writeASCII ( std::string  dir) const [virtual]

Implements pos::PixelMaskBase.

Definition at line 234 of file PixelMaskAllPixels.cc.

References lut2db_cfg::filename, i, maskbits_, python::rootplot::argparse::module, pos::PixelModuleName::modulename(), mergeVDriftHistosByStation::name, and dbtoconf::out.

                                                      {

  if (dir!="") dir+="/";
  PixelModuleName module(maskbits_[0].name().rocname());
  std::string filename=dir+"ROC_Masks_module_"+module.modulename()+".dat";
  
    std::ofstream out(filename.c_str());

    for(unsigned int i=0;i<maskbits_.size();i++){
        maskbits_[i].writeASCII(out);
    }


}
void pos::PixelMaskAllPixels::writeASCII ( std::string  filename) const [virtual]

Implements pos::PixelMaskBase.

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

Implements pos::PixelMaskBase.

Definition at line 221 of file PixelMaskAllPixels.cc.

References i, maskbits_, and dbtoconf::out.

                                                            {

  
    std::ofstream out(filename.c_str(),std::ios::binary);

    for(unsigned int i=0;i<maskbits_.size();i++){
        maskbits_[i].writeBinary(out);
    }


}
void pos::PixelMaskAllPixels::writeBinary ( std::string  filename) const [virtual]

Implements pos::PixelMaskBase.

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

Reimplemented from pos::PixelMaskBase.

Definition at line 37 of file PixelMaskAllPixels.h.

{;}
void PixelMaskAllPixels::writeXML ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelMaskBase.

Definition at line 295 of file PixelMaskAllPixels.cc.

References i, and maskbits_.

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

  for(unsigned int i=0;i<maskbits_.size();i++){
      maskbits_[i].writeXML(outstream);
  }
}
virtual void pos::PixelMaskAllPixels::writeXML ( std::ofstream *  out) const [inline, virtual]

Reimplemented from pos::PixelConfigBase.

Definition at line 33 of file PixelMaskCommon.h.

{;}
void pos::PixelMaskAllPixels::writeXML ( pos::PixelConfigKey  key,
int  version,
std::string  path 
) const [inline, virtual]

Reimplemented from pos::PixelMaskBase.

Definition at line 31 of file PixelMaskCommon.h.

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

Reimplemented from pos::PixelConfigBase.

Definition at line 32 of file PixelMaskCommon.h.

{;}
void PixelMaskAllPixels::writeXMLHeader ( pos::PixelConfigKey  key,
int  version,
std::string  path,
std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelMaskBase.

Definition at line 250 of file PixelMaskAllPixels.cc.

References gather_cfg::cout, pos::PixelConfigBase::getAuthor(), pos::PixelConfigBase::getComment(), pos::PixelTimeFormatter::getmSecTime(), and edm::service::getTime().

{
  std::string mthn = "[PixelMaskAllPixels::writeXMLHeader()]\t\t\t    " ;
  std::stringstream maskFullPath ;

  maskFullPath << path << "/Pixel_RocMasks_" << PixelTimeFormatter::getmSecTime() << ".xml";
  std::cout << __LINE__ << "]\t" << mthn << "Writing to: " << maskFullPath.str() << std::endl ;

  outstream->open(maskFullPath.str().c_str()) ;
  
  *outstream << "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>"                               << std::endl ;
  *outstream << "<ROOT xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'>"                          << std::endl ;
  *outstream << ""                                                                                      << std::endl ; 
  *outstream << " <HEADER>"                                                                             << std::endl ; 
  *outstream << "  <TYPE>"                                                                              << std::endl ; 
  *outstream << "   <EXTENSION_TABLE_NAME>ROC_MASKS</EXTENSION_TABLE_NAME>"                             << std::endl ; 
  *outstream << "   <NAME>ROC Mask Bits</NAME>"                                                         << std::endl ; 
  *outstream << "  </TYPE>"                                                                             << std::endl ; 
  *outstream << "  <RUN>"                                                                               << std::endl ; 
  *outstream << "   <RUN_TYPE>ROC Mask Bits</RUN_TYPE>"                                                 << std::endl ; 
  *outstream << "   <RUN_NUMBER>1</RUN_NUMBER>"                                                         << std::endl ; 
  *outstream << "   <RUN_BEGIN_TIMESTAMP>" << PixelTimeFormatter::getTime() << "</RUN_BEGIN_TIMESTAMP>" << std::endl ; 
  *outstream << "   <LOCATION>CERN P5</LOCATION>"                                                       << std::endl ; 
  *outstream << "  </RUN>"                                                                              << std::endl ; 
  *outstream << " </HEADER>"                                                                            << std::endl ; 
  *outstream << ""                                                                                      << std::endl ; 
  *outstream << " <DATA_SET>"                                                                           << std::endl ;
  *outstream << ""                                                                                      << std::endl ;
  *outstream << "  <VERSION>"             << version      << "</VERSION>"                               << std::endl ;
  *outstream << "  <COMMENT_DESCRIPTION>" << getComment() << "</COMMENT_DESCRIPTION>"                   << std::endl ;
  *outstream << "  <CREATED_BY_USER>"     << getAuthor()  << "</CREATED_BY_USER>"                       << std::endl ;
  *outstream << ""                                                                                      << std::endl ;
  *outstream << "  <PART>"                                                                              << std::endl ;
  *outstream << "   <NAME_LABEL>CMS-PIXEL-ROOT</NAME_LABEL>"                                            << std::endl ;      
  *outstream << "   <KIND_OF_PART>Detector ROOT</KIND_OF_PART>"                                         << std::endl ;         
  *outstream << "  </PART>"                                                                             << std::endl ;
  *outstream << "  "                                                                                    << std::endl ;

}
void PixelMaskAllPixels::writeXMLTrailer ( std::ofstream *  out,
std::ofstream *  out1 = NULL,
std::ofstream *  out2 = NULL 
) const [virtual]

Reimplemented from pos::PixelMaskBase.

Definition at line 306 of file PixelMaskAllPixels.cc.

References gather_cfg::cout.

{
  std::string mthn = "[PixelMaskAllPixels::writeXMLTrailer()]\t\t\t    " ;
  
  *outstream << "  "                                                                                    << std::endl ;
  *outstream << " </DATA_SET>"                                                                          << std::endl ;
  *outstream << "</ROOT>"                                                                               << std::endl ;
  
  outstream->close() ;
  std::cout << __LINE__ << "]\t" << mthn << "Data written "                                             << std::endl ;

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

Reimplemented from pos::PixelConfigBase.

Definition at line 34 of file PixelMaskCommon.h.

{;}

Member Data Documentation

std::vector<bool> pos::PixelMaskAllPixels::maskbits_ [private]

Definition at line 39 of file PixelMaskCommon.h.

std::vector<PixeROCName> pos::PixelMaskAllPixels::rocname_ [private]

Definition at line 38 of file PixelMaskCommon.h.