Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:25

0001 #include "Calibration/Tools/interface/EcalIndexingTools.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include <iostream>
0005 
0006 EcalIndexingTools* EcalIndexingTools::instance_ = nullptr;
0007 
0008 void EcalIndexingTools::setBinRange(
0009     int nBinsEta, double minEta, double maxEta, int nBinsEt, double minEt, double maxEt) {
0010   //  std::cout<< "[EcalIndexingTools::setBinRange] setting values "<< nBinsEta << " " << minEta << " " << maxEta << std::endl;
0011 
0012   totNumberOfBins_ = nBinsEta * nBinsEt;
0013 
0014   nBinsEt_ = nBinsEt;
0015   nBinsEta_ = nBinsEta;
0016 
0017   minEt_ = minEt;
0018   minEta_ = minEta;
0019   maxEt_ = maxEt;
0020   maxEta_ = maxEta;
0021 
0022   //  std::cout<< "[EcalIndexingTools::setBinRange] read back values: "<< nBinsEta_ << " " << minEta_ << " " << maxEta_ << std::endl;
0023 
0024   return;
0025 }
0026 
0027 int EcalIndexingTools::getProgressiveIndex(double myEta, double myEt) {
0028   std::cout << "minEt_ " << minEt_ << std::endl;
0029   std::cout << "minEta_ " << minEta_ << std::endl;
0030   std::cout << "maxEt_ " << maxEt_ << std::endl;
0031   std::cout << "maxEta_ " << maxEta_ << std::endl;
0032 
0033   ///INITIALIZE BOUNDARIES
0034 
0035   double BoundaryEt[100] = {-99.};
0036   double BoundaryEta[100] = {-99.};
0037 
0038   for (int i = 0; i < (nBinsEt_ + 1); i++) {
0039     BoundaryEt[i] = minEt_ + i * ((maxEt_ - minEt_) / (double)nBinsEt_);
0040     //    std::cout << "i " << i << " BoundaryEt[i] "<< BoundaryEt[i] <<std::endl;
0041   }
0042 
0043   for (int i = 0; i < (nBinsEta_ + 1); i++) {
0044     BoundaryEta[i] = minEta_ + i * ((maxEta_ - minEta_) / (double)nBinsEta_);
0045     //std::cout << "i " << i << " BoundaryEta[i] "<< BoundaryEta[i] <<std::endl;
0046   }
0047 
0048   ////FIND ETA BIN AND ET BIN, SEPARATELY
0049   int etBin(-1);
0050   int etaBin(-1);
0051 
0052   for (int i = 0; i < nBinsEta_; i++) {
0053     if (myEta > BoundaryEta[i] && myEta <= BoundaryEta[i + 1])
0054       etaBin = i;
0055   }
0056 
0057   for (int i = 0; i < nBinsEt_; i++) {
0058     if (myEt > BoundaryEt[i] && myEt <= BoundaryEt[i + 1])
0059       etBin = i;
0060   }
0061 
0062   // std::cout << " myEta "<< myEta << " myEt "<< myEt << " etaBin "<< etaBin << " etBin "<< etBin << std::endl;
0063 
0064   /////////////FIND UNIQUE PROGRESSIVE INDEX
0065 
0066   int in = etaBin * nBinsEta_ + etBin;
0067 
0068   //std::cout << "Progressive index " << in << std::endl;
0069 
0070   return in;
0071 }