ATLAS Offline Software
eflowLookupExp.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * eflowLookupExp.h
7  *
8  * Created on: 20.08.2013
9  * Author: tlodd
10  */
11 
12 #ifndef EFLOWLOOKUPEXP_H_
13 #define EFLOWLOOKUPEXP_H_
14 
15 #include <vector>
16 #include <stdexcept>
17 #include <math.h>
18 #include <memory>
19 #include <mutex>
20 
23 public:
24  static const eflowLookupExp* getInstance(int nExpBins = 50, int nExpSubBins = 1000);
25 
26  //private:
27  eflowLookupExp(int nExpBins, int nExpSubBins) :
28  m_nExpBins(nExpBins), m_nExpSubBins(nExpSubBins), m_exp(nExpBins+1), m_subExp(nExpSubBins+1) {
29  /* Lookup table for the integer part of a number */
30  for (int i = 0; i <= nExpBins; ++i) {
31  m_exp[i] = exp(-i);
32  }
33  /* Lookup table for the fractional part of a number */
34  const double substep = 1./nExpSubBins;
35  for (int iSub = 0; iSub <= nExpSubBins; ++iSub){
36  m_subExp[iSub] = exp(-substep* iSub);
37  }
38  }
39 public:
41 
42  double evaluate(double x) const {
43  int iExpBin = (int) x;
44  int iSubBin(((x-iExpBin)*m_nExpSubBins));
45 
46  if (iExpBin > m_nExpBins){
47  return exp(-x);
48  }
49  return m_exp[iExpBin]*m_subExp[iSubBin];
50  }
51 
52 private:
55  std::vector<double> m_exp;
56  std::vector<double> m_subExp;
57 };
58 
59 
60 
61 #endif /* EFLOWLOOKUPEXP_H_ */
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eflowLookupExp::getInstance
static const eflowLookupExp * getInstance(int nExpBins=50, int nExpSubBins=1000)
Definition: eflowLookupExp.cxx:17
eflowLookupExp
Lookup-table based exponential function to save CPU time, which is used by eflowCellIntegrator.
Definition: eflowLookupExp.h:22
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
eflowLookupExp::m_exp
std::vector< double > m_exp
Definition: eflowLookupExp.h:55
x
#define x
eflowLookupExp::~eflowLookupExp
~eflowLookupExp()
Definition: eflowLookupExp.h:40
eflowLookupExp::evaluate
double evaluate(double x) const
Definition: eflowLookupExp.h:42
lumiFormat.i
int i
Definition: lumiFormat.py:85
eflowLookupExp::m_nExpSubBins
int m_nExpSubBins
Definition: eflowLookupExp.h:54
eflowLookupExp::m_nExpBins
int m_nExpBins
Definition: eflowLookupExp.h:53
eflowLookupExp::m_subExp
std::vector< double > m_subExp
Definition: eflowLookupExp.h:56
eflowLookupExp::eflowLookupExp
eflowLookupExp(int nExpBins, int nExpSubBins)
Definition: eflowLookupExp.h:27