GooFit  v2.1.3
GooPdf.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <thrust/functional.h>
4 
6 #include <goofit/PdfBase.h>
8 
9 #ifdef ROOT_FOUND
10 class TH1D;
11 #endif
12 
13 namespace GooFit {
14 
15 enum class EvalFunc : size_t { Eval = 0, NLL, Prob, BinAvg, BinWithError, Chisq };
16 
17 constexpr const char *evalfunc_vals[]
18  = {"ptr_to_Eval", "ptr_to_NLL", "ptr_to_Prob", "ptr_to_BinAvg", "ptr_to_BinWithError", "ptr_to_Chisq"};
19 
20 constexpr const char *evalfunc_to_string(EvalFunc val) { return evalfunc_vals[static_cast<size_t>(val)]; }
21 
22 #ifdef SEPARABLE
23 
25 extern __constant__ fptype cudaArray[maxParams];
26 
29 extern __constant__ unsigned int paramIndices[maxParams];
30 
32 extern __constant__ fptype functorConstants[maxParams];
33 
34 extern __constant__ fptype normalisationFactors[maxParams];
35 
36 extern __device__ void *device_function_table[200];
37 extern void *host_function_table[200];
38 extern unsigned int num_device_functions;
39 extern std::map<void *, int> functionAddressToDeviceIndexMap;
40 #endif
41 
42 __device__ int dev_powi(int base, int exp); // Implemented in SmoothHistogramPdf.
43 void *getMetricPointer(std::string name);
44 
46 typedef fptype (*device_function_ptr)(fptype *, fptype *, unsigned int *);
47 
48 typedef fptype (*device_metric_ptr)(fptype, fptype *, unsigned int);
49 
50 extern void *host_fcn_ptr;
51 
52 __device__ fptype callFunction(fptype *eventAddress, unsigned int functionIdx, unsigned int paramIdx);
53 
54 class GooPdf : public PdfBase {
55  public:
56  using PdfBase::PdfBase;
57 
58  double calculateNLL() const override;
59 
65  __host__ std::vector<fptype> evaluateAtPoints(Observable var);
66 
68  __host__ fptype normalize() const override;
69 
71  __host__ fptype normalise() const { return normalize(); }
72 
73  __host__ virtual fptype integrate(fptype lo, fptype hi) const { return 0; }
74  __host__ bool hasAnalyticIntegral() const override { return false; }
75  __host__ fptype getValue(EvalFunc evalfunc = EvalFunc::Eval);
76 
78  __host__ std::vector<std::vector<fptype>> getCompProbsAtDataPoints();
79 
81  __host__ UnbinnedDataSet makeGrid();
82 
83  __host__ void initialize(std::vector<unsigned int> pindices, void *dev_functionPtr = host_fcn_ptr);
84  __host__ void scan(Observable var, std::vector<fptype> &values);
85  __host__ void setFitControl(std::shared_ptr<FitControl> fc) override;
86  __host__ virtual void setMetrics();
87  __host__ void setParameterConstantness(bool constant = true);
88 
89  __host__ virtual void transformGrid(fptype *host_output);
90  static __host__ int findFunctionIdx(void *dev_functionPtr);
91  __host__ void setDebugMask(int mask, bool setSpecific = true) const;
92 
93 #ifdef ROOT_FOUND
94  __host__ TH1D *plotToROOT(Observable var, double normFactor = 1, std::string name = "");
96 #endif
97 
98  protected:
99  __host__ virtual double sumOfNll(int numVars) const;
100  std::shared_ptr<MetricTaker> logger;
101 
102  private:
103 };
104 
105 } // namespace GooFit
constexpr const char * evalfunc_to_string(EvalFunc val)
Definition: GooPdf.h:20
void normalize(TH1F *dat)
double fptype
constexpr const char * evalfunc_vals[]
Definition: GooPdf.h:18
__host__ fptype normalise() const
Just in case you are British and the previous spelling is offensive.
Definition: GooPdf.h:71
Special class for observables. Used in DataSets.
Definition: Variable.h:109
fptype(* device_function_ptr)(fptype *, fptype *, unsigned int *)
Pass event, parameters, index into parameters.
Definition: GooPdf.h:46
__host__ bool hasAnalyticIntegral() const override
Definition: GooPdf.h:74
fptype(* device_metric_ptr)(fptype, fptype *, unsigned int)
Definition: GooPdf.h:48
PdfBase(std::string n, Args... args)
Definition: PdfBase.h:72
virtual __host__ fptype integrate(fptype lo, fptype hi) const
Definition: GooPdf.h:73
const int maxParams
Definition: PdfBase.h:38
std::shared_ptr< MetricTaker > logger
Definition: GooPdf.h:100
void * getMetricPointer(std::string name)
__device__ fptype callFunction(fptype *eventAddress, unsigned int functionIdx, unsigned int paramIdx)
EvalFunc
Definition: GooPdf.h:15
__device__ int dev_powi(int base, int exp)
void * host_fcn_ptr