64 _mean(
"mean",
"Mean of Gaussian component", this, meanIn),
65 sigma(
"sigma",
"Width", this, sigmaIn),
66 rlife(
"rlife",
"Life time", this, rlifeIn),
67 _meanSF(
"meanSF",
"Scale factor for mean", this, meanSF),
68 ssf(
"ssf",
"Sigma Scale Factor", this, sigmaSF),
69 rsf(
"rsf",
"RLife Scale Factor", this, rlifeSF),
93 sigma(
"sigma",
"Width",this,_sigma),
94 rlife(
"rlife",
"Life time",this,_rlife),
98 _flip(
type==Flipped),_nlo(nlo), _flatSFInt(false), _asympInt(false)
119 sigma(
"sigma",
"Width",this,_sigma),
120 rlife(
"rlife",
"Life time",this,_rlife),
122 ssf(
"ssf",
"Sigma Scale Factor",this,_rsSF),
123 rsf(
"rsf",
"RLife Scale Factor",this,_rsSF),
124 _flip(
type==Flipped),
149 sigma(
"sigma",
"Width",this,_sigma),
150 rlife(
"rlife",
"Life time",this,_rlife),
152 ssf(
"ssf",
"Sigma Scale Factor",this,_sigmaSF),
153 rsf(
"rsf",
"RLife Scale Factor",this,_rlifeSF),
154 _flip(
type==Flipped),
165 _mean(
"mean", this, other._mean),
167 rlife(
"rlife",this,other.rlife),
168 _meanSF(
"meanSf", this, other._meanSF),
169 ssf(
"ssf",this,other.ssf),
170 rsf(
"rsf",this,other.rsf),
173 _flatSFInt(other._flatSFInt),
174 _asympInt(other._asympInt)
211double logErfC(
double xx)
218 ans=log(t)+(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+t*(-0.18628806+
219 t*(0.27886807+t*(-1.13520398+t*(1.48851587+t*(-0.82215223+t*0.17087277)))))))));
221 ans=log(2.0-t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+t*(-0.18628806+
222 t*(0.27886807+t*(-1.13520398+t*(1.48851587+t*(-0.82215223+t*0.17087277))))))))));
234 static double rootpi=
sqrt(
atan2(0.,-1.));
235 std::complex<double> z(swt*
c,u+
c);
236 std::complex<double> zc(u+
c,-swt*
c);
237 std::complex<double> zsq= z*z;
238 std::complex<double>
v= -zsq - u*u;
240 return std::exp(
v)*(-std::exp(zsq)/(zc*rootpi) + 1.)*2.;
245std::complex<double>
evalCerf(
double swt,
double u,
double c)
247 std::complex<double> z(swt*
c,u+
c);
254inline double evalCerfRe(
double u,
double c) {
255 double expArg = u*2*
c+
c*
c ;
259 return exp(expArg+logErfC(u+
c));
271 static double root2(sqrt(2.)) ;
276 double fsign =
_flip?-1:1 ;
285 if (dGamma==0) basisType =
expBasis;
290 if (
verboseEval()>2) cout <<
"RooGExpModel::evaluate(" <<
GetName() <<
") 1st form" << endl ;
292 double expArg = sig*sig/(2*rtau*rtau) + fsign*(
x -
_mean*
_meanSF)/rtau ;
300 result = 1/(2*rtau) * exp(expArg + logErfC(sig/(root2*rtau) + fsign*(
x -
_mean*
_meanSF)/(root2*sig))) ;
320 if (
verboseEval()>2) cout <<
"RooGExpModel::evaluate(" <<
GetName() <<
") 2nd form" << endl ;
328 if (
verboseEval()>2) cout <<
"RooGExpModel::evaluate(" <<
GetName() <<
") 3d form tau=" << tau << endl ;
337 double wt = omega *tau ;
339 if (
verboseEval()>2) cout <<
"RooGExpModel::evaluate(" <<
GetName() <<
") 4th form omega = "
340 << omega <<
", tau = " << tau << endl ;
342 if (wt==0.)
return result ;
352 <<
") 5th form omega = " << omega <<
", tau = " << tau << endl ;
366 <<
") 6th form = " << dgamma <<
", tau = " << tau << endl;
371 double tau1 = 1/(1/tau-dgamma/2) ;
372 double tau2 = 1/(1/tau+dgamma/2) ;
386 <<
") 7th form = " << dgamma <<
", tau = " << tau << endl;
391 double tau1 = 1/(1/tau-dgamma/2) ;
392 double tau2 = 1/(1/tau+dgamma/2) ;
409 static double root2(sqrt(2.)) ;
413 double c1= sig/(root2*tau);
414 double u1=
s1/(2*
c1);
416 double c2= sig/(root2*rtau);
417 double u2= fsign*s2/(2*
c2) ;
420 std::complex<double> eins(1,0);
421 std::complex<double> k(1/tau,sign*omega);
424 return (evalCerf(-sign*omega*tau,u1,
c1)+std::complex<double>(evalCerfRe(u2,
c2),0)*fsign*sign) / (eins + k*fsign*sign*rtau) ;
435 static double root2(sqrt(2.)) ;
439 double c1= sig/(root2*tau);
440 double u1=
s1/(2*
c1);
442 double c2= sig/(root2*rtau);
443 double u2= fsign*s2/(2*
c2) ;
448 return (evalCerfRe(u1,
c1)+evalCerfRe(u2,
c2)*fsign*sign) / (eins + k*fsign*sign*rtau) ;
458 static double root2(sqrt(2.)) ;
459 static double root2pi(sqrt(2*atan2(0.,-1.))) ;
460 static double rootpi(sqrt(atan2(0.,-1.)));
463 double xp(
x - _mean*_meanSF) ;
472 if ((sign<0)&&(std::abs(tau-rtau)<tau/260)) {
474 double MeanTau=0.5*(tau+rtau);
475 if (std::abs(xp/MeanTau)>300) {
479 cFly=1./(MeanTau*MeanTau*root2pi) *
480 exp(-(-xp/MeanTau-sig*sig/(2*MeanTau*MeanTau)))
481 *(sig*exp(-1/(2*sig*sig)*
TMath::Power((sig*sig/MeanTau+xp),2))
482 -(sig*sig/MeanTau+xp)*(rootpi/root2)*
RooMath::erfc(sig/(root2*MeanTau)+xp/(root2*sig)));
486 double a=sig/(root2*MeanTau)+xp/(root2*sig);
487 cFly += 1./(MeanTau*MeanTau)
488 *exp(-(-xp/MeanTau-sig*sig/(2*MeanTau*MeanTau)))
490 (exp(-
a*
a)*(sig/MeanTau*root2/rootpi
491 -(4*
a*sig*sig)/(2*rootpi*MeanTau*MeanTau)
492 +(-4/rootpi+8*
a*
a/rootpi)/6
494 +2/rootpi*(sig*sig/(MeanTau*MeanTau)+xp/MeanTau)*
495 (sig/(root2*MeanTau)-
a*(sig*sig)/(2*MeanTau*MeanTau))
496 +2/rootpi*((3*sig*sig)/(2*MeanTau*MeanTau)+xp/MeanTau+
497 0.5*
TMath::Power(sig*sig/(MeanTau*MeanTau)+xp/MeanTau,2))*sig/(root2*MeanTau))
498 -(2*sig*sig/(MeanTau*MeanTau)+xp/MeanTau+(sig*sig/(MeanTau*MeanTau)+xp/MeanTau)*
499 (3*sig*sig/(2*MeanTau*MeanTau)+xp/MeanTau)
505 double expArg1 = sig*sig/(2*tau*tau)-sign*xp/tau ;
506 double expArg2 = sig*sig/(2*rtau*rtau)+xp/rtau ;
508 double term1, term2 ;
510 term1 = exp(expArg1) *
RooMath::erfc(sig/(root2*tau)-sign*xp/(root2*sig)) ;
512 term1 = exp(expArg1+logErfC(sig/(root2*tau)-sign*xp/(root2*sig))) ; ;
515 term2 = exp(expArg2) *
RooMath::erfc(sig/(root2*rtau)+xp/(root2*sig)) ;
517 term2 = exp(expArg2+logErfC(sig/(root2*rtau)+xp/(root2*sig))) ; ;
520 cFly=(term1+sign*term2)/(2*(tau+sign*rtau));
538double RooGExpModel::calcCoshConv(double sign, double tau, double dgamma, double sig, double rtau, double fsign) const
542 static double root2(sqrt(2.)) ;
543 static double root2pi(sqrt(2*atan2(0.,-1.))) ;
544 static double rootpi(sqrt(atan2(0.,-1.)));
545 double tau1 = 1/(1/tau-dgamma/2);
546 double tau2 = 1/(1/tau+dgamma/2);
554 xp *= fsign ; // modified FMV,08/13/03
555 sign *= fsign ; // modified FMV,08/13/03
557 cFly=tau1*(exp(sig*sig/(2*tau1*tau1)-sign*xp/tau1)
558 *RooMath::erfc(sig/(root2*tau1)-sign*xp/(root2*sig))
559 +sign*exp(sig*sig/(2*rtau*rtau)+xp/rtau)
560 *RooMath::erfc(sig/(root2*rtau)+xp/(root2*sig)))/(2*(tau1+sign*rtau))
561 +tau2*(exp(sig*sig/(2*tau2*tau2)-sign*xp/tau2)
562 *RooMath::erfc(sig/(root2*tau2)-sign*xp/(root2*sig))
563 +sign*exp(sig*sig/(2*rtau*rtau)+xp/rtau)
564 *RooMath::erfc(sig/(root2*rtau)+xp/(root2*sig)))/(2*(tau2+sign*rtau));;
573double RooGExpModel::calcSinhConv(double sign, double sign1, double sign2, double tau, double dgamma, double sig, double rtau, double fsign) const
575 static double root2(sqrt(2.)) ;
576 static double root2pi(sqrt(2*atan2(0.,-1.))) ;
577 static double rootpi(sqrt(atan2(0.,-1.)));
578 double tau1 = 1/(1/tau-dgamma/2);
579 double tau2 = 1/(1/tau+dgamma/2);
588 xp *= fsign ; // modified FMV,08/13/03
589 sign1 *= fsign ; // modified FMV,08/13/03
590 sign2 *= fsign ; // modified FMV,08/13/03
592 cFly=sign1*tau1*(exp(sig*sig/(2*tau1*tau1)-sign*xp/tau1)
593 *RooMath::erfc(sig/(root2*tau1)-sign*xp/(root2*sig))
594 +sign*exp(sig*sig/(2*rtau*rtau)+xp/rtau)
595 *RooMath::erfc(sig/(root2*rtau)+xp/(root2*sig)))/(2*(tau1+sign*rtau))
596 +sign2*tau2*(exp(sig*sig/(2*tau2*tau2)-sign*xp/tau2)
597 *RooMath::erfc(sig/(root2*tau2)-sign*xp/(root2*sig))
598 +sign*exp(sig*sig/(2*rtau*rtau)+xp/rtau)
599 *RooMath::erfc(sig/(root2*rtau)+xp/(root2*sig)))/(2*(tau2+sign*rtau));;
650 static double root2 = sqrt(2.) ;
668 if (dGamma==0) basisType =
expBasis;
670 double fsign =
_flip?-1:1 ;
676 if (
verboseEval()>0) cout <<
"RooGExpModel::analyticalIntegral(" <<
GetName() <<
") 1st form" << endl ;
682 double c = sig/(root2*rtau) ;
683 double umin = xpmin/(2*
c) ;
684 double umax = xpmax/(2*
c) ;
702 if (
verboseEval()>0) cout <<
"RooGExpModel::analyticalIntegral(" <<
GetName() <<
") 2nd form" << endl ;
719 double wt = omega * tau ;
721 if (
verboseEval()>0) cout <<
"RooGExpModel::analyticalIntegral(" <<
GetName() <<
") 4th form omega = "
722 << omega <<
", tau = " << tau << endl ;
725 if (wt==0)
return result ;
738 <<
") 5th form omega = " << omega <<
", tau = " << tau << endl ;
755 <<
") 6th form dgamma = " << dgamma <<
", tau = " << tau << endl ;
756 double tau1 = 1/(1/tau-dgamma/2);
757 double tau2 = 1/(1/tau+dgamma/2);
774 <<
") 6th form dgamma = " << dgamma <<
", tau = " << tau << endl ;
776 double tau1 = 1/(1/tau-dgamma/2);
777 double tau2 = 1/(1/tau+dgamma/2);
803 double sig,
double rtau,
double fsign,
const char* rangeName)
const
805 static double root2(sqrt(2.)) ;
809 double c1= sig/(root2*tau);
810 double umin1= smin1/(2*
c1);
811 double umax1= smax1/(2*
c1);
814 double c2= sig/(root2*rtau);
815 double umin2= smin2/(2*
c2) ;
816 double umax2= smax2/(2*
c2) ;
818 std::complex<double> eins(1,0);
819 std::complex<double> k(1/tau,sign*omega);
820 std::complex<double> term1 =
evalCerfInt(sign,-sign*omega*tau, tau, -sign*umin1, -sign*umax1,
c1);
822 std::complex<double> term2 = std::complex<double>(
evalCerfInt(-fsign, rtau, fsign*umin2, fsign*umax2,
c2)*fsign*sign,0);
823 return (term1+term2)/(eins + k*fsign*sign*rtau) ;
832 static double root2(sqrt(2.)) ;
836 double c1= sig/(root2*tau);
837 double umin1= smin1/(2*
c1);
838 double umax1= smax1/(2*
c1);
841 double c2= sig/(root2*rtau);
842 double umin2= smin2/(2*
c2) ;
843 double umax2= smax2/(2*
c2) ;
847 double term1 =
evalCerfInt(sign, tau, -sign*umin1, -sign*umax1,
c1);
848 double term2 =
evalCerfInt(-fsign, rtau, fsign*umin2, fsign*umax2,
c2)*fsign*sign;
851 if (std::abs(tau-rtau)<1
e-10 && std::abs(term1+term2)<1
e-10) {
852 cout <<
"epsilon method" << endl ;
856 return (term1+term2)/(eins + k*fsign*sign*rtau) ;
864 std::complex<double> diff;
866 diff = std::complex<double>(2,0) ;
870 return std::complex<double>(tau/(1.+wt*wt),0)*std::complex<double>(1,wt)*diff;
882 if ((umin<-8 && umax>8)||(umax<-8 && umin>8)) {
896 if (
matchArgs(directVars,generateVars,
x))
return 1 ;
910 xgen = xgau + (
rlife*
rsf)*log(xexp);
912 xgen = xgau - (
rlife*
rsf)*log(xexp);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static int verboseEval()
Return global level of verbosity for p.d.f. evaluations.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooArgSet is a container object that can hold multiple RooAbsArg objects.
The RooGExpModel is a RooResolutionModel implementation that models a resolution function that is the...
std::complex< double > evalCerfInt(double sign, double wt, double tau, double umin, double umax, double c) const
std::complex< double > calcSinConv(double sign, double sig, double tau, double omega, double rtau, double fsign) const
double calcDecayConv(double sign, double tau, double sig, double rtau, double fsign) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
void generateEvent(Int_t code) override
Interface for generation of an event using the algorithm corresponding to the specified code.
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
std::complex< double > calcSinConvNorm(double sign, double tau, double omega, double sig, double rtau, double fsign, const char *rangeName) const
old code (asymptotic normalization only) std::complex<double> z(1/tau,sign*omega); return z*2/(omega*...
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
~RooGExpModel() override
Destructor.
Int_t basisCode(const char *name) const override
static std::complex< double > erfc(const std::complex< double > z)
complex erfc function
static std::complex< double > erf(const std::complex< double > z)
complex erf function
static std::complex< double > faddeeva_fast(std::complex< double > z)
evaluate Faddeeva function for complex argument (fast version)
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
RooRealConstant provides static functions to create and keep track of RooRealVar constants.
RooRealVar represents a variable that can be changed from the outside.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
Int_t _basisCode
Identifier code for selected basis function.
RooAbsRealLValue & convVar() const
Return the convolution variable of the resolution model.
const RooFormulaVar & basis() const
RooTemplateProxy< RooAbsRealLValue > x
Dependent/convolution variable.
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
const T & arg() const
Return reference to object held in proxy.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
const char * GetName() const override
Returns name of object.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
RVec< PromoteTypes< T0, T1 > > atan2(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > exp(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
__roohost__ __roodevice__ STD::complex< double > evalCerfApprox(double _x, double u, double c)
use the approximation: erf(z) = exp(-z*z)/(STD::sqrt(pi)*z) to explicitly cancel the divergent exp(y*...
__roohost__ __roodevice__ STD::complex< double > evalCerf(double swt, double u, double c)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.