File indexing completed on 2024-04-06 12:30:50
0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "SimMuon/RPCDigitizer/src/RPCDigiProducer.h"
0003 #include "SimMuon/RPCDigitizer/src/RPCDigitizer.h"
0004 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0005 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0006 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "Geometry/Records/interface/MuonGeometryRecord.h"
0009 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0010 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0011 #include "FWCore/ServiceRegistry/interface/Service.h"
0012 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0017 #include "SimMuon/RPCDigitizer/src/RPCSimSetUp.h"
0018 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
0019
0020 #include <cmath>
0021 #include <cmath>
0022 #include <fstream>
0023 #include <sstream>
0024 #include <iostream>
0025 #include <cstring>
0026 #include <string>
0027 #include <vector>
0028 #include <cstdlib>
0029 #include <utility>
0030 #include <map>
0031
0032 using namespace std;
0033
0034 RPCSimSetUp::RPCSimSetUp(const edm::ParameterSet& ps) {
0035 _mapDetIdNoise.clear();
0036 _mapDetIdEff.clear();
0037 _bxmap.clear();
0038 _clsMap.clear();
0039 }
0040
0041 void RPCSimSetUp::setRPCSetUp(const std::vector<RPCStripNoises::NoiseItem>& vnoise, const std::vector<float>& vcls) {
0042 unsigned int counter = 1;
0043 unsigned int row = 1;
0044 std::vector<double> sum_clsize;
0045
0046 for (unsigned int n = 0; n < vcls.size(); ++n) {
0047 sum_clsize.push_back(vcls[n]);
0048
0049 if (counter == row * 20) {
0050 _clsMap[row] = sum_clsize;
0051 row++;
0052 sum_clsize.clear();
0053 }
0054 counter++;
0055 }
0056
0057 unsigned int n = 0;
0058 uint32_t temp = 0;
0059 std::vector<float> veff, vvnoise;
0060 veff.clear();
0061 vvnoise.clear();
0062
0063 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
0064 if (n % 96 == 0) {
0065 if (n > 0) {
0066 _mapDetIdNoise[temp] = vvnoise;
0067 _mapDetIdEff[temp] = veff;
0068 _bxmap[RPCDetId(it->dpid)] = it->time;
0069
0070 veff.clear();
0071 vvnoise.clear();
0072 vvnoise.push_back((it->noise));
0073 veff.push_back((it->eff));
0074 } else if (n == 0) {
0075 vvnoise.push_back((it->noise));
0076 veff.push_back((it->eff));
0077 _bxmap[RPCDetId(it->dpid)] = it->time;
0078 }
0079 } else if (n == vnoise.size() - 1) {
0080 temp = it->dpid;
0081 vvnoise.push_back((it->noise));
0082 veff.push_back((it->eff));
0083 _mapDetIdNoise[temp] = vvnoise;
0084 _mapDetIdEff[temp] = veff;
0085 } else {
0086 temp = it->dpid;
0087 vvnoise.push_back((it->noise));
0088 veff.push_back((it->eff));
0089 }
0090 n++;
0091 }
0092 }
0093
0094 void RPCSimSetUp::setRPCSetUp(const std::vector<RPCStripNoises::NoiseItem>& vnoise,
0095 const std::vector<RPCClusterSize::ClusterSizeItem>& vClusterSize) {
0096 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp(vector<NoiseItem>, vector<ClusterSizeItem>)" << std::endl;
0097
0098 uint32_t detId = 0, current_detId, this_detId;
0099 RPCDetId rpcId, current_rpcId, this_rpcId;
0100 const RPCRoll* current_roll = nullptr;
0101 const RPCRoll* this_roll = nullptr;
0102 unsigned int current_nStrips;
0103
0104 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: begin" << std::endl;
0105 #ifdef EDM_ML_DEBUG
0106 std::stringstream sslogclsitem;
0107 #endif
0108
0109 std::vector<RPCClusterSize::ClusterSizeItem>::const_iterator itCls;
0110 int clsCounter(1);
0111 std::vector<double> clsVect;
0112
0113 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
0114 clsVect.push_back(((double)(itCls->clusterSize)));
0115 #ifdef EDM_ML_DEBUG
0116 sslogclsitem << " Push back clustersize = " << itCls->clusterSize << std::endl;
0117 sslogclsitem << "Filling cls in _mapDetCls[detId,clsVect] :: detId = " << detId;
0118 sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted?";
0119 sslogclsitem << " New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
0120 sslogclsitem << " Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
0121 sslogclsitem << std::endl;
0122 #endif
0123
0124 if ((!(clsCounter % 120)) && (clsCounter != 0)) {
0125 detId = itCls->dpid;
0126 _mapDetClsMap[detId] = clsVect;
0127 #ifdef EDM_ML_DEBUG
0128 std::stringstream LogDebugClsVectString;
0129 LogDebugClsVectString << "[";
0130 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
0131 LogDebugClsVectString << *itClsVect << ",";
0132 }
0133 LogDebugClsVectString << "]";
0134 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
0135 LogDebug("RPCSimSetup") << "Filling clsVect in _mapDetCls[detId,clsVect] :: detId = " << RPCDetId(detId) << " = "
0136 << detId << " clsVec = " << LogDebugClsVectStr;
0137
0138 sslogclsitem << " --> New Method ";
0139 sslogclsitem << " --> saved in map " << std::endl;
0140 sslogclsitem << "Filling cls in _mapDetClsMap[detId,clsVect] :: detId = " << detId;
0141 sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted? "
0142 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
0143 #endif
0144 clsVect.clear();
0145 clsCounter = 0;
0146 } else {
0147 #ifdef EDM_ML_DEBUG
0148 sslogclsitem << " --> not saved in map " << std::endl;
0149 #endif
0150 }
0151 ++clsCounter;
0152 }
0153
0154 for (itCls = vClusterSize.begin(); itCls != vClusterSize.end(); ++itCls) {
0155 clsVect.push_back(((double)(itCls->clusterSize)));
0156 #ifdef EDM_ML_DEBUG
0157 sslogclsitem << " Push back clustersize = " << itCls->clusterSize << std::endl;
0158 sslogclsitem << "Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
0159 sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted?";
0160 sslogclsitem << " New Format ::" << ((!(clsCounter % 120)) && (clsCounter != 0));
0161 sslogclsitem << " Old Format ::" << ((!(clsCounter % 100)) && (clsCounter != 0));
0162 sslogclsitem << std::endl;
0163 #endif
0164
0165 if ((!(clsCounter % 100)) && (clsCounter != 0)) {
0166 detId = itCls->dpid;
0167 _mapDetClsMapLegacy[detId] = clsVect;
0168 #ifdef EDM_ML_DEBUG
0169 std::stringstream LogDebugClsVectString;
0170 LogDebugClsVectString << "[";
0171 for (std::vector<double>::iterator itClsVect = clsVect.begin(); itClsVect != clsVect.end(); ++itClsVect) {
0172 LogDebugClsVectString << *itClsVect << ",";
0173 }
0174 LogDebugClsVectString << "]";
0175 std::string LogDebugClsVectStr = LogDebugClsVectString.str();
0176 LogDebug("RPCSimSetup") << "Filling clsVect in _mapDetClsLegacy[detId,clsVect] :: detId = " << RPCDetId(detId)
0177 << " = " << detId << " clsVec = " << LogDebugClsVectStr;
0178
0179 sslogclsitem << " --> Old Method ";
0180 sslogclsitem << " --> saved in map " << std::endl;
0181 sslogclsitem << "Filling cls in _mapDetClsMapLegacy[detId,clsVect] :: detId = " << detId;
0182 sslogclsitem << " --> will it be accepted? clsCounter = " << clsCounter << " accepted? "
0183 << ((!(clsCounter % 120)) && (clsCounter != 0)) << std::endl;
0184 #endif
0185 clsVect.clear();
0186 clsCounter = 0;
0187 } else {
0188 #ifdef EDM_ML_DEBUG
0189 sslogclsitem << " --> not saved in map " << std::endl;
0190 #endif
0191 }
0192 ++clsCounter;
0193 }
0194
0195 #ifdef EDM_ML_DEBUG
0196 std::string logclsitem = sslogclsitem.str();
0197 sslogclsitem.clear();
0198 LogDebug("RPCSimSetupClsLoopDetails") << logclsitem << std::endl;
0199 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: ClusterSizeItem :: end" << std::endl;
0200
0201 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: begin" << std::endl;
0202 std::stringstream sslognoiseitem;
0203 #endif
0204
0205 unsigned int count_strips = 1;
0206 #ifdef EDM_ML_DEBUG
0207 unsigned int count_all = 1;
0208 #endif
0209 std::vector<float> vveff, vvnoise;
0210
0211
0212
0213
0214 bool quitLoop = false;
0215 current_detId = 0;
0216 current_nStrips = 0;
0217 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end() && !quitLoop;
0218 ++it) {
0219
0220 current_detId = it->dpid;
0221 current_rpcId = RPCDetId(current_detId);
0222
0223 const RPCRoll* roll = theGeometry->roll(current_rpcId);
0224 if (roll == nullptr) {
0225 #ifdef EDM_ML_DEBUG
0226 sslognoiseitem << "Searching for first valid detid :: current_detId = " << current_detId;
0227 sslognoiseitem << " aka " << current_rpcId << " is not in current Geometry --> Skip " << std::endl;
0228 #endif
0229 continue;
0230 } else {
0231 #ifdef EDM_ML_DEBUG
0232 sslognoiseitem << "Searching for first valid detid :: current_detId = " << current_detId;
0233 sslognoiseitem << " aka " << current_rpcId
0234 << " is the first (valid) roll in the current Geometry --> Accept, Assign & Quit Loop"
0235 << std::endl;
0236 #endif
0237 current_roll = theGeometry->roll(current_rpcId);
0238 current_nStrips = current_roll->nstrips();
0239 quitLoop = true;
0240 }
0241 }
0242
0243 #ifdef EDM_ML_DEBUG
0244 sslognoiseitem << "Start Position :: current_detId = " << current_detId << " aka " << current_rpcId;
0245 sslognoiseitem << " is a valid roll with pointer " << current_roll << " and has "
0246 << (current_roll ? current_roll->nstrips() : 0) << " strips" << std::endl;
0247 sslognoiseitem << " -------------------------------------------------------------------------------------------------"
0248 "------------------------------------ "
0249 << std::endl;
0250 #endif
0251 for (std::vector<RPCStripNoises::NoiseItem>::const_iterator it = vnoise.begin(); it != vnoise.end(); ++it) {
0252
0253 this_detId = it->dpid;
0254 this_rpcId = RPCDetId(this_detId);
0255
0256 const RPCRoll* roll = theGeometry->roll(this_rpcId);
0257 if (roll == nullptr) {
0258 #ifdef EDM_ML_DEBUG
0259 sslognoiseitem << "Inside Loop :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
0260 << "] :: this_detId = " << this_detId << " aka " << this_rpcId
0261 << " which is not in current Geometry --> Skip " << std::endl;
0262 #endif
0263 continue;
0264 }
0265
0266
0267
0268 if (this_detId == current_detId && count_strips == 1) {
0269
0270 _bxmap[current_detId] = it->time;
0271
0272 vveff.clear();
0273 vvnoise.clear();
0274
0275 vvnoise.push_back((it->noise));
0276 vveff.push_back((it->eff));
0277 #ifdef EDM_ML_DEBUG
0278 sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 1" << std::endl;
0279 sslognoiseitem << this_detId << " = " << this_rpcId << " with " << roll->nstrips() << " strips" << std::endl;
0280 sslognoiseitem << "[NoiseItem :: n = " << count_all
0281 << "] Filling time in _bxmap[detId] :: detId = " << RPCDetId(it->dpid) << " time = " << it->time
0282 << std::endl;
0283 sslognoiseitem << "First Value :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
0284 << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
0285 sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
0286
0287 ++count_all;
0288 #endif
0289
0290 ++count_strips;
0291 }
0292
0293
0294 else if (this_detId == current_detId && count_strips > 1 && count_strips < current_nStrips) {
0295 #ifdef EDM_ML_DEBUG
0296 sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 2" << std::endl;
0297 sslognoiseitem << "Inside Loop :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
0298 << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
0299 sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
0300
0301 ++count_all;
0302 #endif
0303
0304 vvnoise.push_back((it->noise));
0305 vveff.push_back((it->eff));
0306
0307 ++count_strips;
0308 }
0309
0310
0311
0312 else if (this_detId == current_detId && count_strips == current_nStrips) {
0313 #ifdef EDM_ML_DEBUG
0314 sslognoiseitem << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: case 3" << std::endl;
0315 sslognoiseitem << "Last Value :: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
0316 << "] :: this_detId = " << this_detId << " aka " << this_rpcId;
0317 sslognoiseitem << " Strip " << std::setw(3) << count_strips << " Noise = " << it->noise << " Hz/cm2" << std::endl;
0318
0319 ++count_all;
0320 #endif
0321
0322 vvnoise.push_back((it->noise));
0323 vveff.push_back((it->eff));
0324
0325 ++count_strips;
0326
0327 _mapDetIdNoise[current_detId] = vvnoise;
0328 _mapDetIdEff[current_detId] = vveff;
0329
0330 #ifdef EDM_ML_DEBUG
0331 sslognoiseitem << " fill vectors into map" << std::endl;
0332 std::stringstream LogDebugNoiVectString, LogDebugEffVectString;
0333 LogDebugNoiVectString << "[";
0334 for (std::vector<float>::iterator itNoiVect = vvnoise.begin(); itNoiVect != vvnoise.end(); ++itNoiVect) {
0335 LogDebugNoiVectString << (*itNoiVect) << ",";
0336 }
0337 LogDebugNoiVectString << "]";
0338 std::string LogDebugNoiVectStr = LogDebugNoiVectString.str();
0339 LogDebugEffVectString << "[";
0340 for (std::vector<float>::iterator itEffVect = vveff.begin(); itEffVect != vveff.end(); ++itEffVect) {
0341 LogDebugEffVectString << (*itEffVect) << ",";
0342 }
0343 LogDebugEffVectString << "]";
0344 std::string LogDebugEffVectStr = LogDebugEffVectString.str();
0345 LogDebug("RPCSimSetup") << "Filling vvnoise in _mapDetIdNoise[detId] :: detId = " << RPCDetId(it->dpid) << " = "
0346 << (RPCDetId(it->dpid)).rawId() << " vvnoise = " << LogDebugNoiVectStr;
0347 LogDebug("RPCSimSetup") << "Filling veff in _mapDetIdEff[detId] :: detId = " << RPCDetId(it->dpid) << " = "
0348 << (RPCDetId(it->dpid)).rawId() << " veff = " << LogDebugEffVectStr;
0349 #endif
0350
0351
0352
0353 bool next_detId_found = false;
0354 #ifdef EDM_ML_DEBUG
0355 sslognoiseitem << "look for next different detId" << std::endl;
0356 #endif
0357 while (next_detId_found == 0 && it != vnoise.end() - 1) {
0358 ++it;
0359 this_detId = it->dpid;
0360 this_rpcId = RPCDetId(this_detId);
0361 this_roll = theGeometry->roll(this_rpcId);
0362 if (!this_roll)
0363 continue;
0364 #ifdef EDM_ML_DEBUG
0365 sslognoiseitem << "Inside While:: [" << std::setw(6) << count_all << "][" << std::setw(3) << count_strips
0366 << "] :: this_detId = " << this_detId << " aka " << this_rpcId << " Noise = " << it->noise
0367 << " Hz/cm2" << std::endl;
0368
0369 #endif
0370 ++count_strips;
0371 if (this_detId != current_detId) {
0372 #ifdef EDM_ML_DEBUG
0373 sslognoiseitem << "Different detId is found :: " << this_detId << " aka " << this_rpcId
0374 << " Noise = " << it->noise << " Hz/cm2";
0375 #endif
0376
0377
0378 current_detId = this_detId;
0379 current_rpcId = RPCDetId(current_detId);
0380 next_detId_found = true;
0381 current_nStrips = (theGeometry->roll(current_rpcId))->nstrips();
0382 #ifdef EDM_ML_DEBUG
0383 sslognoiseitem << " with " << current_nStrips << " strips" << std::endl;
0384 #endif
0385 --it;
0386
0387
0388
0389
0390 }
0391 }
0392
0393 count_strips = 1;
0394 }
0395
0396
0397 else {
0398 }
0399 }
0400
0401 #ifdef EDM_ML_DEBUG
0402 std::string lognoiseitem = sslognoiseitem.str();
0403 sslognoiseitem.clear();
0404 LogDebug("RPCSimSetupNoiseLoopDetails") << lognoiseitem << std::endl;
0405 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: NoiseItem :: end" << std::endl;
0406
0407 LogDebug("RPCSimSetup") << "RPCSimSetUp::setRPCSetUp :: end" << std::endl;
0408 #endif
0409 }
0410
0411 const std::vector<float>& RPCSimSetUp::getNoise(uint32_t id) {
0412 std::map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdNoise.find(id);
0413 if (iter == _mapDetIdNoise.end()) {
0414 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no noise information for DetId\t" << id
0415 << std::endl;
0416 }
0417 LogDebug("RPCSimSetupChecks") << "All OK from RPCSimSetUp - noise information for DetId\t" << id << std::endl;
0418 return iter->second;
0419 }
0420
0421 const std::vector<float>& RPCSimSetUp::getEff(uint32_t id) {
0422 std::map<uint32_t, std::vector<float> >::iterator iter = _mapDetIdEff.find(id);
0423 if (iter == _mapDetIdEff.end()) {
0424 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no efficiency information for DetId\t" << id
0425 << std::endl;
0426 }
0427
0428 RPCDetId rpcId = RPCDetId(id);
0429 const RPCRoll* roll = theGeometry->roll(rpcId);
0430 unsigned int numbStrips = roll->nstrips();
0431
0432 if ((iter->second).size() < numbStrips) {
0433 LogDebug("RPCSimSetup") << "Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" << id
0434 << " aka " << RPCDetId(id) << std::endl;
0435 LogDebug("RPCSimSetup") << " number of strips in Conditions\t" << (iter->second).size()
0436 << " number of strips in Geometry\t" << numbStrips << std::endl;
0437 throw cms::Exception("DataCorrupt")
0438 << "Exception from RPCSimSetUp - efficiency information in a wrong format for DetId\t" << id << std::endl;
0439 }
0440
0441 return iter->second;
0442 }
0443
0444 float RPCSimSetUp::getTime(uint32_t id) {
0445 RPCDetId rpcid(id);
0446 std::map<RPCDetId, float>::iterator iter = _bxmap.find(rpcid);
0447 if (iter == _bxmap.end()) {
0448 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no timing information for rpcid.rawId()\t"
0449 << rpcid.rawId() << std::endl;
0450 }
0451 return iter->second;
0452 }
0453
0454 const std::map<int, std::vector<double> >& RPCSimSetUp::getClsMap() {
0455 if (_clsMap.size() != 5) {
0456 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - cluster size - a wrong format " << std::endl;
0457 }
0458 return _clsMap;
0459 }
0460
0461
0462 const std::vector<double>& RPCSimSetUp::getCls(uint32_t id)
0463 {
0464 LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getCls" << std::endl;
0465
0466 std::map<uint32_t, std::vector<double> >::iterator iter = _mapDetClsMapLegacy.find(id);
0467 if (iter == _mapDetClsMapLegacy.end()) {
0468 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - no cluster size information for DetId\t" << id
0469 << std::endl;
0470 }
0471 if ((iter->second).size() != 100) {
0472 throw cms::Exception("DataCorrupt")
0473 << "Exception from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information in a wrong format for DetId\t"
0474 << id << std::endl;
0475 }
0476 LogDebug("RPCSimSetupChecks")
0477 << "All OK from RPCSimSetUp - _mapDetClsMapLegacy - cluster size information for DetId\t" << id << std::endl;
0478 return iter->second;
0479 }
0480
0481 const std::vector<double>& RPCSimSetUp::getAsymmetricClsDistribution(uint32_t id, uint32_t slice) {
0482 LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getAsymmetricClsDistribution" << std::endl;
0483
0484 std::map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(id);
0485 if (iter == _mapDetClsMap.end()) {
0486 throw cms::Exception("DataCorrupt")
0487 << "Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" << id << std::endl;
0488 }
0489 if ((iter->second).size() != 120) {
0490 throw cms::Exception("DataCorrupt")
0491 << "Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" << id
0492 << std::endl;
0493 }
0494
0495
0496 std::vector<double> dataForAsymmCls = iter->second;
0497 if (slice > 4) {
0498 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
0499 }
0500
0501 _DetClsAsymmetric.clear();
0502
0503 std::vector<double> clsFewStripsDistribution;
0504 std::vector<double> clsDistribution;
0505 std::vector<double> clsAccumulativeDistribution;
0506
0507 std::map<int, std::vector<double> > mapSliceVsDistribution;
0508
0509 const int slices = 5;
0510 const int distributionFewStrips = 24;
0511
0512 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
0513
0514 for (int j = 0; j < distributionFewStrips; j++) {
0515 for (int i = 0; i < slices; i++) {
0516 sliceVsFewStripsDistribution[i][j] = dataForAsymmCls[j * slices + i];
0517 }
0518 }
0519
0520 int i = slice;
0521 double sum = 0;
0522 int counter = 0;
0523 for (int j = 0; j < distributionFewStrips; j++) {
0524 counter++;
0525 sum += sliceVsFewStripsDistribution[i][j];
0526 if (counter % 4 == 0) {
0527 _DetClsAsymmetric.push_back(sum);
0528 }
0529 }
0530 return _DetClsAsymmetric;
0531 }
0532
0533 const std::vector<double>& RPCSimSetUp::getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls) {
0534 LogDebug("RPCSimSetupChecks") << "RPCSimSetUp::getAsymmetryForCls" << std::endl;
0535
0536 std::map<uint32_t, std::vector<double> >::const_iterator iter = _mapDetClsMap.find(id);
0537 if (iter == _mapDetClsMap.end()) {
0538 throw cms::Exception("DataCorrupt")
0539 << "Exception from RPCSimSetUp - _mapDetClsMap - no cluster size information for DetId\t" << id << std::endl;
0540 }
0541 if ((iter->second).size() != 120) {
0542 throw cms::Exception("DataCorrupt")
0543 << "Exception from RPCSimSetUp - _mapDetClsMap - cluster size information in a wrong format for DetId\t" << id
0544 << '\t' << (iter->second).size() << std::endl;
0545 }
0546
0547 std::vector<double> dataForAsymmCls = iter->second;
0548
0549 if (slice > 4) {
0550 throw cms::Exception("DataCorrupt") << "Exception from RPCSimSetUp - slice variable not in the range" << std::endl;
0551 }
0552
0553 _DetAsymmetryForCls.clear();
0554
0555 std::vector<double> clsFewStripsDistribution;
0556 std::vector<double> clsDistribution;
0557 std::vector<double> clsAccumulativeDistribution;
0558 std::vector<double> clsDetAsymmetryForCls;
0559 clsDetAsymmetryForCls.clear();
0560
0561 std::map<int, std::vector<double> > mapSliceVsDistribution;
0562
0563 const int slices = 5;
0564 const int distributionFewStrips = 24;
0565
0566 double sliceVsFewStripsDistribution[slices][distributionFewStrips];
0567
0568 for (int j = 0; j < distributionFewStrips; j++) {
0569 for (int i = 0; i < slices; i++) {
0570 sliceVsFewStripsDistribution[i][j] = dataForAsymmCls[j * slices + i];
0571 }
0572 }
0573
0574 int vector_lenght;
0575 switch (cls) {
0576 case 1:
0577 case 3:
0578 case 5:
0579 vector_lenght = 3;
0580 break;
0581 case 2:
0582 case 4:
0583 vector_lenght = 4;
0584 break;
0585 case 6:
0586 default:
0587 vector_lenght = 1;
0588 break;
0589 }
0590
0591 float sum = 0;
0592 float value;
0593 for (int i = 0; i < vector_lenght; i++) {
0594 value = sliceVsFewStripsDistribution[slice][(cls - 1) * 4 + i];
0595 clsDetAsymmetryForCls.push_back(value);
0596 sum += value;
0597
0598
0599 }
0600
0601 float accum = 0;
0602 for (int i = clsDetAsymmetryForCls.size() - 1; i > -1; i--) {
0603 accum += clsDetAsymmetryForCls[i];
0604 _DetAsymmetryForCls.push_back(accum / sum);
0605 }
0606 return _DetAsymmetryForCls;
0607 }
0608
0609 RPCSimSetUp::~RPCSimSetUp() {}