Logo ROOT   6.12/07
Reference Guide
RooExponential.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitModels *
4  * @(#)root/roofit:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 /** \class RooExponential
18  \ingroup Roofit
19 
20 Exponential p.d.f
21 **/
22 
23 #include "RooFit.h"
24 
25 #include "Riostream.h"
26 #include "Riostream.h"
27 #include <math.h>
28 
29 #include "RooExponential.h"
30 #include "RooRealVar.h"
31 
32 using namespace std;
33 
35 
36 ////////////////////////////////////////////////////////////////////////////////
37 
38 RooExponential::RooExponential(const char *name, const char *title,
39  RooAbsReal& _x, RooAbsReal& _c) :
40  RooAbsPdf(name, title),
41  x("x","Dependent",this,_x),
42  c("c","Exponent",this,_c)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 
49  RooAbsPdf(other, name), x("x",this,other.x), c("c",this,other.c)
50 {
51 }
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 ///cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
55 
57  return exp(c*x);
58 }
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 
62 Int_t RooExponential::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
63 {
64  if (matchArgs(allVars,analVars,x)) return 1 ;
65  return 0 ;
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 
70 Double_t RooExponential::analyticalIntegral(Int_t code, const char* rangeName) const
71 {
72  switch(code) {
73  case 1:
74  {
75  Double_t ret(0) ;
76  if(c == 0.0) {
77  ret = (x.max(rangeName) - x.min(rangeName));
78  } else {
79  ret = ( exp( c*x.max(rangeName) ) - exp( c*x.min(rangeName) ) )/c;
80  }
81 
82  //cout << "Int_exp_dx(c=" << c << ", xmin=" << x.min(rangeName) << ", xmax=" << x.max(rangeName) << ")=" << ret << endl ;
83  return ret ;
84  }
85  }
86 
87  assert(0) ;
88  return 0 ;
89 }
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported...
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
int Int_t
Definition: RtypesCore.h:41
STL namespace.
RooRealProxy x
RooRealProxy c
Double_t x[n]
Definition: legend1.C:17
Exponential p.d.f.
Double_t evaluate() const
cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
#define ClassImp(name)
Definition: Rtypes.h:359
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t max(const char *rname=0) const
Definition: RooRealProxy.h:57
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
double exp(double)
char name[80]
Definition: TGX11.cxx:109
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral. ...