ATLAS Offline Software
CaloHadWeight.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //** Default Constructor
10  : m_nBinEta(0),
11  m_nBinSampling(0),
12  m_nBinLogEClus(0),
13  m_nBinLogEDensCell(0),
14  m_MinEta(0),
15  m_MinSampling(0),
16  m_MinLogEClus(0),
17  m_MinLogEDensCell(0),
18  m_MaxEta(0),
19  m_MaxSampling(0),
20  m_MaxLogEClus(0),
21  m_MaxLogEDensCell(0)
22 {
23 }
24 
25 
27  const int & nBinEta,
28  const float & MinEta,
29  const float & MaxEta,
30  const int & nBinSampling,
31  const int & MinSampling,
32  const int & MaxSampling,
33  const int & nBinLogEClus,
34  const float & MinLogEClus,
35  const float & MaxLogEClus,
36  const int & nBinLogEDensCell,
37  const float & MinLogEDensCell,
38  const float & MaxLogEDensCell
39  ) : m_nBinEta (nBinEta),
40  m_nBinSampling (nBinSampling),
41  m_nBinLogEClus (nBinLogEClus),
42  m_nBinLogEDensCell (nBinLogEDensCell),
43  m_MinEta (MinEta),
44  m_MinSampling (MinSampling),
45  m_MinLogEClus (MinLogEClus),
46  m_MinLogEDensCell (MinLogEDensCell),
47  m_MaxEta (MaxEta),
48  m_MaxSampling (MaxSampling),
49  m_MaxLogEClus (MaxLogEClus),
50  m_MaxLogEDensCell (MaxLogEDensCell)
51 {
53 }
54 
55 const struct CaloHadWeight::HadData * CaloHadWeight::getHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const
56 {
57  int iBin = getBin(eta,sampling,logEClus,logEDensCell);
58  if ( iBin > -1 && iBin < (int)m_data.size() )
59  return (& m_data[iBin]);
60  else
61  return nullptr;
62 }
63 
64 
65  // set methods
66 
67 void CaloHadWeight::setHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell, const struct HadData & theData) {
68 
69  const int iEtaSampling = getEtaSamplingBin(eta, sampling);
70  if ( iEtaSampling > -1 ) {
71  if ( m_indexEtaSampling[iEtaSampling] == -1 ) {
72  const int iFilledSamplings = m_data.size()/(m_nBinLogEClus*m_nBinLogEDensCell);
73  m_indexEtaSampling[iEtaSampling] = iFilledSamplings;
74  m_data.resize((iFilledSamplings+1)*(m_nBinLogEClus*m_nBinLogEDensCell));
75  }
76  const int iBin = getBin(eta,sampling,logEClus,logEDensCell);
77  if ( iBin > -1 ) {
78  m_data[iBin] = theData;
79  }
80  }
81 }
82 
83 
84 int CaloHadWeight::getEtaSamplingBin(const float & eta, const int & sampling) const
85 {
86  int iEta,iSampling;
87 
89  if ( iEta >= 0 && iEta < m_nBinEta ) {
90  iSampling = sampling-m_MinSampling;
91  if ( iSampling >= 0 && iSampling < m_nBinSampling ) {
92  return (iEta*m_nBinSampling+iSampling);
93  }
94  }
95  return (-1);
96 }
97 
98 int CaloHadWeight::getBin(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const
99 {
100  int iLogEClus,iLogEDensCell;
101 
102  const int iEtaSampling = getEtaSamplingBin(eta, sampling);
103  if ( iEtaSampling > -1 && m_indexEtaSampling[iEtaSampling] > -1 ) {
104  iLogEClus = (int)((logEClus-m_MinLogEClus)/(m_MaxLogEClus-m_MinLogEClus)*m_nBinLogEClus);
105  if ( iLogEClus >= 0 && iLogEClus < m_nBinLogEClus ) {
106  iLogEDensCell = (int)((logEDensCell-m_MinLogEDensCell)/(m_MaxLogEDensCell-m_MinLogEDensCell)*m_nBinLogEDensCell);
107  if ( iLogEDensCell >= 0 && iLogEDensCell < m_nBinLogEDensCell ) {
108  return (iLogEDensCell + m_nBinLogEDensCell *
109  (iLogEClus + m_nBinLogEClus *
110  m_indexEtaSampling[iEtaSampling]));
111  }
112  }
113  }
114  return -1;
115 }
116 
117 
CaloHadWeight::getBin
int getBin(const float &eta, const int &sampling, const float &logEClus, const float &logEDensCell) const
Definition: CaloHadWeight.cxx:98
CaloHadWeight::m_nBinSampling
int m_nBinSampling
Definition: CaloHadWeight.h:75
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloHadWeight::m_MaxLogEDensCell
float m_MaxLogEDensCell
Definition: CaloHadWeight.h:87
CaloHadWeight::HadData
Definition: CaloHadWeight.h:23
CaloHadWeight::CaloHadWeight
CaloHadWeight()
Definition: CaloHadWeight.cxx:9
CaloHadWeight::m_MinLogEClus
float m_MinLogEClus
Definition: CaloHadWeight.h:81
CaloHadWeight::setHadData
void setHadData(const float &eta, const int &sampling, const float &logEClus, const float &logEDensCell, const struct HadData &theData)
Definition: CaloHadWeight.cxx:67
CaloHadWeight::getHadData
const struct HadData * getHadData(const float &eta, const int &sampling, const float &logEClus, const float &logEDensCell) const
Definition: CaloHadWeight.cxx:55
CaloHadWeight::getEtaSamplingBin
int getEtaSamplingBin(const float &eta, const int &sampling) const
Definition: CaloHadWeight.cxx:84
CaloHadWeight::m_MaxEta
float m_MaxEta
Definition: CaloHadWeight.h:84
CaloHadWeight::m_MinLogEDensCell
float m_MinLogEDensCell
Definition: CaloHadWeight.h:82
CaloHadWeight::m_MinSampling
int m_MinSampling
Definition: CaloHadWeight.h:80
CaloHadWeight::m_indexEtaSampling
std::vector< int > m_indexEtaSampling
Definition: CaloHadWeight.h:89
CaloHadWeight.h
CaloHadWeight::m_MinEta
float m_MinEta
Definition: CaloHadWeight.h:79
CaloHadWeight::m_data
std::vector< struct HadData > m_data
Definition: CaloHadWeight.h:90
CaloHadWeight::m_MaxLogEClus
float m_MaxLogEClus
Definition: CaloHadWeight.h:86
CaloHadWeight::m_nBinEta
int m_nBinEta
Definition: CaloHadWeight.h:74
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:77
CaloHadWeight::m_nBinLogEClus
int m_nBinLogEClus
Definition: CaloHadWeight.h:76
CaloHadWeight::m_nBinLogEDensCell
int m_nBinLogEDensCell
Definition: CaloHadWeight.h:77