CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Calibration/Tools/src/EcalIndexingTools.cc

Go to the documentation of this file.
00001 #include "Calibration/Tools/interface/EcalIndexingTools.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 
00004 #include <iostream>
00005 
00006 EcalIndexingTools* EcalIndexingTools::instance_ = 0;
00007  
00008 
00009 void EcalIndexingTools::setBinRange(int nBinsEta, double minEta, double maxEta, int nBinsEt, double minEt, double maxEt){
00010   
00011   //  std::cout<< "[EcalIndexingTools::setBinRange] setting values "<< nBinsEta << " " << minEta << " " << maxEta << std::endl; 
00012 
00013   totNumberOfBins_ = nBinsEta*nBinsEt;
00014   
00015   nBinsEt_ = nBinsEt;
00016   nBinsEta_ = nBinsEta;
00017   
00018   minEt_ = minEt;
00019   minEta_ = minEta;
00020   maxEt_ = maxEt;
00021   maxEta_ = maxEta;
00022   
00023   //  std::cout<< "[EcalIndexingTools::setBinRange] read back values: "<< nBinsEta_ << " " << minEta_ << " " << maxEta_ << std::endl; 
00024   
00025   return;
00026   
00027 }
00028 
00029 
00030 int EcalIndexingTools::getProgressiveIndex(double myEta, double myEt){
00031   
00032 
00033   std::cout << "minEt_ " << minEt_ <<std::endl;
00034   std::cout << "minEta_ " << minEta_ <<std::endl;
00035   std::cout << "maxEt_ " << maxEt_ <<std::endl;
00036   std::cout << "maxEta_ " << maxEta_ <<std::endl;
00037   
00039   
00040   double BoundaryEt[100] = {-99.};
00041   double BoundaryEta[100] = {-99.};
00042   
00043   for( int i = 0; i < ( nBinsEt_ + 1 ); i++ ){
00044     
00045     BoundaryEt[i] = minEt_ +  i * ( (maxEt_ - minEt_)/ (double)nBinsEt_ );
00046     //    std::cout << "i " << i << " BoundaryEt[i] "<< BoundaryEt[i] <<std::endl;
00047 
00048   }
00049   
00050   for( int i = 0; i < ( nBinsEta_ + 1 ); i++ ){
00051     
00052     BoundaryEta[i] = minEta_ +  i * ( (maxEta_ - minEta_)/ (double)nBinsEta_ );
00053     //std::cout << "i " << i << " BoundaryEta[i] "<< BoundaryEta[i] <<std::endl;
00054   
00055   }
00056   
00058   int etBin(-1);
00059   int etaBin(-1);
00060   
00061   for( int i = 0; i <  nBinsEta_ ; i++ ){
00062     if( myEta > BoundaryEta[i] && 
00063         myEta <= BoundaryEta[i+1] )
00064       etaBin=i;
00065   }
00066   
00067   for( int i = 0; i <  nBinsEt_ ; i++ ){
00068     if( myEt > BoundaryEt[i] && 
00069         myEt <= BoundaryEt[i+1] )
00070       etBin=i;
00071   }
00072 
00073   // std::cout << " myEta "<< myEta << " myEt "<< myEt << " etaBin "<< etaBin << " etBin "<< etBin << std::endl;
00074   
00076   
00077   int in =  etaBin * nBinsEta_ + etBin;
00078   
00079   //std::cout << "Progressive index " << in << std::endl;
00080 
00081   return in;
00082   
00083 }
00084