BOSS 6.6.4.p03
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 ()
 
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 &p) const
 
virtual double pdf (const T &) const =0
 

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 21 of file EvtPdfSum.hh.

Constructor & Destructor Documentation

◆ EvtPdfSum() [1/2]

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

Definition at line 24 of file EvtPdfSum.hh.

24{}

Referenced by EvtPdfSum< T >::clone().

◆ EvtPdfSum() [2/2]

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

Definition at line 61 of file EvtPdfSum.hh.

62 : EvtPdf<T>(other)
63{
64 int i;
65 for(i = 0; i < other.nTerms(); i++) {
66 _c.push_back(other._c[i]);
67 _term.push_back(other._term[i]->clone());
68 }
69}
vector< double > _c
Definition: EvtPdfSum.hh:54
vector< EvtPdf< T > * > _term
Definition: EvtPdfSum.hh:55
Definition: EvtPdf.hh:57
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

◆ ~EvtPdfSum()

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

Definition at line 72 of file EvtPdfSum.hh.

73{
74 int i;
75 for(i = 0; i < _c.size(); i++) delete _term[i];
76}

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.

36 { _c.push_back(c); _term.push_back(pdf); }
virtual double pdf(const T &p) const
Definition: EvtPdfSum.hh:80
double c(int i) const
Definition: EvtPdfSum.hh:40

Referenced by EvtPto3PAmpFactory::processAmp().

◆ addTerm()

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

Definition at line 32 of file EvtPdfSum.hh.

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

Referenced by EvtBtoKD3P::decay().

◆ c()

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

Definition at line 40 of file EvtPdfSum.hh.

40{ return _c[i]; }

Referenced by EvtPdfSum< T >::addOwnedTerm(), and EvtPdfSum< T >::addTerm().

◆ clone()

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

Implements EvtPdf< T >.

Definition at line 27 of file EvtPdfSum.hh.

27{ return new EvtPdfSum(*this); }

◆ compute_integral() [1/2]

template<class T >
EvtValError EvtPdfSum< T >::compute_integral
virtual

Reimplemented from EvtPdf< T >.

Definition at line 93 of file EvtPdfSum.hh.

94{
95 int i;
96 EvtValError itg(0.0,0.0);
97 for(i=0;i<nTerms();i++) itg += _c[i]*_term[i]->getItg();
98 return itg;
99}
int nTerms() const
Definition: EvtPdfSum.hh:38
EvtValError getItg() const
Definition: EvtPdf.hh:83

◆ compute_integral() [2/2]

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

Reimplemented from EvtPdf< T >.

Definition at line 102 of file EvtPdfSum.hh.

103{
104 int i;
105 EvtValError itg(0.0,0.0);
106 for(i=0;i<nTerms();i++) itg += _c[i]*_term[i]->getItg(N);
107 return itg;
108}

◆ getPdf()

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

Definition at line 41 of file EvtPdfSum.hh.

41{ return _term[i]; }

◆ nTerms()

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

Definition at line 38 of file EvtPdfSum.hh.

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

◆ pdf()

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

Implements EvtPdf< T >.

Definition at line 80 of file EvtPdfSum.hh.

81{
82 double ret = 0.;
83 unsigned i;
84 for(i=0; i < _c.size(); i++) ret += _c[i] * _term[i]->evaluate(p);
85 return ret;
86}
double evaluate(const T &p) const
Definition: EvtPdf.hh:65

Referenced by EvtPdfSum< T >::addOwnedTerm(), and EvtPdfSum< T >::addTerm().

◆ randomPoint()

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

Reimplemented from EvtPdf< T >.

Definition at line 118 of file EvtPdfSum.hh.

119{
121
122 double max = _itg.value();
123 double rnd = EvtRandom::Flat(0,max);
124
125 double sum = 0.;
126 int i;
127 for(i = 0; i < nTerms(); i++) {
128 double itg = _term[i]->getItg().value();
129 sum += _c[i] * itg;
130 if(sum > rnd) break;
131 }
132
133 return _term[i]->randomPoint();
134}
EvtValError _itg
Definition: EvtPdfSum.hh:56
virtual EvtValError compute_integral() const
Definition: EvtPdfSum.hh:93
static double Flat()
Definition: EvtRandom.cc:73
int valueKnown() const
Definition: EvtValError.hh:30
double value() const
Definition: EvtValError.hh:31

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.

◆ _term

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

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