CMS 3D CMS Logo

RPCDBSimSetUp.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <cmath>
6 #include <fstream>
7 #include <sstream>
8 #include <iostream>
9 #include <cstring>
10 #include <string>
11 #include <vector>
12 #include <cstdlib>
13 #include <utility>
14 #include <map>
15 
16 using namespace std;
17 
19  _mapDetIdNoise.clear();
20  _mapDetIdEff.clear();
21  _bxmap.clear();
22 
23  //------------------------ Noise Reading ----------------------------
24 
25  edm::FileInPath fp1 = ps.getParameter<edm::FileInPath>("noisemapfile");
26  std::ifstream _infile1(fp1.fullPath().c_str(), std::ios::in);
27 
28  std::vector<float> vnoise;
29 
30  int rpcdetid = 0;
31  std::string buff;
32 
33  std::vector<std::string> words;
34 
35  int count = 0;
36  while (getline(_infile1, buff, '\n')) {
37  words.clear();
38  vnoise.clear();
39 
40  stringstream ss;
41  std::string chname;
42  ss << buff;
43  ss >> chname >> rpcdetid;
44 
45  std::string::size_type pos = 0, prev_pos = 0;
46 
47  while ((pos = buff.find(" ", pos)) != string::npos) {
48  words.push_back(buff.substr(prev_pos, pos - prev_pos));
49  prev_pos = ++pos;
50  }
51  words.push_back(buff.substr(prev_pos, pos - prev_pos));
52 
53  for (unsigned int i = 2; i < words.size(); ++i) {
54  float value = atof(((words)[i]).c_str());
55  vnoise.push_back(value);
56  }
57 
58  _mapDetIdNoise.insert(make_pair(static_cast<uint32_t>(rpcdetid), vnoise));
59 
60  count++;
61  }
62  _infile1.close();
63 
64  //------------------------ Eff Reading ----------------------------
65 
66  edm::FileInPath fp2 = ps.getParameter<edm::FileInPath>("effmapfile");
67  _infile2 = new ifstream(fp2.fullPath().c_str(), std::ios::in);
68 
69  std::vector<float> veff;
70  rpcdetid = 0;
71 
72  while (getline(*_infile2, buff, '\n')) {
73  words.clear();
74  veff.clear();
75 
76  stringstream ss;
77  std::string chname;
78  ss << buff;
79  ss >> chname >> rpcdetid;
80 
81  std::string::size_type pos = 0, prev_pos = 0;
82  while ((pos = buff.find(" ", pos)) != string::npos) {
83  words.push_back(buff.substr(prev_pos, pos - prev_pos));
84  prev_pos = ++pos;
85  }
86  words.push_back(buff.substr(prev_pos, pos - prev_pos));
87 
88  for (unsigned int i = 2; i < words.size(); ++i) {
89  float value = atof(((words)[i]).c_str());
90  veff.push_back(value);
91  }
92  _mapDetIdEff.insert(make_pair(static_cast<uint32_t>(rpcdetid), veff));
93  }
94  _infile2->close();
95 
96  //---------------------- Timing reading ------------------------------------
97 
98  edm::FileInPath fp3 = ps.getParameter<edm::FileInPath>("timingMap");
99  _infile3 = new ifstream(fp3.fullPath().c_str(), std::ios::in);
100 
101  uint32_t detUnit = 0;
102  float timing = 0.;
103  while (!_infile3->eof()) {
104  *_infile3 >> detUnit >> timing;
105  _bxmap[RPCDetId(detUnit)] = timing;
106  }
107  _infile3->close();
108 
109  //---------------------- Cluster size --------------------------------------
110 
111  edm::FileInPath fp4 = ps.getParameter<edm::FileInPath>("clsmapfile");
112  _infile4 = new ifstream(fp4.fullPath().c_str(), ios::in);
113 
114  string buffer;
115  double sum = 0;
116  unsigned int counter = 1;
117  unsigned int row = 1;
118  std::vector<double> sum_clsize;
119 
120  while (*_infile4 >> buffer) {
121  const char* buffer1 = buffer.c_str();
122  double dato = atof(buffer1);
123  sum += dato;
124  sum_clsize.push_back(sum);
125 
126  if (counter == row * 20) {
127  _clsMap[row] = sum_clsize;
128  row++;
129  sum = 0;
130  sum_clsize.clear();
131  }
132  counter++;
133  }
134  _infile4->close();
135 }
136 
137 std::vector<float> RPCDBSimSetUp::getNoise(uint32_t id) {
138  map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(id);
139  return (iter->second);
140 }
141 
142 std::vector<float> RPCDBSimSetUp::getEff(uint32_t id) {
143  map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(id);
144  return iter->second;
145 }
146 
147 float RPCDBSimSetUp::getTime(uint32_t id) {
148  RPCDetId rpcid(id);
149  std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
150  return iter->second;
151 }
152 
153 std::map<int, std::vector<double> > RPCDBSimSetUp::getClsMap() { return _clsMap; }
154 
156  delete _infile1;
157  delete _infile2;
158  delete _infile3;
159  delete _infile4;
160 }
counter
Definition: counter.py:1
RPCDBSimSetUp::RPCDBSimSetUp
RPCDBSimSetUp(const edm::ParameterSet &ps)
Definition: RPCDBSimSetUp.cc:18
mps_fire.i
i
Definition: mps_fire.py:428
RPCDBSimSetUp.h
RPCDBSimSetUp::getEff
std::vector< float > getEff(uint32_t id)
Definition: RPCDBSimSetUp.cc:142
RPCDetId
Definition: RPCDetId.h:16
pos
Definition: PixelAliasList.h:18
RPCDBSimSetUp::getClsMap
std::map< int, std::vector< double > > getClsMap()
Definition: RPCDBSimSetUp.cc:153
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
RPCDBSimSetUp::getNoise
std::vector< float > getNoise(uint32_t id)
Definition: RPCDBSimSetUp.cc:137
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::FileInPath
Definition: FileInPath.h:61
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
RPCDBSimSetUp::getTime
float getTime(uint32_t id)
Definition: RPCDBSimSetUp.cc:147
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
RPCDetId.h
edm::ParameterSet
Definition: ParameterSet.h:47
recoMuon::in
Definition: RecoMuonEnumerators.h:6
value
Definition: value.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDBSimSetUp::~RPCDBSimSetUp
virtual ~RPCDBSimSetUp()
Definition: RPCDBSimSetUp.cc:155
ecalMatacq_cfi.timing
timing
Definition: ecalMatacq_cfi.py:26
std
Definition: JetResolutionObject.h:76
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:161