CMS 3D CMS Logo

SiStripDetInfoFileReader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiStripCommon
3 // Class: SiStripDetInfoFileReader
4 // Original Author: G. Bruno
5 // Created: Mon May 20 10:04:31 CET 2007
6 
9 #include <fstream>
10 
12  edm::LogInfo("SiStripDetInfoFileReader") << "filePath " << filePath;
13 
14  std::map<uint32_t, DetInfo> detData_;
15  std::vector<uint32_t> detIds_;
16 
17  std::ifstream inputFile;
18  inputFile.open(filePath.c_str());
19 
20  if (inputFile.is_open()) {
21  for (;;) {
22  uint32_t detid;
23  double stripLength;
24  unsigned short numberOfAPVs;
25  float thickness;
26 
27  inputFile >> detid >> numberOfAPVs >> stripLength >> thickness;
28 
29  if (!(inputFile.eof() || inputFile.fail())) {
30  detIds_.push_back(detid);
31 
32  // inputFile >> numberOfAPVs;
33  // inputFile >> stripLength;
34 
35  // edm::LogInfo("SiStripDetInfoFileReader::SiStripDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl;
36 
37  if (detData_.find(detid) == detData_.end()) {
38  detData_[detid] = DetInfo(numberOfAPVs, stripLength, thickness);
39  } else {
40  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader")
41  << "DetId " << detid << " already found on file. Ignoring new data";
42 
43  detIds_.pop_back();
44  continue;
45  }
46  } else if (inputFile.eof()) {
47  edm::LogInfo("SiStripDetInfoFileReader::SiStripDetInfoFileReader - END of file reached");
48  break;
49 
50  } else if (inputFile.fail()) {
51  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader - ERROR while reading file");
52  break;
53  }
54  }
55  inputFile.close();
56  } else {
57  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader - Unable to open file");
58  return SiStripDetInfo();
59  }
60 
61  return SiStripDetInfo(std::move(detData_), std::move(detIds_));
62 }
MessageLogger.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripDetInfoFileReader::read
SiStripDetInfo read(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:11
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:115
SiStripDetInfoFileReader::DetInfo
SiStripDetInfo::DetInfo DetInfo
Definition: SiStripDetInfoFileReader.h:8
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:45
SiStripDetInfoFileReader.h
dtResolutionTest_cfi.inputFile
inputFile
Definition: dtResolutionTest_cfi.py:14
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
SiStripDetInfo
Definition: SiStripDetInfo.h:29