test
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 28 of file SiPixelDetInfoFileReader.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file SiPixelDetInfoFileReader.cc.

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

Definition at line 95 of file SiPixelDetInfoFileReader.cc.

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

Member Function Documentation

const std::vector< uint32_t > & SiPixelDetInfoFileReader::getAllDetIds ( ) const

Definition at line 102 of file SiPixelDetInfoFileReader.cc.

Referenced by DetIdSelectorTest::analyze(), and OccupancyPlots::endRun().

102  {
103 
104  return detIds_;
105 
106 }
std::vector< uint32_t > detIds_
const std::pair< int, int > & SiPixelDetInfoFileReader::getDetUnitDimensions ( uint32_t  detId) const

Definition at line 110 of file SiPixelDetInfoFileReader.cc.

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

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

Definition at line 44 of file SiPixelDetInfoFileReader.h.

std::ifstream SiPixelDetInfoFileReader::inputFile_
private

Definition at line 40 of file SiPixelDetInfoFileReader.h.