BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtPdfSum< T > Class Template Reference

#include <EvtPdfSum.hh>

Inheritance diagram for EvtPdfSum< T >:

Public Member Functions

 EvtPdfSum ()
 EvtPdfSum (const EvtPdfSum< T > &other)
virtual ~EvtPdfSum ()
virtual EvtPdf< T > * clone () const
void addTerm (double c, const EvtPdf< T > &pdf)
void addOwnedTerm (double c, EvtPdf< T > *pdf)
int nTerms () const
double c (int i) const
EvtPdf< T > * getPdf (int i) const
virtual EvtValError compute_integral () const
virtual EvtValError compute_integral (int N) const
virtual T randomPoint ()
Public Member Functions inherited from EvtPdf< T >
 EvtPdf ()
 EvtPdf (const EvtPdf &other)
virtual ~EvtPdf ()
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
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.)

Protected Member Functions

virtual double pdf (const T &p) const

Protected Attributes

vector< double > _c
vector< EvtPdf< T > * > _term
EvtValError _itg
Protected Attributes inherited from EvtPdf< T >
EvtValError _itg

Detailed Description

template<class T>
class EvtPdfSum< T >

Definition at line 20 of file EvtPdfSum.hh.

Constructor & Destructor Documentation

◆ EvtPdfSum() [1/2]

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

Definition at line 22 of file EvtPdfSum.hh.

22{}

Referenced by clone(), and EvtPdfSum().

◆ EvtPdfSum() [2/2]

template<class T>
EvtPdfSum< T >::EvtPdfSum ( const EvtPdfSum< T > & other)

Definition at line 59 of file EvtPdfSum.hh.

59 : EvtPdf<T>( other ) {
60 int i;
61 for ( i = 0; i < other.nTerms(); i++ )
62 {
63 _c.push_back( other._c[i] );
64 _term.push_back( other._term[i]->clone() );
65 }
66}
vector< double > _c
Definition EvtPdfSum.hh:54
int nTerms() const
Definition EvtPdfSum.hh:40
vector< EvtPdf< T > * > _term
Definition EvtPdfSum.hh:55
EvtPdf()
Definition EvtPdf.hh:59

◆ ~EvtPdfSum()

template<class T>
EvtPdfSum< T >::~EvtPdfSum ( )
virtual

Definition at line 68 of file EvtPdfSum.hh.

68 {
69 int i;
70 for ( i = 0; i < _c.size(); i++ ) delete _term[i];
71}

Member Function Documentation

◆ addOwnedTerm()

template<class T>
void EvtPdfSum< T >::addOwnedTerm ( double c,
EvtPdf< T > * pdf )
inline

Definition at line 35 of file EvtPdfSum.hh.

35 {
36 _c.push_back( c );
37 _term.push_back( pdf );
38 }
virtual double pdf(const T &p) const
Definition EvtPdfSum.hh:73
double c(int i) const
Definition EvtPdfSum.hh:42

◆ addTerm()

template<class T>
void EvtPdfSum< T >::addTerm ( double c,
const EvtPdf< T > & pdf )
inline

Definition at line 29 of file EvtPdfSum.hh.

29 {
30 assert( c >= 0. );
31 _c.push_back( c );
32 _term.push_back( pdf.clone() );
33 }

Referenced by EvtBtoKD3P::decay().

◆ c()

template<class T>
double EvtPdfSum< T >::c ( int i) const
inline

Definition at line 42 of file EvtPdfSum.hh.

42{ return _c[i]; }

Referenced by addOwnedTerm(), and addTerm().

◆ clone()

template<class T>
virtual EvtPdf< T > * EvtPdfSum< T >::clone ( ) const
inlinevirtual

Implements EvtPdf< T >.

Definition at line 25 of file EvtPdfSum.hh.

25{ return new EvtPdfSum( *this ); }

◆ compute_integral() [1/2]

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

Reimplemented from EvtPdf< T >.

Definition at line 84 of file EvtPdfSum.hh.

84 {
85 int i;
86 EvtValError itg( 0.0, 0.0 );
87 for ( i = 0; i < nTerms(); i++ ) itg += _c[i] * _term[i]->getItg();
88 return itg;
89}
EvtValError getItg() const
Definition EvtPdf.hh:82

Referenced by randomPoint().

◆ compute_integral() [2/2]

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

Reimplemented from EvtPdf< T >.

Definition at line 91 of file EvtPdfSum.hh.

91 {
92 int i;
93 EvtValError itg( 0.0, 0.0 );
94 for ( i = 0; i < nTerms(); i++ ) itg += _c[i] * _term[i]->getItg( N );
95 return itg;
96}

◆ getPdf()

template<class T>
EvtPdf< T > * EvtPdfSum< T >::getPdf ( int i) const
inline

Definition at line 43 of file EvtPdfSum.hh.

43{ return _term[i]; }

◆ nTerms()

template<class T>
int EvtPdfSum< T >::nTerms ( ) const
inline

Definition at line 40 of file EvtPdfSum.hh.

40{ return _term.size(); } // number of terms

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

◆ pdf()

template<class T>
double EvtPdfSum< T >::pdf ( const T & p) const
protectedvirtual

Implements EvtPdf< T >.

Definition at line 73 of file EvtPdfSum.hh.

73 {
74 double ret = 0.;
75 unsigned i;
76 for ( i = 0; i < _c.size(); i++ ) ret += _c[i] * _term[i]->evaluate( p );
77 return ret;
78}
double evaluate(const T &p) const
Definition EvtPdf.hh:64

Referenced by addOwnedTerm(), and addTerm().

◆ randomPoint()

template<class T>
T EvtPdfSum< T >::randomPoint ( )
virtual

Reimplemented from EvtPdf< T >.

Definition at line 104 of file EvtPdfSum.hh.

104 {
105 if ( !_itg.valueKnown() ) _itg = compute_integral();
106
107 double max = _itg.value();
108 double rnd = EvtRandom::Flat( 0, max );
109
110 double sum = 0.;
111 int i;
112 for ( i = 0; i < nTerms(); i++ )
113 {
114 double itg = _term[i]->getItg().value();
115 sum += _c[i] * itg;
116 if ( sum > rnd ) break;
117 }
118
119 return _term[i]->randomPoint();
120}
EvtValError _itg
Definition EvtPdfSum.hh:56
virtual EvtValError compute_integral() const
Definition EvtPdfSum.hh:84
static double Flat()
Definition EvtRandom.cc:69

Referenced by EvtBtoKD3P::decay(), and EvtIntervalDecayAmp< T >::decay().

Member Data Documentation

◆ _c

template<class T>
vector<double> EvtPdfSum< T >::_c
protected

◆ _itg

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

Definition at line 56 of file EvtPdfSum.hh.

Referenced by randomPoint().

◆ _term

template<class T>
vector<EvtPdf<T>*> EvtPdfSum< T >::_term
protected

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