Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:05

0001 #include "Geometry/EcalMapping/interface/ESElectronicsMapper.h"
0002 
0003 ESElectronicsMapper::ESElectronicsMapper(const edm::ParameterSet& ps) {
0004   lookup_ = ps.getParameter<edm::FileInPath>("LookupTable");
0005 
0006   for (int i = 0; i < 2; ++i)
0007     for (int j = 0; j < 2; ++j)
0008       for (int k = 0; k < 40; ++k)
0009         for (int m = 0; m < 40; ++m) {
0010           fed_[i][j][k][m] = -1;
0011           kchip_[i][j][k][m] = -1;
0012         }
0013 
0014   // read in look-up table
0015   int nLines, z, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
0016   std::ifstream file;
0017   file.open(lookup_.fullPath().c_str());
0018   if (file.is_open()) {
0019     file >> nLines;
0020 
0021     for (int i = 0; i < nLines; ++i) {
0022       file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
0023 
0024       if (iz == -1)
0025         z = 2;
0026       else
0027         z = iz;
0028 
0029       fed_[z - 1][ip - 1][ix - 1][iy - 1] = fed;
0030       kchip_[z - 1][ip - 1][ix - 1][iy - 1] = kchip;
0031     }
0032 
0033   } else {
0034     std::cout << "ESElectronicsMapper::ESElectronicsMapper : Look up table file can not be found in "
0035               << lookup_.fullPath().c_str() << std::endl;
0036   }
0037 
0038   // EE-ES FEDs mapping
0039   int eefed[18] = {601, 602, 603, 604, 605, 606, 607, 608, 609, 646, 647, 648, 649, 650, 651, 652, 653, 654};
0040   int nesfed[18] = {10, 7, 9, 10, 8, 10, 8, 10, 8, 10, 7, 8, 8, 8, 9, 8, 10, 10};
0041   int esfed[18][10] = {{520, 522, 523, 531, 532, 534, 535, 545, 546, 547},
0042                        {520, 522, 523, 534, 535, 546, 547},
0043                        {520, 522, 523, 524, 525, 534, 535, 537, 539},
0044                        {520, 522, 523, 524, 525, 534, 535, 537, 539, 540},
0045                        {522, 523, 524, 525, 535, 537, 539, 540},
0046                        {524, 525, 528, 529, 530, 537, 539, 540, 541, 542},
0047                        {528, 529, 530, 531, 532, 541, 542, 545},
0048                        {528, 529, 530, 531, 532, 541, 542, 545, 546, 547},
0049                        {529, 530, 531, 532, 542, 545, 546, 547},
0050                        {548, 549, 551, 560, 561, 563, 564, 572, 573, 574},
0051                        {548, 549, 560, 561, 563, 564, 574},
0052                        {548, 549, 551, 553, 563, 564, 565, 566},
0053                        {551, 553, 554, 563, 564, 565, 566, 568},
0054                        {553, 554, 555, 556, 565, 566, 568, 570},
0055                        {553, 554, 555, 556, 565, 566, 568, 570, 571},
0056                        {553, 554, 555, 556, 557, 568, 570, 571},
0057                        {555, 556, 557, 560, 561, 570, 571, 572, 573, 574},
0058                        {548, 549, 557, 560, 561, 570, 571, 572, 573, 574}};
0059 
0060   for (int i = 0; i < 18; ++i) {  // loop over EE feds
0061     std::vector<int> esFeds;
0062     esFeds.reserve(nesfed[i]);
0063     for (int esFed = 0; esFed < nesfed[i]; esFed++)
0064       esFeds.emplace_back(esfed[i][esFed]);
0065     ee_es_map_.insert(make_pair(eefed[i], esFeds));
0066   }
0067 }
0068 
0069 int ESElectronicsMapper::getFED(const ESDetId& id) {
0070   int zside;
0071   if (id.zside() < 0)
0072     zside = 2;
0073   else
0074     zside = id.zside();
0075 
0076   return fed_[zside - 1][id.plane() - 1][id.six() - 1][id.siy() - 1];
0077 }
0078 
0079 int ESElectronicsMapper::getFED(int zside, int plane, int x, int y) { return fed_[zside - 1][plane - 1][x - 1][y - 1]; }
0080 
0081 std::vector<int> ESElectronicsMapper::GetListofFEDs(const std::vector<int>& eeFEDs) const {
0082   std::vector<int> esFEDs;
0083   GetListofFEDs(eeFEDs, esFEDs);
0084   return esFEDs;
0085 }
0086 
0087 void ESElectronicsMapper::GetListofFEDs(const std::vector<int>& eeFEDs, std::vector<int>& esFEDs) const {
0088   for (int eeFED : eeFEDs) {
0089     std::map<int, std::vector<int> >::const_iterator itr = ee_es_map_.find(eeFED);
0090     if (itr == ee_es_map_.end())
0091       continue;
0092     std::vector<int> fed = itr->second;
0093     for (int j : fed) {
0094       esFEDs.emplace_back(j);
0095     }
0096   }
0097 
0098   sort(esFEDs.begin(), esFEDs.end());
0099   std::vector<int>::iterator it = unique(esFEDs.begin(), esFEDs.end());
0100   esFEDs.erase(it, esFEDs.end());
0101 }
0102 
0103 int ESElectronicsMapper::getKCHIP(const ESDetId& id) {
0104   int zside;
0105   if (id.zside() < 0)
0106     zside = 2;
0107   else
0108     zside = id.zside();
0109 
0110   return kchip_[zside - 1][id.plane() - 1][id.six() - 1][id.siy() - 1];
0111 }
0112 
0113 int ESElectronicsMapper::getKCHIP(int zside, int plane, int x, int y) {
0114   return kchip_[zside - 1][plane - 1][x - 1][y - 1];
0115 }