00001
00002
00011 #include <sstream>
00012 #include <iomanip>
00013
00014 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00015 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00016
00017 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00018 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00019 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
00020 #include "DataFormats/EcalDetId/interface/EcalPnDiodeDetId.h"
00021 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
00022
00023 #include "FWCore/Framework/interface/ESHandle.h"
00024 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00025 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00026 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00027 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00028 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00029
00030 #include "DQM/EcalCommon/interface/Numbers.h"
00031
00032
00033
00034 const EcalElectronicsMapping* Numbers::map = 0;
00035 const EcalTrigTowerConstituentsMap* Numbers::mapTT = 0;
00036 const CaloGeometry *Numbers::geometry = 0;
00037
00038 std::vector<DetId> Numbers::crystalsTCC_[100*108];
00039 std::vector<DetId> Numbers::crystalsDCC_[100* 54];
00040
00041 bool Numbers::init = false;
00042
00043
00044
00045 void Numbers::initGeometry( const edm::EventSetup& setup, bool verbose ) {
00046
00047 if( Numbers::init ) return;
00048
00049 if ( verbose ) std::cout << "Initializing EcalElectronicsMapping ..." << std::endl;
00050
00051 Numbers::init = true;
00052
00053 edm::ESHandle<EcalElectronicsMapping> handle;
00054 setup.get<EcalMappingRcd>().get(handle);
00055 Numbers::map = handle.product();
00056
00057 edm::ESHandle<EcalTrigTowerConstituentsMap> handleTT;
00058 setup.get<IdealGeometryRecord>().get(handleTT);
00059 Numbers::mapTT = handleTT.product();
00060
00061 edm::ESHandle<CaloGeometry> handleGeom;
00062 setup.get<CaloGeometryRecord>().get(handleGeom);
00063 Numbers::geometry = handleGeom.product();
00064
00065 if ( verbose ) std::cout << "done." << std::endl;
00066
00067 }
00068
00069
00070
00071 int Numbers::iEB( const int ism ) throw( std::runtime_error ) {
00072
00073
00074 if( ism >= 1 && ism <= 18 ) return( -ism );
00075
00076
00077 if( ism >= 19 && ism <= 36 ) return( +ism - 18 );
00078
00079 std::ostringstream s;
00080 s << "Wrong SM id determination: iSM = " << ism;
00081 throw( std::runtime_error( s.str() ) );
00082
00083 }
00084
00085
00086
00087 std::string Numbers::sEB( const int ism ) {
00088
00089 int ieb = Numbers::iEB( ism );
00090
00091 std::ostringstream s;
00092 s << "EB" << std::setw(3) << std::setfill('0')
00093 << std::setiosflags( std::ios::showpos )
00094 << std::setiosflags( std::ios::internal )
00095 << ieb
00096 << std::resetiosflags( std::ios::showpos )
00097 << std::resetiosflags( std::ios::internal );
00098 return( s.str() );
00099
00100 }
00101
00102
00103
00104 int Numbers::iEE( const int ism ) throw( std::runtime_error ) {
00105
00106
00107 if( ism == 1 ) return( -7 );
00108 if( ism == 2 ) return( -8 );
00109 if( ism == 3 ) return( -9 );
00110 if( ism == 4 ) return( -1 );
00111 if( ism == 5 ) return( -2 );
00112 if( ism == 6 ) return( -3 );
00113 if( ism == 7 ) return( -4 );
00114 if( ism == 8 ) return( -5 );
00115 if( ism == 9 ) return( -6 );
00116
00117
00118 if( ism == 10 ) return( +7 );
00119 if( ism == 11 ) return( +8 );
00120 if( ism == 12 ) return( +9 );
00121 if( ism == 13 ) return( +1 );
00122 if( ism == 14 ) return( +2 );
00123 if( ism == 15 ) return( +3 );
00124 if( ism == 16 ) return( +4 );
00125 if( ism == 17 ) return( +5 );
00126 if( ism == 18 ) return( +6 );
00127
00128 std::ostringstream s;
00129 s << "Wrong SM id determination: iSM = " << ism;
00130 throw( std::runtime_error( s.str() ) );
00131
00132 }
00133
00134
00135
00136 EcalSubdetector Numbers::subDet( const EBDetId& id ) {
00137
00138 return( id.subdet() );
00139
00140 }
00141
00142
00143
00144 EcalSubdetector Numbers::subDet( const EEDetId& id ) {
00145
00146 return( id.subdet() );
00147
00148 }
00149
00150
00151
00152 EcalSubdetector Numbers::subDet( const EcalTrigTowerDetId& id ) {
00153
00154 return( id.subDet() );
00155
00156 }
00157
00158
00159
00160 EcalSubdetector Numbers::subDet( const EcalScDetId& id ) {
00161
00162 return( id.subdet() );
00163
00164 }
00165
00166
00167
00168 EcalSubdetector Numbers::subDet( const EcalElectronicsId& id ) {
00169
00170 return( id.subdet() );
00171
00172 }
00173
00174
00175
00176 EcalSubdetector Numbers::subDet( const EcalPnDiodeDetId& id ) {
00177
00178 return( (EcalSubdetector) id.iEcalSubDetectorId() );
00179
00180 }
00181
00182
00183
00184 EcalSubdetector Numbers::subDet( const EcalDCCHeaderBlock& id ) throw( std::runtime_error ) {
00185
00186 int idcc = id.id();
00187
00188
00189 if ( idcc >= 1 && idcc <= 9 ) return( EcalEndcap );
00190
00191
00192 if ( idcc >= 10 && idcc <= 45 ) return( EcalBarrel);
00193
00194
00195 if ( idcc >= 46 && idcc <= 54 ) return( EcalEndcap );
00196
00197 std::ostringstream s;
00198 s << "Wrong DCC id: dcc = " << idcc;
00199 throw( std::runtime_error( s.str() ) );
00200
00201 }
00202
00203
00204
00205 std::string Numbers::sEE( const int ism ) {
00206
00207 int iee = Numbers::iEE( ism );
00208
00209 std::ostringstream s;
00210 s << "EE" << std::setw(3) << std::setfill('0')
00211 << std::setiosflags( std::ios::showpos )
00212 << std::setiosflags( std::ios::internal )
00213 << iee
00214 << std::resetiosflags( std::ios::showpos )
00215 << std::resetiosflags( std::ios::internal );
00216 return( s.str() );
00217
00218 }
00219
00220
00221
00222 int Numbers::iSM( const int ism, const EcalSubdetector subdet ) throw( std::runtime_error ) {
00223
00224 if( subdet == EcalBarrel ) {
00225
00226
00227 if( ism >= 1 && ism <= 18 ) return( ism+18 );
00228
00229
00230 if( ism >= 19 && ism <= 36 ) return( ism-18 );
00231
00232 std::ostringstream s;
00233 s << "Wrong SM id: iSM = " << ism;
00234 throw( std::runtime_error( s.str() ) );
00235
00236 } else if( subdet == EcalEndcap ) {
00237
00238
00239 if( ism >= 1 && ism <= 9 ) return( ism+9 );
00240
00241
00242 if (ism >= 10 && ism <= 18 ) return( ism-9 );
00243
00244 std::ostringstream s;
00245 s << "Wrong SM id: iSM = " << ism;
00246 throw( std::runtime_error( s.str() ) );
00247
00248 } else {
00249
00250 std::ostringstream s;
00251 s << "Invalid subdetector: subdet = " << subdet;
00252 throw( std::runtime_error( s.str() ) );
00253
00254 }
00255
00256 }
00257
00258
00259
00260 int Numbers::iSM( const EBDetId& id ) throw( std::runtime_error ) {
00261
00262 if( Numbers::map ) {
00263
00264 const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
00265 int idcc = eid.dccId();
00266
00267
00268 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00269
00270 std::ostringstream s;
00271 s << "Wrong DCC id: dcc = " << idcc;
00272 throw( std::runtime_error( s.str() ) );
00273
00274 } else {
00275
00276 std::ostringstream s;
00277 s << "ECAL Geometry not available";
00278 throw( std::runtime_error( s.str() ) );
00279
00280 }
00281
00282 }
00283
00284
00285
00286 int Numbers::iSM( const EEDetId& id ) throw( std::runtime_error ) {
00287
00288 if( Numbers::map ) {
00289
00290 const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
00291 int idcc = eid.dccId();
00292
00293
00294 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00295
00296
00297 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00298
00299 std::ostringstream s;
00300 s << "Wrong DCC id: dcc = " << idcc;
00301 throw( std::runtime_error( s.str() ) );
00302
00303 } else {
00304
00305 std::ostringstream s;
00306 s << "ECAL Geometry not available";
00307 throw( std::runtime_error( s.str() ) );
00308
00309 }
00310
00311 }
00312
00313
00314
00315 int Numbers::iSM( const EcalTrigTowerDetId& id ) throw( std::runtime_error ) {
00316
00317 EcalSubdetector subdet = Numbers::subDet( id );
00318
00319 if( subdet == EcalBarrel ) {
00320
00321 if( Numbers::map ) {
00322
00323 int idcc = Numbers::map->DCCid(id);
00324
00325
00326 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00327
00328 std::ostringstream s;
00329 s << "Wrong DCC id: dcc = " << idcc;
00330 throw( std::runtime_error( s.str() ) );
00331
00332 } else {
00333
00334 std::ostringstream s;
00335 s << "ECAL Geometry not available";
00336 throw( std::runtime_error( s.str() ) );
00337
00338 }
00339
00340 } else if( subdet == EcalEndcap) {
00341
00342 if( Numbers::map ) {
00343
00344 int idcc = Numbers::map->DCCid(id);
00345
00346
00347 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00348
00349
00350 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00351
00352 std::ostringstream s;
00353 s << "Wrong DCC id: dcc = " << idcc;
00354 throw( std::runtime_error( s.str() ) );
00355
00356 } else {
00357
00358 std::ostringstream s;
00359 s << "ECAL Geometry not available";
00360 throw( std::runtime_error( s.str() ) );
00361
00362 }
00363
00364 } else {
00365
00366 std::ostringstream s;
00367 s << "Invalid subdetector: subdet = " << subdet;
00368 throw( std::runtime_error( s.str() ) );
00369
00370 }
00371
00372 }
00373
00374
00375
00376 int Numbers::iSM( const EcalElectronicsId& id ) throw( std::runtime_error ) {
00377
00378 int idcc = id.dccId();
00379
00380
00381 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00382
00383
00384 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00385
00386
00387 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00388
00389 std::ostringstream s;
00390 s << "Wrong DCC id: dcc = " << idcc;
00391 throw( std::runtime_error( s.str() ) );
00392
00393 }
00394
00395
00396
00397 int Numbers::iSM( const EcalPnDiodeDetId& id ) throw( std::runtime_error ) {
00398
00399 int idcc = id.iDCCId();
00400
00401
00402 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00403
00404
00405 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00406
00407
00408 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00409
00410 std::ostringstream s;
00411 s << "Wrong DCC id: dcc = " << idcc;
00412 throw( std::runtime_error( s.str() ) );
00413
00414 }
00415
00416
00417
00418 int Numbers::iSM( const EcalScDetId& id ) throw( std::runtime_error ) {
00419
00420 std::pair<int, int> dccsc = Numbers::map->getDCCandSC( id );
00421
00422 int idcc = dccsc.first;
00423
00424
00425 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00426
00427
00428 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00429
00430
00431 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00432
00433 std::ostringstream s;
00434 s << "Wrong DCC id: dcc = " << idcc;
00435 throw( std::runtime_error( s.str() ) );
00436
00437 }
00438
00439
00440
00441 int Numbers::iSM( const EcalDCCHeaderBlock& id, const EcalSubdetector subdet ) throw( std::runtime_error ) {
00442
00443 int idcc = id.id();
00444
00445
00446 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00447
00448
00449 if( idcc >= 10 && idcc <= 45 ) return( idcc - 9 );
00450
00451
00452 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00453
00454 std::ostringstream s;
00455 s << "Wrong DCC id: dcc = " << idcc;
00456 throw( std::runtime_error( s.str() ) );
00457
00458 }
00459
00460
00461
00462 int Numbers::iSC( const EcalScDetId& id ) throw( std::runtime_error ) {
00463
00464 std::pair<int, int> dccsc = Numbers::map->getDCCandSC( id );
00465
00466 return dccsc.second;
00467
00468 }
00469
00470
00471
00472 int Numbers::iSC( const int ism, const EcalSubdetector subdet, const int i1, const int i2 ) throw( std::runtime_error ) {
00473
00474 if( subdet == EcalBarrel ) {
00475
00476 int iet = 1 + ((i1-1)/5);
00477 int ipt = 1 + ((i2-1)/5);
00478
00479 return( (ipt-1) + 4*(iet-1) + 1 );
00480
00481 } else if( subdet == EcalEndcap ) {
00482
00483 int iz = 0;
00484
00485 if( ism >= 1 && ism <= 9 ) iz = -1;
00486 if( ism >= 10 && ism <= 18 ) iz = +1;
00487
00488 if( EEDetId::validDetId(i1, i2, iz) ) {
00489
00490 EEDetId id(i1, i2, iz, EEDetId::XYMODE);
00491
00492 if( Numbers::iSM( id ) != ism ) return( -1 );
00493
00494 if( Numbers::map ) {
00495
00496 const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
00497
00498 return( eid.towerId() );
00499
00500 } else {
00501
00502 std::ostringstream s;
00503 s << "ECAL Geometry not available";
00504 throw( std::runtime_error( s.str() ) );
00505
00506 }
00507
00508 } else {
00509
00510 return( -1 );
00511
00512 }
00513
00514 } else {
00515
00516 std::ostringstream s;
00517 s << "Invalid subdetector: subdet = " << subdet;
00518 throw( std::runtime_error( s.str() ) );
00519
00520 }
00521
00522 }
00523
00524
00525
00526 int Numbers::iTT( const int ism, const EcalSubdetector subdet, const int i1, const int i2 ) throw( std::runtime_error ) {
00527
00528 if( subdet == EcalBarrel ) {
00529
00530 return( Numbers::iSC(ism, subdet, i1, i2) );
00531
00532 } else if( subdet == EcalEndcap ) {
00533
00534 int iz = 0;
00535
00536 if( ism >= 1 && ism <= 9 ) iz = -1;
00537 if( ism >= 10 && ism <= 18 ) iz = +1;
00538
00539 if( EEDetId::validDetId(i1, i2, iz) ) {
00540
00541 EEDetId id(i1, i2, iz, EEDetId::XYMODE);
00542
00543 if( Numbers::iSM( id ) != ism ) return( -1 );
00544
00545 if( Numbers::mapTT ) {
00546
00547 const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
00548
00549 return( iTT(towid) );
00550
00551 } else {
00552
00553 std::ostringstream s;
00554 s << "ECAL Geometry not available";
00555 throw( std::runtime_error( s.str() ) );
00556
00557 }
00558
00559 } else {
00560
00561 return( -1 );
00562
00563 }
00564
00565 } else {
00566
00567 std::ostringstream s;
00568 s << "Invalid subdetector: subdet = " << subdet;
00569 throw( std::runtime_error( s.str() ) );
00570
00571 }
00572
00573 }
00574
00575
00576
00577 int Numbers::iTT( const EcalTrigTowerDetId& id ) throw( std::runtime_error ) {
00578
00579 EcalSubdetector subdet = Numbers::subDet( id );
00580
00581 if( subdet == EcalBarrel ) {
00582
00583 if( Numbers::map ) {
00584
00585 return( Numbers::map->iTT(id) );
00586
00587 } else {
00588
00589 std::ostringstream s;
00590 s << "ECAL Geometry not available";
00591 throw( std::runtime_error( s.str() ) );
00592
00593 }
00594
00595 } else if( subdet == EcalEndcap) {
00596
00597 if( Numbers::map ) {
00598
00599 return( Numbers::map->iTT(id) );
00600
00601 } else {
00602
00603 std::ostringstream s;
00604 s << "ECAL Geometry not available";
00605 throw( std::runtime_error( s.str() ) );
00606
00607 }
00608
00609 } else {
00610
00611 std::ostringstream s;
00612 s << "Invalid subdetector: subdet = " << subdet;
00613 throw( std::runtime_error( s.str() ) );
00614
00615 }
00616
00617 }
00618
00619
00620
00621 int Numbers::iTCC( const int ism, const EcalSubdetector subdet, const int i1, const int i2 ) throw( std::runtime_error ) {
00622
00623 if( subdet == EcalBarrel ) {
00624
00625 if( EBDetId::validDetId(i1, i2) ) {
00626
00627 EBDetId id = EBDetId(i1, i2, EBDetId::ETAPHIMODE);
00628
00629 if( Numbers::iSM( id ) != ism ) return( -1 );
00630
00631 if( Numbers::mapTT ) {
00632
00633 const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
00634
00635 return( Numbers::map->TCCid(towid) );
00636
00637 } else {
00638
00639 std::ostringstream s;
00640 s << "ECAL Geometry not available";
00641 throw( std::runtime_error( s.str() ) );
00642
00643 }
00644
00645 } else {
00646
00647 return( -1 );
00648
00649 }
00650
00651 } else if( subdet == EcalEndcap) {
00652
00653 int iz = 0;
00654
00655 if( ism >= 1 && ism <= 9 ) iz = -1;
00656 if( ism >= 10 && ism <= 18 ) iz = +1;
00657
00658 if( EEDetId::validDetId(i1, i2, iz) ) {
00659
00660 EEDetId id(i1, i2, iz, EEDetId::XYMODE);
00661
00662 if( Numbers::iSM( id ) != ism ) return( -1 );
00663
00664 if( Numbers::mapTT ) {
00665
00666 const EcalTrigTowerDetId towid = Numbers::mapTT->towerOf(id);
00667
00668 return( Numbers::map->TCCid(towid) );
00669
00670 } else {
00671
00672 std::ostringstream s;
00673 s << "ECAL Geometry not available";
00674 throw( std::runtime_error( s.str() ) );
00675
00676 }
00677
00678 } else {
00679
00680 return( -1 );
00681
00682 }
00683
00684 } else {
00685
00686 std::ostringstream s;
00687 s << "Invalid subdetector: subdet = " << subdet;
00688 throw( std::runtime_error( s.str() ) );
00689
00690 }
00691
00692 }
00693
00694
00695
00696 int Numbers::iTCC( const EcalTrigTowerDetId& id ) throw( std::runtime_error ) {
00697
00698 EcalSubdetector subdet = Numbers::subDet( id );
00699
00700 if( subdet == EcalBarrel ) {
00701
00702 if( Numbers::map ) {
00703
00704 return( Numbers::map->TCCid(id) );
00705
00706 } else {
00707
00708 std::ostringstream s;
00709 s << "ECAL Geometry not available";
00710 throw( std::runtime_error( s.str() ) );
00711
00712 }
00713
00714 } else if( subdet == EcalEndcap) {
00715
00716 if( Numbers::map ) {
00717
00718 return( Numbers::map->TCCid(id) );
00719
00720 } else {
00721
00722 std::ostringstream s;
00723 s << "ECAL Geometry not available";
00724 throw( std::runtime_error( s.str() ) );
00725
00726 }
00727
00728 } else {
00729
00730 std::ostringstream s;
00731 s << "Invalid subdetector: subdet = " << subdet;
00732 throw( std::runtime_error( s.str() ) );
00733
00734 }
00735
00736 }
00737
00738
00739
00740 std::vector<DetId>* Numbers::crystals( const EcalTrigTowerDetId& id ) throw( std::runtime_error ) {
00741
00742 if( Numbers::map ) {
00743
00744 int itcc = Numbers::map->TCCid(id);
00745 int itt = Numbers::map->iTT(id);
00746
00747 int index = 100*(itcc-1) + (itt-1);
00748
00749 if ( Numbers::crystalsTCC_[index].size() == 0 ) {
00750 Numbers::crystalsTCC_[index] = Numbers::map->ttConstituents( itcc, itt );
00751 }
00752
00753 return &(Numbers::crystalsTCC_[index]);
00754
00755 } else {
00756
00757 std::ostringstream s;
00758 s << "ECAL Geometry not available";
00759 throw( std::runtime_error( s.str() ) );
00760
00761 }
00762
00763 }
00764
00765
00766
00767 int Numbers::RtHalf(const EBDetId& id) {
00768
00769 int ic = id.ic();
00770 int ie = (ic-1)/20 + 1;
00771 int ip = (ic-1)%20 + 1;
00772
00773 if( ie > 5 && ip < 11 ) return 1;
00774
00775 return 0;
00776
00777 }
00778
00779
00780
00781 int Numbers::RtHalf(const EEDetId& id) {
00782
00783 int ix = id.ix();
00784
00785 int ism = Numbers::iSM( id );
00786
00787
00788 if ( ism == 8 && ix > 50 ) return 1;
00789
00790
00791 if ( ism == 17 && ix > 50 ) return 1;
00792
00793 return 0;
00794
00795 }
00796
00797
00798
00799 std::vector<DetId>* Numbers::crystals( const EcalElectronicsId& id ) throw( std::runtime_error ) {
00800
00801 if( Numbers::map ) {
00802
00803 int idcc = id.dccId();
00804 int isc = id.towerId();
00805
00806 return Numbers::crystals( idcc, isc );
00807
00808 } else {
00809
00810 std::ostringstream s;
00811 s << "ECAL Geometry not available";
00812 throw( std::runtime_error( s.str() ) );
00813
00814 }
00815
00816 }
00817
00818
00819
00820 std::vector<DetId>* Numbers::crystals( int idcc, int isc ) throw( std::runtime_error ) {
00821
00822 if( Numbers::map ) {
00823
00824 int index = 100*(idcc-1) + (isc-1);
00825
00826 if ( Numbers::crystalsDCC_[index].size() == 0 ) {
00827 Numbers::crystalsDCC_[index] = Numbers::map->dccTowerConstituents(idcc, isc);
00828 }
00829
00830 return &(Numbers::crystalsDCC_[index]);
00831
00832 } else {
00833
00834 std::ostringstream s;
00835 s << "ECAL Geometry not available";
00836 throw( std::runtime_error( s.str() ) );
00837
00838 }
00839
00840 }
00841
00842
00843
00844 const EcalScDetId Numbers::getEcalScDetId( const EEDetId& id ) throw( std::runtime_error ) {
00845
00846 if( Numbers::map ) {
00847
00848 const EcalElectronicsId& eid = Numbers::map->getElectronicsId(id);
00849
00850 int idcc = eid.dccId();
00851 int isc = eid.towerId();
00852
00853 const std::vector<EcalScDetId> ids = Numbers::map->getEcalScDetId( idcc, isc, true );
00854
00855 return ids.size() > 0 ? ids[0] : EcalScDetId();
00856
00857 } else {
00858
00859 std::ostringstream s;
00860 s << "ECAL Geometry not available";
00861 throw( std::runtime_error( s.str() ) );
00862
00863 }
00864
00865 }
00866
00867
00868
00869 int Numbers::indexEB( const int ism, const int ie, const int ip ) {
00870
00871 return( (ip-1) + 20*(ie-1) + 1 );
00872
00873 }
00874
00875
00876
00877 int Numbers::indexEE( const int ism, const int ix, const int iy ) {
00878
00879 int iz = 0;
00880
00881 if( ism >= 1 && ism <= 9 ) iz = -1;
00882 if( ism >= 10 && ism <= 18 ) iz = +1;
00883
00884 if( EEDetId::validDetId(ix, iy, iz) ) {
00885
00886 return( 1000*ix + iy );
00887
00888 } else {
00889
00890 return( -1 );
00891
00892 }
00893
00894 }
00895
00896
00897
00898 int Numbers::icEB( const int ism, const int ie, const int ip ) {
00899
00900 return( (ip-1) + 20*(ie-1) + 1 );
00901
00902 }
00903
00904
00905
00906 int Numbers::icEE( const int ism, const int ix, const int iy ) throw( std::runtime_error ) {
00907
00908 int iz = 0;
00909
00910 if( ism >= 1 && ism <= 9 ) iz = -1;
00911 if( ism >= 10 && ism <= 18 ) iz = +1;
00912
00913 if( EEDetId::validDetId(ix, iy, iz) ) {
00914
00915 EEDetId id(ix, iy, iz, EEDetId::XYMODE);
00916
00917 if( Numbers::iSM( id ) != ism ) return( -1 );
00918
00919 if( Numbers::map ) {
00920
00921 const EcalElectronicsId eid = Numbers::map->getElectronicsId(id);
00922
00923 int vfe = eid.towerId();
00924 int strip = eid.stripId();
00925 int channel = eid.xtalId();
00926
00927
00928 if( ism == 8 || ism == 17 ) {
00929 if( vfe > 17 ) vfe = vfe - 7;
00930 }
00931
00932 return ( (vfe-1)*25 + (strip-1)*5 + channel );
00933
00934 } else {
00935
00936 std::ostringstream s;
00937 s << "ECAL Geometry not available";
00938 throw( std::runtime_error( s.str() ) );
00939
00940 }
00941
00942 } else {
00943
00944 return( -1 );
00945
00946 }
00947
00948 }
00949
00950
00951
00952 int Numbers::ix0EE( const int ism ) {
00953
00954 if( ism == 1 || ism == 15 ) return( - 5 );
00955 if( ism == 2 || ism == 14 ) return( + 0 );
00956 if( ism == 3 || ism == 13 ) return( + 10 );
00957 if( ism == 4 || ism == 12 ) return( + 40 );
00958 if( ism == 5 || ism == 11 ) return( + 50 );
00959 if( ism == 6 || ism == 10 ) return( + 55 );
00960 if( ism == 7 || ism == 18 ) return( + 50 );
00961 if( ism == 8 || ism == 17 ) return( + 25 );
00962 if( ism == 9 || ism == 16 ) return( + 0 );
00963
00964 return( + 0 );
00965
00966 }
00967
00968
00969
00970 int Numbers::ix0EEm( const int ism ) {
00971
00972 switch( ism ){
00973 case 1: return -105;
00974 case 2: return -100;
00975 case 3: return -90;
00976 case 4: return -60;
00977 case 5: return -50;
00978 case 6: return -45;
00979 case 7: return -50;
00980 case 8: return -75;
00981 case 9: return -100;
00982 }
00983
00984 return ix0EE( ism );
00985 }
00986
00987 int Numbers::iy0EE( const int ism ) {
00988
00989 if( ism == 1 || ism == 10 ) return( + 20 );
00990 if( ism == 2 || ism == 11 ) return( + 45 );
00991 if( ism == 3 || ism == 12 ) return( + 55 );
00992 if( ism == 4 || ism == 13 ) return( + 55 );
00993 if( ism == 5 || ism == 14 ) return( + 45 );
00994 if( ism == 6 || ism == 15 ) return( + 20 );
00995 if( ism == 7 || ism == 16 ) return( + 0 );
00996 if( ism == 8 || ism == 17 ) return( - 5 );
00997 if( ism == 9 || ism == 18 ) return( + 0 );
00998
00999 return( + 0 );
01000
01001 }
01002
01003
01004
01005 bool Numbers::validEE( const int ism, const int ix, const int iy ) {
01006
01007 int iz = 0;
01008
01009 if( ism >= 1 && ism <= 9 ) iz = -1;
01010 if( ism >= 10 && ism <= 18 ) iz = +1;
01011
01012 if( EEDetId::validDetId(ix, iy, iz) ) {
01013
01014 EEDetId id(ix, iy, iz, EEDetId::XYMODE);
01015
01016 if( Numbers::iSM( id ) == ism ) return true;
01017
01018 }
01019
01020 return false;
01021
01022 }
01023
01024
01025
01026 bool Numbers::validEESc( const int ism, const int ix, const int iy ) {
01027
01028 int iz = 0;
01029
01030 if( ism >= 1 && ism <= 9 ) iz = -1;
01031 if( ism >= 10 && ism <= 18 ) iz = +1;
01032
01033 if( EcalScDetId::validDetId(ix, iy, iz) ) {
01034
01035 EcalScDetId id(ix, iy, iz);
01036
01037 if( Numbers::iSM( id ) == ism ) return true;
01038
01039 }
01040
01041 return false;
01042 }
01043
01044 const EcalElectronicsMapping* Numbers::getElectronicsMapping() throw( std::runtime_error ) {
01045
01046 if( Numbers::map ) {
01047
01048 return Numbers::map;
01049
01050 } else {
01051
01052 std::ostringstream s;
01053 s << "ECAL Geometry not available";
01054 throw( std::runtime_error( s.str() ) );
01055
01056 }
01057
01058 }
01059
01060 float Numbers::eta( const DetId &id )
01061 {
01062 const GlobalPoint& pos = geometry->getPosition(id);
01063 return pos.eta();
01064 }
01065
01066 float Numbers::phi( const DetId &id )
01067 {
01068 const GlobalPoint& pos = geometry->getPosition(id);
01069 return pos.phi();
01070 }
01071