Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:36

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