Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooFirstMoment.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$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\file RooFirstMoment.cxx
19\class RooFirstMoment
20\ingroup Roofitcore
21
22RooFirstMoment represents the first, second, or third order derivative
23of any RooAbsReal as calculated (numerically) by the MathCore Richardson
24derivator class.
25**/
26
27
28#include "RooFit.h"
29
30#include "Riostream.h"
31#include <math.h>
32
33#include "RooFirstMoment.h"
34#include "RooAbsReal.h"
35#include "RooAbsPdf.h"
36#include "RooErrorHandler.h"
37#include "RooArgSet.h"
38#include "RooMsgService.h"
39#include "RooRealVar.h"
40#include "RooFunctor.h"
41#include "RooGlobalFunc.h"
42#include "RooConstVar.h"
43#include "RooRealIntegral.h"
44#include "RooNumIntConfig.h"
45#include "RooProduct.h"
46#include <string>
47using namespace std;
48
49
51;
52
53
54////////////////////////////////////////////////////////////////////////////////
55/// Default constructor
56
58{
59}
60
61
62
63////////////////////////////////////////////////////////////////////////////////
64
65RooFirstMoment::RooFirstMoment(const char* name, const char* title, RooAbsReal& func, RooRealVar& x) :
66 RooAbsMoment(name, title,func,x,1,kFALSE),
67 _xf("!xf","xf",this,kFALSE,kFALSE),
68 _ixf("!ixf","ixf",this),
69 _if("!if","if",this)
70{
72
73 string pname=Form("%s_product",name) ;
74
75 RooProduct* XF = new RooProduct(pname.c_str(),pname.c_str(),RooArgSet(x,func)) ;
77
78 if (func.isBinnedDistribution(x)) {
79 XF->specialIntegratorConfig(kTRUE)->method1D().setLabel("RooBinIntegrator");
80 }
81
84 intXF->setCacheNumeric(kTRUE) ;
85 intF->setCacheNumeric(kTRUE) ;
86
87 _xf.setArg(*XF) ;
88 _ixf.setArg(*intXF) ;
89 _if.setArg(*intF) ;
90 addOwnedComponents(RooArgSet(*XF,*intXF,*intF)) ;
91}
92
93////////////////////////////////////////////////////////////////////////////////
94
95RooFirstMoment::RooFirstMoment(const char* name, const char* title, RooAbsReal& func, RooRealVar& x, const RooArgSet& nset, Bool_t intNSet) :
96 RooAbsMoment(name, title,func,x,1,kFALSE),
97 _xf("!xf","xf",this,kFALSE,kFALSE),
98 _ixf("!ixf","ixf",this),
99 _if("!if","if",this)
100{
102
103 _nset.add(nset) ;
104
105 string pname=Form("%s_product",name) ;
106
107 RooProduct* XF = new RooProduct(pname.c_str(),pname.c_str(),RooArgSet(x,func)) ;
109
110 if (func.isBinnedDistribution(x)) {
111 XF->specialIntegratorConfig(kTRUE)->method1D().setLabel("RooBinIntegrator");
112 }
113
114 if (intNSet && _nset.getSize()>0 && func.isBinnedDistribution(_nset)) {
115 XF->specialIntegratorConfig(kTRUE)->method2D().setLabel("RooBinIntegrator");
116 XF->specialIntegratorConfig(kTRUE)->methodND().setLabel("RooBinIntegrator");
117 }
118
119 RooArgSet intSet(x) ;
120 if (intNSet) intSet.add(_nset,kTRUE) ;
121 RooRealIntegral* intXF = (RooRealIntegral*) XF->createIntegral(intSet,&_nset) ;
122 RooRealIntegral* intF = (RooRealIntegral*) func.createIntegral(intSet,&_nset) ;
123 intXF->setCacheNumeric(kTRUE) ;
124 intF->setCacheNumeric(kTRUE) ;
125
126 _xf.setArg(*XF) ;
127 _ixf.setArg(*intXF) ;
128 _if.setArg(*intF) ;
129 addOwnedComponents(RooArgSet(*XF,*intXF,*intF)) ;
130}
131
132
133
134////////////////////////////////////////////////////////////////////////////////
135
137 RooAbsMoment(other, name),
138 _xf("xf",this,other._xf),
139 _ixf("ixf",this,other._ixf),
140 _if("if",this,other._if)
141{
142}
143
144
145
146////////////////////////////////////////////////////////////////////////////////
147/// Destructor
148
150{
151}
152
153
154
155////////////////////////////////////////////////////////////////////////////////
156/// Calculate value
157
159{
160 Double_t ratio = _ixf / _if ;
161 //cout << "\nRooFirstMoment::eval(" << GetName() << ") val = " << ratio << endl ;
162 return ratio ;
163}
164
165
const Bool_t kFALSE
Definition RtypesCore.h:101
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
RooExpensiveObjectCache & expensiveObjectCache() const
friend class RooArgSet
Definition RooAbsArg.h:642
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
Definition RooAbsArg.h:518
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Int_t getSize() const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsMoment represents the first, second, or third order derivative of any RooAbsReal as calculated ...
RooSetProxy _nset
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:64
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Definition RooAbsReal.h:345
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
RooFirstMoment represents the first, second, or third order derivative of any RooAbsReal as calculate...
RooRealProxy _xf
RooFirstMoment()
Default constructor.
RooRealProxy _ixf
virtual ~RooFirstMoment()
Destructor.
Double_t evaluate() const
Calculate value
RooRealProxy _if
RooCategory & method2D()
RooCategory & methodND()
RooCategory & method1D()
A RooProduct represents the product of a given set of RooAbsReal objects.
Definition RooProduct.h:29
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
void setCacheNumeric(Bool_t flag)
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
bool setArg(T &newRef)
Change object held in proxy into newRef.
Double_t x[n]
Definition legend1.C:17