35 _mapDetIdNoise.clear();
44 std::vector<double> sum_clsize;
46 for (
unsigned int n = 0;
n < vcls.size(); ++
n) {
47 sum_clsize.push_back(vcls[
n]);
50 _clsMap[row] = sum_clsize;
59 std::vector<float> veff, vvnoise;
63 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
66 _mapDetIdNoise[
temp] = vvnoise;
67 _mapDetIdEff[
temp] = veff;
68 _bxmap[
RPCDetId(it->dpid)] = it->time;
72 vvnoise.push_back((it->noise));
73 veff.push_back((it->eff));
75 vvnoise.push_back((it->noise));
76 veff.push_back((it->eff));
77 _bxmap[
RPCDetId(it->dpid)] = it->time;
79 }
else if (
n == vnoise.size() - 1) {
81 vvnoise.push_back((it->noise));
82 veff.push_back((it->eff));
83 _mapDetIdNoise[
temp] = vvnoise;
84 _mapDetIdEff[
temp] = veff;
87 vvnoise.push_back((it->noise));
88 veff.push_back((it->eff));
95 const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize) {
96 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)" << std::endl;
98 uint32_t detId = 0, current_detId, this_detId;
99 RPCDetId rpcId, current_rpcId, this_rpcId;
100 const RPCRoll* current_roll =
nullptr;
101 const RPCRoll* this_roll =
nullptr;
102 unsigned int current_nStrips;
104 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin" << std::endl;
106 std::stringstream sslogclsitem;
109 std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
111 std::vector<double> clsVect;
113 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
114 clsVect.push_back(((
double)(itCls->clusterSize)));
116 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
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));
120 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
121 sslogclsitem << std::endl;
124 if ((!(clsCounter % 120)) && (clsCounter != 0)) {
126 _mapDetClsMap[detId] = clsVect;
128 std::stringstream LogDebugClsVectString;
129 LogDebugClsVectString <<
"[";
130 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
131 LogDebugClsVectString << *itClsVect <<
",";
133 LogDebugClsVectString <<
"]";
134 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
135 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " <<
RPCDetId(detId) <<
" = " 136 << detId <<
" clsVec = " << LogDebugClsVectStr;
138 sslogclsitem <<
" --> New Method ";
139 sslogclsitem <<
" --> saved in map " << std::endl;
140 sslogclsitem <<
"Filling cls in _mapDetClsMap[detId,clsVect] :: detId = " << detId;
141 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? " 142 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
148 sslogclsitem <<
" --> not saved in map " << std::endl;
154 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
155 clsVect.push_back(((
double)(itCls->clusterSize)));
157 sslogclsitem <<
" Push back clustersize = " << itCls->clusterSize << std::endl;
158 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
159 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted?";
160 sslogclsitem <<
" New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
161 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
162 sslogclsitem << std::endl;
165 if ((!(clsCounter % 100)) && (clsCounter != 0)) {
167 _mapDetClsMapLegacy[detId] = clsVect;
169 std::stringstream LogDebugClsVectString;
170 LogDebugClsVectString <<
"[";
171 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
172 LogDebugClsVectString << *itClsVect <<
",";
174 LogDebugClsVectString <<
"]";
175 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
176 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " <<
RPCDetId(detId)
177 <<
" = " << detId <<
" clsVec = " << LogDebugClsVectStr;
179 sslogclsitem <<
" --> Old Method ";
180 sslogclsitem <<
" --> saved in map " << std::endl;
181 sslogclsitem <<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
182 sslogclsitem <<
" --> will it be accepted? clsCounter = " << clsCounter <<
" accepted? " 183 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
189 sslogclsitem <<
" --> not saved in map " << std::endl;
197 sslogclsitem.clear();
198 LogDebug(
"RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
199 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
201 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
202 std::stringstream sslognoiseitem;
205 unsigned int count_strips = 1;
206 unsigned int count_all = 1;
207 std::vector<float> vveff, vvnoise;
212 bool quitLoop =
false;
215 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
218 current_detId = it->dpid;
219 current_rpcId =
RPCDetId(current_detId);
221 const RPCRoll* roll = theGeometry->roll(current_rpcId);
222 if (roll ==
nullptr) {
224 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
225 sslognoiseitem <<
" aka " << current_rpcId <<
" is not in current Geometry --> Skip " << std::endl;
230 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
231 sslognoiseitem <<
" aka " << current_rpcId
232 <<
" is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop" 235 current_roll = theGeometry->roll(current_rpcId);
236 current_nStrips = current_roll->
nstrips();
242 sslognoiseitem <<
"Start Position :: current_detId = " << current_detId <<
" aka " << current_rpcId;
243 sslognoiseitem <<
" is a valid roll with pointer " << current_roll <<
" and has " 244 << (current_roll ? current_roll->
nstrips() : 0) <<
" strips" << std::endl;
245 sslognoiseitem <<
" -------------------------------------------------------------------------------------------------" 246 "------------------------------------ " 249 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
251 this_detId = it->dpid;
254 const RPCRoll* roll = theGeometry->roll(this_rpcId);
255 if (roll ==
nullptr) {
257 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
258 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId
259 <<
" which is not in current Geometry --> Skip " << std::endl;
266 if (this_detId == current_detId && count_strips == 1) {
268 _bxmap[current_detId] = it->time;
273 vvnoise.push_back((it->noise));
274 vveff.push_back((it->eff));
276 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
277 sslognoiseitem << this_detId <<
" = " << this_rpcId <<
" with " << roll->
nstrips() <<
" strips" << std::endl;
278 sslognoiseitem <<
"[NoiseItem :: n = " << count_all
279 <<
"] Filling time in _bxmap[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" time = " << it->time
281 sslognoiseitem <<
"First Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
282 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
283 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
291 else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
293 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
294 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
295 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
296 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
299 vvnoise.push_back((it->noise));
300 vveff.push_back((it->eff));
308 else if (this_detId == current_detId && count_strips == current_nStrips) {
310 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
311 sslognoiseitem <<
"Last Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
312 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
313 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " << it->noise <<
" Hz/cm2" << std::endl;
316 vvnoise.push_back((it->noise));
317 vveff.push_back((it->eff));
322 _mapDetIdNoise[current_detId] = vvnoise;
323 _mapDetIdEff[current_detId] = vveff;
326 sslognoiseitem <<
" fill vectors into map" << std::endl;
327 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
328 LogDebugNoiVectString <<
"[";
329 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
330 LogDebugNoiVectString << (*itNoiVect) <<
",";
332 LogDebugNoiVectString <<
"]";
333 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
334 LogDebugEffVectString <<
"[";
335 for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
336 LogDebugEffVectString << (*itEffVect) <<
",";
338 LogDebugEffVectString <<
"]";
339 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
340 LogDebug(
"RPCSimSetup") <<
"Filling vvnoise in _mapDetIdNoise[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = " 341 << (
RPCDetId(it->dpid)).rawId() <<
" vvnoise = " << LogDebugNoiVectStr;
342 LogDebug(
"RPCSimSetup") <<
"Filling veff in _mapDetIdEff[detId] :: detId = " <<
RPCDetId(it->dpid) <<
" = " 343 << (
RPCDetId(it->dpid)).rawId() <<
" veff = " << LogDebugEffVectStr;
348 bool next_detId_found =
false;
350 sslognoiseitem <<
"look for next different detId" << std::endl;
352 while (next_detId_found == 0 && it != vnoise.end() - 1) {
354 this_detId = it->dpid;
356 this_roll = theGeometry->roll(this_rpcId);
360 sslognoiseitem <<
"Inside While:: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
361 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId <<
" Noise = " << it->noise
362 <<
" Hz/cm2" << std::endl;
366 if (this_detId != current_detId) {
368 sslognoiseitem <<
"Different detId is found :: " << this_detId <<
" aka " << this_rpcId
369 <<
" Noise = " << it->noise <<
" Hz/cm2";
373 current_detId = this_detId;
374 current_rpcId =
RPCDetId(current_detId);
375 next_detId_found =
true;
376 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
378 sslognoiseitem <<
" with " << current_nStrips <<
" strips" << std::endl;
398 sslognoiseitem.clear();
399 LogDebug(
"RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
400 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
402 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: end" << std::endl;
407 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(
id);
408 if (iter == _mapDetIdNoise.end()) {
409 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no noise information for DetId\t" <<
id 412 LogDebug(
"RPCSimSetupChecks") <<
"All OK from RPCSimSetUp - noise information for DetId\t" <<
id << std::endl;
417 map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(
id);
418 if (iter == _mapDetIdEff.end()) {
419 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no efficiency information for DetId\t" <<
id 424 const RPCRoll* roll = theGeometry->roll(rpcId);
425 unsigned int numbStrips = roll->
nstrips();
427 if ((iter->second).size() < numbStrips) {
428 LogDebug(
"RPCSimSetup") <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id 429 <<
" aka " <<
RPCDetId(
id) << std::endl;
430 LogDebug(
"RPCSimSetup") <<
" number of strips in Conditions\t" << (iter->second).
size()
431 <<
" number of strips in Geometry\t" << numbStrips << std::endl;
433 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id << std::endl;
441 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
442 if (iter == _bxmap.end()) {
443 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t" 444 << rpcid.
rawId() << std::endl;
450 if (_clsMap.size() != 5) {
451 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
459 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getCls" << std::endl;
461 map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(
id);
462 if (iter == _mapDetClsMapLegacy.end()) {
463 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no cluster size information for DetId\t" <<
id 466 if ((iter->second).size() != 100) {
468 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t" 472 <<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" <<
id << std::endl;
477 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
479 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
480 if (iter == _mapDetClsMap.end()) {
482 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
484 if ((iter->second).size() != 120) {
486 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id 491 std::vector<double> dataForAsymmCls = iter->second;
493 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
496 _DetClsAsymmetric.clear();
498 vector<double> clsFewStripsDistribution;
499 vector<double> clsDistribution;
500 vector<double> clsAccumulativeDistribution;
502 std::map<int, std::vector<double> > mapSliceVsDistribution;
504 const int slices = 5;
505 const int distributionFewStrips = 24;
507 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
509 for (
int j = 0;
j < distributionFewStrips;
j++) {
510 for (
int i = 0;
i < slices;
i++) {
511 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
518 for (
int j = 0;
j < distributionFewStrips;
j++) {
520 sum += sliceVsFewStripsDistribution[
i][
j];
522 _DetClsAsymmetric.push_back(sum);
525 return _DetClsAsymmetric;
529 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetryForCls" << std::endl;
531 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
532 if (iter == _mapDetClsMap.end()) {
534 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
536 if ((iter->second).size() != 120) {
538 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id 539 <<
'\t' << (iter->second).
size() << std::endl;
542 std::vector<double> dataForAsymmCls = iter->second;
545 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
548 _DetAsymmetryForCls.clear();
550 vector<double> clsFewStripsDistribution;
551 vector<double> clsDistribution;
552 vector<double> clsAccumulativeDistribution;
553 vector<double> clsDetAsymmetryForCls;
554 clsDetAsymmetryForCls.clear();
556 std::map<int, std::vector<double> > mapSliceVsDistribution;
558 const int slices = 5;
559 const int distributionFewStrips = 24;
561 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
563 for (
int j = 0;
j < distributionFewStrips;
j++) {
564 for (
int i = 0;
i < slices;
i++) {
565 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
588 for (
int i = 0;
i < vector_lenght;
i++) {
589 value = sliceVsFewStripsDistribution[
slice][(cls - 1) * 4 +
i];
590 clsDetAsymmetryForCls.push_back(
value);
597 for (
int i = clsDetAsymmetryForCls.size() - 1;
i > -1;
i--) {
598 accum += clsDetAsymmetryForCls[
i];
599 _DetAsymmetryForCls.push_back(accum / sum);
601 return _DetAsymmetryForCls;
float getTime(uint32_t 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)
constexpr uint32_t rawId() const
get the raw id
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)