38 _mapDetIdNoise.clear();
47 std::vector<double> sum_clsize;
49 for (
unsigned int n = 0;
n < vcls.size(); ++
n) {
50 sum_clsize.push_back(vcls[
n]);
53 _clsMap[row] = sum_clsize;
62 std::vector<float> veff, vvnoise;
66 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
69 _mapDetIdNoise[
temp] = vvnoise;
70 _mapDetIdEff[
temp] = veff;
71 _bxmap[
RPCDetId(it->dpid)] = it->time;
75 vvnoise.push_back((it->noise));
76 veff.push_back((it->eff));
78 vvnoise.push_back((it->noise));
79 veff.push_back((it->eff));
80 _bxmap[
RPCDetId(it->dpid)] = it->time;
82 }
else if (
n == vnoise.size() - 1) {
84 vvnoise.push_back((it->noise));
85 veff.push_back((it->eff));
86 _mapDetIdNoise[
temp] = vvnoise;
87 _mapDetIdEff[
temp] = veff;
90 vvnoise.push_back((it->noise));
91 veff.push_back((it->eff));
98 const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize) {
99 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)" << std::endl;
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;
107 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin" << std::endl;
108 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 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));
120 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
121 sslogclsitem << std::endl;
124 if ((!(clsCounter % 120)) && (clsCounter != 0)) {
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 <<
",";
132 LogDebugClsVectString <<
"]";
133 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
134 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " <<
RPCDetId(detId) <<
" = "
135 << detId <<
" clsVec = " << LogDebugClsVectStr;
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;
145 sslogclsitem <<
" --> not saved in map " << std::endl;
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));
156 sslogclsitem <<
" Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
157 sslogclsitem << std::endl;
160 if ((!(clsCounter % 100)) && (clsCounter != 0)) {
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 <<
",";
168 LogDebugClsVectString <<
"]";
169 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
170 LogDebug(
"RPCSimSetup") <<
"Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " <<
RPCDetId(detId)
171 <<
" = " << detId <<
" clsVec = " << LogDebugClsVectStr;
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;
181 sslogclsitem <<
" --> not saved in map " << std::endl;
187 sslogclsitem.clear();
188 LogDebug(
"RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
189 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
191 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
192 std::stringstream sslognoiseitem;
194 unsigned int count_strips = 1;
195 unsigned int count_all = 1;
196 std::vector<float> vveff, vvnoise;
201 bool quitLoop =
false;
204 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
207 current_detId = it->dpid;
208 current_rpcId =
RPCDetId(current_detId);
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;
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"
220 current_roll = theGeometry->roll(current_rpcId);
221 current_nStrips = current_roll->
nstrips();
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 "------------------------------------ "
232 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
234 this_detId = it->dpid;
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;
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;
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
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;
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;
276 vvnoise.push_back((it->noise));
277 vveff.push_back((it->eff));
285 else if (this_detId == current_detId && count_strips == current_nStrips) {
286 sslognoiseitem <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
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));
297 sslognoiseitem <<
" fill vectors into map" << std::endl;
298 _mapDetIdNoise[current_detId] = vvnoise;
299 _mapDetIdEff[current_detId] = vveff;
301 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
302 LogDebugNoiVectString <<
"[";
303 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
304 LogDebugNoiVectString << (*itNoiVect) <<
",";
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) <<
",";
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;
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) {
326 this_detId = it->dpid;
328 this_roll = theGeometry->roll(this_rpcId);
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;
336 if (this_detId != current_detId) {
337 sslognoiseitem <<
"Different detId is found :: " << this_detId <<
" aka " << this_rpcId
338 <<
" Noise = " << it->noise <<
" Hz/cm2";
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;
363 sslognoiseitem.clear();
364 LogDebug(
"RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
365 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
367 LogDebug(
"RPCSimSetup") <<
"RPCSimSetUp::setRPCSetUp :: end" << std::endl;
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
376 LogDebug(
"RPCSimSetupChecks") <<
"All OK from RPCSimSetUp - noise information for DetId\t" <<
id << std::endl;
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
388 const RPCRoll* roll = theGeometry->roll(rpcId);
389 unsigned int numbStrips = roll->
nstrips();
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;
397 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" <<
id << std::endl;
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;
414 if (_clsMap.size() != 5) {
415 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
423 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getCls" << std::endl;
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
430 if ((iter->second).size() != 100) {
432 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"
436 <<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" <<
id << std::endl;
441 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
443 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
444 if (iter == _mapDetClsMap.end()) {
446 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
448 if ((iter->second).size() != 120) {
450 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
455 std::vector<double> dataForAsymmCls = iter->second;
457 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
460 _DetClsAsymmetric.clear();
462 vector<double> clsFewStripsDistribution;
463 vector<double> clsDistribution;
464 vector<double> clsAccumulativeDistribution;
466 std::map<int, std::vector<double> > mapSliceVsDistribution;
468 const int slices = 5;
469 const int distributionFewStrips = 24;
471 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
473 for (
int j = 0;
j < distributionFewStrips;
j++) {
474 for (
int i = 0;
i < slices;
i++) {
475 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
480 for (
int j = 0;
j < distributionFewStrips;
j++) {
481 control += sliceVsFewStripsDistribution[0][
j];
485 for (
int j = 0;
j < distributionFewStrips;
j++) {
486 for (
int i = 0;
i < slices;
i++) {
487 control1 += dataForAsymmCls[
j * slices +
i];
494 for (
int j = 0;
j < distributionFewStrips;
j++) {
496 sum += sliceVsFewStripsDistribution[
i][
j];
498 _DetClsAsymmetric.push_back(sum);
501 return _DetClsAsymmetric;
505 LogDebug(
"RPCSimSetupChecks") <<
"RPCSimSetUp::getAsymmetryForCls" << std::endl;
507 map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
508 if (iter == _mapDetClsMap.end()) {
510 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" <<
id << std::endl;
512 if ((iter->second).size() != 120) {
514 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" <<
id
515 <<
'\t' << (iter->second).
size() << std::endl;
518 std::vector<double> dataForAsymmCls = iter->second;
521 throw cms::Exception(
"DataCorrupt") <<
"Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
524 _DetAsymmetryForCls.clear();
526 vector<double> clsFewStripsDistribution;
527 vector<double> clsDistribution;
528 vector<double> clsAccumulativeDistribution;
529 vector<double> clsDetAsymmetryForCls;
530 clsDetAsymmetryForCls.clear();
532 std::map<int, std::vector<double> > mapSliceVsDistribution;
534 const int slices = 5;
535 const int distributionFewStrips = 24;
537 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
539 for (
int j = 0;
j < distributionFewStrips;
j++) {
540 for (
int i = 0;
i < slices;
i++) {
541 sliceVsFewStripsDistribution[
i][
j] = dataForAsymmCls[
j * slices +
i];
564 for (
int i = 0;
i < vector_lenght;
i++) {
565 value = sliceVsFewStripsDistribution[
slice][(cls - 1) * 4 +
i];
566 clsDetAsymmetryForCls.push_back(
value);
573 for (
int i = clsDetAsymmetryForCls.size() - 1;
i > -1;
i--) {
574 accum += clsDetAsymmetryForCls[
i];
575 _DetAsymmetryForCls.push_back(accum / sum);
577 return _DetAsymmetryForCls;