![]() |
|
|||
File indexing completed on 2025-07-01 08:52:12
0001 // @(#)root/mathcore:$Id$ 0002 // Author: L. Moneta Fri Sep 22 15:06:47 2006 0003 0004 /********************************************************************** 0005 * * 0006 * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT * 0007 * * 0008 * * 0009 **********************************************************************/ 0010 // Header file for class TFoamSampler 0011 0012 #ifndef ROOT_TFoamSampler 0013 #define ROOT_TFoamSampler 0014 0015 0016 #include "Math/DistSampler.h" 0017 0018 0019 namespace ROOT { 0020 0021 namespace Fit { 0022 0023 class DataRange; 0024 class BinData; 0025 class UnBinData; 0026 } 0027 0028 namespace Math { 0029 } 0030 } 0031 0032 class TFoamIntegrand; 0033 0034 0035 class TRandom; 0036 class TF1; 0037 class TFoam; 0038 0039 class TFoamSampler : public ROOT::Math::DistSampler { 0040 0041 public: 0042 0043 /// default constructor 0044 TFoamSampler(); 0045 0046 0047 /// virtual destructor 0048 ~TFoamSampler() override; 0049 0050 0051 using DistSampler::SetFunction; 0052 0053 /// set the parent function distribution to use for random sampling (one dim case) 0054 void SetFunction(const ROOT::Math::IGenFunction & func) override { 0055 fFunc1D = &func; 0056 SetFunction<const ROOT::Math::IGenFunction>(func, 1); 0057 } 0058 0059 /// set the Function using a TF1 pointer 0060 void SetFunction(TF1 * pdf); 0061 0062 0063 /** 0064 initialize the generators with the default options 0065 */ 0066 bool Init(const char * = "") override; 0067 0068 /** 0069 initialize the generators with the given options 0070 */ 0071 bool Init(const ROOT::Math::DistSamplerOptions & opt ) override; 0072 0073 /** 0074 Set the random engine to be used 0075 Needs to be called before Init to have effect 0076 */ 0077 void SetRandom(TRandom * r) override; 0078 0079 /** 0080 Set the random seed for the TRandom instances used by the sampler 0081 classes 0082 Needs to be called before Init to have effect 0083 */ 0084 void SetSeed(unsigned int seed) override; 0085 0086 0087 /** 0088 Get the random engine used by the sampler 0089 */ 0090 TRandom * GetRandom() override; 0091 0092 0093 /** 0094 sample one event in multi-dimension by filling the given array 0095 return false if sampling failed 0096 */ 0097 bool Sample(double * x) override; 0098 0099 /** 0100 sample one bin given an estimated of the pdf in the bin 0101 (this can be function value at the center or its integral in the bin 0102 divided by the bin width) 0103 By default do not do random sample, just return the function values 0104 */ 0105 bool SampleBin(double prob, double & value, double *error = nullptr) override; 0106 0107 0108 0109 protected: 0110 0111 0112 private: 0113 0114 // bool fOneDim; // flag to indicate if the function is 1 dimension 0115 // bool fHasMode; // flag to indicate if a mode is set 0116 // bool fHasArea; // flag to indicate if a area is set 0117 // double fMode; // mode of dist 0118 // double fArea; // area of dist 0119 const ROOT::Math::IGenFunction * fFunc1D; // 1D function pointer 0120 TFoam * fFoam; // foam engine class 0121 TFoamIntegrand * fFoamDist; // foam distribution interface 0122 0123 //ClassDefOverride(TFoamSampler,1) //Distribution sampler class based on FOAM 0124 0125 }; 0126 0127 0128 0129 #endif /* ROOT_TFoamSampler */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |