RooExponential.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitModels                                                     *
00004  * @(#)root/roofit:$Id: RooExponential.cxx 25185 2008-08-20 14:00:42Z wouter $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
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 
00017 //////////////////////////////////////////////////////////////////////////////
00018 //
00019 // BEGIN_HTML
00020 // Exponential p.d.f
00021 // END_HTML
00022 //
00023 
00024 #include "RooFit.h"
00025 
00026 #include "Riostream.h"
00027 #include "Riostream.h"
00028 #include <math.h>
00029 
00030 #include "RooExponential.h"
00031 #include "RooRealVar.h"
00032 
00033 ClassImp(RooExponential)
00034 
00035 
00036 //_____________________________________________________________________________
00037 RooExponential::RooExponential(const char *name, const char *title,
00038                                RooAbsReal& _x, RooAbsReal& _c) :
00039   RooAbsPdf(name, title), 
00040   x("x","Dependent",this,_x),
00041   c("c","Exponent",this,_c)
00042 {
00043 }
00044 
00045 
00046 //_____________________________________________________________________________
00047 RooExponential::RooExponential(const RooExponential& other, const char* name) :
00048   RooAbsPdf(other, name), x("x",this,other.x), c("c",this,other.c)
00049 {
00050 }
00051 
00052 
00053 //_____________________________________________________________________________
00054 Double_t RooExponential::evaluate() const{
00055   //cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
00056   return exp(c*x);
00057 }
00058 
00059 
00060 //_____________________________________________________________________________
00061 Int_t RooExponential::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const 
00062 {
00063   if (matchArgs(allVars,analVars,x)) return 1 ;
00064   return 0 ;
00065 }
00066 
00067 
00068 //_____________________________________________________________________________
00069 Double_t RooExponential::analyticalIntegral(Int_t code, const char* rangeName) const 
00070 {
00071   switch(code) {
00072   case 1: 
00073     {
00074       Double_t ret(0) ;
00075       if(c == 0.0) {
00076         ret = (x.max(rangeName) - x.min(rangeName));
00077       } else {
00078         ret =  ( exp( c*x.max(rangeName) ) - exp( c*x.min(rangeName) ) )/c;
00079       }
00080 
00081       //cout << "Int_exp_dx(c=" << c << ", xmin=" << x.min(rangeName) << ", xmax=" << x.max(rangeName) << ")=" << ret << endl ;
00082       return ret ;
00083     }
00084   }
00085   
00086   assert(0) ;
00087   return 0 ;
00088 }
00089 

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