Logo ROOT   6.18/05
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
20Exponential 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
32using namespace std;
33
35
36////////////////////////////////////////////////////////////////////////////////
37
38RooExponential::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
62Int_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
70Double_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}
#define c(i)
Definition: RSha256.hxx:101
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
double exp(double)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
Exponential p.d.f.
RooRealProxy c
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
RooRealProxy x
Double_t evaluate() const
cout << "exp(x=" << x << ",c=" << c << ")=" << exp(c*x) << endl ;
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Double_t min(const char *rname=0) const
Definition: RooRealProxy.h:56
Double_t max(const char *rname=0) const
Definition: RooRealProxy.h:57
Double_t x[n]
Definition: legend1.C:17