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]);
50 if (counter == row * 20) {
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;
107 std::stringstream sslogclsitem;
110 std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
112 std::vector<double> clsVect;
114 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
115 clsVect.push_back(((
double)(itCls->clusterSize)));
117 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
118 sslogclsitem <<
"Filling cls in _mapDetCls[detId,clsVect] :: detId = " << detId;
119 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted?";
120 sslogclsitem <<
" New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
121 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
122 sslogclsitem << std::endl;
125 if ((!(clsCounter % 120)) && (clsCounter != 0)) {
127 _mapDetClsMap[detId] = clsVect;
129 std::stringstream LogDebugClsVectString;
130 LogDebugClsVectString <<
"[";
131 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
132 LogDebugClsVectString << *itClsVect <<
",";
134 LogDebugClsVectString <<
"]";
135 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
136 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " <<
RPCDetId(detId) <<
" = "
137 << detId <<
" clsVec = " << LogDebugClsVectStr;
139 sslogclsitem <<
" --> New Method ";
140 sslogclsitem <<
" --> saved in map " << std::endl;
141 sslogclsitem <<
"Filling cls in _mapDetClsMap[detId,clsVect] :: detId = " << detId;
142 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? "
143 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
149 sslogclsitem <<
" --> not saved in map " << std::endl;
155 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
156 clsVect.push_back(((
double)(itCls->clusterSize)));
158 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
159 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
160 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted?";
161 sslogclsitem <<
" New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
162 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
163 sslogclsitem << std::endl;
166 if ((!(clsCounter % 100)) && (clsCounter != 0)) {
168 _mapDetClsMapLegacy[detId] = clsVect;
170 std::stringstream LogDebugClsVectString;
171 LogDebugClsVectString <<
"[";
172 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
173 LogDebugClsVectString << *itClsVect <<
",";
175 LogDebugClsVectString <<
"]";
176 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
177 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " <<
RPCDetId(detId)
178 <<
" = " << detId <<
" clsVec = " << LogDebugClsVectStr;
180 sslogclsitem <<
" --> Old Method ";
181 sslogclsitem <<
" --> saved in map " << std::endl;
182 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
183 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? "
184 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
190 sslogclsitem <<
" --> not saved in map " << std::endl;
198 sslogclsitem.clear();
199 LogDebug(
"RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
200 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
202 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
203 std::stringstream sslognoiseitem;
206 unsigned int count_strips = 1;
207 unsigned int count_all = 1;
208 std::vector<float> vveff, vvnoise;
213 bool quitLoop =
false;
216 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
219 current_detId = it->dpid;
220 current_rpcId =
RPCDetId(current_detId);
222 const RPCRoll* roll = theGeometry->roll(current_rpcId);
223 if (roll ==
nullptr) {
225 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
226 sslognoiseitem <<
" aka " << current_rpcId <<
" is not in current Geometry --> Skip " << std::endl;
231 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
232 sslognoiseitem <<
" aka " << current_rpcId
233 <<
" is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop"
236 current_roll = theGeometry->roll(current_rpcId);
237 current_nStrips = current_roll->
nstrips();
243 sslognoiseitem <<
"Start Position :: current_detId = " << current_detId <<
" aka " << current_rpcId;
244 sslognoiseitem <<
" is a valid roll with pointer " << current_roll <<
" and has "
245 << (current_roll ? current_roll->
nstrips() : 0) <<
" strips" << std::endl;
246 sslognoiseitem <<
" -------------------------------------------------------------------------------------------------"
247 "------------------------------------ "
250 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
252 this_detId = it->dpid;
255 const RPCRoll* roll = theGeometry->roll(this_rpcId);
256 if (roll ==
nullptr) {
258 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
259 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId
260 <<
" which is not in current Geometry --> Skip " << std::endl;
267 if (this_detId == current_detId && count_strips == 1) {
269 _bxmap[current_detId] = it->time;
274 vvnoise.push_back((it->noise));
275 vveff.push_back((it->eff));
277 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
278 sslognoiseitem << this_detId <<
" = " << this_rpcId <<
" with " << roll->
nstrips() <<
" strips" << std::endl;
279 sslognoiseitem <<
"[NoiseItem :: n = " << count_all
280 <<
"] Filling time in _bxmap[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" time = " << it->time
282 sslognoiseitem <<
"First Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
283 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
284 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
292 else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
294 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
295 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
296 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
297 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
300 vvnoise.push_back((it->noise));
301 vveff.push_back((it->eff));
309 else if (this_detId == current_detId && count_strips == current_nStrips) {
311 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
312 sslognoiseitem <<
"Last Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
313 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
314 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
317 vvnoise.push_back((it->noise));
318 vveff.push_back((it->eff));
323 _mapDetIdNoise[current_detId] = vvnoise;
324 _mapDetIdEff[current_detId] = vveff;
327 sslognoiseitem <<
" fill vectors into map" << std::endl;
328 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
329 LogDebugNoiVectString <<
"[";
330 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
331 LogDebugNoiVectString << (*itNoiVect) <<
",";
333 LogDebugNoiVectString <<
"]";
334 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
335 LogDebugEffVectString <<
"[";
336 for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
337 LogDebugEffVectString << (*itEffVect) <<
",";
339 LogDebugEffVectString <<
"]";
340 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
341 LogDebug(
"RPCSimSetup") <<
"Filling vvnoise in _mapDetIdNoise[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = "
342 << (
RPCDetId(it->dpid)).rawId() <<
" vvnoise = " << LogDebugNoiVectStr;
343 LogDebug(
"RPCSimSetup") <<
"Filling veff in _mapDetIdEff[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = "
344 << (
RPCDetId(it->dpid)).rawId() <<
" veff = " << LogDebugEffVectStr;
349 bool next_detId_found =
false;
351 sslognoiseitem <<
"look for next different detId" << std::endl;
353 while (next_detId_found == 0 && it != vnoise.end() - 1) {
355 this_detId = it->dpid;
357 this_roll = theGeometry->roll(this_rpcId);
361 sslognoiseitem <<
"Inside While:: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
362 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId <<
" Noise = " << it->noise
363 <<
" Hz/cm2" << std::endl;
367 if (this_detId != current_detId) {
369 sslognoiseitem <<
"Different detId is found :: " << this_detId <<
" aka " << this_rpcId
370 <<
" Noise = " << it->noise <<
" Hz/cm2";
374 current_detId = this_detId;
375 current_rpcId =
RPCDetId(current_detId);
376 next_detId_found =
true;
377 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
379 sslognoiseitem <<
" with " << current_nStrips <<
" strips" << std::endl;
399 sslognoiseitem.clear();
400 LogDebug(
"RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
401 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
403 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: end" << std::endl;
408 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(
id);
409 if (iter == _mapDetIdNoise.end()) {
410 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no noise information for DetId\t" <<
id
413 LogDebug(
"RPCSimSetupChecks") <<
"All OK from RPCSimSetUp - noise information for DetId\t" <<
id << std::endl;
418 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(
id);
419 if (iter == _mapDetIdEff.end()) {
420 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no efficiency information for DetId\t" <<
id
425 const RPCRoll* roll = theGeometry->roll(rpcId);
426 unsigned int numbStrips = roll->
nstrips();
428 if ((iter->second).size() < numbStrips) {
429 LogDebug(
"RPCSimSetup") <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id
430 <<
" aka " <<
RPCDetId(
id) << std::endl;
431 LogDebug(
"RPCSimSetup") <<
" number of strips in Conditions\t" << (iter->second).
size()
432 <<
" number of strips in Geometry\t" << numbStrips << std::endl;
434 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id << std::endl;
442 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
443 if (iter == _bxmap.end()) {
444 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t"
445 << rpcid.
rawId() << std::endl;
451 if (_clsMap.size() != 5) {
452 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
460 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getCls" << std::endl;
462 map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(
id);
463 if (iter == _mapDetClsMapLegacy.end()) {
464 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no cluster size information for DetId\t" <<
id
467 if ((iter->second).size() != 100) {
469 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"
473 <<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" <<
id << std::endl;
478 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
480 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
481 if (iter == _mapDetClsMap.end()) {
483 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
485 if ((iter->second).size() != 120) {
487 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
492 std::vector<double> dataForAsymmCls = iter->second;
494 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
497 _DetClsAsymmetric.clear();
499 vector<double> clsFewStripsDistribution;
500 vector<double> clsDistribution;
501 vector<double> clsAccumulativeDistribution;
503 std::map<int, std::vector<double> > mapSliceVsDistribution;
505 const int slices = 5;
506 const int distributionFewStrips = 24;
508 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
510 for (
int j = 0;
j < distributionFewStrips;
j++) {
511 for (
int i = 0;
i < slices;
i++) {
512 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
517 for (
int j = 0;
j < distributionFewStrips;
j++) {
518 control += sliceVsFewStripsDistribution[0][
j];
522 for (
int j = 0;
j < distributionFewStrips;
j++) {
523 for (
int i = 0;
i < slices;
i++) {
524 control1 += dataForAsymmCls[
j * slices +
i];
531 for (
int j = 0;
j < distributionFewStrips;
j++) {
533 sum += sliceVsFewStripsDistribution[
i][
j];
534 if (counter % 4 == 0) {
535 _DetClsAsymmetric.push_back(sum);
538 return _DetClsAsymmetric;
542 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetryForCls" << std::endl;
544 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
545 if (iter == _mapDetClsMap.end()) {
547 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
549 if ((iter->second).size() != 120) {
551 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
552 <<
'\t' << (iter->second).
size() << std::endl;
555 std::vector<double> dataForAsymmCls = iter->second;
558 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
561 _DetAsymmetryForCls.clear();
563 vector<double> clsFewStripsDistribution;
564 vector<double> clsDistribution;
565 vector<double> clsAccumulativeDistribution;
566 vector<double> clsDetAsymmetryForCls;
567 clsDetAsymmetryForCls.clear();
569 std::map<int, std::vector<double> > mapSliceVsDistribution;
571 const int slices = 5;
572 const int distributionFewStrips = 24;
574 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
576 for (
int j = 0;
j < distributionFewStrips;
j++) {
577 for (
int i = 0;
i < slices;
i++) {
578 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
601 for (
int i = 0;
i < vector_lenght;
i++) {
602 value = sliceVsFewStripsDistribution[slice][(cls - 1) * 4 +
i];
603 clsDetAsymmetryForCls.push_back(value);
610 for (
int i = clsDetAsymmetryForCls.size() - 1;
i > -1;
i--) {
611 accum += clsDetAsymmetryForCls[
i];
612 _DetAsymmetryForCls.push_back(accum / sum);
614 return _DetAsymmetryForCls;
float getTime(uint32_t id)
constexpr uint32_t rawId() const
get the raw id
RPCSimSetUp(const edm::ParameterSet &ps)
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
const std::vector< float > & getEff(uint32_t id)
const std::vector< float > & getNoise(uint32_t id)
const std::vector< double > & getCls(uint32_t id)
const std::map< int, std::vector< double > > & getClsMap()
const std::vector< double > & getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls)
static std::atomic< unsigned int > counter
tuple size
Write out results.
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)