test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalIndexingTools.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 
7 
8 
9 void EcalIndexingTools::setBinRange(int nBinsEta, double minEta, double maxEta, int nBinsEt, double minEt, double maxEt){
10 
11  // std::cout<< "[EcalIndexingTools::setBinRange] setting values "<< nBinsEta << " " << minEta << " " << maxEta << std::endl;
12 
13  totNumberOfBins_ = nBinsEta*nBinsEt;
14 
15  nBinsEt_ = nBinsEt;
16  nBinsEta_ = nBinsEta;
17 
18  minEt_ = minEt;
19  minEta_ = minEta;
20  maxEt_ = maxEt;
21  maxEta_ = maxEta;
22 
23  // std::cout<< "[EcalIndexingTools::setBinRange] read back values: "<< nBinsEta_ << " " << minEta_ << " " << maxEta_ << std::endl;
24 
25  return;
26 
27 }
28 
29 
30 int EcalIndexingTools::getProgressiveIndex(double myEta, double myEt){
31 
32 
33  std::cout << "minEt_ " << minEt_ <<std::endl;
34  std::cout << "minEta_ " << minEta_ <<std::endl;
35  std::cout << "maxEt_ " << maxEt_ <<std::endl;
36  std::cout << "maxEta_ " << maxEta_ <<std::endl;
37 
39 
40  double BoundaryEt[100] = {-99.};
41  double BoundaryEta[100] = {-99.};
42 
43  for( int i = 0; i < ( nBinsEt_ + 1 ); i++ ){
44 
45  BoundaryEt[i] = minEt_ + i * ( (maxEt_ - minEt_)/ (double)nBinsEt_ );
46  // std::cout << "i " << i << " BoundaryEt[i] "<< BoundaryEt[i] <<std::endl;
47 
48  }
49 
50  for( int i = 0; i < ( nBinsEta_ + 1 ); i++ ){
51 
52  BoundaryEta[i] = minEta_ + i * ( (maxEta_ - minEta_)/ (double)nBinsEta_ );
53  //std::cout << "i " << i << " BoundaryEta[i] "<< BoundaryEta[i] <<std::endl;
54 
55  }
56 
58  int etBin(-1);
59  int etaBin(-1);
60 
61  for( int i = 0; i < nBinsEta_ ; i++ ){
62  if( myEta > BoundaryEta[i] &&
63  myEta <= BoundaryEta[i+1] )
64  etaBin=i;
65  }
66 
67  for( int i = 0; i < nBinsEt_ ; i++ ){
68  if( myEt > BoundaryEt[i] &&
69  myEt <= BoundaryEt[i+1] )
70  etBin=i;
71  }
72 
73  // std::cout << " myEta "<< myEta << " myEt "<< myEt << " etaBin "<< etaBin << " etBin "<< etBin << std::endl;
74 
76 
77  int in = etaBin * nBinsEta_ + etBin;
78 
79  //std::cout << "Progressive index " << in << std::endl;
80 
81  return in;
82 
83 }
84 
int i
Definition: DBlmapReader.cc:9
void setBinRange(int, double, double, int, double, double)
double maxEta
static EcalIndexingTools * instance_
int getProgressiveIndex(double, double)
tuple cout
Definition: gather_cfg.py:121