CMS 3D CMS Logo

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::SiPixelDetInfoFileReader ( std::string  filePath)
explicit

Definition at line 15 of file SiPixelDetInfoFileReader.cc.

15  {
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 }

References dt4ml_dqm_sourceclient-live_cfg::filePath, and hgcalPlots::ncols.

◆ ~SiPixelDetInfoFileReader()

SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader ( )

Definition at line 79 of file SiPixelDetInfoFileReader.cc.

79  {
80  edm::LogInfo("SiPixelDetInfoFileReader::~SiPixelDetInfoFileReader");
81 }

Member Function Documentation

◆ getAllDetIds()

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

◆ getDetUnitDimensions()

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

Definition at line 89 of file SiPixelDetInfoFileReader.cc.

89  {
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 }

Member Data Documentation

◆ detData_

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

Definition at line 40 of file SiPixelDetInfoFileReader.h.

◆ detIds_

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

Definition at line 41 of file SiPixelDetInfoFileReader.h.

◆ inputFile_

std::ifstream SiPixelDetInfoFileReader::inputFile_
private

Definition at line 37 of file SiPixelDetInfoFileReader.h.

hgcalPlots.ncols
ncols
Definition: hgcalPlots.py:105
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:45
SiPixelDetInfoFileReader::detIds_
std::vector< uint32_t > detIds_
Definition: SiPixelDetInfoFileReader.h:41
SiPixelDetInfoFileReader::inputFile_
std::ifstream inputFile_
Definition: SiPixelDetInfoFileReader.h:37
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelDetInfoFileReader::detData_
std::map< uint32_t, std::pair< int, int > > detData_
Definition: SiPixelDetInfoFileReader.h:40