36 _mapDetIdNoise.clear();
45 std::vector<double> sum_clsize;
47 for (
unsigned int n = 0;
n < vcls.size(); ++
n) {
48 sum_clsize.push_back(vcls[
n]);
51 _clsMap[row] = sum_clsize;
60 std::vector<float> veff, vvnoise;
64 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
67 _mapDetIdNoise[
temp] = vvnoise;
68 _mapDetIdEff[
temp] = veff;
69 _bxmap[
RPCDetId(it->dpid)] = it->time;
73 vvnoise.push_back((it->noise));
74 veff.push_back((it->eff));
76 vvnoise.push_back((it->noise));
77 veff.push_back((it->eff));
78 _bxmap[
RPCDetId(it->dpid)] = it->time;
80 }
else if (
n == vnoise.size() - 1) {
82 vvnoise.push_back((it->noise));
83 veff.push_back((it->eff));
84 _mapDetIdNoise[
temp] = vvnoise;
85 _mapDetIdEff[
temp] = veff;
88 vvnoise.push_back((it->noise));
89 veff.push_back((it->eff));
96 const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize) {
97 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)" << std::endl;
99 uint32_t detId = 0, current_detId, this_detId;
100 RPCDetId rpcId, current_rpcId, this_rpcId;
101 const RPCRoll* current_roll =
nullptr;
102 const RPCRoll* this_roll =
nullptr;
103 unsigned int current_nStrips;
105 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin" << std::endl;
106 std::stringstream sslogclsitem;
108 std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
110 std::vector<double> clsVect;
112 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
113 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
114 clsVect.push_back(((
double)(itCls->clusterSize)));
115 sslogclsitem <<
"Filling cls in _mapDetCls[detId,clsVect] :: detId = " << detId;
116 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted?";
117 sslogclsitem <<
" New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
118 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
119 sslogclsitem << std::endl;
122 if ((!(clsCounter % 120)) && (clsCounter != 0)) {
124 _mapDetClsMap[detId] = clsVect;
125 std::stringstream LogDebugClsVectString;
126 LogDebugClsVectString <<
"[";
127 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
128 LogDebugClsVectString << *itClsVect <<
",";
130 LogDebugClsVectString <<
"]";
131 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
132 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " <<
RPCDetId(detId) <<
" = "
133 << detId <<
" clsVec = " << LogDebugClsVectStr;
135 sslogclsitem <<
" --> New Method ";
136 sslogclsitem <<
" --> saved in map " << std::endl;
137 sslogclsitem <<
"Filling cls in _mapDetClsMap[detId,clsVect] :: detId = " << detId;
138 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? "
139 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
143 sslogclsitem <<
" --> not saved in map " << std::endl;
148 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
149 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
150 clsVect.push_back(((
double)(itCls->clusterSize)));
151 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
152 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted?";
153 sslogclsitem <<
" New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
154 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
155 sslogclsitem << std::endl;
158 if ((!(clsCounter % 100)) && (clsCounter != 0)) {
160 _mapDetClsMapLegacy[detId] = clsVect;
161 std::stringstream LogDebugClsVectString;
162 LogDebugClsVectString <<
"[";
163 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
164 LogDebugClsVectString << *itClsVect <<
",";
166 LogDebugClsVectString <<
"]";
167 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
168 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " <<
RPCDetId(detId)
169 <<
" = " << detId <<
" clsVec = " << LogDebugClsVectStr;
171 sslogclsitem <<
" --> Old Method ";
172 sslogclsitem <<
" --> saved in map " << std::endl;
173 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
174 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? "
175 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
179 sslogclsitem <<
" --> not saved in map " << std::endl;
185 sslogclsitem.clear();
186 LogDebug(
"RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
187 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
189 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
190 std::stringstream sslognoiseitem;
192 unsigned int count_strips = 1;
193 unsigned int count_all = 1;
194 std::vector<float> vveff, vvnoise;
199 bool quitLoop =
false;
202 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
205 current_detId = it->dpid;
206 current_rpcId =
RPCDetId(current_detId);
208 const RPCRoll* roll = theGeometry->roll(current_rpcId);
209 if (roll ==
nullptr) {
210 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
211 sslognoiseitem <<
" aka " << current_rpcId <<
" is not in current Geometry --> Skip " << std::endl;
214 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
215 sslognoiseitem <<
" aka " << current_rpcId
216 <<
" is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop"
218 current_roll = theGeometry->roll(current_rpcId);
219 current_nStrips = current_roll->
nstrips();
224 sslognoiseitem <<
"Start Position :: current_detId = " << current_detId <<
" aka " << current_rpcId;
225 sslognoiseitem <<
" is a valid roll with pointer " << current_roll <<
" and has "
226 << (current_roll ? current_roll->
nstrips() : 0) <<
" strips" << std::endl;
227 sslognoiseitem <<
" -------------------------------------------------------------------------------------------------"
228 "------------------------------------ "
230 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
232 this_detId = it->dpid;
235 const RPCRoll* roll = theGeometry->roll(this_rpcId);
236 if (roll ==
nullptr) {
237 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
238 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId
239 <<
" which is not in current Geometry --> Skip " << std::endl;
245 if (this_detId == current_detId && count_strips == 1) {
246 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
247 sslognoiseitem << this_detId <<
" = " << this_rpcId <<
" with " << roll->
nstrips() <<
" strips" << std::endl;
249 _bxmap[current_detId] = it->time;
250 sslognoiseitem <<
"[NoiseItem :: n = " << count_all
251 <<
"] Filling time in _bxmap[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" time = " << it->time
257 vvnoise.push_back((it->noise));
258 vveff.push_back((it->eff));
259 sslognoiseitem <<
"First Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
260 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
261 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
268 else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
269 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
270 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
271 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
272 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
274 vvnoise.push_back((it->noise));
275 vveff.push_back((it->eff));
283 else if (this_detId == current_detId && count_strips == current_nStrips) {
284 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
286 sslognoiseitem <<
"Last Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
287 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
288 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
289 vvnoise.push_back((it->noise));
290 vveff.push_back((it->eff));
295 sslognoiseitem <<
" fill vectors into map" << std::endl;
296 _mapDetIdNoise[current_detId] = vvnoise;
297 _mapDetIdEff[current_detId] = vveff;
299 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
300 LogDebugNoiVectString <<
"[";
301 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
302 LogDebugNoiVectString << (*itNoiVect) <<
",";
304 LogDebugNoiVectString <<
"]";
305 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
306 LogDebugEffVectString <<
"[";
307 for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
308 LogDebugEffVectString << (*itEffVect) <<
",";
310 LogDebugEffVectString <<
"]";
311 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
312 LogDebug(
"RPCSimSetup") <<
"Filling vvnoise in _mapDetIdNoise[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = "
313 << (
RPCDetId(it->dpid)).rawId() <<
" vvnoise = " << LogDebugNoiVectStr;
314 LogDebug(
"RPCSimSetup") <<
"Filling veff in _mapDetIdEff[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = "
315 << (
RPCDetId(it->dpid)).rawId() <<
" veff = " << LogDebugEffVectStr;
320 bool next_detId_found =
false;
321 sslognoiseitem <<
"look for next different detId" << std::endl;
322 while (next_detId_found == 0 && it != vnoise.end() - 1) {
324 this_detId = it->dpid;
326 this_roll = theGeometry->roll(this_rpcId);
329 sslognoiseitem <<
"Inside While:: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
330 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId <<
" Noise = " << it->noise
331 <<
" Hz/cm2" << std::endl;
334 if (this_detId != current_detId) {
335 sslognoiseitem <<
"Different detId is found :: " << this_detId <<
" aka " << this_rpcId
336 <<
" Noise = " << it->noise <<
" Hz/cm2";
339 current_detId = this_detId;
340 current_rpcId =
RPCDetId(current_detId);
341 next_detId_found =
true;
342 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
343 sslognoiseitem <<
" with " << current_nStrips <<
" strips" << std::endl;
361 sslognoiseitem.clear();
362 LogDebug(
"RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
363 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
365 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: end" << std::endl;
369 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(
id);
370 if (iter == _mapDetIdNoise.end()) {
371 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no noise information for DetId\t" <<
id
374 LogDebug(
"RPCSimSetupChecks") <<
"All OK from RPCSimSetUp - noise information for DetId\t" <<
id << std::endl;
379 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(
id);
380 if (iter == _mapDetIdEff.end()) {
381 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no efficiency information for DetId\t" <<
id
386 const RPCRoll* roll = theGeometry->roll(rpcId);
387 unsigned int numbStrips = roll->
nstrips();
389 if ((iter->second).size() < numbStrips) {
390 LogDebug(
"RPCSimSetup") <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id
391 <<
" aka " <<
RPCDetId(
id) << std::endl;
392 LogDebug(
"RPCSimSetup") <<
" number of strips in Conditions\t" << (iter->second).
size()
393 <<
" number of strips in Geometry\t" << numbStrips << std::endl;
395 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id << std::endl;
403 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
404 if (iter == _bxmap.end()) {
405 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t"
406 << rpcid.
rawId() << std::endl;
412 if (_clsMap.size() != 5) {
413 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
421 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getCls" << std::endl;
423 map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(
id);
424 if (iter == _mapDetClsMapLegacy.end()) {
425 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no cluster size information for DetId\t" <<
id
428 if ((iter->second).size() != 100) {
430 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"
434 <<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" <<
id << std::endl;
439 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
441 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
442 if (iter == _mapDetClsMap.end()) {
444 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
446 if ((iter->second).size() != 120) {
448 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
453 std::vector<double> dataForAsymmCls = iter->second;
455 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
458 _DetClsAsymmetric.clear();
460 vector<double> clsFewStripsDistribution;
461 vector<double> clsDistribution;
462 vector<double> clsAccumulativeDistribution;
464 std::map<int, std::vector<double> > mapSliceVsDistribution;
466 const int slices = 5;
467 const int distributionFewStrips = 24;
469 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
471 for (
int j = 0;
j < distributionFewStrips;
j++) {
472 for (
int i = 0;
i < slices;
i++) {
473 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
478 for (
int j = 0;
j < distributionFewStrips;
j++) {
479 control += sliceVsFewStripsDistribution[0][
j];
483 for (
int j = 0;
j < distributionFewStrips;
j++) {
484 for (
int i = 0;
i < slices;
i++) {
485 control1 += dataForAsymmCls[
j * slices +
i];
492 for (
int j = 0;
j < distributionFewStrips;
j++) {
494 sum += sliceVsFewStripsDistribution[
i][
j];
496 _DetClsAsymmetric.push_back(sum);
499 return _DetClsAsymmetric;
503 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetryForCls" << std::endl;
505 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
506 if (iter == _mapDetClsMap.end()) {
508 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
510 if ((iter->second).size() != 120) {
512 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
513 <<
'\t' << (iter->second).
size() << std::endl;
516 std::vector<double> dataForAsymmCls = iter->second;
519 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
522 _DetAsymmetryForCls.clear();
524 vector<double> clsFewStripsDistribution;
525 vector<double> clsDistribution;
526 vector<double> clsAccumulativeDistribution;
527 vector<double> clsDetAsymmetryForCls;
528 clsDetAsymmetryForCls.clear();
530 std::map<int, std::vector<double> > mapSliceVsDistribution;
532 const int slices = 5;
533 const int distributionFewStrips = 24;
535 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
537 for (
int j = 0;
j < distributionFewStrips;
j++) {
538 for (
int i = 0;
i < slices;
i++) {
539 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
562 for (
int i = 0;
i < vector_lenght;
i++) {
563 value = sliceVsFewStripsDistribution[
slice][(cls - 1) * 4 +
i];
564 clsDetAsymmetryForCls.push_back(
value);
571 for (
int i = clsDetAsymmetryForCls.size() - 1;
i > -1;
i--) {
572 accum += clsDetAsymmetryForCls[
i];
573 _DetAsymmetryForCls.push_back(accum / sum);
575 return _DetAsymmetryForCls;