RooBifurGauss.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitModels                                                     *
00004  * @(#)root/roofit:$Id: RooBifurGauss.cxx 24286 2008-06-16 15:47:04Z wouter $
00005  * Authors:                                                                  *
00006  *   Abi Soffer, Colorado State University, abi@slac.stanford.edu            *
00007  *                                                                           *
00008  * Copyright (c) 2000-2005, Regents of the University of California,         *
00009  *                          Colorado State University                        *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #include "RooFit.h"
00017 
00018 //////////////////////////////////////////////////////////////////////////////
00019 //
00020 // BEGIN_HTML
00021 // Bifurcated Gaussian p.d.f with different widths on left and right
00022 // side of maximum value
00023 // END_HTML
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* /*rangeName*/) 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       //      return rootPiBy2*(sigmaR*RooMath::erf((x.max(rangeName) - mean)/xscaleR) - 
00127       //                        sigmaL*RooMath::erf((x.min(rangeName) - mean)/xscaleL));
00128       return integral*rootPiBy2;
00129     }
00130   }  
00131 
00132   assert(0) ; 
00133   return 0 ; // to prevent compiler warnings
00134 }

Generated on Tue Jul 5 14:54:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1