CMS 3D CMS Logo

SiPixelDetInfoFileReader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiPixelESProducers
3 // Class: SiPixelDetInfoFileReader
4 // Original Author: V.Chiochia
5 // Created: Mon May 20 10:04:31 CET 2007
6 
10 //#include "FWCore/ParameterSet/interface/FileInPath.h"
11 
12 using namespace cms;
13 using namespace std;
14 
16  // if(filePath==std::string("")){
17  // filePath = edm::FileInPath(std::string("CalibTracker/SiPixelCommon/data/SiPixelDetInfo.dat") ).fullPath();
18  // }
19 
20  detData_.clear();
21  detIds_.clear();
22 
23  inputFile_.open(filePath.c_str());
24 
25  if (inputFile_.is_open()) {
26  for (;;) {
27  uint32_t detid;
28  int ncols;
29  int nrows;
30 
31  inputFile_ >> detid >> ncols >> nrows;
32 
33  if (!(inputFile_.eof() || inputFile_.fail())) {
34  detIds_.push_back(detid);
35 
36  //inputFile_ >> numberOfAPVs;
37  //inputFile_ >> stripLength;
38 
39  // edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl;
40 
41  std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detid);
42 
43  if (it == detData_.end()) {
44  detData_[detid] = pair<int, int>(ncols, nrows);
45 
46  } else {
47  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader")
48  << "DetId " << detid << " already found on file. Ignoring new data" << endl;
49  detIds_.pop_back();
50  continue;
51  }
52  } else if (inputFile_.eof()) {
53  edm::LogInfo("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - END of file reached") << endl;
54  break;
55 
56  } else if (inputFile_.fail()) {
57  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - ERROR while reading file") << endl;
58  break;
59  }
60  }
61 
62  inputFile_.close();
63 
64  } else {
65  edm::LogError("SiPixelDetInfoFileReader::SiPixelDetInfoFileReader - Unable to open file") << endl;
66  return;
67  }
68 
69  // int i=0;
70  // for(std::map<uint32_t, std::pair<unsigned short, double> >::iterator it =detData_.begin(); it!=detData_.end(); it++ ) {
71  // std::cout<< it->first << " " << (it->second).first << " " << (it->second).second<<endl;
72  // i++;
73  // }
74  // std::cout<<i;
75 }
76 //
77 // Destructor
78 //
80  edm::LogInfo("SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader");
81 }
82 //
83 // get DetId's
84 //
85 const std::vector<uint32_t>& SiPixelDetInfoFileReader::getAllDetIds() const { return detIds_; }
86 //
87 // get method
88 //
89 const std::pair<int, int>& SiPixelDetInfoFileReader::getDetUnitDimensions(uint32_t detId) const {
90  std::map<uint32_t, std::pair<int, int> >::const_iterator it = detData_.find(detId);
91 
92  if (it != detData_.end()) {
93  return (*it).second;
94 
95  } else {
96  static const std::pair<int, int> defaultValue(0, 0);
98  "SiPixelDetInfoFileReader::getDetUnitDimensions - Unable to find requested detid. Returning invalid data ")
99  << endl;
100  return defaultValue;
101  }
102 }
SiPixelDetInfoFileReader::getAllDetIds
const std::vector< uint32_t > & getAllDetIds() const
Definition: SiPixelDetInfoFileReader.cc:85
hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
SiPixelDetInfoFileReader::SiPixelDetInfoFileReader
SiPixelDetInfoFileReader(std::string filePath)
Definition: SiPixelDetInfoFileReader.cc:15
MessageLogger.h
SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader
~SiPixelDetInfoFileReader()
Definition: SiPixelDetInfoFileReader.cc:79
edm::LogInfo
Definition: MessageLogger.h:254
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::LogError
Definition: MessageLogger.h:183
SiPixelDetInfoFileReader.h
std
Definition: JetResolutionObject.h:76
Exception.h
SiPixelDetInfoFileReader::getDetUnitDimensions
const std::pair< int, int > & getDetUnitDimensions(uint32_t detId) const
Definition: SiPixelDetInfoFileReader.cc:89
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21