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;
72 vvnoise.push_back((
it->noise));
73 veff.push_back((
it->eff));
75 vvnoise.push_back((
it->noise));
76 veff.push_back((
it->eff));
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;
207 unsigned int count_all = 1;
209 std::vector<float> vveff, vvnoise;
214 bool quitLoop =
false;
217 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator
it = vnoise.begin();
it != vnoise.end() && !quitLoop;
220 current_detId =
it->dpid;
221 current_rpcId =
RPCDetId(current_detId);
223 const RPCRoll*
roll = theGeometry->roll(current_rpcId);
224 if (
roll ==
nullptr) {
226 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
227 sslognoiseitem <<
" aka " << current_rpcId <<
" is not in current Geometry --> Skip " << std::endl;
232 sslognoiseitem <<
"Searching for first valid detid :: current_detId = " << current_detId;
233 sslognoiseitem <<
" aka " << current_rpcId
234 <<
" is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop" 237 current_roll = theGeometry->roll(current_rpcId);
238 current_nStrips = current_roll->
nstrips();
244 sslognoiseitem <<
"Start Position :: current_detId = " << current_detId <<
" aka " << current_rpcId;
245 sslognoiseitem <<
" is a valid roll with pointer " << current_roll <<
" and has " 246 << (current_roll ? current_roll->
nstrips() : 0) <<
" strips" << std::endl;
247 sslognoiseitem <<
" -------------------------------------------------------------------------------------------------" 248 "------------------------------------ " 251 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator
it = vnoise.begin();
it != vnoise.end(); ++
it) {
253 this_detId =
it->dpid;
256 const RPCRoll*
roll = theGeometry->roll(this_rpcId);
257 if (
roll ==
nullptr) {
259 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
260 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId
261 <<
" which is not in current Geometry --> Skip " << std::endl;
268 if (this_detId == current_detId && count_strips == 1) {
270 _bxmap[current_detId] =
it->time;
275 vvnoise.push_back((
it->noise));
276 vveff.push_back((
it->eff));
278 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
279 sslognoiseitem << this_detId <<
" = " << this_rpcId <<
" with " <<
roll->nstrips() <<
" strips" << std::endl;
280 sslognoiseitem <<
"[NoiseItem :: n = " << count_all
281 <<
"] Filling time in _bxmap[detId] :: detId = " <<
RPCDetId(
it->dpid) <<
" time = " <<
it->time
283 sslognoiseitem <<
"First Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
284 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
285 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " <<
it->noise <<
" Hz/cm2" << std::endl;
294 else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
296 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
297 sslognoiseitem <<
"Inside Loop :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
298 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
299 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " <<
it->noise <<
" Hz/cm2" << std::endl;
304 vvnoise.push_back((
it->noise));
305 vveff.push_back((
it->eff));
312 else if (this_detId == current_detId && count_strips == current_nStrips) {
314 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
315 sslognoiseitem <<
"Last Value :: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
316 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId;
317 sslognoiseitem <<
" Strip " << std::setw(3) << count_strips <<
" Noise = " <<
it->noise <<
" Hz/cm2" << std::endl;
322 vvnoise.push_back((
it->noise));
323 vveff.push_back((
it->eff));
327 _mapDetIdNoise[current_detId] = vvnoise;
328 _mapDetIdEff[current_detId] = vveff;
331 sslognoiseitem <<
" fill vectors into map" << std::endl;
332 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
333 LogDebugNoiVectString <<
"[";
334 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
335 LogDebugNoiVectString << (*itNoiVect) <<
",";
337 LogDebugNoiVectString <<
"]";
338 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
339 LogDebugEffVectString <<
"[";
340 for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
341 LogDebugEffVectString << (*itEffVect) <<
",";
343 LogDebugEffVectString <<
"]";
344 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
345 LogDebug(
"RPCSimSetup") <<
"Filling vvnoise in _mapDetIdNoise[detId] :: detId = " <<
RPCDetId(
it->dpid) <<
" = " 346 << (
RPCDetId(
it->dpid)).
rawId() <<
" vvnoise = " << LogDebugNoiVectStr;
347 LogDebug(
"RPCSimSetup") <<
"Filling veff in _mapDetIdEff[detId] :: detId = " <<
RPCDetId(
it->dpid) <<
" = " 353 bool next_detId_found =
false;
355 sslognoiseitem <<
"look for next different detId" << std::endl;
357 while (next_detId_found == 0 &&
it != vnoise.end() - 1) {
359 this_detId =
it->dpid;
361 this_roll = theGeometry->roll(this_rpcId);
365 sslognoiseitem <<
"Inside While:: [" << std::setw(6) << count_all <<
"][" << std::setw(3) << count_strips
366 <<
"] :: this_detId = " << this_detId <<
" aka " << this_rpcId <<
" Noise = " <<
it->noise
367 <<
" Hz/cm2" << std::endl;
371 if (this_detId != current_detId) {
373 sslognoiseitem <<
"Different detId is found :: " << this_detId <<
" aka " << this_rpcId
374 <<
" Noise = " <<
it->noise <<
" Hz/cm2";
378 current_detId = this_detId;
379 current_rpcId =
RPCDetId(current_detId);
380 next_detId_found =
true;
381 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
383 sslognoiseitem <<
" with " << current_nStrips <<
" strips" << std::endl;
403 sslognoiseitem.clear();
404 LogDebug(
"RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
405 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
407 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: end" << std::endl;
412 std::map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(
id);
413 if (iter == _mapDetIdNoise.end()) {
414 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no noise information for DetId\t" <<
id 417 LogDebug(
"RPCSimSetupChecks") <<
"All OK from RPCSimSetUp - noise information for DetId\t" <<
id << std::endl;
422 std::map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(
id);
423 if (iter == _mapDetIdEff.end()) {
424 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no efficiency information for DetId\t" <<
id 430 unsigned int numbStrips =
roll->nstrips();
432 if ((iter->second).size() < numbStrips) {
433 LogDebug(
"RPCSimSetup") <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id 434 <<
" aka " <<
RPCDetId(
id) << std::endl;
435 LogDebug(
"RPCSimSetup") <<
" number of strips in Conditions\t" << (iter->second).size()
436 <<
" number of strips in Geometry\t" << numbStrips << std::endl;
438 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id << std::endl;
446 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
447 if (iter == _bxmap.end()) {
448 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t" 449 << rpcid.
rawId() << std::endl;
455 if (_clsMap.size() != 5) {
456 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
464 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getCls" << std::endl;
466 std::map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(
id);
467 if (iter == _mapDetClsMapLegacy.end()) {
468 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - no cluster size information for DetId\t" <<
id 471 if ((iter->second).size() != 100) {
473 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t" 477 <<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" <<
id << std::endl;
482 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
484 std::map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
485 if (iter == _mapDetClsMap.end()) {
487 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
489 if ((iter->second).size() != 120) {
491 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id 496 std::vector<double> dataForAsymmCls = iter->second;
498 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
501 _DetClsAsymmetric.clear();
503 std::vector<double> clsFewStripsDistribution;
504 std::vector<double> clsDistribution;
505 std::vector<double> clsAccumulativeDistribution;
507 std::map<int, std::vector<double> > mapSliceVsDistribution;
509 const int slices = 5;
510 const int distributionFewStrips = 24;
512 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
514 for (
int j = 0;
j < distributionFewStrips;
j++) {
515 for (
int i = 0;
i < slices;
i++) {
516 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
523 for (
int j = 0;
j < distributionFewStrips;
j++) {
525 sum += sliceVsFewStripsDistribution[
i][
j];
527 _DetClsAsymmetric.push_back(sum);
530 return _DetClsAsymmetric;
534 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetryForCls" << std::endl;
536 std::map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
537 if (iter == _mapDetClsMap.end()) {
539 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
541 if ((iter->second).size() != 120) {
543 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id 544 <<
'\t' << (iter->second).size() << std::endl;
547 std::vector<double> dataForAsymmCls = iter->second;
550 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
553 _DetAsymmetryForCls.clear();
555 std::vector<double> clsFewStripsDistribution;
556 std::vector<double> clsDistribution;
557 std::vector<double> clsAccumulativeDistribution;
558 std::vector<double> clsDetAsymmetryForCls;
559 clsDetAsymmetryForCls.clear();
561 std::map<int, std::vector<double> > mapSliceVsDistribution;
563 const int slices = 5;
564 const int distributionFewStrips = 24;
566 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
568 for (
int j = 0;
j < distributionFewStrips;
j++) {
569 for (
int i = 0;
i < slices;
i++) {
570 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
593 for (
int i = 0;
i < vector_lenght;
i++) {
594 value = sliceVsFewStripsDistribution[
slice][(cls - 1) * 4 +
i];
595 clsDetAsymmetryForCls.push_back(
value);
602 for (
int i = clsDetAsymmetryForCls.size() - 1;
i > -1;
i--) {
603 accum += clsDetAsymmetryForCls[
i];
604 _DetAsymmetryForCls.push_back(accum / sum);
606 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)