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