ROOT  6.06/09
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 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // Exponential p.d.f
21 // END_HTML
22 //
23 
24 #include "RooFit.h"
25 
26 #include "Riostream.h"
27 #include "Riostream.h"
28 #include <math.h>
29 
30 #include "RooExponential.h"
31 #include "RooRealVar.h"
32 
33 using namespace std;
34 
36 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 
40 RooExponential::RooExponential(const char *name, const char *title,
41  RooAbsReal& _x, RooAbsReal& _c) :
42  RooAbsPdf(name, title),
43  x("x","Dependent",this,_x),
44  c("c","Exponent",this,_c)
45 {
46 }
47 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 
52  RooAbsPdf(other, name), x("x",this,other.x), c("c",this,other.c)
53 {
54 }
55 
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 ///cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
59 
61  return exp(c*x);
62 }
63 
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 
67 Int_t RooExponential::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
68 {
69  if (matchArgs(allVars,analVars,x)) return 1 ;
70  return 0 ;
71 }
72 
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 
76 Double_t RooExponential::analyticalIntegral(Int_t code, const char* rangeName) const
77 {
78  switch(code) {
79  case 1:
80  {
81  Double_t ret(0) ;
82  if(c == 0.0) {
83  ret = (x.max(rangeName) - x.min(rangeName));
84  } else {
85  ret = ( exp( c*x.max(rangeName) ) - exp( c*x.min(rangeName) ) )/c;
86  }
87 
88  //cout << "Int_exp_dx(c=" << c << ", xmin=" << x.min(rangeName) << ", xmax=" << x.max(rangeName) << ")=" << ret << endl ;
89  return ret ;
90  }
91  }
92 
93  assert(0) ;
94  return 0 ;
95 }
96 
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported...
Double_t evaluate() const
cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
#define assert(cond)
Definition: unittest.h:542
int Int_t
Definition: RtypesCore.h:41
STL namespace.
RooRealProxy x
RooRealProxy c
Double_t x[n]
Definition: legend1.C:17
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral. ...
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
#define name(a, b)
Definition: linkTestLib0.cpp:5
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
ClassImp(RooExponential) RooExponential
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
double exp(double)
Double_t max(const char *rname=0) const
Definition: RooRealProxy.h:57