#include <CalibTracker/SiPixelCommon/src/SiPixelDetInfoFileReader.cc>
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_ |
Implementation: <Notes on="" implementation>="">
Definition at line 29 of file SiPixelDetInfoFileReader.h.
SiPixelDetInfoFileReader::SiPixelDetInfoFileReader | ( | std::string | filePath | ) | [explicit] |
Definition at line 17 of file SiPixelDetInfoFileReader.cc.
References detData_, detIds_, lat::endl(), inputFile_, and it.
00017 { 00018 00019 // if(filePath==std::string("")){ 00020 // filePath = edm::FileInPath(std::string("CalibTracker/SiPixelCommon/data/SiPixelDetInfo.dat") ).fullPath(); 00021 // } 00022 00023 detData_.clear(); 00024 detIds_.clear(); 00025 00026 inputFile_.open(filePath.c_str()); 00027 00028 if (inputFile_.is_open()){ 00029 00030 for(;;) { 00031 00032 uint32_t detid; 00033 int ncols; 00034 int nrows; 00035 00036 inputFile_ >> detid >> ncols >> nrows ; 00037 00038 if (!(inputFile_.eof() || inputFile_.fail())){ 00039 00040 detIds_.push_back(detid); 00041 00042 //inputFile_ >> numberOfAPVs; 00043 //inputFile_ >> stripLength; 00044 00045 // edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl; 00046 00047 std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detid); 00048 00049 if( it==detData_.end() ){ 00050 00051 detData_[detid]=pair<int, int>(ncols,nrows); 00052 00053 } 00054 else{ 00055 edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") <<"DetId " << detid << " already found on file. Ignoring new data"<<endl; 00056 detIds_.pop_back(); 00057 continue; 00058 } 00059 } 00060 else if (inputFile_.eof()){ 00061 00062 edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - END of file reached")<<endl; 00063 break; 00064 00065 } 00066 else if (inputFile_.fail()) { 00067 00068 edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - ERROR while reading file")<<endl; 00069 break; 00070 } 00071 } 00072 00073 inputFile_.close(); 00074 00075 } 00076 else { 00077 00078 edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - Unable to open file")<<endl; 00079 return; 00080 00081 } 00082 00083 00084 // int i=0; 00085 // for(std::map<uint32_t, std::pair<unsigned short, double> >::iterator it =detData_.begin(); it!=detData_.end(); it++ ) { 00086 // std::cout<< it->first << " " << (it->second).first << " " << (it->second).second<<endl; 00087 // i++; 00088 // } 00089 // std::cout<<i; 00090 00091 00092 }
SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader | ( | ) |
Definition at line 96 of file SiPixelDetInfoFileReader.cc.
00096 { 00097 00098 edm::LogInfo("SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader"); 00099 }
const std::vector< uint32_t > & SiPixelDetInfoFileReader::getAllDetIds | ( | ) | const |
Definition at line 103 of file SiPixelDetInfoFileReader.cc.
References detIds_.
00103 { 00104 00105 return detIds_; 00106 00107 }
const std::pair< int, int > & SiPixelDetInfoFileReader::getDetUnitDimensions | ( | uint32_t | detId | ) | const |
Definition at line 111 of file SiPixelDetInfoFileReader.cc.
References detData_, lat::endl(), and it.
00111 { 00112 00113 std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detId); 00114 00115 if(it!=detData_.end()){ 00116 00117 return (*it).second; 00118 00119 } 00120 else{ 00121 00122 static std::pair< int, int> defaultValue(0,0); 00123 edm::LogWarning("SiPixelDetInfoFileReader::getDetUnitDimensions - Unable to find requested detid. Returning invalid data ")<<endl; 00124 return defaultValue; 00125 00126 } 00127 00128 }
std::map<uint32_t, std::pair<int, int> > SiPixelDetInfoFileReader::detData_ [private] |
Definition at line 44 of file SiPixelDetInfoFileReader.h.
Referenced by getDetUnitDimensions(), and SiPixelDetInfoFileReader().
std::vector<uint32_t> SiPixelDetInfoFileReader::detIds_ [private] |
Definition at line 45 of file SiPixelDetInfoFileReader.h.
Referenced by getAllDetIds(), and SiPixelDetInfoFileReader().
std::ifstream SiPixelDetInfoFileReader::inputFile_ [private] |