CMS 3D CMS Logo

Public Member Functions | Private Attributes

SiPixelDetInfoFileReader Class Reference

#include <CalibTracker/SiPixelCommon/src/SiPixelDetInfoFileReader.cc>

List of all members.

Public Member Functions

const std::vector< uint32_t > & getAllDetIds () const
const std::pair< int, int > & getDetUnitDimensions (uint32_t detId) const
 SiPixelDetInfoFileReader (std::string filePath)
 ~SiPixelDetInfoFileReader ()

Private Attributes

std::map< uint32_t, std::pair
< int, int > > 
detData_
std::vector< uint32_t > detIds_
std::ifstream inputFile_

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 29 of file SiPixelDetInfoFileReader.h.


Constructor & Destructor Documentation

SiPixelDetInfoFileReader::SiPixelDetInfoFileReader ( std::string  filePath) [explicit]

Definition at line 17 of file SiPixelDetInfoFileReader.cc.

References cond::rpcobgas::detid.

                                                                     {

//   if(filePath==std::string("")){
//     filePath = edm::FileInPath(std::string("CalibTracker/SiPixelCommon/data/SiPixelDetInfo.dat") ).fullPath();
//   }

  detData_.clear();
  detIds_.clear();

  inputFile_.open(filePath.c_str());

  if (inputFile_.is_open()){

    for(;;) {

      uint32_t detid;
      int ncols;
      int nrows;

      inputFile_ >> detid >> ncols  >> nrows ;

      if (!(inputFile_.eof() || inputFile_.fail())){

        detIds_.push_back(detid);

        //inputFile_ >> numberOfAPVs;
        //inputFile_ >> stripLength;
        
        //       edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl;
        
        std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detid);
        
        if( it==detData_.end() ){
          
          detData_[detid]=pair<int, int>(ncols,nrows);
          
        }
        else{     
          edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") <<"DetId " << detid << " already found on file. Ignoring new data"<<endl;
          detIds_.pop_back();
          continue;
        }
      }
      else if (inputFile_.eof()){
        
        edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - END of file reached")<<endl;
        break;
        
      }
      else if (inputFile_.fail()) {
        
        edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - ERROR while reading file")<<endl;     
        break;
      }
    }
    
    inputFile_.close();
    
  }  
  else {
    
    edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - Unable to open file")<<endl;
    return;
    
  }
  

//   int i=0;
//   for(std::map<uint32_t, std::pair<unsigned short, double> >::iterator it =detData_.begin(); it!=detData_.end(); it++ ) {
//     std::cout<< it->first << " " << (it->second).first << " " << (it->second).second<<endl;
//     i++;
//   }
//   std::cout<<i;


}
SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader ( )

Definition at line 96 of file SiPixelDetInfoFileReader.cc.

                                                   {

   edm::LogInfo("SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader");
}

Member Function Documentation

const std::vector< uint32_t > & SiPixelDetInfoFileReader::getAllDetIds ( ) const
const std::pair< int, int > & SiPixelDetInfoFileReader::getDetUnitDimensions ( uint32_t  detId) const

Definition at line 111 of file SiPixelDetInfoFileReader.cc.

                                                                                            {

  std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detId);

  if(it!=detData_.end()){
    
    return (*it).second; 

  }
  else{

    static std::pair< int, int> defaultValue(0,0);
    edm::LogWarning("SiPixelDetInfoFileReader::getDetUnitDimensions - Unable to find requested detid. Returning invalid data ")<<endl; 
    return defaultValue;

  }

}

Member Data Documentation

std::map<uint32_t, std::pair<int, int> > SiPixelDetInfoFileReader::detData_ [private]

Definition at line 44 of file SiPixelDetInfoFileReader.h.

std::vector<uint32_t> SiPixelDetInfoFileReader::detIds_ [private]

Definition at line 45 of file SiPixelDetInfoFileReader.h.

std::ifstream SiPixelDetInfoFileReader::inputFile_ [private]

Definition at line 41 of file SiPixelDetInfoFileReader.h.