39 _mapDetIdNoise.clear();
49 std::vector<double> sum_clsize;
51 for(
unsigned int n = 0;
n < vcls.size(); ++
n){
53 sum_clsize.push_back(vcls[
n]);
55 if(counter == row*20) {
57 _clsMap[row] = sum_clsize;
66 std::vector<float> veff, vvnoise;
70 for(std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it){
73 _mapDetIdNoise[
temp]= vvnoise;
74 _mapDetIdEff[
temp] = veff;
75 _bxmap[
RPCDetId(it->dpid)] = it->time;
79 vvnoise.push_back((it->noise));
80 veff.push_back((it->eff));
83 vvnoise.push_back((it->noise));
84 veff.push_back((it->eff));
85 _bxmap[
RPCDetId(it->dpid)] = it->time;
87 }
else if (n == vnoise.size()-1 ){
89 vvnoise.push_back((it->noise));
90 veff.push_back((it->eff));
91 _mapDetIdNoise[
temp]= vvnoise;
92 _mapDetIdEff[
temp] = veff;
95 vvnoise.push_back((it->noise));
96 veff.push_back((it->eff));
102 void RPCSimSetUp::setRPCSetUp(
const std::vector<RPCStripNoises::NoiseItem>& vnoise,
const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize){
104 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)"<<std::endl;
106 uint32_t detId, current_detId, this_detId;
107 RPCDetId rpcId, current_rpcId, this_rpcId;
108 const RPCRoll * current_roll =
nullptr;
109 const RPCRoll * this_roll =
nullptr;
110 unsigned int current_nStrips;
112 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin"<<std::endl;
113 std::stringstream sslogclsitem;
115 std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
117 std::vector<double> clsVect;
119 for(itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls){
120 sslogclsitem<<
" Push back clustersize = "<<itCls->clusterSize<<std::endl;
121 clsVect.push_back(((
double)(itCls->clusterSize)));
122 sslogclsitem<<
"Filling cls in _mapDetCls[detId,clsVect] :: detId = "<<detId;
123 sslogclsitem<<
" --> will it be accepted? clsCounter = "<<clsCounter<<
" accepted?";
124 sslogclsitem<<
" New Format ::"<<((!(clsCounter%120)) && (clsCounter!=0));
125 sslogclsitem<<
" Old Format ::"<<((!(clsCounter%100)) && (clsCounter!=0));
126 sslogclsitem<<std::endl;
129 if((!(clsCounter%120)) && (clsCounter!=0)){
131 _mapDetClsMap[detId]=clsVect;
132 std::stringstream LogDebugClsVectString;
133 LogDebugClsVectString<<
"[";
134 for(std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
135 LogDebugClsVectString<<*itClsVect<<
",";
137 LogDebugClsVectString<<
"]";
138 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
139 LogDebug (
"RPCSimSetup")<<
"Filling clsVect in _mapDetCls[detId,clsVect] :: detId = "<<
RPCDetId(detId)<<
" = "<<detId<<
" clsVec = "<<LogDebugClsVectStr;
141 sslogclsitem<<
" --> New Method ";
142 sslogclsitem<<
" --> saved in map "<<std::endl;
143 sslogclsitem<<
"Filling cls in _mapDetClsMap[detId,clsVect] :: detId = "<<detId;
144 sslogclsitem<<
" --> will it be accepted? clsCounter = "<<clsCounter<<
" accepted? "<<((!(clsCounter%120)) && (clsCounter!=0))<<std::endl;
149 sslogclsitem<<
" --> not saved in map "<<std::endl;
154 for(itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls){
155 sslogclsitem<<
" Push back clustersize = "<<itCls->clusterSize<<std::endl;
156 clsVect.push_back(((
double)(itCls->clusterSize)));
157 sslogclsitem<<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = "<<detId;
158 sslogclsitem<<
" --> will it be accepted? clsCounter = "<<clsCounter<<
" accepted?";
159 sslogclsitem<<
" New Format ::"<<((!(clsCounter%120)) && (clsCounter!=0));
160 sslogclsitem<<
" Old Format ::"<<((!(clsCounter%100)) && (clsCounter!=0));
161 sslogclsitem<<std::endl;
164 if((!(clsCounter%100)) && (clsCounter!=0)){
166 _mapDetClsMapLegacy[detId]=clsVect;
167 std::stringstream LogDebugClsVectString;
168 LogDebugClsVectString<<
"[";
169 for(std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
170 LogDebugClsVectString<<*itClsVect<<
",";
172 LogDebugClsVectString<<
"]";
173 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
174 LogDebug (
"RPCSimSetup")<<
"Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = "<<
RPCDetId(detId)<<
" = "<<detId<<
" clsVec = "<<LogDebugClsVectStr;
176 sslogclsitem<<
" --> Old Method ";
177 sslogclsitem<<
" --> saved in map "<<std::endl;
178 sslogclsitem<<
"Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = "<<detId;
179 sslogclsitem<<
" --> will it be accepted? clsCounter = "<<clsCounter<<
" accepted? "<<((!(clsCounter%120)) && (clsCounter!=0))<<std::endl;
184 sslogclsitem<<
" --> not saved in map "<<std::endl;
189 std::string logclsitem = sslogclsitem.str(); sslogclsitem.clear();
190 LogDebug (
"RPCSimSetupClsLoopDetails")<<logclsitem<<std::endl;
191 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end"<<std::endl;
193 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin"<<std::endl;
194 std::stringstream sslognoiseitem;
196 unsigned int count_strips = 1;
197 unsigned int count_all = 1;
198 std::vector<float> vveff, vvnoise;
203 bool quitLoop =
false;
204 current_detId = 0; current_nStrips = 0;
205 for(std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop; ++it) {
207 current_detId = it->dpid;
208 current_rpcId =
RPCDetId(current_detId);
210 const RPCRoll* roll = theGeometry->roll(current_rpcId);
212 sslognoiseitem <<
"Searching for first valid detid :: current_detId = "<<current_detId;
213 sslognoiseitem <<
" aka "<<current_rpcId<<
" is not in current Geometry --> Skip "<<std::endl;
217 sslognoiseitem <<
"Searching for first valid detid :: current_detId = "<<current_detId;
218 sslognoiseitem <<
" aka "<<current_rpcId<<
" is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop"<<std::endl;
219 current_roll = theGeometry->roll(current_rpcId);
220 current_nStrips = current_roll->
nstrips();
225 sslognoiseitem <<
"Start Position :: current_detId = "<<current_detId<<
" aka "<<current_rpcId;
226 sslognoiseitem <<
" is a valid roll with pointer "<<current_roll<<
" and has "<<(current_roll?current_roll->
nstrips():0)<<
" strips"<<std::endl;
227 sslognoiseitem <<
" ------------------------------------------------------------------------------------------------------------------------------------- "<<std::endl;
228 for(std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
231 this_detId = it->dpid;
234 const RPCRoll* roll = theGeometry->roll(this_rpcId);
236 sslognoiseitem <<
"Inside Loop :: ["<<std::setw(6)<<count_all<<
"]["<<std::setw(3)<<count_strips<<
"] :: this_detId = "<<this_detId<<
" aka "<<this_rpcId<<
" which is not in current Geometry --> Skip "<<std::endl;
242 if(this_detId == current_detId && count_strips == 1) {
243 sslognoiseitem<<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1"<<std::endl;
244 sslognoiseitem<<this_detId<<
" = "<<this_rpcId<<
" with "<<roll->
nstrips()<<
" strips"<<std::endl;
246 _bxmap[current_detId] = it->time;
247 sslognoiseitem<<
"[NoiseItem :: n = "<<count_all<<
"] Filling time in _bxmap[detId] :: detId = "<<
RPCDetId(it->dpid)<<
" time = "<<it->time<<std::endl;
252 vvnoise.push_back((it->noise));
253 vveff.push_back((it->eff));
254 sslognoiseitem <<
"First Value :: ["<<std::setw(6)<<count_all<<
"]["<<std::setw(3)<<count_strips<<
"] :: this_detId = "<<this_detId<<
" aka "<<this_rpcId;
255 sslognoiseitem <<
" Strip "<<std::setw(3)<<count_strips<<
" Noise = "<<it->noise<<
" Hz/cm2"<<std::endl;
262 else if(this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
263 sslognoiseitem<<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2"<<std::endl;
264 sslognoiseitem <<
"Inside Loop :: ["<<std::setw(6)<<count_all<<
"]["<<std::setw(3)<<count_strips<<
"] :: this_detId = "<<this_detId<<
" aka "<<this_rpcId;
265 sslognoiseitem <<
" Strip "<<std::setw(3)<<count_strips<<
" Noise = "<<it->noise<<
" Hz/cm2"<<std::endl;
267 vvnoise.push_back((it->noise));
268 vveff.push_back((it->eff));
276 else if(this_detId == current_detId && count_strips == current_nStrips) {
277 sslognoiseitem<<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3"<<std::endl;
279 sslognoiseitem <<
"Last Value :: ["<<std::setw(6)<<count_all<<
"]["<<std::setw(3)<<count_strips<<
"] :: this_detId = "<<this_detId<<
" aka "<<this_rpcId;
280 sslognoiseitem <<
" Strip "<<std::setw(3)<<count_strips<<
" Noise = "<<it->noise<<
" Hz/cm2"<<std::endl;
281 vvnoise.push_back((it->noise));
282 vveff.push_back((it->eff));
287 sslognoiseitem <<
" fill vectors into map"<<std::endl;
288 _mapDetIdNoise[current_detId]= vvnoise;
289 _mapDetIdEff[current_detId] = vveff;
291 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
292 LogDebugNoiVectString<<
"[";
293 for(std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
294 LogDebugNoiVectString<<(*itNoiVect)<<
",";
296 LogDebugNoiVectString<<
"]";
297 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
298 LogDebugEffVectString<<
"[";
299 for(std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
300 LogDebugEffVectString<<(*itEffVect)<<
",";
302 LogDebugEffVectString<<
"]";
303 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
304 LogDebug (
"RPCSimSetup")<<
"Filling vvnoise in _mapDetIdNoise[detId] :: detId = "<<
RPCDetId(it->dpid)<<
" = "<<(
RPCDetId(it->dpid)).rawId()<<
" vvnoise = "<<LogDebugNoiVectStr;
305 LogDebug (
"RPCSimSetup")<<
"Filling veff in _mapDetIdEff[detId] :: detId = "<<
RPCDetId(it->dpid)<<
" = "<<(
RPCDetId(it->dpid)).rawId()<<
" veff = "<<LogDebugEffVectStr;
310 bool next_detId_found =
false;
311 sslognoiseitem <<
"look for next different detId"<<std::endl;
312 while(next_detId_found==0 && it != vnoise.end()-1) {
314 this_detId = it->dpid;
316 this_roll = theGeometry->roll(this_rpcId);
317 if(!this_roll)
continue;
318 sslognoiseitem <<
"Inside While:: ["<<std::setw(6)<<count_all<<
"]["<<std::setw(3)<<count_strips<<
"] :: this_detId = "<<this_detId<<
" aka "<<this_rpcId<<
" Noise = "<<it->noise<<
" Hz/cm2"<<std::endl;
321 if(this_detId != current_detId) {
322 sslognoiseitem <<
"Different detId is found :: "<<this_detId<<
" aka "<<this_rpcId<<
" Noise = "<<it->noise<<
" Hz/cm2";
325 current_detId = this_detId;
326 current_rpcId =
RPCDetId(current_detId);
327 next_detId_found =
true;
328 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
329 sslognoiseitem <<
" with "<<current_nStrips<<
" strips"<<std::endl;
345 std::string lognoiseitem = sslognoiseitem.str(); sslognoiseitem.clear();
346 LogDebug (
"RPCSimSetupNoiseLoopDetails")<<lognoiseitem<<std::endl;
347 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp :: NoiseItem :: end"<<std::endl;
349 LogDebug (
"RPCSimSetup")<<
"RPCSimSetUp::setRPCSetUp :: end"<<std::endl;
355 map<uint32_t,std::vector<float> >::iterator iter = _mapDetIdNoise.find(
id);
356 if(iter == _mapDetIdNoise.end()){
358 <<
"Exception from RPCSimSetUp - no noise information for DetId\t"<<
id<< std::endl;
360 LogDebug (
"RPCSimSetupChecks")<<
"All OK from RPCSimSetUp - noise information for DetId\t"<<
id<< std::endl;
366 map<uint32_t,std::vector<float> >::iterator iter = _mapDetIdEff.find(
id);
367 if(iter == _mapDetIdEff.end()){
369 <<
"Exception from RPCSimSetUp - no efficiency information for DetId\t"<<
id<< std::endl;
373 const RPCRoll* roll = theGeometry->roll(rpcId);
374 unsigned int numbStrips = roll->
nstrips();
376 if((iter->second).size() < numbStrips){
377 LogDebug (
"RPCSimSetup")<<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t"<<
id<<
" aka "<<
RPCDetId(
id)<<std::endl;
378 LogDebug (
"RPCSimSetup")<<
" number of strips in Conditions\t"<<(iter->second).
size()<<
" number of strips in Geometry\t"<<numbStrips<<std::endl;
380 <<
"Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t"<<
id<< std::endl;
389 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
390 if(iter == _bxmap.end()){
392 <<
"Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t"<<rpcid.
rawId()<< std::endl;
399 if(_clsMap.size()!=5){
401 <<
"Exception from RPCSimSetUp - cluster size - a wrong format "<< std::endl;
411 LogDebug (
"RPCSimSetupChecks")<<
"RPCSimSetUp::getCls"<<std::endl;
413 map<uint32_t,std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(
id);
414 if(iter == _mapDetClsMapLegacy.end()){
416 <<
"Exception from RPCSimSetUp - no cluster size information for DetId\t"<<
id<< std::endl;
418 if((iter->second).size() != 100){
420 <<
"Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"<<
id<< std::endl;
422 LogDebug (
"RPCSimSetupChecks")<<
"All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t"<<
id<< std::endl;
428 LogDebug (
"RPCSimSetupChecks")<<
"RPCSimSetUp::getAsymmetricClsDistribution"<<std::endl;
430 map<uint32_t,std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
431 if(iter == _mapDetClsMap.end()){
433 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t"<<
id<< std::endl;
435 if((iter->second).size() != 120){
437 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t"<<
id<< std::endl;
441 std::vector<double> dataForAsymmCls = iter->second;
444 <<
"Exception from RPCSimSetUp - slice variable not in the range"<< std::endl;
447 _DetClsAsymmetric.clear();
450 vector<double> clsFewStripsDistribution;
451 vector<double> clsDistribution;
452 vector<double> clsAccumulativeDistribution;
454 std::map< int, std::vector<double> > mapSliceVsDistribution;
457 const int distributionFewStrips=24;
459 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
461 for(
int j = 0; j < distributionFewStrips; j++){
462 for(
int i = 0;
i < slices;
i++){
463 sliceVsFewStripsDistribution[
i][j]=dataForAsymmCls[j*slices+
i];
468 for(
int j = 0 ; j < distributionFewStrips; j++){
469 control+=sliceVsFewStripsDistribution[0][j];
473 for(
int j = 0; j < distributionFewStrips; j++){
474 for(
int i = 0;
i < slices;
i++){
475 control1+=dataForAsymmCls[j*slices+
i];
482 for(
int j = 0; j < distributionFewStrips; j++){
484 sum+=sliceVsFewStripsDistribution[
i][j];
486 _DetClsAsymmetric.push_back(sum);
489 return _DetClsAsymmetric;
494 LogDebug (
"RPCSimSetupChecks")<<
"RPCSimSetUp::getAsymmetryForCls"<<std::endl;
496 map<uint32_t,std::vector<double> >::const_iterator iter = _mapDetClsMap.find(
id);
497 if(iter == _mapDetClsMap.end()){
499 <<
"Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t"<<
id<< std::endl;
501 if((iter->second).size() != 120){
503 <<
"Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t"<<
id<<
'\t'<<(iter->second).
size()<< std::endl;
506 std::vector<double> dataForAsymmCls = iter->second;
510 <<
"Exception from RPCSimSetUp - slice variable not in the range"<< std::endl;
513 _DetAsymmetryForCls.clear();
515 vector<double> clsFewStripsDistribution;
516 vector<double> clsDistribution;
517 vector<double> clsAccumulativeDistribution;
518 vector<double> clsDetAsymmetryForCls;
519 clsDetAsymmetryForCls.clear();
521 std::map< int, std::vector<double> > mapSliceVsDistribution;
524 const int distributionFewStrips=24;
526 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
528 for(
int j = 0; j < distributionFewStrips; j++){
529 for(
int i = 0;
i < slices;
i++){
530 sliceVsFewStripsDistribution[
i][j]=dataForAsymmCls[j*slices+
i];
536 case 1:
case 3:
case 5: vector_lenght =3;
break;
537 case 2:
case 4: vector_lenght =4;
break;
538 case 6:
default: vector_lenght = 1;
break;
543 for(
int i = 0;
i < vector_lenght ;
i ++){
544 value = sliceVsFewStripsDistribution[slice][(cls-1)*4+
i];
545 clsDetAsymmetryForCls.push_back(value);
552 for(
int i = clsDetAsymmetryForCls.size()-1;
i>-1;
i--){
553 accum += clsDetAsymmetryForCls[
i];
554 _DetAsymmetryForCls.push_back(accum/sum);
556 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)
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)