CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCSimSetUp.cc
Go to the documentation of this file.
22 
23 #include <cmath>
24 #include <math.h>
25 #include <fstream>
26 #include <sstream>
27 #include <iostream>
28 #include<cstring>
29 #include<string>
30 #include<vector>
31 #include<stdlib.h>
32 #include <utility>
33 #include <map>
34 
35 using namespace std;
36 
38 
39  _mapDetIdNoise.clear();
40  _mapDetIdEff.clear();
41  _bxmap.clear();
42  _clsMap.clear();
43 
44 }
45 
46 void RPCSimSetUp::setRPCSetUp(std::vector<RPCStripNoises::NoiseItem> vnoise, std::vector<float> vcls){
47 
48  unsigned int counter = 1;
49  unsigned int row = 1;
50  std::vector<double> sum_clsize;
51 
52  for(unsigned int n = 0; n < vcls.size(); ++n){
53 
54  sum_clsize.push_back(vcls[n]);
55 
56  if(counter == row*20) {
57 
58  _clsMap[row] = sum_clsize;
59  row++;
60  sum_clsize.clear();
61  }
62  counter++;
63  }
64 
65  unsigned int n = 0;
66  uint32_t temp = 0;
67  std::vector<float> veff, vvnoise;
68  veff.clear();
69  vvnoise.clear();
70 
71  for(std::vector<RPCStripNoises::NoiseItem>::iterator it = vnoise.begin(); it != vnoise.end(); ++it){
72  if(n%96 == 0) {
73  if(n > 0 ){
74  _mapDetIdNoise[temp]= vvnoise;
75  _mapDetIdEff[temp] = veff;
76  _bxmap[RPCDetId(it->dpid)] = it->time;
77 
78  veff.clear();
79  vvnoise.clear();
80  vvnoise.push_back((it->noise));
81  veff.push_back((it->eff));
82  }
83  else if(n == 0 ){
84  vvnoise.push_back((it->noise));
85  veff.push_back((it->eff));
86  _bxmap[RPCDetId(it->dpid)] = it->time;
87  }
88  } else if (n == vnoise.size()-1 ){
89  temp = it->dpid;
90  vvnoise.push_back((it->noise));
91  veff.push_back((it->eff));
92  _mapDetIdNoise[temp]= vvnoise;
93  _mapDetIdEff[temp] = veff;
94  } else {
95  temp = it->dpid;
96  vvnoise.push_back((it->noise));
97  veff.push_back((it->eff));
98  }
99  n++;
100  }
101 }
102 
103 void RPCSimSetUp::setRPCSetUp(std::vector<RPCStripNoises::NoiseItem> vnoise, std::vector<RPCClusterSize::ClusterSizeItem> vClusterSize){
104 
105  std::vector<RPCClusterSize::ClusterSizeItem>::iterator itCls;
106  uint32_t detId;
107  int clsCounter(1);
108  std::vector<double> clsVect;
109 
110  for(itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls){
111  clsVect.push_back(((double)(itCls->clusterSize)));
112  if((!(clsCounter%100)) && (clsCounter!=0)){
113  detId=itCls->dpid;
114  _mapDetClsMap[detId]=clsVect;
115  clsVect.clear();
116  clsCounter=0;
117  }
118  ++clsCounter;
119  }
120 
121  unsigned int n = 0;
122  uint32_t temp = 0;
123  std::vector<float> veff, vvnoise;
124  veff.clear();
125  vvnoise.clear();
126 
127  for(std::vector<RPCStripNoises::NoiseItem>::iterator it = vnoise.begin(); it != vnoise.end(); ++it){
128  if(n%96 == 0) {
129  if(n > 0 ){
130  _mapDetIdNoise[temp]= vvnoise;
131  _mapDetIdEff[temp] = veff;
132  _bxmap[RPCDetId(it->dpid)] = it->time;
133 
134  veff.clear();
135  vvnoise.clear();
136  vvnoise.push_back((it->noise));
137  veff.push_back((it->eff));
138  }
139  else if(n == 0 ){
140  vvnoise.push_back((it->noise));
141  veff.push_back((it->eff));
142  _bxmap[RPCDetId(it->dpid)] = it->time;
143  }
144  } else if (n == vnoise.size()-1 ){
145  temp = it->dpid;
146  vvnoise.push_back((it->noise));
147  veff.push_back((it->eff));
148  _mapDetIdNoise[temp]= vvnoise;
149  _mapDetIdEff[temp] = veff;
150  } else {
151  temp = it->dpid;
152  vvnoise.push_back((it->noise));
153  veff.push_back((it->eff));
154  }
155  n++;
156  }
157 }
158 
159 
160 const std::vector<float>& RPCSimSetUp::getNoise(uint32_t id)
161 {
162  map<uint32_t,std::vector<float> >::iterator iter = _mapDetIdNoise.find(id);
163  if(iter == _mapDetIdNoise.end()){
164  throw cms::Exception("DataCorrupt")
165  << "Exception comming from RPCSimSetUp - no noise information for DetId\t"<<id<< std::endl;
166  }
167  return iter->second;
168 }
169 
170 const std::vector<float>& RPCSimSetUp::getEff(uint32_t id)
171 {
172  map<uint32_t,std::vector<float> >::iterator iter = _mapDetIdEff.find(id);
173  if(iter == _mapDetIdEff.end()){
174  throw cms::Exception("DataCorrupt")
175  << "Exception comming from RPCSimSetUp - no efficiency information for DetId\t"<<id<< std::endl;
176  }
177  if((iter->second).size() != 96){
178  throw cms::Exception("DataCorrupt")
179  << "Exception comming from RPCSimSetUp - efficiency information in a wrong format for DetId\t"<<id<< std::endl;
180  }
181  return iter->second;
182 }
183 
184 float RPCSimSetUp::getTime(uint32_t id)
185 {
186  RPCDetId rpcid(id);
187  std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
188  if(iter == _bxmap.end()){
189  throw cms::Exception("DataCorrupt")
190  << "Exception comming from RPCSimSetUp - no timing information for rpcid.rawId()\t"<<rpcid.rawId()<< std::endl;
191  }
192  return iter->second;
193 }
194 
195 const std::map< int, std::vector<double> >& RPCSimSetUp::getClsMap()
196 {
197  if(_clsMap.size()!=5){
198  throw cms::Exception("DataCorrupt")
199  << "Exception comming from RPCSimSetUp - cluster size - a wrong format "<< std::endl;
200  }
201  return _clsMap;
202 }
203 
204 
205 //const std::map<int, std::vector<double> >& RPCSimSetUp::getClsMap(uint32_t id)
206 const std::vector<double>& RPCSimSetUp::getCls(uint32_t id)
207 {
208 
209  map<uint32_t,std::vector<double> >::iterator iter = _mapDetClsMap.find(id);
210  if(iter == _mapDetClsMap.end()){
211  throw cms::Exception("DataCorrupt")
212  << "Exception comming from RPCSimSetUp - no cluster size information for DetId\t"<<id<< std::endl;
213  }
214  if((iter->second).size() != 100){
215  throw cms::Exception("DataCorrupt")
216  << "Exception comming from RPCSimSetUp - cluster size information in a wrong format for DetId\t"<<id<< std::endl;
217  }
218  return iter->second;
219 }
220 
float getTime(uint32_t id)
Definition: RPCSimSetUp.cc:184
RPCSimSetUp(const edm::ParameterSet &ps)
Definition: RPCSimSetUp.cc:37
const std::vector< float > & getEff(uint32_t id)
Definition: RPCSimSetUp.cc:170
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
const std::vector< float > & getNoise(uint32_t id)
Definition: RPCSimSetUp.cc:160
virtual ~RPCSimSetUp()
Definition: RPCSimSetUp.cc:221
const std::vector< double > & getCls(uint32_t id)
Definition: RPCSimSetUp.cc:206
const std::map< int, std::vector< double > > & getClsMap()
Definition: RPCSimSetUp.cc:195
void setRPCSetUp(std::vector< RPCStripNoises::NoiseItem > vnoise, std::vector< float > vcls)
Definition: RPCSimSetUp.cc:46