#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 () |
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 |
Definition at line 21 of file EvtPdfSum.hh.
Definition at line 61 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_term, genRecEmupikp::i, and EvtCyclic3::other().
00062 : EvtPdf<T>(other) 00063 { 00064 int i; 00065 for(i = 0; i < other.nTerms(); i++) { 00066 _c.push_back(other._c[i]); 00067 _term.push_back(other._term[i]->clone()); 00068 } 00069 }
Definition at line 72 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_term, and genRecEmupikp::i.
EvtPredGen< EvtPdfGen< T >, EvtPdfPred< T > > EvtPdf< T >::accRejGen | ( | const EvtPdf< T > & | pc, | |
int | nMax, | |||
double | factor = 1. | |||
) | [inherited] |
Definition at line 301 of file EvtPdf.hh.
References EvtPdfPred< T >::compute_max(), and iter().
Referenced by EvtPdf< T >::findGenEff().
00302 { 00303 EvtPdfGen<T> gen(pc); 00304 EvtPdfDiv<T> pdfdiv(*this,pc); 00305 EvtPdfPred<T> pred(pdfdiv); 00306 pred.compute_max(iter(gen,nMax),iter(gen),factor); 00307 return EvtPredGen<EvtPdfGen<T>,EvtPdfPred<T> >(gen,pred); 00308 }
double EvtPdfSum< T >::c | ( | int | i | ) | const [inline] |
Implements EvtPdf< T >.
Definition at line 27 of file EvtPdfSum.hh.
00027 { return new EvtPdfSum(*this); }
EvtValError EvtPdfSum< T >::compute_integral | ( | int | N | ) | const [virtual] |
Reimplemented from EvtPdf< T >.
Definition at line 102 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_term, EvtPdf< T >::getItg(), genRecEmupikp::i, and EvtPdfSum< T >::nTerms().
00103 { 00104 int i; 00105 EvtValError itg(0.0,0.0); 00106 for(i=0;i<nTerms();i++) itg += _c[i]*_term[i]->getItg(N); 00107 return itg; 00108 }
EvtValError EvtPdfSum< T >::compute_integral | ( | ) | const [virtual] |
Reimplemented from EvtPdf< T >.
Definition at line 93 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_term, EvtPdf< T >::getItg(), genRecEmupikp::i, and EvtPdfSum< T >::nTerms().
Referenced by EvtPdfSum< T >::randomPoint().
00094 { 00095 int i; 00096 EvtValError itg(0.0,0.0); 00097 for(i=0;i<nTerms();i++) itg += _c[i]*_term[i]->getItg(); 00098 return itg; 00099 }
EvtValError EvtPdf< T >::compute_mc_integral | ( | const EvtPdf< T > & | pc, | |
int | N | |||
) | [inherited] |
Definition at line 253 of file EvtPdf.hh.
References EvtPdf< T >::_itg, deljobs::end, ers::error, EvtPdf< T >::evaluate(), EvtPdf< T >::getItg(), iter(), and x.
00254 { 00255 assert(N > 0); 00256 00257 EvtValError otherItg = pc.getItg(); 00258 EvtPdfDiv<T> pdfdiv(*this,pc); 00259 EvtPdfUnary<T> unary(pdfdiv); 00260 00261 EvtPdfGen<T> gen(pc); 00262 EvtStreamInputIterator<T> begin = iter(gen,N); 00263 EvtStreamInputIterator<T> end; 00264 00265 double sum = 0.; 00266 double sum2 = 0.; 00267 while(!(begin == end)) { 00268 00269 double value = pdfdiv.evaluate(*begin++); 00270 sum += value; 00271 sum2 += value*value; 00272 } 00273 00274 EvtValError x; 00275 if(N > 0) { 00276 double av = sum/((double) N); 00277 if(N > 1) { 00278 double dev2 = (sum2 - av*av*N)/((double) (N - 1)); 00279 // Due to numerical precision dev2 may sometimes be negative 00280 if(dev2 < 0.) dev2 = 0.; 00281 double error = sqrt(dev2/((double) N)); 00282 x = EvtValError(av,error); 00283 } 00284 else x = EvtValError(av); 00285 } 00286 _itg = x * pc.getItg(); 00287 return _itg; 00288 }
double EvtPdf< T >::evaluate | ( | const T & | p | ) | const [inline, inherited] |
Definition at line 65 of file EvtPdf.hh.
Referenced by EvtPdf< T >::compute_mc_integral(), EvtIntervalDecayAmp< EvtDalitzPoint >::decay(), EvtBtoKD3P::decay(), EvtRelBreitWignerBarrierFact::getRandMass(), and EvtPdfSum< T >::pdf().
00065 { 00066 if(p.isValid()) return pdf(p); 00067 else return 0.; 00068 }
EvtValError EvtPdf< T >::findGenEff | ( | const EvtPdf< T > & | pc, | |
int | N, | |||
int | nFindMax | |||
) | [inherited] |
Definition at line 241 of file EvtPdf.hh.
References EvtPdf< T >::accRejGen(), showlog::err, EvtPredGen< Generator, Predicate >::getPassed(), EvtPredGen< Generator, Predicate >::getTried(), and genRecEmupikp::i.
00242 { 00243 assert(N > 0 || nFindMax > 0); 00244 EvtPredGen<EvtPdfGen<T>,EvtPdfPred<T> > gen = accRejGen(pc,nFindMax); 00245 int i; 00246 for(i=0;i<N;i++) gen(); 00247 double eff = double(gen.getPassed())/double(gen.getTried()); 00248 double err = sqrt(double(gen.getPassed()))/double(gen.getTried()); 00249 return EvtValError(eff,err); 00250 }
Definition at line 230 of file EvtPdf.hh.
References EvtPdfPred< T >::compute_max(), EvtPdfPred< T >::getMax(), and iter().
Referenced by EvtIntervalDecayAmp< EvtDalitzPoint >::initProbMax().
00231 { 00232 EvtPdfPred<T> pred(*this); 00233 EvtPdfGen<T> gen(pc); 00234 pred.compute_max(iter(gen,N),iter(gen)); 00235 EvtPdfMax<T> p = pred.getMax(); 00236 return p; 00237 }
EvtValError EvtPdf< T >::getItg | ( | int | N | ) | const [inline, inherited] |
Definition at line 87 of file EvtPdf.hh.
00087 { 00088 if(!_itg.valueKnown()) _itg = compute_integral(N); 00089 return _itg; 00090 }
EvtValError EvtPdf< T >::getItg | ( | ) | const [inline, inherited] |
Definition at line 83 of file EvtPdf.hh.
Referenced by EvtPdfSum< T >::compute_integral(), EvtPdf< T >::compute_mc_integral(), and EvtPdfSum< T >::randomPoint().
00083 { 00084 if(!_itg.valueKnown()) _itg = compute_integral(); 00085 return _itg; 00086 }
int EvtPdfSum< T >::nTerms | ( | ) | const [inline] |
Definition at line 38 of file EvtPdfSum.hh.
Referenced by EvtPdfSum< T >::compute_integral(), and EvtPdfSum< T >::randomPoint().
00038 { return _term.size(); } // number of terms
double EvtPdfSum< T >::pdf | ( | const T & | p | ) | const [protected, virtual] |
Implements EvtPdf< T >.
Definition at line 80 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_term, EvtPdf< T >::evaluate(), and genRecEmupikp::i.
Referenced by EvtPdfSum< EvtDalitzPoint >::addOwnedTerm(), and EvtPdfSum< EvtDalitzPoint >::addTerm().
00081 { 00082 double ret = 0.; 00083 unsigned i; 00084 for(i=0; i < _c.size(); i++) ret += _c[i] * _term[i]->evaluate(p); 00085 return ret; 00086 }
T EvtPdfSum< T >::randomPoint | ( | ) | [virtual] |
Reimplemented from EvtPdf< T >.
Definition at line 118 of file EvtPdfSum.hh.
References EvtPdfSum< T >::_c, EvtPdfSum< T >::_itg, EvtPdfSum< T >::_term, EvtPdfSum< T >::compute_integral(), EvtRandom::Flat(), EvtPdf< T >::getItg(), genRecEmupikp::i, max, EvtPdfSum< T >::nTerms(), EvtValError::value(), and EvtValError::valueKnown().
Referenced by EvtIntervalDecayAmp< EvtDalitzPoint >::decay(), and EvtBtoKD3P::decay().
00119 { 00120 if(!_itg.valueKnown()) _itg = compute_integral(); 00121 00122 double max = _itg.value(); 00123 double rnd = EvtRandom::Flat(0,max); 00124 00125 double sum = 0.; 00126 int i; 00127 for(i = 0; i < nTerms(); i++) { 00128 double itg = _term[i]->getItg().value(); 00129 sum += _c[i] * itg; 00130 if(sum > rnd) break; 00131 } 00132 00133 return _term[i]->randomPoint(); 00134 }
void EvtPdf< T >::setItg | ( | EvtValError | itg | ) | [inline, inherited] |
Definition at line 54 of file EvtPdfSum.hh.
Referenced by EvtPdfSum< EvtDalitzPoint >::addOwnedTerm(), EvtPdfSum< EvtDalitzPoint >::addTerm(), EvtPdfSum< EvtDalitzPoint >::c(), EvtPdfSum< T >::compute_integral(), EvtPdfSum< T >::EvtPdfSum(), EvtPdfSum< T >::pdf(), EvtPdfSum< T >::randomPoint(), and EvtPdfSum< T >::~EvtPdfSum().
EvtValError EvtPdfSum< T >::_itg [mutable, protected] |
Reimplemented from EvtPdf< T >.
Definition at line 56 of file EvtPdfSum.hh.
Referenced by EvtPdfSum< T >::randomPoint().
Definition at line 55 of file EvtPdfSum.hh.
Referenced by EvtPdfSum< EvtDalitzPoint >::addOwnedTerm(), EvtPdfSum< EvtDalitzPoint >::addTerm(), EvtPdfSum< T >::compute_integral(), EvtPdfSum< T >::EvtPdfSum(), EvtPdfSum< EvtDalitzPoint >::getPdf(), EvtPdfSum< EvtDalitzPoint >::nTerms(), EvtPdfSum< T >::pdf(), EvtPdfSum< T >::randomPoint(), and EvtPdfSum< T >::~EvtPdfSum().