EvtPdfDiv< T > Class Template Reference

#include <EvtPdf.hh>

Inheritance diagram for EvtPdfDiv< T >:

EvtPdf< T > List of all members.

Public Member Functions

 EvtPdfDiv ()
 EvtPdfDiv (const EvtPdf< T > &theNum, const EvtPdf< T > &theDen)
 EvtPdfDiv (const EvtPdfDiv< T > &other)
virtual ~EvtPdfDiv ()
virtual EvtPdf< T > * clone () const
virtual double pdf (const T &p) const
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 Attributes

EvtValError _itg

Private Attributes

EvtPdf< T > * itsNum
EvtPdf< T > * itsDen

Detailed Description

template<class T>
class EvtPdfDiv< T >

Definition at line 200 of file EvtPdf.hh.


Constructor & Destructor Documentation

template<class T>
EvtPdfDiv< T >::EvtPdfDiv (  )  [inline]

Definition at line 203 of file EvtPdf.hh.

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

00203 : itsNum(0), itsDen(0) {}

template<class T>
EvtPdfDiv< T >::EvtPdfDiv ( const EvtPdf< T > &  theNum,
const EvtPdf< T > &  theDen 
) [inline]

Definition at line 204 of file EvtPdf.hh.

00205     : EvtPdf<T>(), itsNum(theNum.clone()), itsDen(theDen.clone())
00206   {}

template<class T>
EvtPdfDiv< T >::EvtPdfDiv ( const EvtPdfDiv< T > &  other  )  [inline]

Definition at line 207 of file EvtPdf.hh.

00208     : EvtPdf<T>(other), COPY_PTR(itsNum), COPY_PTR(itsDen)
00209   {} 

template<class T>
virtual EvtPdfDiv< T >::~EvtPdfDiv (  )  [inline, virtual]

Definition at line 210 of file EvtPdf.hh.

References EvtPdfDiv< T >::itsDen, and EvtPdfDiv< T >::itsNum.

00210 { delete itsNum; delete itsDen; }


Member Function Documentation

template<class T>
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 }

template<class T>
virtual EvtPdf<T>* EvtPdfDiv< T >::clone (  )  const [inline, virtual]

Implements EvtPdf< T >.

Definition at line 211 of file EvtPdf.hh.

References EvtPdfDiv< T >::EvtPdfDiv().

00212   { return new EvtPdfDiv(*this); }

template<class T>
virtual EvtValError EvtPdf< T >::compute_integral ( int  N  )  const [inline, virtual, inherited]

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

Definition at line 95 of file EvtPdf.hh.

00095 { return compute_integral(); }

template<class T>
virtual EvtValError EvtPdf< T >::compute_integral (  )  const [inline, virtual, inherited]

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

Definition at line 92 of file EvtPdf.hh.

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

00094   { printf("Analytic integration of PDF is not defined\n"); assert(0); return compute_integral();}

template<class T>
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 }

template<class T>
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   }

template<class T>
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 }

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

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 }

template<class T>
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   }

template<class T>
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   }

template<class T>
virtual double EvtPdfDiv< T >::pdf ( const T &  p  )  const [inline, virtual]

Implements EvtPdf< T >.

Definition at line 214 of file EvtPdf.hh.

References EvtPdfDiv< T >::itsDen, EvtPdfDiv< T >::itsNum, and num.

00215   {
00216     double num = itsNum->evaluate(p);
00217     double den = itsDen->evaluate(p);
00218     assert(den != 0);
00219     return num/den;
00220   }

template<class T>
T EvtPdf< T >::randomPoint (  )  [virtual, inherited]

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

Definition at line 291 of file EvtPdf.hh.

References T, and subSeperate::temp.

00292 {
00293   printf("Function defined for analytic PDFs only\n");
00294   assert(0);
00295   T temp;
00296   return temp;
00297 }

template<class T>
void EvtPdf< T >::setItg ( EvtValError  itg  )  [inline, inherited]

Definition at line 81 of file EvtPdf.hh.

00081 {_itg = itg; }


Member Data Documentation

template<class T>
EvtValError EvtPdf< T >::_itg [mutable, protected, inherited]

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

Definition at line 111 of file EvtPdf.hh.

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

template<class T>
EvtPdf<T>* EvtPdfDiv< T >::itsDen [private]

Definition at line 225 of file EvtPdf.hh.

Referenced by EvtPdfDiv< T >::pdf(), and EvtPdfDiv< T >::~EvtPdfDiv().

template<class T>
EvtPdf<T>* EvtPdfDiv< T >::itsNum [private]

Definition at line 224 of file EvtPdf.hh.

Referenced by EvtPdfDiv< T >::pdf(), and EvtPdfDiv< T >::~EvtPdfDiv().


Generated on Tue Nov 29 23:19:10 2016 for BOSS_7.0.2 by  doxygen 1.4.7