RooOsipDisc.cc

Go to the documentation of this file.
00001 // The function is a fourthorder Polynomial for 0<x<r and a Gaussian for r<x<1
00002 // The restrictions are that: 1.The derivative be 0 at x=0, 2. That the function be continuous at r, 3. That the first derivative be continuous at r.
00003 // by Osipenkov, Ilya.
00004 
00005 #include "RooRarFit/rarVersion.hh"
00006 
00007 #include "Riostream.h"
00008 #include "TMath.h"
00009 
00010 #include "RooRarFit/RooOsipDisc.hh"
00011 #include "RooFitCore/RooAbsReal.hh"
00012 #include "RooFitCore/RooRealVar.hh"
00013 #include "RooFitCore/RooRandom.hh"
00014 #include "RooFitCore/RooMath.hh"
00015 
00016 ClassImp(RooOsipDisc)
00017 
00018 RooOsipDisc::RooOsipDisc(const char *name, const char *title,
00019                          RooAbsReal& _x, RooAbsReal& _r,
00020                          RooAbsReal& _b,RooAbsReal& _a,RooAbsReal& _h,RooAbsReal& _s) :
00021   RooAbsPdf(name,title),
00022   x("x","Dependent",this,_x),
00023   r("r","r",this,_r),
00024   bb("b","b",this,_b),
00025   a("a","a",this,_a),
00026   h("h","h",this,_h),
00027   s("s","s",this,_s)
00028 {
00029 }
00030 
00031 RooOsipDisc::RooOsipDisc(const RooOsipDisc& other, const char* name) : 
00032   RooAbsPdf(other,name), x("x",this,other.x), r("r",this,other.r),
00033   bb("b",this,other.bb),a("a",this,other.a),h("h",this,other.h),s("s",this,other.s)
00034 {
00035 }
00036 
00037 
00038 Double_t RooOsipDisc::evaluate() const
00039 {
00040   Double_t t = -(2*a*r+3*bb*r*r+4*s*r*r*r)*h*h/(1+a*r*r+bb*r*r*r+s*r*r*r*r);
00041   Double_t d = (1+a*r*r+bb*r*r*r+s*r*r*r*r)*exp(t*t/(2*h*h));
00042   if (x<r) {
00043     return 1+a*x*x+bb*x*x*x+s*x*x*x*x;
00044   }
00045   if ((x>r)||(x==r)) {
00046   return d*exp(-0.5*(x-r+t)*(x-r+t)/(h*h));
00047   }
00048   return 0;
00049 }
00050 
00051 Int_t RooOsipDisc::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const 
00052 {
00053   if (matchArgs(allVars,analVars,x)) return 1 ;
00054   return 0 ;
00055 }
00056 
00057 Double_t RooOsipDisc::analyticalIntegral(Int_t code, const char* /* rangeName */) const 
00058 {
00059   assert(code==1) ;
00060 
00061   const Double_t rootPiBy2 = sqrt(TMath::PiOver2());
00062   Double_t t = -(2*a*r+3*bb*r*r+4*s*r*r*r)*h*h/(1+a*r*r+bb*r*r*r+s*r*r*r*r);
00063   Double_t d = (1+a*r*r+bb*r*r*r+s*r*r*r*r)*exp(t*t/(2*h*h));
00064   Double_t xscale = TMath::Sqrt2() * h;
00065 
00066   return  r+a*r*r*r/3+bb*r*r*r*r/4+s*r*r*r*r*r/5+d*rootPiBy2*h*(TMath::Erf((1-r+t)/xscale)-TMath::Erf(t/xscale)); 
00067 }
00068 
00069 Int_t RooOsipDisc::getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t /*staticInitOK*/) const
00070 {
00071   if (matchArgs(directVars,generateVars,x)) return 1 ;  
00072   return 0 ;
00073 }
00074 
00075 void RooOsipDisc::generateEvent(Int_t code)
00076 {
00077   assert(code==1) ;
00078   Double_t xgen ;
00079   while(1) {    
00080     xgen = 0.5; //RooRandom::randomGenerator()->OsipDisc(r,bb,a,h,s);
00081     if (xgen<x.max() && xgen>x.min()) {
00082       x = xgen ;
00083       break;
00084     }
00085   }
00086   return;
00087 }
00088 
00089 

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7