ATLAS Offline Software
Loading...
Searching...
No Matches
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
23public:
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 }
39public:
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
52private:
55 std::vector<double> m_exp;
56 std::vector<double> m_subExp;
57};
58
59
60
61#endif /* EFLOWLOOKUPEXP_H_ */
#define x
double evaluate(double x) const
std::vector< double > m_subExp
static const eflowLookupExp * getInstance(int nExpBins=50, int nExpSubBins=1000)
eflowLookupExp(int nExpBins, int nExpSubBins)
std::vector< double > m_exp