BOSS 8.0.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]

◆ EvtPdf() [2/2]

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

Definition at line 60 of file EvtPdf.hh.

60: _itg( other._itg ) {}
EvtValError _itg
Definition EvtPdf.hh:114

◆ ~EvtPdf()

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

Definition at line 61 of file EvtPdf.hh.

61{}

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 281 of file EvtPdf.hh.

282 {
284 EvtPdfDiv<T> pdfdiv( *this, pc );
286 pred.compute_max( iter( gen, nMax ), iter( gen ), factor );
288}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)

Referenced by findGenEff().

◆ 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 91 of file EvtPdf.hh.

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

Referenced by compute_integral(), getItg(), and getItg().

◆ compute_integral() [2/2]

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

Reimplemented in EvtPdfSum< T >.

Definition at line 98 of file EvtPdf.hh.

98{ return compute_integral(); }

Referenced by compute_integral().

◆ compute_mc_integral()

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

Definition at line 234 of file EvtPdf.hh.

234 {
235 assert( N > 0 );
236
238 EvtPdfDiv<T> pdfdiv( *this, pc );
240
244
245 double sum = 0.;
246 double sum2 = 0.;
247 while ( !( begin == end ) )
248 {
249
250 double value = pdfdiv.evaluate( *begin++ );
251 sum += value;
252 sum2 += value * value;
253 }
254
256 if ( N > 0 )
257 {
258 double av = sum / ( (double)N );
259 if ( N > 1 )
260 {
261 double dev2 = ( sum2 - av * av * N ) / ( (double)( N - 1 ) );
262 // Due to numerical precision dev2 may sometimes be negative
263 if ( dev2 < 0. ) dev2 = 0.;
264 double error = sqrt( dev2 / ( (double)N ) );
265 x = EvtValError( av, error );
266 }
267 else x = EvtValError( av );
268 }
269 _itg = x * pc.getItg();
270 return _itg;
271}
double evaluate(const T &p) const
Definition EvtPdf.hh:64
EvtValError getItg() const
Definition EvtPdf.hh:82

◆ evaluate()

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

Definition at line 64 of file EvtPdf.hh.

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

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

◆ findGenEff()

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

Definition at line 224 of file EvtPdf.hh.

224 {
225 assert( N > 0 || nFindMax > 0 );
227 int i;
228 for ( i = 0; i < N; i++ ) gen();
229 double eff = double( gen.getPassed() ) / double( gen.getTried() );
230 double err = sqrt( double( gen.getPassed() ) ) / double( gen.getTried() );
231 return EvtValError( eff, err );
232}
EvtPredGen< EvtPdfGen< T >, EvtPdfPred< T > > accRejGen(const EvtPdf< T > &pc, int nMax, double factor=1.)
Definition EvtPdf.hh:281

◆ findMax()

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

Definition at line 215 of file EvtPdf.hh.

215 {
216 EvtPdfPred<T> pred( *this );
218 pred.compute_max( iter( gen, N ), iter( gen ) );
219 EvtPdfMax<T> p = pred.getMax();
220 return p;
221}

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

◆ getItg() [1/2]

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

Definition at line 82 of file EvtPdf.hh.

82 {
83 if ( !_itg.valueKnown() ) _itg = compute_integral();
84 return _itg;
85 }

Referenced by EvtPdfSum< T >::compute_integral(), EvtPdfSum< T >::compute_integral(), and compute_mc_integral().

◆ getItg() [2/2]

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

Definition at line 86 of file EvtPdf.hh.

86 {
87 if ( !_itg.valueKnown() ) _itg = compute_integral( N );
88 return _itg;
89 }

◆ 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 273 of file EvtPdf.hh.

273 {
274 printf( "Function defined for analytic PDFs only\n" );
275 assert( 0 );
276 T temp;
277 return temp;
278}

◆ setItg()

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

Definition at line 80 of file EvtPdf.hh.

80{ _itg = itg; }

Member Data Documentation

◆ _itg

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

Definition at line 114 of file EvtPdf.hh.

Referenced by compute_mc_integral(), EvtPdf(), getItg(), getItg(), and setItg().


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