58 RooMoment::RooMoment()
66 RooMoment::RooMoment(
const char* name,
const char* title, RooAbsReal& func, RooRealVar& x, Int_t orderIn, Bool_t centr, Bool_t takeRoot) :
67 RooAbsMoment(name, title,func,x,orderIn,takeRoot),
68 _xf(
"!xf",
"xf",this,kFALSE,kFALSE),
69 _ixf(
"!ixf",
"ixf",this),
72 setExpensiveObjectCache(func.expensiveObjectCache()) ;
74 string pname=Form(
"%s_product",name) ;
78 string formula=Form(
"pow((@0-@1),%d)*@2",_order) ;
79 string m1name=Form(
"%s_moment1",GetName()) ;
80 RooAbsReal* mom1 = func.mean(x) ;
81 XF =
new RooFormulaVar(pname.c_str(),formula.c_str(),RooArgList(x,*mom1,func)) ;
82 XF->setExpensiveObjectCache(func.expensiveObjectCache()) ;
83 addOwnedComponents(*mom1) ;
86 string formula=Form(
"pow(@0,%d)*@1",_order) ;
87 XF =
new RooFormulaVar(pname.c_str(),formula.c_str(),RooArgSet(x,func)) ;
88 XF->setExpensiveObjectCache(func.expensiveObjectCache()) ;
91 if (func.isBinnedDistribution(x)) {
92 XF->specialIntegratorConfig(kTRUE)->method1D().setLabel(
"RooBinIntegrator");
95 RooRealIntegral* intXF = (RooRealIntegral*) XF->createIntegral(x) ;
96 RooRealIntegral* intF = (RooRealIntegral*) func.createIntegral(x) ;
97 intXF->setCacheNumeric(kTRUE) ;
98 intF->setCacheNumeric(kTRUE) ;
101 _ixf.setArg(*intXF) ;
103 addOwnedComponents(RooArgSet(*XF,*intXF,*intF)) ;
108 RooMoment::RooMoment(
const char* name,
const char* title, RooAbsReal& func, RooRealVar& x,
const RooArgSet& nset,
109 Int_t orderIn, Bool_t centr, Bool_t takeRoot, Bool_t intNSet) :
110 RooAbsMoment(name, title,func,x,orderIn,takeRoot),
111 _xf(
"!xf",
"xf",this,kFALSE,kFALSE),
112 _ixf(
"!ixf",
"ixf",this),
115 setExpensiveObjectCache(func.expensiveObjectCache()) ;
119 string pname=Form(
"%s_product",name) ;
122 string formula=Form(
"pow((@0-@1),%d)*@2",_order) ;
123 string m1name=Form(
"%s_moment1",GetName()) ;
124 RooAbsReal* mom1 = func.mean(x,nset) ;
125 XF =
new RooFormulaVar(pname.c_str(),formula.c_str(),RooArgList(x,*mom1,func)) ;
126 XF->setExpensiveObjectCache(func.expensiveObjectCache()) ;
127 addOwnedComponents(*mom1) ;
128 _mean.setArg(*mom1) ;
130 string formula=Form(
"pow(@0,%d)*@1",_order) ;
131 XF =
new RooFormulaVar(pname.c_str(),formula.c_str(),RooArgSet(x,func)) ;
132 XF->setExpensiveObjectCache(func.expensiveObjectCache()) ;
135 if (func.isBinnedDistribution(x)) {
136 XF->specialIntegratorConfig(kTRUE)->method1D().setLabel(
"RooBinIntegrator");
139 RooArgSet intSet(x) ;
140 if (intNSet) intSet.add(_nset,kTRUE) ;
142 RooRealIntegral* intXF = (RooRealIntegral*) XF->createIntegral(intSet,&_nset) ;
143 RooRealIntegral* intF = (RooRealIntegral*) func.createIntegral(intSet,&_nset) ;
144 intXF->setCacheNumeric(kTRUE) ;
145 intF->setCacheNumeric(kTRUE) ;
148 _ixf.setArg(*intXF) ;
150 addOwnedComponents(RooArgSet(*XF,*intXF,*intF)) ;
157 RooMoment::RooMoment(
const RooMoment& other,
const char* name) :
158 RooAbsMoment(other, name),
159 _xf(
"xf",this,other._xf),
160 _ixf(
"ixf",this,other._ixf),
161 _if(
"if",this,other._if)
170 RooMoment::~RooMoment()
179 Double_t RooMoment::evaluate()
const
181 Double_t ratio = _ixf / _if ;
182 Double_t ret = _takeRoot ? pow(ratio,1.0/_order) : ratio ;