 /***************************************************************************** 
  * Project: RooFit                                                           * 
  *                                                                           * 
  * This code was autogenerated by RooClassFactory                            * 
  *****************************************************************************/ 

 // Your description goes here... 

 #include "Riostream.h" 

 #include "CMSBkgLineShape.h" 
 #include "RooAbsReal.h" 
 #include "RooAbsCategory.h" 
 #include <math.h> 
 #include "TMath.h" 
 #include "RooMath.h"

 ClassImp(CMSBkgLineShape); 

 CMSBkgLineShape::CMSBkgLineShape(const char *name, const char *title, 
                        RooAbsReal& _x,
                        RooAbsReal& _alpha,
                        RooAbsReal& _beta,
                        RooAbsReal& _peak,
                        RooAbsReal& _gamma) :
   RooAbsPdf(name,title), 
   x("x","x",this,_x),
   alpha("alpha","alpha",this,_alpha),
   beta("beta","beta",this,_beta),
   peak("peak","peak",this,_peak),
   gamma("gamma","gamma",this,_gamma)
 { 
 } 


 CMSBkgLineShape::CMSBkgLineShape(const CMSBkgLineShape& other, const char* name) :  
   RooAbsPdf(other,name), 
   x("x",this,other.x),
   alpha("alpha",this,other.alpha),
   beta("beta",this,other.beta),
   peak("peak",this,other.peak),
   gamma("gamma",this,other.gamma)
 { 
 } 



 Double_t CMSBkgLineShape::evaluate() const 
 { 

   Double_t erf = RooMath::erfc((alpha - x) * beta);
   Double_t u = (x - peak)*gamma;

   if(u < -70) u = 1e20;
   else if( u>70 ) u = 0;
   else u = exp(-u);   //exponential decay
   return erf*u;
 } 



