CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
SiPixelDetInfoFileReader Class Reference

#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_
 

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.

17  {
18 
19 // if(filePath==std::string("")){
20 // filePath = edm::FileInPath(std::string("CalibTracker/SiPixelCommon/data/SiPixelDetInfo.dat") ).fullPath();
21 // }
22 
23  detData_.clear();
24  detIds_.clear();
25 
26  inputFile_.open(filePath.c_str());
27 
28  if (inputFile_.is_open()){
29 
30  for(;;) {
31 
32  uint32_t detid;
33  int ncols;
34  int nrows;
35 
36  inputFile_ >> detid >> ncols >> nrows ;
37 
38  if (!(inputFile_.eof() || inputFile_.fail())){
39 
40  detIds_.push_back(detid);
41 
42  //inputFile_ >> numberOfAPVs;
43  //inputFile_ >> stripLength;
44 
45  // edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl;
46 
47  std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detid);
48 
49  if( it==detData_.end() ){
50 
51  detData_[detid]=pair<int, int>(ncols,nrows);
52 
53  }
54  else{
55  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") <<"DetId " << detid << " already found on file. Ignoring new data"<<endl;
56  detIds_.pop_back();
57  continue;
58  }
59  }
60  else if (inputFile_.eof()){
61 
62  edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - END of file reached")<<endl;
63  break;
64 
65  }
66  else if (inputFile_.fail()) {
67 
68  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - ERROR while reading file")<<endl;
69  break;
70  }
71  }
72 
73  inputFile_.close();
74 
75  }
76  else {
77 
78  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - Unable to open file")<<endl;
79  return;
80 
81  }
82 
83 
84 // int i=0;
85 // for(std::map<uint32_t, std::pair<unsigned short, double> >::iterator it =detData_.begin(); it!=detData_.end(); it++ ) {
86 // std::cout<< it->first << " " << (it->second).first << " " << (it->second).second<<endl;
87 // i++;
88 // }
89 // std::cout<<i;
90 
91 
92 }
std::vector< uint32_t > detIds_
std::map< uint32_t, std::pair< int, int > > detData_
SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader ( )

Definition at line 96 of file SiPixelDetInfoFileReader.cc.

96  {
97 
98  edm::LogInfo("SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader");
99 }

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.

111  {
112 
113  std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detId);
114 
115  if(it!=detData_.end()){
116 
117  return (*it).second;
118 
119  }
120  else{
121 
122  static std::pair< int, int> defaultValue(0,0);
123  edm::LogWarning("SiPixelDetInfoFileReader::getDetUnitDimensions - Unable to find requested detid. Returning invalid data ")<<endl;
124  return defaultValue;
125 
126  }
127 
128 }
std::map< uint32_t, std::pair< int, int > > detData_

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.