00001 #include "DQM/EcalCommon/interface/EcalDQMBinningService.h"
00002 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00003
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/Utilities/interface/Exception.h"
00008 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
00009
00010 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00012 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00013 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00014
00015 #include <utility>
00016 #include <iomanip>
00017 #include <sstream>
00018
00019 #include "TMath.h"
00020 #include "TObjArray.h"
00021 #include "TObjString.h"
00022 #include "TString.h"
00023 #include "TPRegexp.h"
00024
00025 using namespace ecaldqm;
00026
00027 EcalDQMBinningService::EcalDQMBinningService(const edm::ParameterSet& _ps, edm::ActivityRegistry &_registry) :
00028 cacheId_(0),
00029 cacheOtype_(nObjType),
00030 cacheBtype_(nBinType),
00031 etaBound_(1.479),
00032 geometry_(0),
00033 initialized_(false),
00034 verbosity_(_ps.getUntrackedParameter<int>("verbosity"))
00035 {
00036 _registry.watchPostBeginRun(this, &EcalDQMBinningService::postBeginRun);
00037 }
00038
00039 EcalDQMBinningService::~EcalDQMBinningService()
00040 {
00041 }
00042
00043 void
00044 EcalDQMBinningService::postBeginRun(const edm::Run &, const edm::EventSetup &_es)
00045 {
00046
00047 edm::ESHandle<EcalElectronicsMapping> elecMapHandle;
00048 _es.get<EcalMappingRcd>().get(elecMapHandle);
00049 setElectronicsMap(elecMapHandle.product());
00050
00051
00052 edm::ESHandle<EcalTrigTowerConstituentsMap> ttMapHandle;
00053 _es.get<IdealGeometryRecord>().get(ttMapHandle);
00054 setTrigTowerMap(ttMapHandle.product());
00055
00056 edm::ESHandle<CaloGeometry> geomHndl;
00057 _es.get<CaloGeometryRecord>().get(geomHndl);
00058 geometry_ = geomHndl.product();
00059 if(!geometry_)
00060 throw cms::Exception("EventSetup") << "CaloGeometry invalid";
00061
00062 initialized_ = true;
00063 }
00064
00065 std::vector<EcalDQMBinningService::AxisSpecs>
00066 EcalDQMBinningService::getBinning(ObjectType _otype, BinningType _btype, bool _isMap, unsigned _objOffset) const
00067 {
00068 if(_otype >= nObjType || _btype >= unsigned(nPresetBinnings))
00069 return std::vector<AxisSpecs>(0);
00070
00071 switch(_otype){
00072 case kEB:
00073 return getBinningEB_(_btype, _isMap);
00074 case kEBMEM:
00075 return getBinningEBMEM_(_btype, _isMap);
00076 case kEE:
00077 return getBinningEE_(_btype, _isMap, 0);
00078 case kEEm:
00079 return getBinningEE_(_btype, _isMap, -1);
00080 case kEEp:
00081 return getBinningEE_(_btype, _isMap, 1);
00082 case kEEMEM:
00083 return getBinningEEMEM_(_btype, _isMap);
00084 case kSM:
00085 return getBinningSM_(_btype, _isMap, _objOffset);
00086 case kSMMEM:
00087 return getBinningSMMEM_(_btype, _isMap, _objOffset);
00088 case kEcal:
00089 return getBinningEcal_(_btype, _isMap);
00090 default:
00091 return std::vector<AxisSpecs>(0);
00092 }
00093 }
00094
00095 int
00096 EcalDQMBinningService::xlow(int _iSM) const
00097 {
00098 switch(_iSM){
00099 case kEEm01: case kEEp01: return 15;
00100 case kEEm02: case kEEp02: return 0;
00101 case kEEm03: case kEEp03: return 0;
00102 case kEEm04: case kEEp04: return 5;
00103 case kEEm05: case kEEp05: return 30;
00104 case kEEm06: case kEEp06: return 55;
00105 case kEEm07: case kEEp07: return 60;
00106 case kEEm08: case kEEp08: return 55;
00107 case kEEm09: case kEEp09: return 45;
00108 default: break;
00109 }
00110
00111 if(_iSM >= kEBmLow && _iSM <= kEBpHigh) return 0;
00112
00113 return 0;
00114 }
00115
00116 int
00117 EcalDQMBinningService::ylow(int _iSM) const
00118 {
00119 switch(_iSM){
00120 case kEEm01: case kEEp01: case kEEm09: case kEEp09: return 60;
00121 case kEEm02: case kEEp02: case kEEm08: case kEEp08: return 50;
00122 case kEEm03: case kEEp03: case kEEm07: case kEEp07: return 25;
00123 case kEEm04: case kEEp04: case kEEm06: case kEEp06: return 5;
00124 case kEEm05: case kEEp05: return 0;
00125 default: break;
00126 }
00127
00128 if(_iSM >= kEBmLow && _iSM <= kEBmHigh) return ((_iSM - kEBmLow) % 18) * 20;
00129 if(_iSM >= kEBpLow && _iSM <= kEBpHigh) return (-1 - ((_iSM - kEBpLow) % 18)) * 20;
00130
00131 return 0;
00132 }
00133
00134 const std::vector<int>*
00135 EcalDQMBinningService::getBinMap(ObjectType& _okey, BinningType& _bkey) const
00136 {
00137 if(unsigned(_okey) >= nPlotType || unsigned(_bkey) >= nPresetBinnings) return 0;
00138
00139 if((_okey == kEEm || _okey == kEEp) && _bkey == kProjPhi)
00140 _okey = kEE;
00141
00142 if(_bkey == kTriggerTower){
00143 if(_okey == kEB) _bkey = kSuperCrystal;
00144 else if(_okey == kEE || _okey == kEEm || _okey == kEEp) _bkey = kCrystal;
00145 }
00146
00147 if(binMaps_[_okey][_bkey].size() != 0) return &(binMaps_[_okey][_bkey]);
00148
00149
00150
00151 const std::vector<int>* binMap(0);
00152
00153 switch(_okey){
00154 case kEB:
00155 binMap = getBinMapEB_(_bkey);
00156 break;
00157 case kEBMEM:
00158 binMap = getBinMapEBMEM_(_bkey);
00159 break;
00160 case kEE:
00161 binMap = getBinMapEE_(_bkey, 0);
00162 break;
00163 case kEEm:
00164 binMap = getBinMapEE_(_bkey, -1);
00165 break;
00166 case kEEp:
00167 binMap = getBinMapEE_(_bkey, 1);
00168 break;
00169 case kEEMEM:
00170 binMap = getBinMapEEMEM_(_bkey);
00171 break;
00172 case kSM:
00173 binMap = getBinMapSM_(_bkey);
00174 break;
00175 case kSMMEM:
00176 binMap = getBinMapSMMEM_(_bkey);
00177 break;
00178 case kEcal:
00179 binMap = getBinMapEcal_(_bkey);
00180 break;
00181 default:
00182 return 0;
00183 }
00184
00185 if(verbosity_ > 0){
00186 std::cout << "EcalDQMBinningService: Booked new binMap for " << int(_okey) << " " << int(_bkey);
00187 std::cout << " (Current memory usage: ";
00188 int bytes(0);
00189 for(unsigned iO(0); iO < nPlotType; iO++)
00190 for(unsigned iB(0); iB < nPresetBinnings; iB++)
00191 bytes += binMaps_[iO][iB].size() * sizeof(int);
00192 std::cout << bytes / 1024. << "kB)" << std::endl;
00193 }
00194
00195 return binMap;
00196 }
00197
00198 std::pair<unsigned, std::vector<int> >
00199 EcalDQMBinningService::findBins(ObjectType _otype, BinningType _btype, const DetId &_id) const
00200 {
00201 using namespace std;
00202
00203 if(_otype == cacheOtype_ && _btype == cacheBtype_ && _id == cacheId_) return cache_;
00204
00205 pair<unsigned, std::vector<int> > ret(-1, std::vector<int>(0));
00206
00207 if(_otype >= nObjType || _btype >= unsigned(nPresetBinnings)) return ret;
00208
00209 ret.first = findOffset(_otype, _id);
00210 if(ret.first == unsigned(-1)) return ret;
00211
00212
00213 ObjectType okey(objectFromOffset(_otype, ret.first));
00214 BinningType bkey(_btype);
00215
00216 if(okey == nObjType) return ret;
00217
00218 const std::vector<int>* binMap(getBinMap(okey, bkey));
00219 if(binMap == 0) return ret;
00220
00221 switch(bkey){
00222 case kCrystal:
00223 findBinsCrystal_(_id, okey, *binMap, ret.second);
00224 break;
00225 case kTriggerTower:
00226 findBinsTriggerTower_(_id, okey, *binMap, ret.second);
00227 break;
00228 case kSuperCrystal:
00229 findBinsSuperCrystal_(_id, okey, *binMap, ret.second);
00230 break;
00231 case kDCC:
00232 findBinsDCC_(_id, okey, *binMap, ret.second);
00233 break;
00234 case kTCC:
00235 findBinsTCC_(_id, okey, *binMap, ret.second);
00236 break;
00237 case kProjEta:
00238 findBinsProjEta_(_id, okey, *binMap, ret.second);
00239 break;
00240 case kProjPhi:
00241 findBinsProjPhi_(_id, okey, *binMap, ret.second);
00242 default :
00243 break;
00244 }
00245
00246
00247 if(_otype == kSM || _otype == kSMMEM){
00248 for(vector<int>::iterator binItr(ret.second.begin()); binItr != ret.second.end(); ++binItr)
00249 *binItr -= smOffsetBins(_otype, _btype, ret.first);
00250 }
00251
00252 cacheId_ = _id;
00253 cacheOtype_ = _otype;
00254 cacheBtype_ = _btype;
00255 cache_ = ret;
00256
00257 return ret;
00258 }
00259
00260 std::pair<unsigned, std::vector<int> >
00261 EcalDQMBinningService::findBins(ObjectType _otype, BinningType _btype, const EcalElectronicsId &_id) const
00262 {
00263 return findBins(_otype, _btype, getElectronicsMap()->getDetId(_id));
00264 }
00265
00266 std::pair<unsigned, std::vector<int> >
00267 EcalDQMBinningService::findBins(ObjectType _otype, BinningType _btype, unsigned _dcctccid) const
00268 {
00269 using namespace std;
00270
00271 if(_otype == cacheOtype_ && _btype == cacheBtype_ && _dcctccid == cacheId_) return cache_;
00272
00273 pair<unsigned, std::vector<int> > ret(-1, std::vector<int>(0));
00274
00275 if(_btype != kTCC && _btype != kDCC) return ret;
00276
00277 ret.first = findOffset(_otype, _btype, _dcctccid);
00278
00279 if(ret.first == unsigned(-1)) return ret;
00280
00281
00282 ObjectType okey(objectFromOffset(_otype, ret.first));
00283 BinningType bkey(_btype);
00284
00285 const std::vector<int>* binMap(getBinMap(okey, bkey));
00286 if(binMap == 0) return ret;
00287
00288 unsigned index(_dcctccid - 1);
00289
00290 if(bkey == kDCC){
00291 if(okey == kEB) index -= kEBmLow;
00292 else if(okey == kEE && index >= kEEpLow) index -= (kEBpHigh - kEEmHigh);
00293 else if(okey == kEEp) index -= kEEpLow;
00294 }
00295 else{
00296 if(okey == kEB) index -= kEBTCCLow;
00297 else if(okey == kEE && index >= kEEpLow) index -= (kEBTCCHigh - kEEmTCCHigh);
00298 else if(okey == kEEp) index -= kEEpTCCLow;
00299 }
00300
00301 ret.second.push_back(binMap->at(index));
00302
00303 cacheId_ = _dcctccid;
00304 cacheOtype_ = _otype;
00305 cacheBtype_ = _btype;
00306 cache_ = ret;
00307
00308 return ret;
00309 }
00310
00311 std::pair<unsigned, std::vector<int> >
00312 EcalDQMBinningService::findBinsNoMap(ObjectType _otype, BinningType _btype, const DetId& _id) const
00313 {
00314 using namespace std;
00315
00316
00317 if(!((_otype == kSM && _btype == kSuperCrystal) ||
00318 (_otype == kSM && _btype == kTriggerTower) ||
00319 (_otype == kEcal2P && _btype == kDCC) ||
00320 (_otype == kEcal2P && _btype == kTCC)))
00321 throw cms::Exception("NotImplemented") << "1D bin finding only for SM - SC plots or Ecal2P - DCC plots" << std::endl;
00322
00323 if(_otype == kEcal2P && (_btype == kDCC || _btype == kTCC))
00324 return findBins(_otype, _btype, _id);
00325
00326 pair<unsigned, std::vector<int> > ret(-1, std::vector<int>(0));
00327
00328 ret.first = findOffset(_otype, _id);
00329 if(ret.first == unsigned(-1)) return ret;
00330
00331 if(_otype == kSM && _btype == kSuperCrystal)
00332 ret.second.push_back(towerId(_id));
00333 else if(_otype == kSM && _btype == kTriggerTower){
00334 unsigned tccid(tccId(_id));
00335 if(tccid >= 37 && tccid <= 72)
00336 ret.second.push_back(ttId(_id));
00337 else{
00338 unsigned bin(ttId(_id));
00339 tccid = (tccid - 1) % 36;
00340 bool outer(tccid >= 18);
00341 tccid = (tccid + 1) % 18;
00342 if(outer) bin += 48;
00343 bin += (tccid % 2) * (outer ? 16 : 24);
00344 ret.second.push_back(bin);
00345 }
00346 }
00347
00348 return ret;
00349 }
00350
00351 std::pair<unsigned, std::vector<int> >
00352 EcalDQMBinningService::findBinsNoMap(ObjectType _otype, BinningType _btype, const EcalElectronicsId& _id) const
00353 {
00354 return findBinsNoMap(_otype, _btype, getElectronicsMap()->getDetId(_id));
00355 }
00356
00357 unsigned
00358 EcalDQMBinningService::findOffset(ObjectType _otype, const DetId &_id) const
00359 {
00360 if(_otype == cacheOtype_ && _id == cacheId_) return cache_.first;
00361
00362 unsigned iSM(dccId(_id) - 1);
00363
00364 if(_otype == kEcal3P){
00365 if(iSM <= kEEmHigh) return findOffset(kEcal3P, kUser, (unsigned)kEEm + 1);
00366 else if(iSM <= kEBpHigh) return findOffset(kEcal3P, kUser, (unsigned)kEB + 1);
00367 else return findOffset(kEcal3P, kUser, (unsigned)kEEp + 1);
00368 }
00369 else if(_otype == kEcal2P){
00370 if(iSM <= kEEmHigh) return findOffset(kEcal2P, kUser, (unsigned)kEE + 1);
00371 else if(iSM <= kEBpHigh) return findOffset(kEcal2P, kUser, (unsigned)kEB + 1);
00372 else return findOffset(kEcal2P, kUser, (unsigned)kEE + 1);
00373 }
00374 else if(_otype == kEcal)
00375 return 0;
00376 else if(_otype == kEcalMEM2P){
00377 if(iSM <= kEEmHigh) return findOffset(kEcal2P, kUser, (unsigned)kEE + 1);
00378 else if(iSM <= kEBpHigh) return findOffset(kEcal2P, kUser, (unsigned)kEB + 1);
00379 else return findOffset(kEcal2P, kUser, (unsigned)kEE + 1);
00380 }
00381
00382 return findOffset(_otype, kDCC, iSM + 1);
00383 }
00384
00385 unsigned
00386 EcalDQMBinningService::findOffset(ObjectType _otype, const EcalElectronicsId &_id) const
00387 {
00388 return findOffset(_otype, getElectronicsMap()->getDetId(_id));
00389 }
00390
00391 unsigned
00392 EcalDQMBinningService::findOffset(ObjectType _otype, BinningType _btype, unsigned _dcctccid) const
00393 {
00394 unsigned iSM(_dcctccid - 1);
00395
00396 switch(_otype){
00397 case kEB:
00398 if(_btype == kDCC && iSM >= kEBmLow && iSM <= kEBpHigh) return 0;
00399 else if(_btype == kTCC && iSM >= kEBTCCLow && iSM <= kEBTCCHigh) return 0;
00400 return -1;
00401 case kEE:
00402 if(_btype == kDCC &&
00403 (iSM <= kEEmHigh ||
00404 (iSM >= kEEpLow && iSM <= kEEpHigh))) return 0;
00405 else if(_btype == kTCC &&
00406 (iSM <= kEEmTCCHigh ||
00407 (iSM >= kEEpTCCLow && iSM <= kEEpTCCHigh))) return 0;
00408 return -1;
00409 case kEEm:
00410 if(_btype == kDCC && iSM <= kEEmHigh) return 0;
00411 else if(_btype == kTCC && iSM <= kEEmTCCHigh) return 0;
00412 else return -1;
00413 case kEEp:
00414 if(_btype == kDCC && (iSM >= kEEpLow && iSM <= kEEpHigh)) return 0;
00415 else if(_btype == kTCC && (iSM >= kEEpTCCLow && iSM <= kEEpTCCHigh)) return 0;
00416 else return -1;
00417 case kSM:
00418 if(iSM < nDCC) return iSM;
00419 else return -1;
00420 case kSMMEM:
00421 if(iSM < nDCC && dccNoMEM.find(iSM) == dccNoMEM.end()) return memDCCIndex(_dcctccid);
00422 else return -1;
00423 case kEcal:
00424 if(_btype == kDCC && iSM < nDCC) return 0;
00425 else if(_btype == kTCC && iSM < nTCC) return 0;
00426 else if(_btype == kUser) return 0;
00427 else return -1;
00428 case kEcal2P:
00429 {
00430 int iSubdet(iSM);
00431 if(_btype == kDCC){
00432 if(iSM <= kEEmHigh) iSubdet = kEE;
00433 else if(iSM <= kEBpHigh) iSubdet = kEB;
00434 else iSubdet = kEE;
00435 }
00436 else if(_btype == kTCC){
00437 if(iSM <= kEEmTCCHigh) iSubdet = kEE;
00438 else if(iSM <= kEBTCCHigh) iSubdet = kEB;
00439 else iSubdet = kEE;
00440 }
00441 if(iSubdet == kEE || iSubdet == kEEm || iSubdet == kEEp) return 0;
00442 else if(iSubdet == kEB) return 1;
00443 else return -1;
00444 }
00445 case kEcal3P:
00446 {
00447 int iSubdet(iSM);
00448 if(_btype == kDCC){
00449 if(iSM <= kEEmHigh) iSubdet = kEEm;
00450 else if(iSM <= kEBpHigh) iSubdet = kEB;
00451 else iSubdet = kEEp;
00452 }
00453 else if(_btype == kTCC){
00454 if(iSM <= kEEmTCCHigh) iSubdet = kEEm;
00455 else if(iSM <= kEBTCCHigh) iSubdet = kEB;
00456 else iSubdet = kEEp;
00457 }
00458 if(iSubdet == kEEm) return 0;
00459 else if(iSubdet == kEB) return 1;
00460 else if(iSubdet == kEEp) return 2;
00461 else return -1;
00462 }
00463 case kEcalMEM2P:
00464 {
00465 int iSubdet(iSM);
00466 if(iSubdet == kEE || iSubdet == kEEm || iSubdet == kEEp) return 0;
00467 else if(iSubdet == kEB) return 1;
00468 else return -1;
00469 }
00470 default:
00471 return -1;
00472 }
00473 }
00474
00475 EcalDQMBinningService::ObjectType
00476 EcalDQMBinningService::objectFromOffset(ObjectType _otype, unsigned _offset) const
00477 {
00478 if(_otype == kEcal3P) {
00479 switch(_offset){
00480 case 0: return kEEm;
00481 case 1: return kEB;
00482 case 2: return kEEp;
00483 default: return nObjType;
00484 }
00485 }
00486 else if(_otype == kEcal2P){
00487 switch(_offset){
00488 case 0: return kEE;
00489 case 1: return kEB;
00490 default: return nObjType;
00491 }
00492 }
00493 else if(_otype == kEcalMEM2P){
00494 switch(_offset){
00495 case 0: return kEEMEM;
00496 case 1: return kEBMEM;
00497 default: return nObjType;
00498 }
00499 }
00500 else
00501 return _otype;
00502 }
00503
00504 int
00505 EcalDQMBinningService::smOffsetBins(ObjectType _otype, BinningType _btype, unsigned _offset) const
00506 {
00507 if(!_offset) return 0;
00508
00509 switch(_otype) {
00510 case kSM :
00511 {
00512 int bins(0);
00513 int offset(_offset);
00514
00515 if(offset > kEEpLow){
00516 int ext(0);
00517 if(offset > kEEp02) ext += 1;
00518 if(offset > kEEp08) ext += 1;
00519 int offBins(nEESMBins * (offset - kEEpLow) + (nEESMBinsExt - nEESMBins) * ext);
00520 switch(_btype){
00521 case kCrystal:
00522 case kTriggerTower:
00523 bins += offBins; break;
00524 case kSuperCrystal:
00525 bins += offBins / 25; break;
00526 default:
00527 break;
00528 }
00529 offset = kEEpLow;
00530 }
00531 if(offset > kEBmLow){
00532 int offBins(nEBSMBins * (offset - kEBmLow));
00533 switch(_btype){
00534 case kCrystal:
00535 bins += offBins; break;
00536 case kTriggerTower:
00537 case kSuperCrystal:
00538 bins += offBins / 25; break;
00539 default:
00540 break;
00541 }
00542 offset = kEBmLow;
00543 }
00544 if(offset > kEEmLow){
00545 int ext(0);
00546 if(offset > kEEm02) ext += 1;
00547 if(offset > kEEm08) ext += 1;
00548 int offBins(nEESMBins * (offset - kEEmLow) + (nEESMBinsExt - nEESMBins) * ext);
00549 switch(_btype){
00550 case kCrystal:
00551 case kTriggerTower:
00552 bins += offBins; break;
00553 case kSuperCrystal:
00554 bins += offBins / 25; break;
00555 default:
00556 break;
00557 }
00558 }
00559
00560 return bins;
00561 }
00562 case kSMMEM :
00563 {
00564 return _offset * 10;
00565 }
00566 default :
00567 break;
00568 }
00569
00570 return 0;
00571 }
00572
00573 std::string
00574 EcalDQMBinningService::channelName(uint32_t _rawId, BinningType _btype) const
00575 {
00576 std::stringstream ss;
00577
00578 switch(_btype){
00579 case kCrystal:
00580 {
00581
00582 EcalElectronicsId eid(_rawId);
00583 ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " CCU " << eid.towerId() << " strip " << eid.stripId() << " xtal " << eid.xtalId();
00584 if(eid.towerId() >= 69) break;
00585
00586 if(eid.dccId() >= kEBmLow + 1 && eid.dccId() <= kEBpHigh + 1){
00587 EBDetId ebid(getElectronicsMap()->getDetId(eid));
00588 ss << " (EB ieta " << std::showpos << ebid.ieta() << std::noshowpos << " iphi " << ebid.iphi() << ")";
00589 }
00590 else{
00591 EEDetId eeid(getElectronicsMap()->getDetId(eid));
00592 ss << " (EE ix " << eeid.ix() << " iy " << eeid.iy() << ")";
00593 }
00594 EcalTriggerElectronicsId teid(getElectronicsMap()->getTriggerElectronicsId(eid));
00595 ss << " (TCC " << teid.tccId() << " TT " << teid.ttId() << " pstrip " << teid.pseudoStripId() << " chan " << teid.channelId() << ")";
00596 break;
00597 }
00598 case kTriggerTower:
00599 {
00600
00601 EcalTriggerElectronicsId teid(_rawId);
00602 EcalElectronicsId eid(getElectronicsMap()->getElectronicsId(teid));
00603 ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " TCC " << teid.tccId() << " TT " << teid.ttId();
00604 break;
00605 }
00606 case kSuperCrystal:
00607 {
00608
00609 EcalElectronicsId eid(_rawId);
00610 ss << smName(eid.dccId()) << " DCC " << eid.dccId() << " CCU " << eid.towerId();
00611 if(eid.dccId() >= kEBmLow + 1 && eid.dccId() <= kEBpHigh + 1){
00612 EcalTrigTowerDetId ttid(EBDetId(getElectronicsMap()->getDetId(eid)).tower());
00613 ss << " (EBTT ieta " << std::showpos << ttid.ieta() << std::noshowpos << " iphi " << ttid.iphi() << ")";
00614 }
00615 else{
00616 EcalScDetId scid(EEDetId(getElectronicsMap()->getDetId(eid)).sc());
00617 ss << " (EESC ix " << scid.ix() << " iy " << scid.iy() << ")";
00618 }
00619 break;
00620 }
00621 case kTCC:
00622 {
00623
00624 int tccid(_rawId - nDCC);
00625 int dccid(getElectronicsMap()->DCCid(getElectronicsMap()->getTrigTowerDetId(tccid, 1)));
00626 ss << smName(dccid) << " TCC " << (_rawId - nDCC);
00627 break;
00628 }
00629 case kDCC:
00630 ss << smName(_rawId);
00631 break;
00632 default:
00633 break;
00634 }
00635
00636 return ss.str();
00637 }
00638
00639 uint32_t
00640 EcalDQMBinningService::idFromName(std::string const& _name) const
00641 {
00642 TString name(_name);
00643 TPRegexp re("(EB|EE)([+-][0-9][0-9])(?: TCC ([0-9]+)| DCC ([0-9]+) (CCU|TCC) ([0-9]+)(?: (?:TT|strip) ([0-9]+)(?: xtal ([0-9]+)|)|)|)");
00644
00645 uint32_t rawId(0);
00646
00647 TObjArray* matches(re.MatchS(name));
00648 if(matches->GetEntries() == 0) return 0;
00649 else if(matches->GetEntries() == 3){
00650 TString subdet(static_cast<TObjString*>(matches->At(1))->GetString());
00651 if(subdet == "EB"){
00652 int dccid(static_cast<TObjString*>(matches->At(2))->GetString().Atoi());
00653 unsigned offset(0);
00654 if(dccid < 0){
00655 dccid *= -1;
00656 offset = kEEmLow;
00657 }
00658 else offset = kEEpLow;
00659 rawId = (dccid + 2) % 9 + 1 + offset;
00660 }
00661 else{
00662 int dccid(static_cast<TObjString*>(matches->At(2))->GetString().Atoi());
00663 if(dccid < 0) dccid *= -1;
00664 else dccid += 18;
00665 rawId = kEBmLow + dccid;
00666 }
00667 }
00668 else if(matches->GetEntries() == 4)
00669 rawId = static_cast<TObjString*>(matches->At(3))->GetString().Atoi() + nDCC;
00670 else{
00671 TString subtype(static_cast<TObjString*>(matches->At(5))->GetString());
00672 if(subtype == "TCC"){
00673 int tccid(static_cast<TObjString*>(matches->At(6))->GetString().Atoi());
00674 int ttid(static_cast<TObjString*>(matches->At(7))->GetString().Atoi());
00675 rawId = EcalTriggerElectronicsId(tccid, ttid, 1, 1).rawId();
00676 }
00677 else{
00678 int dccid(static_cast<TObjString*>(matches->At(4))->GetString().Atoi());
00679 int towerid(static_cast<TObjString*>(matches->At(6))->GetString().Atoi());
00680 if(matches->GetEntries() == 7)
00681 rawId = EcalElectronicsId(dccid, towerid, 1, 1).rawId();
00682 else{
00683 int stripid(static_cast<TObjString*>(matches->At(7))->GetString().Atoi());
00684 int xtalid(static_cast<TObjString*>(matches->At(8))->GetString().Atoi());
00685 rawId = EcalElectronicsId(dccid, towerid, stripid, xtalid).rawId();
00686 }
00687 }
00688 }
00689
00690 delete matches;
00691
00692 return rawId;
00693 }