CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Geometry/EcalMapping/src/ESElectronicsMapper.cc

Go to the documentation of this file.
00001 #include "Geometry/EcalMapping/interface/ESElectronicsMapper.h"
00002 
00003 ESElectronicsMapper::ESElectronicsMapper(const edm::ParameterSet& ps) {
00004 
00005   lookup_ = ps.getParameter<edm::FileInPath>("LookupTable");
00006 
00007   for (int i=0; i<2; ++i) 
00008     for (int j=0; j<2; ++j) 
00009       for (int k=0; k<40; ++k) 
00010         for (int m=0; m<40; ++m) {
00011           fed_[i][j][k][m] = -1; 
00012           kchip_[i][j][k][m] = -1;
00013         }
00014   
00015   // read in look-up table
00016   int nLines, z, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
00017   std::ifstream file;
00018   file.open(lookup_.fullPath().c_str());
00019   if( file.is_open() ) {
00020 
00021     file >> nLines;
00022 
00023     for (int i=0; i<nLines; ++i) {
00024       file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
00025       
00026       if (iz==-1) z = 2;
00027       else z = iz;
00028       
00029       fed_[z-1][ip-1][ix-1][iy-1] = fed;
00030       kchip_[z-1][ip-1][ix-1][iy-1] = kchip;
00031     }
00032 
00033   } else {
00034     std::cout<<"ESElectronicsMapper::ESElectronicsMapper : Look up table file can not be found in "<<lookup_.fullPath().c_str()<<std::endl;
00035   }
00036   
00037   // EE-ES FEDs mapping
00038   int eefed[18]  = {601, 602, 603, 604, 605, 606, 607, 608, 609, 646, 647, 648, 649, 650, 651, 652, 653, 654};
00039   int nesfed[18] = { 10,   7,   9,  10,   8,  10,   8,  10,   8,  10,   7,   8,   8,   8,   9,   8,  10,  10};
00040   int esfed[18][10] = {
00041     {520, 522, 523, 531, 532, 534, 535, 545, 546, 547},
00042     {520, 522, 523, 534, 535, 546, 547},
00043     {520, 522, 523, 524, 525, 534, 535, 537, 539},
00044     {520, 522, 523, 524, 525, 534, 535, 537, 539, 540},
00045     {522, 523, 524, 525, 535, 537, 539, 540},
00046     {524, 525, 528, 529, 530, 537, 539, 540, 541, 542},
00047     {528, 529, 530, 531, 532, 541, 542, 545},
00048     {528, 529, 530, 531, 532, 541, 542, 545, 546, 547},
00049     {529, 530, 531, 532, 542, 545, 546, 547},
00050     {548, 549, 551, 560, 561, 563, 564, 572, 573, 574},
00051     {548, 549, 560, 561, 563, 564, 574},
00052     {548, 549, 551, 553, 563, 564, 565, 566},
00053     {551, 553, 554, 563, 564, 565, 566, 568},
00054     {553, 554, 555, 556, 565, 566, 568, 570},
00055     {553, 554, 555, 556, 565, 566, 568, 570, 571},
00056     {553, 554, 555, 556, 557, 568, 570, 571},
00057     {555, 556, 557, 560, 561, 570, 571, 572, 573, 574},
00058     {548, 549, 557, 560, 561, 570, 571, 572, 573, 574}
00059   };
00060 
00061   for (int i=0; i<18; ++i) { // loop over EE feds
00062     std::vector<int> esFeds;
00063     for(int esFed=0; esFed<nesfed[i]; esFed++) esFeds.push_back(esfed[i][esFed]);
00064     ee_es_map_.insert( make_pair(eefed[i],esFeds));
00065   }
00066   
00067 }
00068 
00069 int ESElectronicsMapper::getFED(const ESDetId& id) { 
00070 
00071   int zside;
00072   if (id.zside()<0) zside = 2;
00073   else zside = id.zside();
00074 
00075   return fed_[zside-1][id.plane()-1][id.six()-1][id.siy()-1]; 
00076 } 
00077 
00078 int ESElectronicsMapper::getFED(int zside, int plane, int x, int y) { 
00079 
00080   return fed_[zside-1][plane-1][x-1][y-1]; 
00081 } 
00082 
00083 std::vector<int> ESElectronicsMapper::GetListofFEDs(const std::vector<int> eeFEDs) const {
00084   std::vector<int> esFEDs;
00085   GetListofFEDs(eeFEDs, esFEDs);
00086   return esFEDs;
00087 }
00088 
00089 void ESElectronicsMapper::GetListofFEDs(std::vector<int> eeFEDs, std::vector<int> & esFEDs) const {
00090 
00091   for (unsigned int i=0; i<eeFEDs.size(); ++i) {
00092     std::map< int, std::vector<int> >::const_iterator itr = ee_es_map_.find(eeFEDs[i]);
00093     if(itr == ee_es_map_.end()) continue; 
00094     std::vector<int> fed = itr->second;
00095     for (unsigned int j=0; j<fed.size(); ++j) {
00096       esFEDs.push_back(fed[j]);
00097     }
00098   }
00099   
00100   sort(esFEDs.begin(), esFEDs.end());
00101   std::vector<int>::iterator it = unique(esFEDs.begin(), esFEDs.end());
00102   esFEDs.erase(it, esFEDs.end());
00103 
00104 }
00105 
00106 int ESElectronicsMapper::getKCHIP(const ESDetId& id) { 
00107 
00108   int zside;
00109   if (id.zside()<0) zside = 2;
00110   else zside = id.zside();
00111 
00112   return kchip_[zside-1][id.plane()-1][id.six()-1][id.siy()-1]; 
00113 } 
00114 
00115 int ESElectronicsMapper::getKCHIP(int zside, int plane, int x, int y) { 
00116 
00117   return kchip_[zside-1][plane-1][x-1][y-1]; 
00118 }