CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/HiggsAnalysis/CombinedLimit/src/HZZ2L2QRooPdfs.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <math.h>
00003 #include "TMath.h"
00004 
00005 //#include "../interface/RooDoubleCB.h"
00006 //#include "../interface/RooFermi.h"
00007 //#include "../interface/RooRelBW.h"
00008 #include "../interface/HZZ2L2QRooPdfs.h"
00009 #include "RooRealVar.h"
00010 #include "RooRealConstant.h"
00011 
00012 using namespace RooFit;
00013 ClassImp(RooCB)
00014 
00015   RooCB::RooCB(){}
00016 
00017 RooCB::RooCB(const char *name, const char *title,
00018              RooAbsReal& _x,
00019              RooAbsReal& _mean,
00020              RooAbsReal& _width,
00021              RooAbsReal& _alpha,
00022              RooAbsReal& _n,
00023               RooAbsReal& _theta
00024              ) :
00025   RooAbsPdf(name,title),
00026   x("x","x",this,_x),
00027   mean("mean","mean",this,_mean),
00028   width("width","width",this,_width),
00029   alpha("alpha","alpha",this,_alpha),
00030   n("n","n",this,_n),
00031   theta("theta","theta",this,_theta)
00032 {
00033 }
00034 
00035 RooCB::RooCB(const RooCB& other, const char* name) :
00036   RooAbsPdf(other,name),
00037   x("x",this,other.x),
00038   mean("mean",this,other.mean),
00039   width("width",this,other.width),
00040   alpha("alpha",this,other.alpha),
00041   n("n",this,other.n),
00042   theta("theta",this,other.theta)
00043 {
00044 }
00045 
00046 double RooCB::evaluate() const
00047 {
00048   double a = cos(theta)*alpha - sin(theta)*width;
00049   double w = sin(theta)*alpha + cos(theta)*width;
00050 
00051   double t = (x-mean)/w;
00052   if(a<0) t = -t;
00053 
00054   double absa = fabs((double)a);
00055 
00056   double A = TMath::Power(n/absa,n)*exp(-0.5*absa*absa);
00057   double B = n/absa-absa;
00058 
00059   if(t >= -absa){
00060     return exp(-0.5*t*t);
00061   }else{
00062     return A/TMath::Power(B-t,n);
00063   }
00064 }
00065 
00066 
00067  ClassImp(RooDoubleCB) 
00068 
00069  RooDoubleCB::RooDoubleCB(){}
00070 
00071  RooDoubleCB::RooDoubleCB(const char *name, const char *title, 
00072                     RooAbsReal& _x,
00073                     RooAbsReal& _mean,
00074                     RooAbsReal& _width,
00075                     RooAbsReal& _alpha1,
00076                     RooAbsReal& _n1,
00077                     RooAbsReal& _alpha2,
00078                     RooAbsReal& _n2
00079                     ) :
00080    RooAbsPdf(name,title), 
00081    x("x","x",this,_x),
00082    mean("mean","mean",this,_mean),
00083    width("width","width",this,_width),
00084    alpha1("alpha1","alpha1",this,_alpha1),
00085    n1("n1","n1",this,_n1),
00086    alpha2("alpha2","alpha2",this,_alpha2),
00087    n2("n2","n2",this,_n2)
00088  { 
00089  } 
00090 
00091 
00092  RooDoubleCB::RooDoubleCB(const RooDoubleCB& other, const char* name) :  
00093    RooAbsPdf(other,name), 
00094    x("x",this,other.x),
00095    mean("mean",this,other.mean),
00096    width("width",this,other.width),
00097    alpha1("alpha1",this,other.alpha1),
00098    n1("n1",this,other.n1),
00099    alpha2("alpha2",this,other.alpha2),
00100    n2("n2",this,other.n2)
00101 
00102  { 
00103  } 
00104 
00105  double RooDoubleCB::evaluate() const 
00106  { 
00107    double A1 = pow(n1/fabs(alpha1),n1)*exp(-alpha1*alpha1/2);
00108    double A2 = pow(n2/fabs(alpha2),n2)*exp(-alpha2*alpha2/2);
00109    double B1 = n1/fabs(alpha1)-fabs(alpha1);
00110    double B2 = n2/fabs(alpha2)-fabs(alpha2);
00111 
00112    if((x-mean)/width>-alpha1 && (x-mean)/width<alpha2){
00113      return exp(-(x-mean)*(x-mean)/(2*width*width));
00114    }else if((x-mean)/width<-alpha1){
00115      return A1*pow(B1-(x-mean)/width,-n1);
00116    }else if((x-mean)/width>alpha2){
00117      return A2*pow(B2+(x-mean)/width,-n2);
00118    }else{
00119      cout << "ERROR evaluating range..." << endl;
00120      return 99;
00121    }
00122    
00123  } 
00124 
00125  ClassImp(RooFermi) 
00126 
00127  RooFermi::RooFermi(){}
00128 
00129  RooFermi::RooFermi(const char *name, const char *title, 
00130                       RooAbsReal& _x,
00131                       RooAbsReal& _cutOff,
00132                     RooAbsReal& _beta
00133                     ) :
00134    RooAbsPdf(name,title), 
00135    x("x","x",this,_x),
00136    cutOff("cutOff","cutOff",this,_cutOff),
00137    beta("beta","beta",this,_beta)
00138  { 
00139  } 
00140 
00141 
00142  RooFermi::RooFermi(const RooFermi& other, const char* name) :  
00143    RooAbsPdf(other,name), 
00144    x("x",this,other.x),
00145    cutOff("cutOff",this,other.cutOff),
00146    beta("beta",this,other.beta)
00147 
00148  { 
00149  } 
00150 
00151 
00152 
00153  double RooFermi::evaluate() const 
00154  { 
00155    return 1.0/(exp((cutOff-x)/beta)+1);
00156  } 
00157 
00158  ClassImp(RooRelBW) 
00159 
00160  RooRelBW::RooRelBW(){}
00161 
00162  RooRelBW::RooRelBW(const char *name, const char *title, 
00163                     RooAbsReal& _x,
00164                     RooAbsReal& _mean,
00165                     RooAbsReal& _width,
00166                     RooAbsReal& _n
00167                     ) :
00168    RooAbsPdf(name,title), 
00169    x("x","x",this,_x),
00170    mean("mean","mean",this,_mean),
00171    width("width","width",this,_width),
00172    n("n","n",this,_n)
00173  { 
00174  } 
00175 
00176 
00177  RooRelBW::RooRelBW(const RooRelBW& other, const char* name) :  
00178    RooAbsPdf(other,name), 
00179    x("x",this,other.x),
00180    mean("mean",this,other.mean),
00181    width("width",this,other.width),
00182    n("n",this,other.n)
00183 
00184  { 
00185  } 
00186 
00187 
00188 
00189  double RooRelBW::evaluate() const 
00190  { 
00191    return pow(x*x,n)/((x*x-mean*mean)*(x*x-mean*mean)+pow(x*x/(mean*mean),2*n)*mean*mean*width*width);
00192  } 
00193 
00194 
00195 ClassImp(Triangle)
00196 
00197   Triangle::Triangle(){}
00198 
00199 Triangle::Triangle(const char *name, const char *title,                
00200                    RooAbsReal& _m,
00201                    RooAbsReal& _start,
00202                    RooAbsReal& _turn,
00203                    RooAbsReal& _stop
00204                    ):
00205   RooAbsPdf(name, title),
00206   m("m", "Dependent", this, _m),
00207   start("start","start",this,_start),
00208   turn("turn","turn",this,_turn),
00209   stop("stop","stop",this,_stop)
00210 {
00211 }
00212 
00213 Triangle::Triangle(const Triangle& other, const char* name) :
00214   RooAbsPdf(other, name), m("m", this, other.m),start("start", this, other.start), turn("turn", this, other.turn), stop("stop", this, other.stop)
00215 {
00216 }
00217 
00218 Double_t Triangle::evaluate() const 
00219 {
00220   //std::cout << m << " "<<1.+(start-m)/turn << " " << 1+(turn-m)/stop << std::endl;
00221   if(m<turn  && m > turn+start)
00222     return 1.+(turn-m)/start;
00223   if(m>=turn && m < turn+stop)
00224     return 1.+(turn-m)/stop;
00225   
00226   return 0;
00227 }
00228 
00229 
00230 Int_t Triangle::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* range) const 
00231 {
00232   if (matchArgs(allVars,analVars,m)) return 1;
00233   return 0;
00234 }
00235 
00236 Double_t Triangle::analyticalIntegral(Int_t code, const char* rangeName) const 
00237 {
00238 
00239   // WARNING, ASSSUMES TURN TO BE IN INTERVAL
00240   assert(code==1) ;
00241   //whole triangle
00242   Double_t sumleft = sqrt(1+ (turn+start)*(turn+start) ) ;
00243   Double_t sumright= sqrt(1+ (turn+stop)*(turn+stop) );
00244 
00245 
00246   if(m.min() < turn+start)// correct for left missing bit
00247     sumleft -= sumleft*(m.min()-(turn+start))/fabs(start);
00248 
00249 
00250   if(m.max() > turn+stop)// correct for right missing bit
00251     sumright -= sumright*(turn+stop -m.max())/fabs(stop);
00252 
00253   
00254 
00255   return sumleft+sumright;    
00256 }
00257 
00258 
00259 
00260 
00261 ClassImp(RooLevelledExp)
00262 
00263   RooLevelledExp::RooLevelledExp(){}
00264 
00265 RooLevelledExp::RooLevelledExp(const char *name, const char *title,
00266                                RooAbsReal& _x,
00267                                RooAbsReal& _sigma, 
00268                                RooAbsReal& _alpha,
00269                                RooAbsReal& _m,
00270                                RooAbsReal& _theta):
00271   RooAbsPdf(name,title),
00272   x("x","x",this,_x),
00273   sigma("sigma","sigma",this,_sigma),
00274   alpha("alpha","alpha",this,_alpha),
00275   m("m","m",this,_m),
00276   //  k("k","k",this,_k),
00277   theta("theta","theta",this,_theta)
00278 {
00279 }
00280 
00281 RooLevelledExp::RooLevelledExp(const RooLevelledExp& other, const char* name) :
00282   RooAbsPdf(other,name),
00283   x("x",this,other.x),
00284   sigma("sigma",this,other.sigma),
00285   alpha("alpha",this,other.alpha),
00286   m("m",this,other.m),
00287   theta("theta",this,other.theta)
00288 {
00289 }
00290 
00291 double RooLevelledExp::evaluate() const
00292 {
00293   double res=0.0;
00294   double s = cos(theta)*sigma - sin(theta)*alpha;
00295   double a = sin(theta)*sigma + cos(theta)*alpha;
00296     
00297   //original
00298   double t = fabs(x-m);
00299   double den = (s + a*t);
00300   res=exp(-1.0*t/den);
00301   
00302 
00303   return res;
00304 }