00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "RooFit.h"
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "Riostream.h"
00028 #include "TMath.h"
00029 #include <math.h>
00030
00031 #include "RooBifurGauss.h"
00032 #include "RooAbsReal.h"
00033 #include "RooMath.h"
00034
00035 ClassImp(RooBifurGauss)
00036
00037 static const char rcsid[] =
00038 "$Id: RooBifurGauss.cxx 24286 2008-06-16 15:47:04Z wouter $";
00039
00040
00041
00042 RooBifurGauss::RooBifurGauss(const char *name, const char *title,
00043 RooAbsReal& _x, RooAbsReal& _mean,
00044 RooAbsReal& _sigmaL, RooAbsReal& _sigmaR) :
00045 RooAbsPdf(name, title),
00046 x ("x" , "Dependent" , this, _x),
00047 mean ("mean" , "Mean" , this, _mean),
00048 sigmaL("sigmaL", "Left Sigma" , this, _sigmaL),
00049 sigmaR("sigmaR", "Right Sigma", this, _sigmaR)
00050
00051 {
00052 }
00053
00054
00055
00056 RooBifurGauss::RooBifurGauss(const RooBifurGauss& other, const char* name) :
00057 RooAbsPdf(other,name), x("x",this,other.x), mean("mean",this,other.mean),
00058 sigmaL("sigmaL",this,other.sigmaL), sigmaR("sigmaR", this, other.sigmaR)
00059 {
00060 }
00061
00062
00063
00064 Double_t RooBifurGauss::evaluate() const {
00065
00066 Double_t arg = x - mean;
00067
00068 Double_t coef(0.0);
00069
00070 if (arg < 0.0){
00071 if (TMath::Abs(sigmaL) > 1e-30) {
00072 coef = -0.5/(sigmaL*sigmaL);
00073 }
00074 } else {
00075 if (TMath::Abs(sigmaR) > 1e-30) {
00076 coef = -0.5/(sigmaR*sigmaR);
00077 }
00078 }
00079
00080 return exp(coef*arg*arg);
00081 }
00082
00083
00084
00085 Int_t RooBifurGauss::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* ) const
00086 {
00087 if (matchArgs(allVars,analVars,x)) return 1 ;
00088 return 0 ;
00089 }
00090
00091
00092
00093 Double_t RooBifurGauss::analyticalIntegral(Int_t code, const char* rangeName) const
00094 {
00095 switch(code) {
00096 case 1:
00097 {
00098 static Double_t root2 = sqrt(2.) ;
00099 static Double_t rootPiBy2 = sqrt(atan2(0.0,-1.0)/2.0);
00100
00101 Double_t coefL(0.0), coefR(0.0);
00102 if (TMath::Abs(sigmaL) > 1e-30) {
00103 coefL = -0.5/(sigmaL*sigmaL);
00104 }
00105
00106 if (TMath::Abs(sigmaR) > 1e-30) {
00107 coefR = -0.5/(sigmaR*sigmaR);
00108 }
00109
00110 Double_t xscaleL = root2*sigmaL;
00111 Double_t xscaleR = root2*sigmaR;
00112
00113 Double_t integral = 0.0;
00114 if(x.max(rangeName) < mean)
00115 {
00116 integral = sigmaL * ( RooMath::erf((x.max(rangeName) - mean)/xscaleL) - RooMath::erf((x.min(rangeName) - mean)/xscaleL) );
00117 }
00118 else if (x.min(rangeName) > mean)
00119 {
00120 integral = sigmaR * ( RooMath::erf((x.max(rangeName) - mean)/xscaleR) - RooMath::erf((x.min(rangeName) - mean)/xscaleR) );
00121 }
00122 else
00123 {
00124 integral = sigmaR*RooMath::erf((x.max(rangeName) - mean)/xscaleR) - sigmaL*RooMath::erf((x.min(rangeName) - mean)/xscaleL);
00125 }
00126
00127
00128 return integral*rootPiBy2;
00129 }
00130 }
00131
00132 assert(0) ;
00133 return 0 ;
00134 }