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 
11 
12 using namespace cms;
13 using namespace std;
14 
16  detData_ = copy.detData_;
17  detIds_ = copy.detIds_;
18  return *this;
19 }
20 
23  pset.getUntrackedParameter<std::string>("filePath", "CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
24  reader(fp.fullPath());
25 }
26 
28  detData_ = copy.detData_;
29  detIds_ = copy.detIds_;
30 }
31 
33 
35  // if(filePath==std::string("")){
36  // filePath = edm::FileInPath(std::string("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat") ).fullPath();
37  // }
38 
39  edm::LogInfo("SiStripDetInfoFileReader") << "filePath " << filePath << std::endl;
40 
41  detData_.clear();
42  detIds_.clear();
43 
44  inputFile_.open(filePath.c_str());
45 
46  if (inputFile_.is_open()) {
47  for (;;) {
48  uint32_t detid;
49  double stripLength;
50  unsigned short numberOfAPVs;
51  float thickness;
52 
53  inputFile_ >> detid >> numberOfAPVs >> stripLength >> thickness;
54 
55  if (!(inputFile_.eof() || inputFile_.fail())) {
56  detIds_.push_back(detid);
57 
58  // inputFile_ >> numberOfAPVs;
59  // inputFile_ >> stripLength;
60 
61  // edm::LogInfo("SiStripDetInfoFileReader::SiStripDetInfoFileReader") << detid <<" " <<numberOfAPVs <<" " <<stripLength << " "<< thickness<< endl;
62 
63  std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detid);
64 
65  if (it == detData_.end()) {
66  detData_[detid] = DetInfo(numberOfAPVs, stripLength, thickness);
67  } else {
68  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader")
69  << "DetId " << detid << " already found on file. Ignoring new data" << endl;
70 
71  detIds_.pop_back();
72  continue;
73  }
74  } else if (inputFile_.eof()) {
75  edm::LogInfo("SiStripDetInfoFileReader::SiStripDetInfoFileReader - END of file reached") << endl;
76  break;
77 
78  } else if (inputFile_.fail()) {
79  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader - ERROR while reading file") << endl;
80  break;
81  }
82  }
83 
84  inputFile_.close();
85 
86  } else {
87  edm::LogError("SiStripDetInfoFileReader::SiStripDetInfoFileReader - Unable to open file") << endl;
88  return;
89  }
90 
91  // int i=0;
92  // for(std::map<uint32_t, std::pair<unsigned short, double> >::iterator it =detData_.begin(); it!=detData_.end(); it++ ) {
93  // std::cout<< it->first << " " << (it->second).first << " " << (it->second).second<<endl;
94  // i++;
95  // }
96  // std::cout<<i;
97 }
98 
100 
101 const std::pair<unsigned short, double> SiStripDetInfoFileReader::getNumberOfApvsAndStripLength(uint32_t detId) const {
102  std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);
103 
104  if (it != detData_.end()) {
105  return std::pair<unsigned short, double>(it->second.nApvs, it->second.stripLength);
106 
107  } else {
108  std::pair<unsigned short, double> defaultValue(0, 0.);
110  "SiStripDetInfoFileReader::getNumberOfApvsAndStripLength - Unable to find requested detid. Returning invalid "
111  "data ")
112  << endl;
113  return defaultValue;
114  }
115 }
116 
117 const float& SiStripDetInfoFileReader::getThickness(uint32_t detId) const {
118  std::map<uint32_t, DetInfo>::const_iterator it = detData_.find(detId);
119 
120  if (it != detData_.end()) {
121  return it->second.thickness;
122 
123  } else {
124  static const float defaultValue = 0;
125  edm::LogWarning("SiStripDetInfoFileReader::getThickness - Unable to find requested detid. Returning invalid data ")
126  << endl;
127  return defaultValue;
128  }
129 }
MessageLogger.h
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
edm::LogInfo
Definition: MessageLogger.h:254
personalPlayback.fp
fp
Definition: personalPlayback.py:523
SiStripDetInfoFileReader
Definition: SiStripDetInfoFileReader.h:30
FileInPath.h
SiStripDetInfoFileReader::operator=
SiStripDetInfoFileReader & operator=(const SiStripDetInfoFileReader &copy)
Definition: SiStripDetInfoFileReader.cc:15
edm::FileInPath
Definition: FileInPath.h:64
DQM.reader
reader
Definition: DQM.py:105
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:114
SiStripDetInfoFileReader::getThickness
const float & getThickness(uint32_t detId) const
Definition: SiStripDetInfoFileReader.cc:117
edm::ActivityRegistry
Definition: ActivityRegistry.h:132
dt4ml_dqm_sourceclient-live_cfg.filePath
filePath
CUSTOMIZE FOR ML.
Definition: dt4ml_dqm_sourceclient-live_cfg.py:39
SiStripDetInfoFileReader.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
SiStripDetInfoFileReader::DetInfo
Definition: SiStripDetInfoFileReader.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
SiStripDetInfoFileReader::reader
void reader(std::string filePath)
Definition: SiStripDetInfoFileReader.cc:34
SiStripDetInfoFileReader::SiStripDetInfoFileReader
SiStripDetInfoFileReader()
Definition: SiStripDetInfoFileReader.h:42
std
Definition: JetResolutionObject.h:76
SiStripDetInfoFileReader::getNumberOfApvsAndStripLength
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
Definition: SiStripDetInfoFileReader.cc:101
SiStripDetInfoFileReader::~SiStripDetInfoFileReader
~SiStripDetInfoFileReader()
Definition: SiStripDetInfoFileReader.cc:99
Exception.h
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21