CMS 3D CMS Logo

RPCSimSetUp.cc
Go to the documentation of this file.
22 
23 #include <cmath>
24 #include <cmath>
25 #include <fstream>
26 #include <sstream>
27 #include <iostream>
28 #include <cstring>
29 #include <string>
30 #include <vector>
31 #include <cstdlib>
32 #include <utility>
33 #include <map>
34 
35 using namespace std;
36 
38  _mapDetIdNoise.clear();
39  _mapDetIdEff.clear();
40  _bxmap.clear();
41  _clsMap.clear();
42 }
43 
44 void RPCSimSetUp::setRPCSetUp(const std::vector<RPCStripNoises::NoiseItem>& vnoise, const std::vector<float>& vcls) {
45  unsigned int counter = 1;
46  unsigned int row = 1;
47  std::vector<double> sum_clsize;
48 
49  for (unsigned int n = 0; n < vcls.size(); ++n) {
50  sum_clsize.push_back(vcls[n]);
51 
52  if (counter == row * 20) {
53  _clsMap[row] = sum_clsize;
54  row++;
55  sum_clsize.clear();
56  }
57  counter++;
58  }
59 
60  unsigned int n = 0;
61  uint32_t temp = 0;
62  std::vector<float> veff, vvnoise;
63  veff.clear();
64  vvnoise.clear();
65 
66  for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
67  if (n % 96 == 0) {
68  if (n > 0) {
69  _mapDetIdNoise[temp] = vvnoise;
70  _mapDetIdEff[temp] = veff;
71  _bxmap[RPCDetId(it->dpid)] = it->time;
72 
73  veff.clear();
74  vvnoise.clear();
75  vvnoise.push_back((it->noise));
76  veff.push_back((it->eff));
77  } else if (n == 0) {
78  vvnoise.push_back((it->noise));
79  veff.push_back((it->eff));
80  _bxmap[RPCDetId(it->dpid)] = it->time;
81  }
82  } else if (n == vnoise.size() - 1) {
83  temp = it->dpid;
84  vvnoise.push_back((it->noise));
85  veff.push_back((it->eff));
86  _mapDetIdNoise[temp] = vvnoise;
87  _mapDetIdEff[temp] = veff;
88  } else {
89  temp = it->dpid;
90  vvnoise.push_back((it->noise));
91  veff.push_back((it->eff));
92  }
93  n++;
94  }
95 }
96 
97 void RPCSimSetUp::setRPCSetUp(const std::vector<RPCStripNoises::NoiseItem>& vnoise,
98  const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize) {
99  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)" << std::endl;
100 
101  uint32_t detId = 0, current_detId, this_detId;
102  RPCDetId rpcId, current_rpcId, this_rpcId;
103  const RPCRoll* current_roll = nullptr;
104  const RPCRoll* this_roll = nullptr;
105  unsigned int current_nStrips;
106 
107  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin" << std::endl;
108  std::stringstream sslogclsitem;
109  // ### ClusterSizeItem #######################################################
110  std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
111  int clsCounter(1);
112  std::vector<double> clsVect;
113  // ### loop for New Format (120 entries)
114  for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
115  sslogclsitem << " Push back clustersize = " << itCls->clusterSize << std::endl;
116  clsVect.push_back(((double)(itCls->clusterSize)));
117  sslogclsitem << "Filling cls in _mapDetCls[detId,clsVect] :: detId = " << detId;
118  sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted?";
119  sslogclsitem << " New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0)); // <<std::endl;
120  sslogclsitem << " Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0)); // <<std::endl;
121  sslogclsitem << std::endl;
122 
123  // New Format :: loop until 120
124  if ((!(clsCounter % 120)) && (clsCounter != 0)) {
125  detId = itCls->dpid;
126  _mapDetClsMap[detId] = clsVect;
127  std::stringstream LogDebugClsVectString;
128  LogDebugClsVectString << "[";
129  for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
130  LogDebugClsVectString << *itClsVect << ",";
131  }
132  LogDebugClsVectString << "]";
133  std::string LogDebugClsVectStr = LogDebugClsVectString.str();
134  LogDebug("RPCSimSetup") << "Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " << RPCDetId(detId) << " = "
135  << detId << " clsVec = " << LogDebugClsVectStr;
136 
137  sslogclsitem << " --> New Method ";
138  sslogclsitem << " --> saved in map " << std::endl;
139  sslogclsitem << "Filling cls in _mapDetClsMap[detId,clsVect] :: detId = " << detId;
140  sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted? "
141  << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
142  clsVect.clear();
143  clsCounter = 0;
144  } else {
145  sslogclsitem << " --> not saved in map " << std::endl;
146  }
147  ++clsCounter;
148  }
149  // ### loop for Old Format (100 entries)
150  for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
151  sslogclsitem << " Push back clustersize = " << itCls->clusterSize << std::endl;
152  clsVect.push_back(((double)(itCls->clusterSize)));
153  sslogclsitem << "Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
154  sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted?";
155  sslogclsitem << " New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0)); // <<std::endl;
156  sslogclsitem << " Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0)); // <<std::endl;
157  sslogclsitem << std::endl;
158 
159  // Old Format :: same until 100
160  if ((!(clsCounter % 100)) && (clsCounter != 0)) {
161  detId = itCls->dpid;
162  _mapDetClsMapLegacy[detId] = clsVect;
163  std::stringstream LogDebugClsVectString;
164  LogDebugClsVectString << "[";
165  for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
166  LogDebugClsVectString << *itClsVect << ",";
167  }
168  LogDebugClsVectString << "]";
169  std::string LogDebugClsVectStr = LogDebugClsVectString.str();
170  LogDebug("RPCSimSetup") << "Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " << RPCDetId(detId)
171  << " = " << detId << " clsVec = " << LogDebugClsVectStr;
172 
173  sslogclsitem << " --> Old Method ";
174  sslogclsitem << " --> saved in map " << std::endl;
175  sslogclsitem << "Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
176  sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted? "
177  << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
178  clsVect.clear();
179  clsCounter = 0;
180  } else {
181  sslogclsitem << " --> not saved in map " << std::endl;
182  }
183  ++clsCounter;
184  }
185  // ###########################################################################
186  std::string logclsitem = sslogclsitem.str();
187  sslogclsitem.clear();
188  LogDebug("RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
189  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
190 
191  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
192  std::stringstream sslognoiseitem;
193  // ### NoiseItem #############################################################
194  unsigned int count_strips = 1;
195  unsigned int count_all = 1;
196  std::vector<float> vveff, vvnoise;
197 
198  // DetId to start with needs to be a DetId inside the Geometry used
199  // Therefore loop on the NoiseItems and search for the first valid roll in the Geometry
200  // Assign this as the DetId to start with (so called current_roll) and quit the loop
201  bool quitLoop = false;
202  current_detId = 0;
203  current_nStrips = 0; // current_rpcId = 0; current_roll = 0;
204  for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
205  ++it) {
206  // roll associated to the conditions of this strip (iterator)
207  current_detId = it->dpid;
208  current_rpcId = RPCDetId(current_detId);
209  // Test whether this roll (picked up from the conditions) is inside the RPC Geometry
210  const RPCRoll* roll = theGeometry->roll(current_rpcId);
211  if (roll == nullptr) {
212  sslognoiseitem << "Searching for first valid detid :: current_detId = " << current_detId;
213  sslognoiseitem << " aka " << current_rpcId << " is not in current Geometry --> Skip " << std::endl;
214  continue;
215  } else {
216  sslognoiseitem << "Searching for first valid detid :: current_detId = " << current_detId;
217  sslognoiseitem << " aka " << current_rpcId
218  << " is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop"
219  << std::endl;
220  current_roll = theGeometry->roll(current_rpcId);
221  current_nStrips = current_roll->nstrips();
222  quitLoop = true;
223  }
224  }
225 
226  sslognoiseitem << "Start Position :: current_detId = " << current_detId << " aka " << current_rpcId;
227  sslognoiseitem << " is a valid roll with pointer " << current_roll << " and has "
228  << (current_roll ? current_roll->nstrips() : 0) << " strips" << std::endl;
229  sslognoiseitem << " -------------------------------------------------------------------------------------------------"
230  "------------------------------------ "
231  << std::endl;
232  for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
233  // roll associated to the conditions of this strip (iterator)
234  this_detId = it->dpid;
235  this_rpcId = RPCDetId(this_detId);
236  // Test whether this roll (picked up from the conditions) is inside the RPC Geometry
237  const RPCRoll* roll = theGeometry->roll(this_rpcId);
238  if (roll == nullptr) {
239  sslognoiseitem << "Inside Loop :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
240  << "] :: this_detId = " << this_detId << " aka " << this_rpcId
241  << " which is not in current Geometry --> Skip " << std::endl;
242  continue;
243  }
244 
245  // Case 1 :: FIRST ENTRY
246  // ---------------------
247  if (this_detId == current_detId && count_strips == 1) {
248  sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
249  sslognoiseitem << this_detId << " = " << this_rpcId << " with " << roll->nstrips() << " strips" << std::endl;
250  // fill bx in map
251  _bxmap[current_detId] = it->time;
252  sslognoiseitem << "[NoiseItem :: n = " << count_all
253  << "] Filling time in _bxmap[detId] :: detId = " << RPCDetId(it->dpid) << " time = " << it->time
254  << std::endl;
255  // clear vectors
256  vveff.clear();
257  vvnoise.clear();
258  // fill the vectors
259  vvnoise.push_back((it->noise));
260  vveff.push_back((it->eff));
261  sslognoiseitem << "First Value :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
262  << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
263  sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
264  // update counter
265  ++count_strips;
266  ++count_all;
267  }
268  // Case 2 :: 2ND ENTRY --> LAST-1 ENTRY
269  // ------------------------------------
270  else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
271  sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
272  sslognoiseitem << "Inside Loop :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
273  << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
274  sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
275  // fill the vectors
276  vvnoise.push_back((it->noise));
277  vveff.push_back((it->eff));
278  // update counter
279  ++count_strips;
280  ++count_all;
281  }
282 
283  // Case 3 :: LAST ENTRY
284  // --------------------
285  else if (this_detId == current_detId && count_strips == current_nStrips) {
286  sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
287  // fill last value in the vector
288  sslognoiseitem << "Last Value :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
289  << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
290  sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
291  vvnoise.push_back((it->noise));
292  vveff.push_back((it->eff));
293  // update counter
294  ++count_strips;
295  ++count_all;
296  // fill vectors into map
297  sslognoiseitem << " fill vectors into map" << std::endl;
298  _mapDetIdNoise[current_detId] = vvnoise;
299  _mapDetIdEff[current_detId] = vveff;
300 
301  std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
302  LogDebugNoiVectString << "[";
303  for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
304  LogDebugNoiVectString << (*itNoiVect) << ",";
305  }
306  LogDebugNoiVectString << "]";
307  std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
308  LogDebugEffVectString << "[";
309  for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
310  LogDebugEffVectString << (*itEffVect) << ",";
311  }
312  LogDebugEffVectString << "]";
313  std::string LogDebugEffVectStr = LogDebugEffVectString.str();
314  LogDebug("RPCSimSetup") << "Filling vvnoise in _mapDetIdNoise[detId] :: detId = " << RPCDetId(it->dpid) << " = "
315  << (RPCDetId(it->dpid)).rawId() << " vvnoise = " << LogDebugNoiVectStr;
316  LogDebug("RPCSimSetup") << "Filling veff in _mapDetIdEff[detId] :: detId = " << RPCDetId(it->dpid) << " = "
317  << (RPCDetId(it->dpid)).rawId() << " veff = " << LogDebugEffVectStr;
318 
319  // look for next different detId and rename it to the current_detId
320  // at this point we skip all the conditions for the strips that are not in this roll
321  // and we will go to the conditions for the first strip of the next roll
322  bool next_detId_found = false;
323  sslognoiseitem << "look for next different detId" << std::endl;
324  while (next_detId_found == 0 && it != vnoise.end() - 1) {
325  ++it;
326  this_detId = it->dpid;
327  this_rpcId = RPCDetId(this_detId);
328  this_roll = theGeometry->roll(this_rpcId);
329  if (!this_roll)
330  continue;
331  sslognoiseitem << "Inside While:: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
332  << "] :: this_detId = " << this_detId << " aka " << this_rpcId << " Noise = " << it->noise
333  << " Hz/cm2" << std::endl;
334  ++count_strips;
335  // ++count_all;
336  if (this_detId != current_detId) {
337  sslognoiseitem << "Different detId is found :: " << this_detId << " aka " << this_rpcId
338  << " Noise = " << it->noise << " Hz/cm2";
339  // next roll is found. update current_detId to this newly found detId
340  // and update also the number of strips
341  current_detId = this_detId;
342  current_rpcId = RPCDetId(current_detId);
343  next_detId_found = true;
344  current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
345  sslognoiseitem << " with " << current_nStrips << " strips" << std::endl;
346  --it; // subtract one, because at the end of the loop the iterator will be increased with one
347  // in fact the treatment for roll N stops when we find the first occurence of roll N+1
348  // however we want to start the treatment for roll N+1 with the first occurence of roll N+1
349  // so the first entry of each new roll N+1 is manipulated twice in the loop (once as a stop, once as a start)
350  // therefore we have to manipulate the iterator here, subtracting one, to treat again this entry
351  }
352  }
353  // reset count_strips
354  count_strips = 1;
355  }
356  // There should be no Case 4
357  // -------------------------
358  else {
359  }
360  }
361  // ###########################################################################
362  std::string lognoiseitem = sslognoiseitem.str();
363  sslognoiseitem.clear();
364  LogDebug("RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
365  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
366 
367  LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: end" << std::endl;
368 }
369 
370 const std::vector<float>& RPCSimSetUp::getNoise(uint32_t id) {
371  map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(id);
372  if (iter == _mapDetIdNoise.end()) {
373  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no noise information for DetId\t" << id
374  << std::endl;
375  }
376  LogDebug("RPCSimSetupChecks") << "All OK from RPCSimSetUp - noise information for DetId\t" << id << std::endl;
377  return iter->second;
378 }
379 
380 const std::vector<float>& RPCSimSetUp::getEff(uint32_t id) {
381  map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(id);
382  if (iter == _mapDetIdEff.end()) {
383  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no efficiency information for DetId\t" << id
384  << std::endl;
385  }
386 
387  RPCDetId rpcId = RPCDetId(id);
388  const RPCRoll* roll = theGeometry->roll(rpcId);
389  unsigned int numbStrips = roll->nstrips();
390 
391  if ((iter->second).size() < numbStrips) {
392  LogDebug("RPCSimSetup") << "Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" << id
393  << " aka " << RPCDetId(id) << std::endl;
394  LogDebug("RPCSimSetup") << " number of strips in Conditions\t" << (iter->second).size()
395  << " number of strips in Geometry\t" << numbStrips << std::endl;
396  throw cms::Exception("DataCorrupt")
397  << "Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" << id << std::endl;
398  }
399 
400  return iter->second;
401 }
402 
403 float RPCSimSetUp::getTime(uint32_t id) {
404  RPCDetId rpcid(id);
405  std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
406  if (iter == _bxmap.end()) {
407  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t"
408  << rpcid.rawId() << std::endl;
409  }
410  return iter->second;
411 }
412 
413 const std::map<int, std::vector<double> >& RPCSimSetUp::getClsMap() {
414  if (_clsMap.size() != 5) {
415  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
416  }
417  return _clsMap;
418 }
419 
420 //const std::map<int, std::vector<double> >& RPCSimSetUp::getClsMap(uint32_t id)
421 const std::vector<double>& RPCSimSetUp::getCls(uint32_t id) //legacy member function
422 {
423  LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getCls" << std::endl;
424 
425  map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(id);
426  if (iter == _mapDetClsMapLegacy.end()) {
427  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no cluster size information for DetId\t" << id
428  << std::endl;
429  }
430  if ((iter->second).size() != 100) {
431  throw cms::Exception("DataCorrupt")
432  << "Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"
433  << id << std::endl;
434  }
435  LogDebug("RPCSimSetupChecks")
436  << "All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" << id << std::endl;
437  return iter->second;
438 }
439 
440 const std::vector<double>& RPCSimSetUp::getAsymmetricClsDistribution(uint32_t id, uint32_t slice) {
441  LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
442 
443  map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(id);
444  if (iter == _mapDetClsMap.end()) {
445  throw cms::Exception("DataCorrupt")
446  << "Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" << id << std::endl;
447  }
448  if ((iter->second).size() != 120) {
449  throw cms::Exception("DataCorrupt")
450  << "Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" << id
451  << std::endl;
452  }
453  // return iter->second;
454 
455  std::vector<double> dataForAsymmCls = iter->second;
456  if (slice > 4) {
457  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
458  }
459 
460  _DetClsAsymmetric.clear();
461 
462  vector<double> clsFewStripsDistribution;
463  vector<double> clsDistribution;
464  vector<double> clsAccumulativeDistribution;
465 
466  std::map<int, std::vector<double> > mapSliceVsDistribution;
467 
468  const int slices = 5;
469  const int distributionFewStrips = 24;
470 
471  double sliceVsFewStripsDistribution[slices][distributionFewStrips];
472 
473  for (int j = 0; j < distributionFewStrips; j++) {
474  for (int i = 0; i < slices; i++) {
475  sliceVsFewStripsDistribution[i][j] = dataForAsymmCls[j * slices + i];
476  }
477  }
478 
479  double control = 0;
480  for (int j = 0; j < distributionFewStrips; j++) {
481  control += sliceVsFewStripsDistribution[0][j];
482  }
483 
484  double control1 = 0;
485  for (int j = 0; j < distributionFewStrips; j++) {
486  for (int i = 0; i < slices; i++) {
487  control1 += dataForAsymmCls[j * slices + i];
488  }
489  }
490 
491  int i = slice;
492  double sum = 0;
493  int counter = 0;
494  for (int j = 0; j < distributionFewStrips; j++) {
495  counter++;
496  sum += sliceVsFewStripsDistribution[i][j];
497  if (counter % 4 == 0) {
498  _DetClsAsymmetric.push_back(sum);
499  }
500  }
501  return _DetClsAsymmetric;
502 }
503 
504 const std::vector<double>& RPCSimSetUp::getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls) {
505  LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getAsymmetryForCls" << std::endl;
506 
507  map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(id);
508  if (iter == _mapDetClsMap.end()) {
509  throw cms::Exception("DataCorrupt")
510  << "Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" << id << std::endl;
511  }
512  if ((iter->second).size() != 120) {
513  throw cms::Exception("DataCorrupt")
514  << "Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" << id
515  << '\t' << (iter->second).size() << std::endl;
516  }
517 
518  std::vector<double> dataForAsymmCls = iter->second;
519 
520  if (slice > 4) {
521  throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
522  }
523 
524  _DetAsymmetryForCls.clear();
525 
526  vector<double> clsFewStripsDistribution;
527  vector<double> clsDistribution;
528  vector<double> clsAccumulativeDistribution;
529  vector<double> clsDetAsymmetryForCls;
530  clsDetAsymmetryForCls.clear();
531 
532  std::map<int, std::vector<double> > mapSliceVsDistribution;
533 
534  const int slices = 5;
535  const int distributionFewStrips = 24;
536 
537  double sliceVsFewStripsDistribution[slices][distributionFewStrips];
538 
539  for (int j = 0; j < distributionFewStrips; j++) {
540  for (int i = 0; i < slices; i++) {
541  sliceVsFewStripsDistribution[i][j] = dataForAsymmCls[j * slices + i];
542  }
543  }
544 
545  int vector_lenght;
546  switch (cls) {
547  case 1:
548  case 3:
549  case 5:
550  vector_lenght = 3;
551  break;
552  case 2:
553  case 4:
554  vector_lenght = 4;
555  break;
556  case 6:
557  default:
558  vector_lenght = 1;
559  break;
560  }
561 
562  float sum = 0;
563  float value;
564  for (int i = 0; i < vector_lenght; i++) {
565  value = sliceVsFewStripsDistribution[slice][(cls - 1) * 4 + i];
566  clsDetAsymmetryForCls.push_back(value);
567  sum += value;
568  // LogDebug ("RPCSimSetup")<<"value\t"<<value<<std::endl;
569  // LogDebug ("RPCSimSetup")<<"sum\t"<<sum<<std::endl;
570  }
571 
572  float accum = 0;
573  for (int i = clsDetAsymmetryForCls.size() - 1; i > -1; i--) {
574  accum += clsDetAsymmetryForCls[i];
575  _DetAsymmetryForCls.push_back(accum / sum);
576  }
577  return _DetAsymmetryForCls;
578 }
579 
RPCSimSetUp::getTime
float getTime(uint32_t id)
Definition: RPCSimSetUp.cc:403
RPCRoll
Definition: RPCRoll.h:12
counter
Definition: counter.py:1
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
RPCSimSetUp::getAsymmetricClsDistribution
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
Definition: RPCSimSetUp.cc:440
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
EDProducer.h
ESHandle.h
RandomNumberGenerator.h
CrossingFrame.h
RPCSimSetUp::RPCSimSetUp
RPCSimSetUp(const edm::ParameterSet &ps)
Definition: RPCSimSetUp.cc:37
RPCDetId
Definition: RPCDetId.h:16
PSimHitContainer.h
RPCSimSetUp::getNoise
const std::vector< float > & getNoise(uint32_t id)
Definition: RPCSimSetUp.cc:370
RPCDigiProducer.h
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
std::size
constexpr auto size(const C &c) -> decltype(c.size())
Definition: cuda_cxx17.h:13
MixCollection.h
Service.h
RPCSimSetUp::~RPCSimSetUp
virtual ~RPCSimSetUp()
Definition: RPCSimSetUp.cc:580
IdealMagneticFieldRecord.h
RPCSimSetUp::getCls
const std::vector< double > & getCls(uint32_t id)
Definition: RPCSimSetUp.cc:421
RPCSimSetUp::getEff
const std::vector< float > & getEff(uint32_t id)
Definition: RPCSimSetUp.cc:380
RPCSimSetUp::getClsMap
const std::map< int, std::vector< double > > & getClsMap()
Definition: RPCSimSetUp.cc:413
RPCSimSetUp::getAsymmetryForCls
const std::vector< double > & getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls)
Definition: RPCSimSetUp.cc:504
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDetId.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
RPCRoll::nstrips
int nstrips() const
Definition: RPCRoll.cc:24
value
Definition: value.py:1
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
RPCDigitizer.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Exception
Definition: hltDiff.cc:246
EventSetup.h
RPCSimSetUp.h
ParameterSet.h
RPCSimSetUp::setRPCSetUp
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)
Definition: RPCSimSetUp.cc:44
MuonGeometryRecord.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
mergeAndRegister.slice
slice
Definition: mergeAndRegister.py:121