BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtPdf< T > Class Template Referenceabstract

#include <EvtPdf.hh>

+ Inheritance diagram for EvtPdf< T >:

Public Member Functions

 EvtPdf ()
 
 EvtPdf (const EvtPdf &other)
 
virtual ~EvtPdf ()
 
virtual EvtPdf< T > * clone () const =0
 
double evaluate (const T &p) const
 
EvtPdfMax< T > findMax (const EvtPdf< T > &pc, int N)
 
EvtValError findGenEff (const EvtPdf< T > &pc, int N, int nFindMax)
 
void setItg (EvtValError itg)
 
EvtValError getItg () const
 
EvtValError getItg (int N) const
 
virtual EvtValError compute_integral () const
 
virtual EvtValError compute_integral (int N) const
 
EvtValError compute_mc_integral (const EvtPdf< T > &pc, int N)
 
EvtPredGen< EvtPdfGen< T >, EvtPdfPred< T > > accRejGen (const EvtPdf< T > &pc, int nMax, double factor=1.)
 
virtual T randomPoint ()
 

Protected Member Functions

virtual double pdf (const T &) const =0
 

Protected Attributes

EvtValError _itg
 

Detailed Description

template<class T>
class EvtPdf< T >

Definition at line 57 of file EvtPdf.hh.

Constructor & Destructor Documentation

◆ EvtPdf() [1/2]

template<class T >
EvtPdf< T >::EvtPdf ( )
inline

Definition at line 60 of file EvtPdf.hh.

60{}

◆ EvtPdf() [2/2]

template<class T >
EvtPdf< T >::EvtPdf ( const EvtPdf< T > &  other)
inline

Definition at line 61 of file EvtPdf.hh.

61: _itg(other._itg) {}
EvtValError _itg
Definition: EvtPdf.hh:111
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

◆ ~EvtPdf()

template<class T >
virtual EvtPdf< T >::~EvtPdf ( )
inlinevirtual

Definition at line 62 of file EvtPdf.hh.

62{}

Member Function Documentation

◆ accRejGen()

template<class T >
EvtPredGen< EvtPdfGen< T >, EvtPdfPred< T > > EvtPdf< T >::accRejGen ( const EvtPdf< T > &  pc,
int  nMax,
double  factor = 1. 
)

Definition at line 301 of file EvtPdf.hh.

302{
303 EvtPdfGen<T> gen(pc);
304 EvtPdfDiv<T> pdfdiv(*this,pc);
305 EvtPdfPred<T> pred(pdfdiv);
306 pred.compute_max(iter(gen,nMax),iter(gen),factor);
307 return EvtPredGen<EvtPdfGen<T>,EvtPdfPred<T> >(gen,pred);
308}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)

◆ clone()

◆ compute_integral() [1/2]

template<class T >
virtual EvtValError EvtPdf< T >::compute_integral ( ) const
inlinevirtual

Reimplemented in EvtIntegPdf1D, EvtIntervalFlatPdf, EvtPdfSum< T >, and EvtPdfSum< EvtDalitzPoint >.

Definition at line 92 of file EvtPdf.hh.

94 { printf("Analytic integration of PDF is not defined\n"); assert(0); return compute_integral();}
virtual EvtValError compute_integral() const
Definition: EvtPdf.hh:92

Referenced by EvtPdf< T >::compute_integral(), and EvtPdf< T >::getItg().

◆ compute_integral() [2/2]

template<class T >
virtual EvtValError EvtPdf< T >::compute_integral ( int  N) const
inlinevirtual

Reimplemented in EvtDalitzFlatPdf, EvtDalitzResPdf, EvtPdfSum< T >, and EvtPdfSum< EvtDalitzPoint >.

Definition at line 95 of file EvtPdf.hh.

95{ return compute_integral(); }

Referenced by EvtPdf< T >::compute_integral().

◆ compute_mc_integral()

template<class T >
EvtValError EvtPdf< T >::compute_mc_integral ( const EvtPdf< T > &  pc,
int  N 
)

Definition at line 253 of file EvtPdf.hh.

254{
255 assert(N > 0);
256
257 EvtValError otherItg = pc.getItg();
258 EvtPdfDiv<T> pdfdiv(*this,pc);
259 EvtPdfUnary<T> unary(pdfdiv);
260
261 EvtPdfGen<T> gen(pc);
262 EvtStreamInputIterator<T> begin = iter(gen,N);
264
265 double sum = 0.;
266 double sum2 = 0.;
267 while(!(begin == end)) {
268
269 double value = pdfdiv.evaluate(*begin++);
270 sum += value;
271 sum2 += value*value;
272 }
273
275 if(N > 0) {
276 double av = sum/((double) N);
277 if(N > 1) {
278 double dev2 = (sum2 - av*av*N)/((double) (N - 1));
279 // Due to numerical precision dev2 may sometimes be negative
280 if(dev2 < 0.) dev2 = 0.;
281 double error = sqrt(dev2/((double) N));
282 x = EvtValError(av,error);
283 }
284 else x = EvtValError(av);
285 }
286 _itg = x * pc.getItg();
287 return _itg;
288}
Double_t x[10]
EvtValError getItg() const
Definition: EvtPdf.hh:83
@ error
Definition: Core.h:24

◆ evaluate()

template<class T >
double EvtPdf< T >::evaluate ( const T &  p) const
inline

Definition at line 65 of file EvtPdf.hh.

65 {
66 if(p.isValid()) return pdf(p);
67 else return 0.;
68 }
virtual double pdf(const T &) const =0

Referenced by EvtPdf< T >::compute_mc_integral(), EvtBtoKD3P::decay(), EvtIntervalDecayAmp< T >::decay(), and EvtRelBreitWignerBarrierFact::getRandMass().

◆ findGenEff()

template<class T >
EvtValError EvtPdf< T >::findGenEff ( const EvtPdf< T > &  pc,
int  N,
int  nFindMax 
)

Definition at line 241 of file EvtPdf.hh.

242{
243 assert(N > 0 || nFindMax > 0);
245 int i;
246 for(i=0;i<N;i++) gen();
247 double eff = double(gen.getPassed())/double(gen.getTried());
248 double err = sqrt(double(gen.getPassed()))/double(gen.getTried());
249 return EvtValError(eff,err);
250}
EvtPredGen< EvtPdfGen< T >, EvtPdfPred< T > > accRejGen(const EvtPdf< T > &pc, int nMax, double factor=1.)
Definition: EvtPdf.hh:301
int getPassed() const
Definition: EvtPredGen.hh:65
int getTried() const
Definition: EvtPredGen.hh:64

◆ findMax()

template<class T >
EvtPdfMax< T > EvtPdf< T >::findMax ( const EvtPdf< T > &  pc,
int  N 
)

Definition at line 230 of file EvtPdf.hh.

231{
232 EvtPdfPred<T> pred(*this);
233 EvtPdfGen<T> gen(pc);
234 pred.compute_max(iter(gen,N),iter(gen));
235 EvtPdfMax<T> p = pred.getMax();
236 return p;
237}

Referenced by EvtIntervalDecayAmp< T >::initProbMax().

◆ getItg() [1/2]

template<class T >
EvtValError EvtPdf< T >::getItg ( ) const
inline

Definition at line 83 of file EvtPdf.hh.

83 {
85 return _itg;
86 }
int valueKnown() const
Definition: EvtValError.hh:30

Referenced by EvtPdf< T >::compute_mc_integral().

◆ getItg() [2/2]

template<class T >
EvtValError EvtPdf< T >::getItg ( int  N) const
inline

Definition at line 87 of file EvtPdf.hh.

87 {
89 return _itg;
90 }

◆ pdf()

template<class T >
virtual double EvtPdf< T >::pdf ( const T &  ) const
protectedpure virtual

◆ randomPoint()

template<class T >
T EvtPdf< T >::randomPoint
virtual

Reimplemented in EvtDalitzFlatPdf, EvtDalitzResPdf, EvtIntegPdf1D, EvtIntervalFlatPdf, EvtPdfSum< T >, and EvtPdfSum< EvtDalitzPoint >.

Definition at line 291 of file EvtPdf.hh.

292{
293 printf("Function defined for analytic PDFs only\n");
294 assert(0);
295 T temp;
296 return temp;
297}

◆ setItg()

template<class T >
void EvtPdf< T >::setItg ( EvtValError  itg)
inline

Definition at line 81 of file EvtPdf.hh.

81{_itg = itg; }

Member Data Documentation

◆ _itg

template<class T >
EvtValError EvtPdf< T >::_itg
mutableprotected

Definition at line 111 of file EvtPdf.hh.

Referenced by EvtPdf< T >::getItg(), and EvtPdf< T >::setItg().


The documentation for this class was generated from the following file: