Logo ROOT   6.16/01
Reference Guide
RooAbsReal.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
19/** \class RooAbsReal
20
21 RooAbsReal is the common abstract base class for objects that represent a
22 real value and implements functionality common to all real-valued objects
23 such as the ability to plot them, to construct integrals of them, the
24 ability to advertise (partial) analytical integrals etc.
25
26 Implementation of RooAbsReal may be derived, thus no interface
27 is provided to modify the contents.
28
29 \ingroup Roofitcore
30*/
31
32
33
34
35#include <sys/types.h>
36
37
38#include "RooFit.h"
39#include "RooMsgService.h"
40
41#include "RooAbsReal.h"
42#include "RooAbsReal.h"
43#include "RooArgSet.h"
44#include "RooArgList.h"
45#include "RooBinning.h"
46#include "RooPlot.h"
47#include "RooCurve.h"
48#include "RooRealVar.h"
49#include "RooArgProxy.h"
50#include "RooFormulaVar.h"
51#include "RooRealBinding.h"
52#include "RooRealIntegral.h"
54#include "RooCustomizer.h"
55#include "RooAbsData.h"
56#include "RooScaledFunc.h"
57#include "RooAddPdf.h"
58#include "RooCmdConfig.h"
59#include "RooCategory.h"
60#include "RooNumIntConfig.h"
61#include "RooAddition.h"
62#include "RooDataSet.h"
63#include "RooDataHist.h"
65#include "RooNumRunningInt.h"
66#include "RooGlobalFunc.h"
67#include "RooParamBinning.h"
68#include "RooProfileLL.h"
69#include "RooFunctor.h"
70#include "RooDerivative.h"
71#include "RooGenFunction.h"
72#include "RooMultiGenFunction.h"
73#include "RooCmdConfig.h"
74#include "RooXYChi2Var.h"
75#include "RooMinuit.h"
76#include "RooMinimizer.h"
77#include "RooChi2Var.h"
78#include "RooFitResult.h"
79#include "RooAbsMoment.h"
80#include "RooMoment.h"
81#include "RooFirstMoment.h"
82#include "RooSecondMoment.h"
83#include "RooBrentRootFinder.h"
84#include "RooVectorDataStore.h"
85#include "RooCachedReal.h"
86
87#include "Riostream.h"
88
89#include "Compression.h"
90#include "Math/IFunction.h"
91#include "TMath.h"
92#include "TObjString.h"
93#include "TTree.h"
94#include "TH1.h"
95#include "TH2.h"
96#include "TH3.h"
97#include "TBranch.h"
98#include "TLeaf.h"
99#include "TAttLine.h"
100#include "TF1.h"
101#include "TF2.h"
102#include "TF3.h"
103#include "TMatrixD.h"
104#include "TVector.h"
105
106#include <sstream>
107
108using namespace std ;
109
111;
112
116
119
122map<const RooAbsArg*,pair<string,list<RooAbsReal::EvalError> > > RooAbsReal::_evalErrorList ;
125////////////////////////////////////////////////////////////////////////////////
126/// coverity[UNINIT_CTOR]
127/// Default constructor
128
129RooAbsReal::RooAbsReal() : _specIntegratorConfig(0), _treeVar(kFALSE), _selectComp(kTRUE), _lastNSet(0)
130{
131}
133
135////////////////////////////////////////////////////////////////////////////////
136/// Constructor with unit label
137
138RooAbsReal::RooAbsReal(const char *name, const char *title, const char *unit) :
139 RooAbsArg(name,title), _plotMin(0), _plotMax(0), _plotBins(100),
140 _value(0), _unit(unit), _forceNumInt(kFALSE), _specIntegratorConfig(0), _treeVar(kFALSE), _selectComp(kTRUE), _lastNSet(0)
141{
142 setValueDirty() ;
143 setShapeDirty() ;
144
145}
146
147
148
149////////////////////////////////////////////////////////////////////////////////
150/// Constructor with plot range and unit label
151
152RooAbsReal::RooAbsReal(const char *name, const char *title, Double_t inMinVal,
153 Double_t inMaxVal, const char *unit) :
154 RooAbsArg(name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _plotBins(100),
155 _value(0), _unit(unit), _forceNumInt(kFALSE), _specIntegratorConfig(0), _treeVar(kFALSE), _selectComp(kTRUE), _lastNSet(0)
156{
157 setValueDirty() ;
158 setShapeDirty() ;
159
160}
161
162
163
164////////////////////////////////////////////////////////////////////////////////
165/// coverity[UNINIT_CTOR]
166/// Copy constructor
167
168RooAbsReal::RooAbsReal(const RooAbsReal& other, const char* name) :
169 RooAbsArg(other,name), _plotMin(other._plotMin), _plotMax(other._plotMax),
170 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
171 _forceNumInt(other._forceNumInt), _treeVar(other._treeVar), _selectComp(other._selectComp), _lastNSet(0)
172{
173 if (other._specIntegratorConfig) {
175 } else {
177 }
178}
179
180
181
182////////////////////////////////////////////////////////////////////////////////
183/// Destructor
184
186{
188}
189
190
191
192////////////////////////////////////////////////////////////////////////////////
193/// Equality operator comparing to a Double_t
194
196{
197 return (getVal()==value) ;
198}
199
200
201
202////////////////////////////////////////////////////////////////////////////////
203/// Equality operator when comparing to another RooAbsArg.
204/// Only functional when the other arg is a RooAbsReal
205
207{
208 const RooAbsReal* otherReal = dynamic_cast<const RooAbsReal*>(&other) ;
209 return otherReal ? operator==(otherReal->getVal()) : kFALSE ;
210}
211
212
213////////////////////////////////////////////////////////////////////////////////
214
215Bool_t RooAbsReal::isIdentical(const RooAbsArg& other, Bool_t assumeSameType)
216{
217 if (!assumeSameType) {
218 const RooAbsReal* otherReal = dynamic_cast<const RooAbsReal*>(&other) ;
219 return otherReal ? operator==(otherReal->getVal()) : kFALSE ;
220 } else {
221 return getVal()==((RooAbsReal&)other).getVal() ;
222 }
223}
224
225
226////////////////////////////////////////////////////////////////////////////////
227/// Return this variable's title string. If appendUnit is true and
228/// this variable has units, also append a string " (<unit>)".
229
230TString RooAbsReal::getTitle(Bool_t appendUnit) const
231{
232 TString title(GetTitle());
233 if(appendUnit && 0 != strlen(getUnit())) {
234 title.Append(" (");
235 title.Append(getUnit());
236 title.Append(")");
237 }
238 return title;
239}
240
241
242
243////////////////////////////////////////////////////////////////////////////////
244/// Return value of object. If the cache is clean, return the
245/// cached value, otherwise recalculate on the fly and refill
246/// the cache
247
249{
250 if (nset && nset!=_lastNSet) {
251 ((RooAbsReal*) this)->setProxyNormSet(nset) ;
252 _lastNSet = (RooArgSet*) nset ;
253 }
254
255 if (isValueDirtyAndClear()) {
256 _value = traceEval(nset) ;
257 // clearValueDirty() ;
258 }
259 // cout << "RooAbsReal::getValV(" << GetName() << ") writing _value = " << _value << endl ;
260
261 Double_t ret(_value) ;
262 if (hideOffset()) ret += offset() ;
263
264 return ret ;
265}
266
267
268////////////////////////////////////////////////////////////////////////////////
269
271{
272 return _evalErrorList.size() ;
273}
274
275
276////////////////////////////////////////////////////////////////////////////////
277
279{
280 return _evalErrorList.begin() ;
281}
282
283
284////////////////////////////////////////////////////////////////////////////////
285/// Calculate current value of object, with error tracing wrapper
286
288{
289 Double_t value = evaluate() ;
290
291 if (TMath::IsNaN(value)) {
292 logEvalError("function value is NAN") ;
293 }
294
295 //cxcoutD(Tracing) << "RooAbsReal::getValF(" << GetName() << ") operMode = " << _operMode << " recalculated, new value = " << value << endl ;
296
297 //Standard tracing code goes here
298 if (!isValidReal(value)) {
299 coutW(Tracing) << "RooAbsReal::traceEval(" << GetName()
300 << "): validation failed: " << value << endl ;
301 }
302
303 //Call optional subclass tracing code
304 // traceEvalHook(value) ;
305
306 return value ;
307}
308
309
310
311////////////////////////////////////////////////////////////////////////////////
312/// Variant of getAnalyticalIntegral that is also passed the normalization set
313/// that should be applied to the integrand of which the integral is request.
314/// For certain operator p.d.f it is useful to overload this function rather
315/// than analyticalIntegralWN() as the additional normalization information
316/// may be useful in determining a more efficient decomposition of the
317/// requested integral
318
320 const RooArgSet* /*normSet*/, const char* rangeName) const
321{
322 return _forceNumInt ? 0 : getAnalyticalIntegral(allDeps,analDeps,rangeName) ;
323}
324
325
326
327////////////////////////////////////////////////////////////////////////////////
328/// Interface function getAnalyticalIntergral advertises the
329/// analytical integrals that are supported. 'integSet'
330/// is the set of dependents for which integration is requested. The
331/// function should copy the subset of dependents it can analytically
332/// integrate to anaIntSet and return a unique identification code for
333/// this integration configuration. If no integration can be
334/// performed, zero should be returned.
335
336Int_t RooAbsReal::getAnalyticalIntegral(RooArgSet& /*integSet*/, RooArgSet& /*anaIntSet*/, const char* /*rangeName*/) const
337{
338 return 0 ;
339}
340
341
342
343////////////////////////////////////////////////////////////////////////////////
344/// Implements the actual analytical integral(s) advertised by
345/// getAnalyticalIntegral. This functions will only be called with
346/// codes returned by getAnalyticalIntegral, except code zero.
347
348Double_t RooAbsReal::analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName) const
349{
350// cout << "RooAbsReal::analyticalIntegralWN(" << GetName() << ") code = " << code << " normSet = " << (normSet?*normSet:RooArgSet()) << endl ;
351 if (code==0) return getVal(normSet) ;
352 return analyticalIntegral(code,rangeName) ;
353}
354
355
356
357////////////////////////////////////////////////////////////////////////////////
358/// Implements the actual analytical integral(s) advertised by
359/// getAnalyticalIntegral. This functions will only be called with
360/// codes returned by getAnalyticalIntegral, except code zero.
361
362Double_t RooAbsReal::analyticalIntegral(Int_t code, const char* /*rangeName*/) const
363{
364 // By default no analytical integrals are implemented
365 coutF(Eval) << "RooAbsReal::analyticalIntegral(" << GetName() << ") code " << code << " not implemented" << endl ;
366 return 0 ;
367}
368
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Get the label associated with the variable
373
374const char *RooAbsReal::getPlotLabel() const
375{
376 return _label.IsNull() ? fName.Data() : _label.Data();
377}
378
379
380
381////////////////////////////////////////////////////////////////////////////////
382/// Set the label associated with this variable
383
384void RooAbsReal::setPlotLabel(const char *label)
385{
386 _label= label;
387}
388
389
390
391////////////////////////////////////////////////////////////////////////////////
392///Read object contents from stream (dummy for now)
393
394Bool_t RooAbsReal::readFromStream(istream& /*is*/, Bool_t /*compact*/, Bool_t /*verbose*/)
395{
396 return kFALSE ;
397}
398
399
400
401////////////////////////////////////////////////////////////////////////////////
402///Write object contents to stream (dummy for now)
403
404void RooAbsReal::writeToStream(ostream& /*os*/, Bool_t /*compact*/) const
405{
406}
407
408
409
410////////////////////////////////////////////////////////////////////////////////
411/// Print object value
412
413void RooAbsReal::printValue(ostream& os) const
414{
415 os << getVal() ;
416}
417
418
419
420////////////////////////////////////////////////////////////////////////////////
421/// Structure printing
422
423void RooAbsReal::printMultiline(ostream& os, Int_t contents, Bool_t verbose, TString indent) const
424{
425 RooAbsArg::printMultiline(os,contents,verbose,indent) ;
426 os << indent << "--- RooAbsReal ---" << endl;
427 TString unit(_unit);
428 if(!unit.IsNull()) unit.Prepend(' ');
429 //os << indent << " Value = " << getVal() << unit << endl;
430 os << endl << indent << " Plot label is \"" << getPlotLabel() << "\"" << endl;
431
432}
433
434
435////////////////////////////////////////////////////////////////////////////////
436/// Check if current value is valid
437
439{
440 return isValidReal(_value) ;
441}
442
443
444
445////////////////////////////////////////////////////////////////////////////////
446/// Interface function to check if given value is a valid value for this object.
447/// This default implementation considers all values valid
448
449Bool_t RooAbsReal::isValidReal(Double_t /*value*/, Bool_t /*printError*/) const
450{
451 return kTRUE ;
452}
453
454
455
456
457////////////////////////////////////////////////////////////////////////////////
458/// Create a RooProfileLL object that eliminates all nuisance parameters in the
459/// present function. The nuisance parameters are defined as all parameters
460/// of the function except the stated paramsOfInterest
461
463{
464 // Construct name of profile object
465 TString name(Form("%s_Profile[",GetName())) ;
466 TIterator* iter = paramsOfInterest.createIterator() ;
467 RooAbsArg* arg ;
469 while((arg=(RooAbsArg*)iter->Next())) {
470 if (first) {
471 first=kFALSE ;
472 } else {
473 name.Append(",") ;
474 }
475 name.Append(arg->GetName()) ;
476 }
477 delete iter ;
478 name.Append("]") ;
479
480 // Create and return profile object
481 return new RooProfileLL(name.Data(),Form("Profile of %s",GetTitle()),*this,paramsOfInterest) ;
482}
483
484
485
486
487
488
489////////////////////////////////////////////////////////////////////////////////
490/// Create an object that represents the integral of the function over one or more observables listed in iset
491/// The actual integration calculation is only performed when the return object is evaluated. The name
492/// of the integral object is automatically constructed from the name of the input function, the variables
493/// it integrates and the range integrates over
494///
495/// The following named arguments are accepted
496/// | | Effect on integral creation
497/// |--|-------------------------------
498/// | `NormSet(const RooArgSet&)` | Specify normalization set, mostly useful when working with PDFS
499/// | `NumIntConfig(const RooNumIntConfig&)` | Use given configuration for any numeric integration, if necessary
500/// | `Range(const char* name)` | Integrate only over given range. Multiple ranges may be specified by passing multiple Range() arguments
501
503 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
504 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8) const
505{
506
507
508 // Define configuration for this method
509 RooCmdConfig pc(Form("RooAbsReal::createIntegral(%s)",GetName())) ;
510 pc.defineString("rangeName","RangeWithName",0,"",kTRUE) ;
511 pc.defineObject("normSet","NormSet",0,0) ;
512 pc.defineObject("numIntConfig","NumIntConfig",0,0) ;
513
514 // Process & check varargs
515 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
516 if (!pc.ok(kTRUE)) {
517 return 0 ;
518 }
519
520 // Extract values from named arguments
521 const char* rangeName = pc.getString("rangeName",0,kTRUE) ;
522 const RooArgSet* nset = static_cast<const RooArgSet*>(pc.getObject("normSet",0)) ;
523 const RooNumIntConfig* cfg = static_cast<const RooNumIntConfig*>(pc.getObject("numIntConfig",0)) ;
524
525 return createIntegral(iset,nset,cfg,rangeName) ;
526}
527
528
529
530
531
532////////////////////////////////////////////////////////////////////////////////
533/// Create an object that represents the integral of the function over one or more observables listed in iset
534/// The actual integration calculation is only performed when the return object is evaluated. The name
535/// of the integral object is automatically constructed from the name of the input function, the variables
536/// it integrates and the range integrates over. If nset is specified the integrand is request
537/// to be normalized over nset (only meaningful when the integrand is a pdf). If rangename is specified
538/// the integral is performed over the named range, otherwise it is performed over the domain of each
539/// integrated observable. If cfg is specified it will be used to configure any numeric integration
540/// aspect of the integral. It will not force the integral to be performed numerically, which is
541/// decided automatically by RooRealIntegral
542
544 const RooNumIntConfig* cfg, const char* rangeName) const
545{
546 if (!rangeName || strchr(rangeName,',')==0) {
547 // Simple case: integral over full range or single limited range
548 return createIntObj(iset,nset,cfg,rangeName) ;
549 }
550
551 // Integral over multiple ranges
552 RooArgSet components ;
553
554 TObjArray* oa = TString(rangeName).Tokenize(",");
555
556 for( Int_t i=0; i < oa->GetEntries(); ++i) {
557 TObjString* os = (TObjString*) (*oa)[i];
558 if(!os) break;
559 RooAbsReal* compIntegral = createIntObj(iset,nset,cfg,os->GetString().Data()) ;
560 components.add(*compIntegral) ;
561 }
562 delete oa;
563
564 TString title(GetTitle()) ;
565 title.Prepend("Integral of ") ;
566 TString fullName(GetName()) ;
567 fullName.Append(integralNameSuffix(iset,nset,rangeName)) ;
568
569 return new RooAddition(fullName.Data(),title.Data(),components,kTRUE) ;
570}
571
572
573
574////////////////////////////////////////////////////////////////////////////////
575/// Utility function for createIntegral that creates the actual integreal object
576
578 const RooNumIntConfig* cfg, const char* rangeName) const
579{
580 // Make internal use copies of iset and nset
581 RooArgSet iset(iset2) ;
582 const RooArgSet* nset = nset2 ;
583
584
585 // Initialize local variables perparing for recursive loop
586 Bool_t error = kFALSE ;
587 const RooAbsReal* integrand = this ;
588 RooAbsReal* integral = 0 ;
589
590 // Handle trivial case of no integration here explicitly
591 if (iset.getSize()==0) {
592
593 TString title(GetTitle()) ;
594 title.Prepend("Integral of ") ;
595
596 TString name(GetName()) ;
597 name.Append(integralNameSuffix(iset,nset,rangeName)) ;
598
599 return new RooRealIntegral(name,title,*this,iset,nset,cfg,rangeName) ;
600 }
601
602 // Process integration over remaining integration variables
603 while(iset.getSize()>0) {
604
605
606 // Find largest set of observables that can be integrated in one go
607 RooArgSet innerSet ;
608 findInnerMostIntegration(iset,innerSet,rangeName) ;
609
610 // If largest set of observables that can be integrated is empty set, problem was ill defined
611 // Postpone error messaging and handling to end of function, exit loop here
612 if (innerSet.getSize()==0) {
613 error = kTRUE ;
614 break ;
615 }
616
617 // Prepare name and title of integral to be created
618 TString title(integrand->GetTitle()) ;
619 title.Prepend("Integral of ") ;
620
621 TString name(integrand->GetName()) ;
622 name.Append(integrand->integralNameSuffix(innerSet,nset,rangeName)) ;
623
624 // Construct innermost integral
625 integral = new RooRealIntegral(name,title,*integrand,innerSet,nset,cfg,rangeName) ;
626
627 // Integral of integral takes ownership of innermost integral
628 if (integrand != this) {
629 integral->addOwnedComponents(*integrand) ;
630 }
631
632 // Remove already integrated observables from to-do list
633 iset.remove(innerSet) ;
634
635 // Send info message on recursion if needed
636 if (integrand == this && iset.getSize()>0) {
637 coutI(Integration) << GetName() << " : multidimensional integration over observables with parameterized ranges in terms of other integrated observables detected, using recursive integration strategy to construct final integral" << endl ;
638 }
639
640 // Prepare for recursion, next integral should integrate last integrand
641 integrand = integral ;
642
643
644 // Only need normalization set in innermost integration
645 nset = 0 ;
646 }
647
648 if (error) {
649 coutE(Integration) << GetName() << " : ERROR while defining recursive integral over observables with parameterized integration ranges, please check that integration rangs specify uniquely defined integral " << endl;
650 delete integral ;
651 integral = 0 ;
652 return integral ;
653 }
654
655
656 // After-burner: apply interpolating cache on (numeric) integral if requested by user
657 const char* cacheParamsStr = getStringAttribute("CACHEPARAMINT") ;
658 if (cacheParamsStr && strlen(cacheParamsStr)) {
659
660 RooArgSet* intParams = integral->getVariables() ;
661
662 RooNameSet cacheParamNames ;
663 cacheParamNames.setNameList(cacheParamsStr) ;
664 RooArgSet* cacheParams = cacheParamNames.select(*intParams) ;
665
666 if (cacheParams->getSize()>0) {
667 cxcoutD(Caching) << "RooAbsReal::createIntObj(" << GetName() << ") INFO: constructing " << cacheParams->getSize()
668 << "-dim value cache for integral over " << iset2 << " as a function of " << *cacheParams << " in range " << (rangeName?rangeName:"<none>") << endl ;
669 string name = Form("%s_CACHE_[%s]",integral->GetName(),cacheParams->contentsString().c_str()) ;
670 RooCachedReal* cachedIntegral = new RooCachedReal(name.c_str(),name.c_str(),*integral,*cacheParams) ;
671 cachedIntegral->setInterpolationOrder(2) ;
672 cachedIntegral->addOwnedComponents(*integral) ;
673 cachedIntegral->setCacheSource(kTRUE) ;
674 if (integral->operMode()==ADirty) {
675 cachedIntegral->setOperMode(ADirty) ;
676 }
677 //cachedIntegral->disableCache(kTRUE) ;
678 integral = cachedIntegral ;
679 }
680
681 delete cacheParams ;
682 delete intParams ;
683 }
684
685 return integral ;
686}
687
688
689
690////////////////////////////////////////////////////////////////////////////////
691/// Utility function for createIntObj() that aids in the construct of recursive integrals
692/// over functions with multiple observables with parameterized ranges. This function
693/// finds in a given set allObs over which integration is requested the largeset subset
694/// of observables that can be integrated simultaneously. This subset consists of
695/// observables with fixed ranges and observables with parameterized ranges whose
696/// parameterization does not depend on any observable that is also integrated.
697
698void RooAbsReal::findInnerMostIntegration(const RooArgSet& allObs, RooArgSet& innerObs, const char* rangeName) const
699{
700 // Make lists of
701 // a) integrated observables with fixed ranges,
702 // b) integrated observables with parameterized ranges depending on other integrated observables
703 // c) integrated observables used in definition of any parameterized ranges of integrated observables
704 RooArgSet obsWithFixedRange(allObs) ;
705 RooArgSet obsWithParamRange ;
706 RooArgSet obsServingAsRangeParams ;
707
708 // Loop over all integrated observables
709 TIterator* oiter = allObs.createIterator() ;
710 RooAbsArg* aarg ;
711 while((aarg=(RooAbsArg*)oiter->Next())) {
712 // Check if observable is real-valued lvalue
713 RooAbsRealLValue* arglv = dynamic_cast<RooAbsRealLValue*>(aarg) ;
714 if (arglv) {
715
716 // Check if range is parameterized
717 RooAbsBinning& binning = arglv->getBinning(rangeName,kFALSE,kTRUE) ;
718 if (binning.isParameterized()) {
719 RooArgSet* loBoundObs = binning.lowBoundFunc()->getObservables(allObs) ;
720 RooArgSet* hiBoundObs = binning.highBoundFunc()->getObservables(allObs) ;
721
722 // Check if range parameterization depends on other integrated observables
723 if (loBoundObs->overlaps(allObs) || hiBoundObs->overlaps(allObs)) {
724 obsWithParamRange.add(*aarg) ;
725 obsWithFixedRange.remove(*aarg) ;
726 obsServingAsRangeParams.add(*loBoundObs,kFALSE) ;
727 obsServingAsRangeParams.add(*hiBoundObs,kFALSE) ;
728 }
729 delete loBoundObs ;
730 delete hiBoundObs ;
731 }
732 }
733 }
734 delete oiter ;
735
736 // Make list of fixed-range observables that are _not_ involved in the parameterization of ranges of other observables
737 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
738 obsWithFixedRangeNP.remove(obsServingAsRangeParams) ;
739
740 // Make list of param-range observables that are _not_ involved in the parameterization of ranges of other observables
741 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
742 obsWithParamRangeNP.remove(obsServingAsRangeParams) ;
743
744 // Construct inner-most integration: over observables (with fixed or param range) not used in any other param range definitions
745 innerObs.removeAll() ;
746 innerObs.add(obsWithFixedRangeNP) ;
747 innerObs.add(obsWithParamRangeNP) ;
748
749}
750
751
752////////////////////////////////////////////////////////////////////////////////
753/// Construct string with unique suffix name to give to integral object that encodes
754/// integrated observables, normalization observables and the integration range name
755
756TString RooAbsReal::integralNameSuffix(const RooArgSet& iset, const RooArgSet* nset, const char* rangeName, Bool_t omitEmpty) const
757{
758 TString name ;
759 if (iset.getSize()>0) {
760
761 RooArgSet isetTmp(iset) ;
762 isetTmp.sort() ;
763
764 name.Append("_Int[") ;
765 TIterator* iter = isetTmp.createIterator() ;
766 RooAbsArg* arg ;
768 while((arg=(RooAbsArg*)iter->Next())) {
769 if (first) {
770 first=kFALSE ;
771 } else {
772 name.Append(",") ;
773 }
774 name.Append(arg->GetName()) ;
775 }
776 delete iter ;
777 if (rangeName) {
778 name.Append("|") ;
779 name.Append(rangeName) ;
780 }
781 name.Append("]");
782 } else if (!omitEmpty) {
783 name.Append("_Int[]") ;
784 }
785
786 if (nset && nset->getSize()>0 ) {
787
788 RooArgSet nsetTmp(*nset) ;
789 nsetTmp.sort() ;
790
791 name.Append("_Norm[") ;
793 TIterator* iter = nsetTmp.createIterator() ;
794 RooAbsArg* arg ;
795 while((arg=(RooAbsArg*)iter->Next())) {
796 if (first) {
797 first=kFALSE ;
798 } else {
799 name.Append(",") ;
800 }
801 name.Append(arg->GetName()) ;
802 }
803 delete iter ;
804 const RooAbsPdf* thisPdf = dynamic_cast<const RooAbsPdf*>(this) ;
805 if (thisPdf && thisPdf->normRange()) {
806 name.Append("|") ;
807 name.Append(thisPdf->normRange()) ;
808 }
809 name.Append("]") ;
810 }
811
812 return name ;
813}
814
815
816
817////////////////////////////////////////////////////////////////////////////////
818/// Utility function for plotOn() that creates a projection of a function or p.d.f
819/// to be plotted on a RooPlot.
820/// \ref createPlotProjAnchor "createPlotProjection()"
821
822const RooAbsReal* RooAbsReal::createPlotProjection(const RooArgSet& depVars, const RooArgSet& projVars,
823 RooArgSet*& cloneSet) const
824{
825 return createPlotProjection(depVars,&projVars,cloneSet) ;
826}
827
828
829
830////////////////////////////////////////////////////////////////////////////////
831/// Utility function for plotOn() that creates a projection of a function or p.d.f
832/// to be plotted on a RooPlot.
833/// \ref createPlotProjAnchor "createPlotProjection()"
834
835const RooAbsReal* RooAbsReal::createPlotProjection(const RooArgSet& depVars, const RooArgSet& projVars) const
836{
837 RooArgSet* cloneSet = new RooArgSet() ;
838 return createPlotProjection(depVars,&projVars,cloneSet) ;
839}
840
841
842
843////////////////////////////////////////////////////////////////////////////////
844/// Utility function for plotOn() that creates a projection of a function or p.d.f
845/// to be plotted on a RooPlot.
846/// \anchor createPlotProjAnchor
847///
848/// Create a new object \f$ G \f$ that represents the normalized projection:
849/// \f[
850/// G[x,p] = \frac{\int F[x,y,p] \; \mathrm{d}\{y\}}
851/// {\int F[x,y,p] \; \mathrm{d}\{x\} \, \mathrm{d}\{y\}}
852/// \f]
853/// where \f$ F[x,y,p] \f$ is the function we represent, and
854/// \f$ \{ p \} \f$ are the remaining variables ("parameters").
855///
856/// \param[in] dependentVars Dependent variables over which to normalise, \f$ \{x\} \f$
857/// \param[in] projectedVars Variables to project out, \f$ \{ y \} \f$
858/// \param[out] cloneSet Will be set to a RooArgSet*, which will contain a clone of *this plus its projection integral object.
859/// The latter will also be returned. The caller takes ownership of this set.
860/// \param[in] rangeName Optional range for projection integrals
861/// \param[in] condObs Conditional observables, which are not integrated for normalisation, even if they
862/// are in `dependentVars` or `projectedVars`
863/// \return A pointer to the newly created object, or else zero in case of an
864/// error. The caller is responsible for deleting the contents of
865/// cloneSet (which includes the returned projection object)
866
867const RooAbsReal *RooAbsReal::createPlotProjection(const RooArgSet &dependentVars, const RooArgSet *projectedVars,
868 RooArgSet *&cloneSet, const char* rangeName, const RooArgSet* condObs) const
869{
870 // Get the set of our leaf nodes
871 RooArgSet leafNodes;
872 RooArgSet treeNodes;
873 leafNodeServerList(&leafNodes,this);
874 treeNodeServerList(&treeNodes,this) ;
875
876
877 // Check that the dependents are all fundamental. Filter out any that we
878 // do not depend on, and make substitutions by name in our leaf list.
879 // Check for overlaps with the projection variables.
880
881 TIterator *dependentIterator= dependentVars.createIterator();
882 assert(0 != dependentIterator);
883 const RooAbsArg *arg = 0;
884 while((arg= (const RooAbsArg*)dependentIterator->Next())) {
885 if(!arg->isFundamental() && !dynamic_cast<const RooAbsLValue*>(arg)) {
886 coutE(Plotting) << ClassName() << "::" << GetName() << ":createPlotProjection: variable \"" << arg->GetName()
887 << "\" of wrong type: " << arg->ClassName() << endl;
888 delete dependentIterator;
889 return 0;
890 }
891
892 RooAbsArg *found= treeNodes.find(arg->GetName());
893 if(!found) {
894 coutE(Plotting) << ClassName() << "::" << GetName() << ":createPlotProjection: \"" << arg->GetName()
895 << "\" is not a dependent and will be ignored." << endl;
896 continue;
897 }
898 if(found != arg) {
899 if (leafNodes.find(found->GetName())) {
900 leafNodes.replace(*found,*arg);
901 } else {
902 leafNodes.add(*arg) ;
903
904 // Remove any dependents of found, replace by dependents of LV node
905 RooArgSet* lvDep = arg->getObservables(&leafNodes) ;
906 RooAbsArg* lvs ;
907 TIterator* iter = lvDep->createIterator() ;
908 while((lvs=(RooAbsArg*)iter->Next())) {
909 RooAbsArg* tmp = leafNodes.find(lvs->GetName()) ;
910 if (tmp) {
911 leafNodes.remove(*tmp) ;
912 leafNodes.add(*lvs) ;
913 }
914 }
915 delete iter ;
916
917 }
918 }
919
920 // check if this arg is also in the projection set
921 if(0 != projectedVars && projectedVars->find(arg->GetName())) {
922 coutE(Plotting) << ClassName() << "::" << GetName() << ":createPlotProjection: \"" << arg->GetName()
923 << "\" cannot be both a dependent and a projected variable." << endl;
924 delete dependentIterator;
925 return 0;
926 }
927 }
928
929 // Remove the projected variables from the list of leaf nodes, if necessary.
930 if(0 != projectedVars) leafNodes.remove(*projectedVars,kTRUE);
931
932 // Make a deep-clone of ourself so later operations do not disturb our original state
933 cloneSet= (RooArgSet*)RooArgSet(*this).snapshot(kTRUE);
934 if (!cloneSet) {
935 coutE(Plotting) << "RooAbsPdf::createPlotProjection(" << GetName() << ") Couldn't deep-clone PDF, abort," << endl ;
936 return 0 ;
937 }
938 RooAbsReal *theClone= (RooAbsReal*)cloneSet->find(GetName());
939
940 // The remaining entries in our list of leaf nodes are the the external
941 // dependents (x) and parameters (p) of the projection. Patch them back
942 // into the theClone. This orphans the nodes they replace, but the orphans
943 // are still in the cloneList and so will be cleaned up eventually.
944 //cout << "redirection leafNodes : " ; leafNodes.Print("1") ;
945
946 RooArgSet* plotLeafNodes = (RooArgSet*) leafNodes.selectCommon(dependentVars) ;
947 theClone->recursiveRedirectServers(*plotLeafNodes,kFALSE,kFALSE,kFALSE);
948 delete plotLeafNodes ;
949
950 // Create the set of normalization variables to use in the projection integrand
951 RooArgSet normSet(dependentVars);
952 if(0 != projectedVars) normSet.add(*projectedVars);
953 if(0 != condObs) {
954 normSet.remove(*condObs,kTRUE,kTRUE) ;
955 }
956
957 // Try to create a valid projection integral. If no variables are to be projected,
958 // create a null projection anyway to bind our normalization over the dependents
959 // consistently with the way they would be bound with a non-trivial projection.
960 RooArgSet empty;
961 if(0 == projectedVars) projectedVars= &empty;
962
963 TString name = GetName() ;
964 name += integralNameSuffix(*projectedVars,&normSet,rangeName,kTRUE) ;
965
966 TString title(GetTitle());
967 title.Prepend("Projection of ");
968
969
970 RooAbsReal* projected= theClone->createIntegral(*projectedVars,normSet,rangeName) ;
971
972 if(0 == projected || !projected->isValid()) {
973 coutE(Plotting) << ClassName() << "::" << GetName() << ":createPlotProjection: cannot integrate out ";
974 projectedVars->printStream(cout,kName|kArgs,kSingleLine);
975 // cleanup and exit
976 if(0 != projected) delete projected;
977 delete dependentIterator;
978 return 0;
979 }
980
981 if(projected->InheritsFrom(RooRealIntegral::Class())){
982 ((RooRealIntegral*)projected)->setAllowComponentSelection(true);
983 }
984
985 projected->SetName(name.Data()) ;
986 projected->SetTitle(title.Data()) ;
987
988 // Add the projection integral to the cloneSet so that it eventually gets cleaned up by the caller.
989 cloneSet->addOwned(*projected);
990
991 // cleanup
992 delete dependentIterator;
993
994 // return a const pointer to remind the caller that they do not delete the returned object
995 // directly (it is contained in the cloneSet instead).
996 return projected;
997}
998
999
1000
1001
1002////////////////////////////////////////////////////////////////////////////////
1003/// Fill the ROOT histogram 'hist' with values sampled from this
1004/// function at the bin centers. Our value is calculated by first
1005/// integrating out any variables in projectedVars and then scaling
1006/// the result by scaleFactor. Returns a pointer to the input
1007/// histogram, or zero in case of an error. The input histogram can
1008/// be any TH1 subclass, and therefore of arbitrary
1009/// dimension. Variables are matched with the (x,y,...) dimensions of
1010/// the input histogram according to the order in which they appear
1011/// in the input plotVars list. If scaleForDensity is true the
1012/// histogram is filled with a the functions density rather than
1013/// the functions value (i.e. the value at the bin center is multiplied
1014/// with bin volume)
1015
1017 Double_t scaleFactor, const RooArgSet *projectedVars, Bool_t scaleForDensity,
1018 const RooArgSet* condObs, Bool_t setError) const
1019{
1020 // Do we have a valid histogram to use?
1021 if(0 == hist) {
1022 coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: no valid histogram to fill" << endl;
1023 return 0;
1024 }
1025
1026 // Check that the number of plotVars matches the input histogram's dimension
1027 Int_t hdim= hist->GetDimension();
1028 if(hdim != plotVars.getSize()) {
1029 coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: plotVars has the wrong dimension" << endl;
1030 return 0;
1031 }
1032
1033
1034 // Check that the plot variables are all actually RooRealVars and print a warning if we do not
1035 // explicitly depend on one of them. Fill a set (not list!) of cloned plot variables.
1036 RooArgSet plotClones;
1037 for(Int_t index= 0; index < plotVars.getSize(); index++) {
1038 const RooAbsArg *var= plotVars.at(index);
1039 const RooRealVar *realVar= dynamic_cast<const RooRealVar*>(var);
1040 if(0 == realVar) {
1041 coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: cannot plot variable \"" << var->GetName()
1042 << "\" of type " << var->ClassName() << endl;
1043 return 0;
1044 }
1045 if(!this->dependsOn(*realVar)) {
1046 coutE(InputArguments) << ClassName() << "::" << GetName()
1047 << ":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->GetName() << endl;
1048 }
1049 plotClones.addClone(*realVar,kTRUE); // do not complain about duplicates
1050 }
1051
1052 // Reconnect all plotClones to each other, imported when plotting N-dim integrals with entangled parameterized ranges
1053 TIterator* pciter= plotClones.createIterator() ;
1054 RooAbsArg* pc ;
1055 while((pc=(RooAbsArg*)pciter->Next())) {
1056 pc->recursiveRedirectServers(plotClones,kFALSE,kFALSE,kTRUE) ;
1057 }
1058
1059 delete pciter ;
1060
1061 // Call checkObservables
1062 RooArgSet allDeps(plotClones) ;
1063 if (projectedVars) {
1064 allDeps.add(*projectedVars) ;
1065 }
1066 if (checkObservables(&allDeps)) {
1067 coutE(InputArguments) << "RooAbsReal::fillHistogram(" << GetName() << ") error in checkObservables, abort" << endl ;
1068 return hist ;
1069 }
1070
1071 // Create a standalone projection object to use for calculating bin contents
1072 RooArgSet *cloneSet = 0;
1073 const RooAbsReal *projected= createPlotProjection(plotClones,projectedVars,cloneSet,0,condObs);
1074
1075 cxcoutD(Plotting) << "RooAbsReal::fillHistogram(" << GetName() << ") plot projection object is " << projected->GetName() << endl ;
1076
1077 // Prepare to loop over the histogram bins
1078 Int_t xbins(0),ybins(1),zbins(1);
1079 RooRealVar *xvar = 0;
1080 RooRealVar *yvar = 0;
1081 RooRealVar *zvar = 0;
1082 TAxis *xaxis = 0;
1083 TAxis *yaxis = 0;
1084 TAxis *zaxis = 0;
1085 switch(hdim) {
1086 case 3:
1087 zbins= hist->GetNbinsZ();
1088 zvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(2)->GetName()));
1089 zaxis= hist->GetZaxis();
1090 assert(0 != zvar && 0 != zaxis);
1091 if (scaleForDensity) {
1092 scaleFactor*= (zaxis->GetXmax() - zaxis->GetXmin())/zbins;
1093 }
1094 // fall through to next case...
1095 case 2:
1096 ybins= hist->GetNbinsY();
1097 yvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(1)->GetName()));
1098 yaxis= hist->GetYaxis();
1099 assert(0 != yvar && 0 != yaxis);
1100 if (scaleForDensity) {
1101 scaleFactor*= (yaxis->GetXmax() - yaxis->GetXmin())/ybins;
1102 }
1103 // fall through to next case...
1104 case 1:
1105 xbins= hist->GetNbinsX();
1106 xvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(0)->GetName()));
1107 xaxis= hist->GetXaxis();
1108 assert(0 != xvar && 0 != xaxis);
1109 if (scaleForDensity) {
1110 scaleFactor*= (xaxis->GetXmax() - xaxis->GetXmin())/xbins;
1111 }
1112 break;
1113 default:
1114 coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: cannot fill histogram with "
1115 << hdim << " dimensions" << endl;
1116 break;
1117 }
1118
1119 // Loop over the input histogram's bins and fill each one with our projection's
1120 // value, calculated at the center.
1122 Int_t xbin(0),ybin(0),zbin(0);
1123 Int_t bins= xbins*ybins*zbins;
1124 for(Int_t bin= 0; bin < bins; bin++) {
1125 switch(hdim) {
1126 case 3:
1127 if(bin % (xbins*ybins) == 0) {
1128 zbin++;
1129 zvar->setVal(zaxis->GetBinCenter(zbin));
1130 }
1131 // fall through to next case...
1132 case 2:
1133 if(bin % xbins == 0) {
1134 ybin= (ybin%ybins) + 1;
1135 yvar->setVal(yaxis->GetBinCenter(ybin));
1136 }
1137 // fall through to next case...
1138 case 1:
1139 xbin= (xbin%xbins) + 1;
1140 xvar->setVal(xaxis->GetBinCenter(xbin));
1141 break;
1142 default:
1143 coutE(InputArguments) << "RooAbsReal::fillHistogram: Internal Error!" << endl;
1144 break;
1145 }
1146
1147 Double_t result= scaleFactor*projected->getVal();
1148 if (RooAbsReal::numEvalErrors()>0) {
1149 coutW(Plotting) << "WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->getVal() ;
1150 if (hdim==2) ccoutW(Plotting) << " [y]=" << yvar->getVal() ;
1151 if (hdim==3) ccoutW(Plotting) << " [z]=" << zvar->getVal() ;
1152 ccoutW(Plotting) << endl ;
1153 // RooAbsReal::printEvalErrors(ccoutW(Plotting),10) ;
1154 result = 0 ;
1155 }
1157
1158 hist->SetBinContent(hist->GetBin(xbin,ybin,zbin),result);
1159 if (setError) {
1160 hist->SetBinError(hist->GetBin(xbin,ybin,zbin),sqrt(result)) ;
1161 }
1162
1163 //cout << "bin " << bin << " -> (" << xbin << "," << ybin << "," << zbin << ") = " << result << endl;
1164 }
1166
1167 // cleanup
1168 delete cloneSet;
1169
1170 return hist;
1171}
1172
1173
1174
1175////////////////////////////////////////////////////////////////////////////////
1176/// Fill a RooDataHist with values sampled from this function at the
1177/// bin centers. If extendedMode is true, the p.d.f. values is multiplied
1178/// by the number of expected events in each bin
1179///
1180/// An optional scaling by a given scaleFactor can be performed.
1181/// Returns a pointer to the input RooDataHist, or zero
1182/// in case of an error.
1183///
1184/// If correctForBinSize is true the RooDataHist
1185/// is filled with the functions density (function value times the
1186/// bin volume) rather than function value.
1187///
1188/// If showProgress is true
1189/// a process indicator is printed on stdout in steps of one percent,
1190/// which is mostly useful for the sampling of expensive functions
1191/// such as likelihoods
1192
1194 Bool_t correctForBinSize, Bool_t showProgress) const
1195{
1196 // Do we have a valid histogram to use?
1197 if(0 == hist) {
1198 coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillDataHist: no valid RooDataHist to fill" << endl;
1199 return 0;
1200 }
1201
1202 // Call checkObservables
1203 RooArgSet allDeps(*hist->get()) ;
1204 if (checkObservables(&allDeps)) {
1205 coutE(InputArguments) << "RooAbsReal::fillDataHist(" << GetName() << ") error in checkObservables, abort" << endl ;
1206 return hist ;
1207 }
1208
1209 // Make deep clone of self and attach to dataset observables
1210 //RooArgSet* origObs = getObservables(hist) ;
1211 RooArgSet* cloneSet = (RooArgSet*) RooArgSet(*this).snapshot(kTRUE) ;
1212 RooAbsReal* theClone = (RooAbsReal*) cloneSet->find(GetName()) ;
1213 theClone->recursiveRedirectServers(*hist->get()) ;
1214 //const_cast<RooAbsReal*>(this)->recursiveRedirectServers(*hist->get()) ;
1215
1216 // Iterator over all bins of RooDataHist and fill weights
1217 Int_t onePct = hist->numEntries()/100 ;
1218 if (onePct==0) {
1219 onePct++ ;
1220 }
1221 for (Int_t i=0 ; i<hist->numEntries() ; i++) {
1222 if (showProgress && (i%onePct==0)) {
1223 ccoutP(Eval) << "." << flush ;
1224 }
1225 const RooArgSet* obs = hist->get(i) ;
1226 Double_t binVal = theClone->getVal(normSet?normSet:obs)*scaleFactor ;
1227 if (correctForBinSize) {
1228 binVal*= hist->binVolume() ;
1229 }
1230 hist->set(binVal) ;
1231 }
1232
1233 delete cloneSet ;
1234 //const_cast<RooAbsReal*>(this)->recursiveRedirectServers(*origObs) ;
1235 //delete origObs ;
1236
1237 return hist;
1238}
1239
1240
1241
1242
1243////////////////////////////////////////////////////////////////////////////////
1244/// Create and fill a ROOT histogram TH1, TH2 or TH3 with the values of this function for the variables with given names.
1245/// \param[in] varNameList List of variables to use for x, y, z axis, separated by ':'
1246/// \param[in] xbins Number of bins for first variable
1247/// \param[in] ybins Number of bins for second variable
1248/// \param[in] zbins Number of bins for third variable
1249/// \return TH1*, which is one of TH[1-3]. The histogram is owned by the caller.
1250///
1251/// For a greater degree of control use
1252/// RooAbsReal::createHistogram(const char *, const RooAbsRealLValue&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&) const
1253///
1254
1255TH1* RooAbsReal::createHistogram(const char* varNameList, Int_t xbins, Int_t ybins, Int_t zbins) const
1256{
1257 // Parse list of variable names
1258 char buf[1024] ;
1259 strlcpy(buf,varNameList,1024) ;
1260 char* varName = strtok(buf,",:") ;
1261
1262 RooArgSet* vars = getVariables() ;
1263
1264 RooRealVar* xvar = (RooRealVar*) vars->find(varName) ;
1265 varName = strtok(0,",") ;
1266 RooRealVar* yvar = varName ? (RooRealVar*) vars->find(varName) : 0 ;
1267 varName = strtok(0,",") ;
1268 RooRealVar* zvar = varName ? (RooRealVar*) vars->find(varName) : 0 ;
1269
1270 delete vars ;
1271
1272 // Construct list of named arguments to pass to the implementation version of createHistogram()
1273
1274 RooLinkedList argList ;
1275 if (xbins>0) {
1276 argList.Add(RooFit::Binning(xbins).Clone()) ;
1277 }
1278
1279 if (yvar) {
1280 if (ybins>0) {
1281 argList.Add(RooFit::YVar(*yvar,RooFit::Binning(ybins)).Clone()) ;
1282 } else {
1283 argList.Add(RooFit::YVar(*yvar).Clone()) ;
1284 }
1285 }
1286
1287
1288 if (zvar) {
1289 if (zbins>0) {
1290 argList.Add(RooFit::ZVar(*zvar,RooFit::Binning(zbins)).Clone()) ;
1291 } else {
1292 argList.Add(RooFit::ZVar(*zvar).Clone()) ;
1293 }
1294 }
1295
1296
1297 // Call implementation function
1298 TH1* result = createHistogram(GetName(),*xvar,argList) ;
1299
1300 // Delete temporary list of RooCmdArgs
1301 argList.Delete() ;
1302
1303 return result ;
1304}
1305
1306
1307
1308////////////////////////////////////////////////////////////////////////////////
1309/// Create and fill a ROOT histogram TH1, TH2 or TH3 with the values of this function.
1310///
1311/// \param[in] name Name of the ROOT histogram
1312/// \param[in] xvar Observable to be mapped on x axis of ROOT histogram
1313/// \param[in] arg[0-9] Arguments according to list below
1314/// \return TH1 *, one of TH{1,2,3}. The caller takes ownership.
1315///
1316/// <table>
1317/// <tr><th><th> Effect on histogram creation
1318/// <tr><td> `IntrinsicBinning()` <td> Apply binning defined by function or pdf (as advertised via binBoundaries() method)
1319/// <tr><td> `Binning(const char* name)` <td> Apply binning with given name to x axis of histogram
1320/// <tr><td> `Binning(RooAbsBinning& binning)` <td> Apply specified binning to x axis of histogram
1321/// <tr><td> `Binning(int nbins, [double lo, double hi])` <td> Apply specified binning to x axis of histogram
1322/// <tr><td> `ConditionalObservables(const RooArgSet& set)` <td> Do not normalized PDF over following observables when projecting PDF into histogram
1323/// <tr><td> `Scaling(Bool_t)` <td> Apply density-correction scaling (multiply by bin volume), default is kTRUE
1324/// <tr><td> `Extended(Bool_t)` <td> Plot event yield instead of probability density (for extended pdfs only)
1325///
1326/// <tr><td> `YVar(const RooAbsRealLValue& var,...)` <td> Observable to be mapped on y axis of ROOT histogram.
1327/// The YVar() and ZVar() arguments can be supplied with optional Binning() arguments to control the binning of the Y and Z axes, e.g.
1328/// ```
1329/// createHistogram("histo",x,Binning(-1,1,20), YVar(y,Binning(-1,1,30)), ZVar(z,Binning("zbinning")))
1330/// ```
1331/// <tr><td> `ZVar(const RooAbsRealLValue& var,...)` <td> Observable to be mapped on z axis of ROOT histogram
1332/// </table>
1333///
1334///
1335
1337 const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1338 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8) const
1339{
1340
1342 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
1343 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
1344 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
1345 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
1346
1347 return createHistogram(name,xvar,l) ;
1348}
1349
1350
1351////////////////////////////////////////////////////////////////////////////////
1352/// Internal method implementing createHistogram
1353
1354TH1* RooAbsReal::createHistogram(const char *name, const RooAbsRealLValue& xvar, RooLinkedList& argList) const
1355{
1356
1357 // Define configuration for this method
1358 RooCmdConfig pc(Form("RooAbsReal::createHistogram(%s)",GetName())) ;
1359 pc.defineInt("scaling","Scaling",0,1) ;
1360 pc.defineInt("intBinning","IntrinsicBinning",0,2) ;
1361 pc.defineInt("extended","Extended",0,2) ;
1362
1363 pc.defineObject("compSet","SelectCompSet",0) ;
1364 pc.defineString("compSpec","SelectCompSpec",0) ;
1365 pc.defineSet("projObs","ProjectedObservables",0,0) ;
1366 pc.defineObject("yvar","YVar",0,0) ;
1367 pc.defineObject("zvar","ZVar",0,0) ;
1368 pc.defineMutex("SelectCompSet","SelectCompSpec") ;
1369 pc.defineMutex("IntrinsicBinning","Binning") ;
1370 pc.defineMutex("IntrinsicBinning","BinningName") ;
1371 pc.defineMutex("IntrinsicBinning","BinningSpec") ;
1372 pc.allowUndefined() ;
1373
1374 // Process & check varargs
1375 pc.process(argList) ;
1376 if (!pc.ok(kTRUE)) {
1377 return 0 ;
1378 }
1379
1380 RooArgList vars(xvar) ;
1381 RooAbsArg* yvar = static_cast<RooAbsArg*>(pc.getObject("yvar")) ;
1382 if (yvar) {
1383 vars.add(*yvar) ;
1384 }
1385 RooAbsArg* zvar = static_cast<RooAbsArg*>(pc.getObject("zvar")) ;
1386 if (zvar) {
1387 vars.add(*zvar) ;
1388 }
1389
1390 RooArgSet* projObs = pc.getSet("projObs") ;
1391 RooArgSet* intObs = 0 ;
1392
1393 Bool_t doScaling = pc.getInt("scaling") ;
1394 Int_t doIntBinning = pc.getInt("intBinning") ;
1395 Int_t doExtended = pc.getInt("extended") ;
1396
1397 // If doExtended is two, selection is automatic, set to 1 of pdf is extended, to zero otherwise
1398 const RooAbsPdf* pdfSelf = dynamic_cast<const RooAbsPdf*>(this) ;
1399 if (!pdfSelf && doExtended>0) {
1400 coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName() << ") WARNING extended mode requested for a non-pdf object, ignored" << endl ;
1401 doExtended=0 ;
1402 }
1403 if (pdfSelf && doExtended==1 && pdfSelf->extendMode()==RooAbsPdf::CanNotBeExtended) {
1404 coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName() << ") WARNING extended mode requested for a non-extendable pdf, ignored" << endl ;
1405 doExtended=0 ;
1406 }
1407 if (pdfSelf && doExtended==2) {
1408 doExtended = pdfSelf->extendMode()==RooAbsPdf::CanNotBeExtended ? 0 : 1 ;
1409 }
1410
1411 const char* compSpec = pc.getString("compSpec") ;
1412 const RooArgSet* compSet = (const RooArgSet*) pc.getObject("compSet") ;
1413 Bool_t haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1414
1415 RooBinning* intBinning(0) ;
1416 if (doIntBinning>0) {
1417 // Given RooAbsPdf* pdf and RooRealVar* obs
1418 list<Double_t>* bl = binBoundaries((RooRealVar&)xvar,xvar.getMin(),xvar.getMax()) ;
1419 if (!bl) {
1420 // Only emit warning when intrinsic binning is explicitly requested
1421 if (doIntBinning==1) {
1422 coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName()
1423 << ") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< endl ;
1424 }
1425 } else {
1426 if (doIntBinning==2) {
1427 coutI(InputArguments) << "RooAbsReal::createHistogram(" << GetName()
1428 << ") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< endl ;
1429 }
1430 Double_t* ba = new Double_t[bl->size()] ; int i=0 ;
1431 for (list<double>::iterator it=bl->begin() ; it!=bl->end() ; ++it) { ba[i++] = *it ; }
1432 intBinning = new RooBinning(bl->size()-1,ba) ;
1433 delete[] ba ;
1434 }
1435 }
1436
1437 RooLinkedList argListCreate(argList) ;
1438 pc.stripCmdList(argListCreate,"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1439
1440 TH1* histo(0) ;
1441 if (intBinning) {
1442 RooCmdArg tmp = RooFit::Binning(*intBinning) ;
1443 argListCreate.Add(&tmp) ;
1444 histo = xvar.createHistogram(name,argListCreate) ;
1445 delete intBinning ;
1446 } else {
1447 histo = xvar.createHistogram(name,argListCreate) ;
1448 }
1449
1450 // Do component selection here
1451 if (haveCompSel) {
1452
1453 // Get complete set of tree branch nodes
1454 RooArgSet branchNodeSet ;
1455 branchNodeServerList(&branchNodeSet) ;
1456
1457 // Discard any non-RooAbsReal nodes
1458 TIterator* iter = branchNodeSet.createIterator() ;
1459 RooAbsArg* arg ;
1460 while((arg=(RooAbsArg*)iter->Next())) {
1461 if (!dynamic_cast<RooAbsReal*>(arg)) {
1462 branchNodeSet.remove(*arg) ;
1463 }
1464 }
1465 delete iter ;
1466
1467 RooArgSet* dirSelNodes ;
1468 if (compSet) {
1469 dirSelNodes = (RooArgSet*) branchNodeSet.selectCommon(*compSet) ;
1470 } else {
1471 dirSelNodes = (RooArgSet*) branchNodeSet.selectByName(compSpec) ;
1472 }
1473 if (dirSelNodes->getSize()>0) {
1474 coutI(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") directly selected PDF components: " << *dirSelNodes << endl ;
1475
1476 // Do indirect selection and activate both
1477 plotOnCompSelect(dirSelNodes) ;
1478 } else {
1479 if (compSet) {
1480 coutE(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") ERROR: component selection set " << *compSet << " does not match any components of p.d.f." << endl ;
1481 } else {
1482 coutE(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") ERROR: component selection expression '" << compSpec << "' does not select any components of p.d.f." << endl ;
1483 }
1484 return 0 ;
1485 }
1486 delete dirSelNodes ;
1487 }
1488
1489 Double_t scaleFactor(1.0) ;
1490 if (doExtended) {
1491 scaleFactor = pdfSelf->expectedEvents(vars) ;
1492 doScaling=kFALSE ;
1493 }
1494
1495 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,kFALSE) ;
1496
1497 // Deactivate component selection
1498 if (haveCompSel) {
1499 plotOnCompSelect(0) ;
1500 }
1501
1502
1503 return histo ;
1504}
1505
1506
1507////////////////////////////////////////////////////////////////////////////////
1508/// Helper function for plotting of composite p.d.fs. Given
1509/// a set of selected components that should be plotted,
1510/// find all nodes that (in)directly depend on these selected
1511/// nodes. Mark all directly and indirecty selected nodes
1512/// as 'selected' using the selectComp() method
1513
1515{
1516 // Get complete set of tree branch nodes
1517 RooArgSet branchNodeSet ;
1518 branchNodeServerList(&branchNodeSet) ;
1519
1520 // Discard any non-PDF nodes
1521 TIterator* iter = branchNodeSet.createIterator() ;
1522 RooAbsArg* arg ;
1523 while((arg=(RooAbsArg*)iter->Next())) {
1524 if (!dynamic_cast<RooAbsReal*>(arg)) {
1525 branchNodeSet.remove(*arg) ;
1526 }
1527 }
1528
1529 // If no set is specified, restored all selection bits to kTRUE
1530 if (!selNodes) {
1531 // Reset PDF selection bits to kTRUE
1532 iter->Reset() ;
1533 while((arg=(RooAbsArg*)iter->Next())) {
1534 ((RooAbsReal*)arg)->selectComp(kTRUE) ;
1535 }
1536 delete iter ;
1537 return ;
1538 }
1539
1540
1541 // Add all nodes below selected nodes
1542 iter->Reset() ;
1543 TIterator* sIter = selNodes->createIterator() ;
1544 RooArgSet tmp ;
1545 while((arg=(RooAbsArg*)iter->Next())) {
1546 sIter->Reset() ;
1547 RooAbsArg* selNode ;
1548 while((selNode=(RooAbsArg*)sIter->Next())) {
1549 if (selNode->dependsOn(*arg)) {
1550 tmp.add(*arg,kTRUE) ;
1551 }
1552 }
1553 }
1554 delete sIter ;
1555
1556 // Add all nodes that depend on selected nodes
1557 iter->Reset() ;
1558 while((arg=(RooAbsArg*)iter->Next())) {
1559 if (arg->dependsOn(*selNodes)) {
1560 tmp.add(*arg,kTRUE) ;
1561 }
1562 }
1563
1564 tmp.remove(*selNodes,kTRUE) ;
1565 tmp.remove(*this) ;
1566 selNodes->add(tmp) ;
1567 coutI(Plotting) << "RooAbsPdf::plotOn(" << GetName() << ") indirectly selected PDF components: " << tmp << endl ;
1568
1569 // Set PDF selection bits according to selNodes
1570 iter->Reset() ;
1571 while((arg=(RooAbsArg*)iter->Next())) {
1572 Bool_t select = selNodes->find(arg->GetName()) ? kTRUE : kFALSE ;
1573 ((RooAbsReal*)arg)->selectComp(select) ;
1574 }
1575
1576 delete iter ;
1577}
1578
1579
1580
1581////////////////////////////////////////////////////////////////////////////////
1582/// Plot (project) PDF on specified frame. If a PDF is plotted in an empty frame, it
1583/// will show a unit normalized curve in the frame variable, taken at the present value
1584/// of other observables defined for this PDF
1585///
1586/// If a PDF is plotted in a frame in which a dataset has already been plotted, it will
1587/// show a projected curve integrated over all variables that were present in the shown
1588/// dataset except for the one on the x-axis. The normalization of the curve will also
1589/// be adjusted to the event count of the plotted dataset. An informational message
1590/// will be printed for each projection step that is performed
1591///
1592/// This function takes the following named arguments
1593/// <table>
1594/// <tr><th><th> Projection control
1595/// <tr><td> `Slice(const RooArgSet& set)` <td> Override default projection behaviour by omittting observables listed
1596/// in set from the projection, resulting a 'slice' plot. Slicing is usually
1597/// only sensible in discrete observables. The slice is position at the 'current'
1598/// value of the observable objects
1599///
1600/// <tr><td> `Slice(RooCategory& cat, const char* label)` <td> Override default projection behaviour by omittting specified category
1601/// observable from the projection, resulting in a 'slice' plot. The slice is positioned
1602/// at the given label value. Multiple Slice() commands can be given to specify slices
1603/// in multiple observables
1604///
1605/// <tr><td> `Project(const RooArgSet& set)` <td> Override default projection behaviour by projecting over observables
1606/// given in set and complete ignoring the default projection behavior. Advanced use only.
1607///
1608/// <tr><td> `ProjWData(const RooAbsData& d)` <td> Override default projection _technique_ (integration). For observables present in given dataset
1609/// projection of PDF is achieved by constructing an average over all observable values in given set.
1610/// Consult RooFit plotting tutorial for further explanation of meaning & use of this technique
1611///
1612/// <tr><td> `ProjWData(const RooArgSet& s, const RooAbsData& d)` <td> As above but only consider subset 's' of observables in dataset 'd' for projection through data averaging
1613///
1614/// <tr><td> `ProjectionRange(const char* rn)` <td> Override default range of projection integrals to a different range speficied by given range name.
1615/// This technique allows you to project a finite width slice in a real-valued observable
1616///
1617/// <tr><td> `NumCPU(Int_t ncpu)` <td> Number of CPUs to use simultaneously to calculate data-weighted projections (only in combination with ProjWData)
1618///
1619///
1620/// <tr><th><th> Misc content control
1621/// <tr><td> `PrintEvalErrors(Int_t numErr)` <td> Control number of p.d.f evaluation errors printed per curve. A negative
1622/// value suppress output completely, a zero value will only print the error count per p.d.f component,
1623/// a positive value is will print details of each error up to numErr messages per p.d.f component.
1624///
1625/// <tr><td> `EvalErrorValue(Double_t value)` <td> Set curve points at which (pdf) evaluation error occur to specified value. By default the
1626/// function value is plotted.
1627///
1628/// <tr><td> `Normalization(Double_t scale, ScaleType code)` <td> Adjust normalization by given scale factor. Interpretation of number depends on code: Relative:
1629/// relative adjustment factor, NumEvent: scale to match given number of events.
1630///
1631/// <tr><td> `Name(const chat* name)` <td> Give curve specified name in frame. Useful if curve is to be referenced later
1632///
1633/// <tr><td> `Asymmetry(const RooCategory& c)` <td> Show the asymmetry of the PDF in given two-state category [F(+)-F(-)] / [F(+)+F(-)] rather than
1634/// the PDF projection. Category must have two states with indices -1 and +1 or three states with
1635/// indeces -1,0 and +1.
1636///
1637/// <tr><td> `ShiftToZero(Bool_t flag)` <td> Shift entire curve such that lowest visible point is at exactly zero. Mostly useful when plotting \f$ -\log(L) \f$ or \f$ \chi^2 \f$ distributions
1638///
1639/// <tr><td> `AddTo(const char* name, double_t wgtSelf, double_t wgtOther)` <td> Add constructed projection to already existing curve with given name and relative weight factors
1640///
1641/// <tr><th><th> Plotting control
1642/// <tr><td> `DrawOption(const char* opt)` <td> Select ROOT draw option for resulting TGraph object
1643///
1644/// <tr><td> `LineStyle(Int_t style)` <td> Select line style by ROOT line style code, default is solid
1645///
1646/// <tr><td> `LineColor(Int_t color)` <td> Select line color by ROOT color code, default is blue
1647///
1648/// <tr><td> `LineWidth(Int_t width)` <td> Select line with in pixels, default is 3
1649///
1650/// <tr><td> `FillStyle(Int_t style)` <td> Select fill style, default is not filled. If a filled style is selected, also use VLines()
1651/// to add vertical downward lines at end of curve to ensure proper closure
1652/// <tr><td> `FillColor(Int_t color)` <td> Select fill color by ROOT color code
1653///
1654/// <tr><td> `Range(const char* name)` <td> Only draw curve in range defined by given name
1655///
1656/// <tr><td> `Range(double lo, double hi)` <td> Only draw curve in specified range
1657///
1658/// <tr><td> `VLines()` <td> Add vertical lines to y=0 at end points of curve
1659///
1660/// <tr><td> `Precision(Double_t eps)` <td> Control precision of drawn curve w.r.t to scale of plot, default is 1e-3. Higher precision
1661/// will result in more and more densely spaced curve points
1662///
1663/// <tr><td> `Invisible(Bool_t flag)` <td> Add curve to frame, but do not display. Useful in combination AddTo()
1664///
1665/// <tr><td> `VisualizeError(const RooFitResult& fitres, Double_t Z=1, Bool_t linearMethod=kTRUE)`
1666/// <td> Visualize the uncertainty on the parameters, as given in fitres, at 'Z' sigma'
1667///
1668/// <tr><td> `VisualizeError(const RooFitResult& fitres, const RooArgSet& param, Double_t Z=1, Bool_t linearMethod=kTRUE)`
1669/// <td> Visualize the uncertainty on the subset of parameters 'param', as given in fitres, at 'Z' sigma'
1670/// </table>
1671///
1672/// Details on error band visualization
1673/// -----------------------------------
1674/// *VisualizeError() uses plotOnWithErrorBand(). Documentation of the latter:*
1675/// \copydetails plotOnWithErrorBand()
1676
1677RooPlot* RooAbsReal::plotOn(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2,
1678 const RooCmdArg& arg3, const RooCmdArg& arg4,
1679 const RooCmdArg& arg5, const RooCmdArg& arg6,
1680 const RooCmdArg& arg7, const RooCmdArg& arg8,
1681 const RooCmdArg& arg9, const RooCmdArg& arg10) const
1682{
1684 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
1685 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
1686 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
1687 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
1688 l.Add((TObject*)&arg9) ; l.Add((TObject*)&arg10) ;
1689 return plotOn(frame,l) ;
1690}
1691
1692
1693
1694////////////////////////////////////////////////////////////////////////////////
1695/// Internal back-end function of plotOn() with named arguments
1696
1698{
1699 // Special handling here if argList contains RangeWithName argument with multiple
1700 // range names -- Need to translate this call into multiple calls
1701
1702 RooCmdArg* rcmd = (RooCmdArg*) argList.FindObject("RangeWithName") ;
1703 if (rcmd && TString(rcmd->getString(0)).Contains(",")) {
1704
1705 // List joint ranges as choice of normalization for all later processing
1706 RooCmdArg rnorm = RooFit::NormRange(rcmd->getString(0)) ;
1707 argList.Add(&rnorm) ;
1708
1709 list<string> rlist ;
1710
1711 // Separate named ranges using strtok
1712 char buf[1024] ;
1713 strlcpy(buf,rcmd->getString(0),1024) ;
1714 char* oneRange = strtok(buf,",") ;
1715 while(oneRange) {
1716 rlist.push_back(oneRange) ;
1717 oneRange = strtok(0,",") ;
1718 }
1719
1720 for (list<string>::iterator riter=rlist.begin() ; riter!=rlist.end() ; ++riter) {
1721 // Process each range with a separate command with a single range to be plotted
1722 rcmd->setString(0,riter->c_str()) ;
1723 RooAbsReal::plotOn(frame,argList) ;
1724 }
1725 return frame ;
1726
1727 }
1728
1729 // Define configuration for this method
1730 RooCmdConfig pc(Form("RooAbsReal::plotOn(%s)",GetName())) ;
1731 pc.defineString("drawOption","DrawOption",0,"L") ;
1732 pc.defineString("projectionRangeName","ProjectionRange",0,"",kTRUE) ;
1733 pc.defineString("curveNameSuffix","CurveNameSuffix",0,"") ;
1734 pc.defineString("sliceCatState","SliceCat",0,"",kTRUE) ;
1735 pc.defineDouble("scaleFactor","Normalization",0,1.0) ;
1736 pc.defineObject("sliceSet","SliceVars",0) ;
1737 pc.defineObject("sliceCatList","SliceCat",0,0,kTRUE) ;
1738 pc.defineObject("projSet","Project",0) ;
1739 pc.defineObject("asymCat","Asymmetry",0) ;
1740 pc.defineDouble("precision","Precision",0,1e-3) ;
1741 pc.defineDouble("evalErrorVal","EvalErrorValue",0,0) ;
1742 pc.defineInt("doEvalError","EvalErrorValue",0,0) ;
1743 pc.defineInt("shiftToZero","ShiftToZero",0,0) ;
1744 pc.defineObject("projDataSet","ProjData",0) ;
1745 pc.defineObject("projData","ProjData",1) ;
1746 pc.defineObject("errorFR","VisualizeError",0) ;
1747 pc.defineDouble("errorZ","VisualizeError",0,1.) ;
1748 pc.defineSet("errorPars","VisualizeError",0) ;
1749 pc.defineInt("linearMethod","VisualizeError",0,0) ;
1750 pc.defineInt("binProjData","ProjData",0,0) ;
1751 pc.defineDouble("rangeLo","Range",0,-999.) ;
1752 pc.defineDouble("rangeHi","Range",1,-999.) ;
1753 pc.defineInt("numee","PrintEvalErrors",0,10) ;
1754 pc.defineInt("rangeAdjustNorm","Range",0,0) ;
1755 pc.defineInt("rangeWNAdjustNorm","RangeWithName",0,0) ;
1756 pc.defineInt("VLines","VLines",0,2) ; // 2==ExtendedWings
1757 pc.defineString("rangeName","RangeWithName",0,"") ;
1758 pc.defineString("normRangeName","NormRange",0,"") ;
1759 pc.defineInt("lineColor","LineColor",0,-999) ;
1760 pc.defineInt("lineStyle","LineStyle",0,-999) ;
1761 pc.defineInt("lineWidth","LineWidth",0,-999) ;
1762 pc.defineInt("fillColor","FillColor",0,-999) ;
1763 pc.defineInt("fillStyle","FillStyle",0,-999) ;
1764 pc.defineString("curveName","Name",0,"") ;
1765 pc.defineInt("curveInvisible","Invisible",0,0) ;
1766 pc.defineInt("showProg","ShowProgress",0,0) ;
1767 pc.defineInt("numCPU","NumCPU",0,1) ;
1768 pc.defineInt("interleave","NumCPU",1,0) ;
1769 pc.defineString("addToCurveName","AddTo",0,"") ;
1770 pc.defineDouble("addToWgtSelf","AddTo",0,1.) ;
1771 pc.defineDouble("addToWgtOther","AddTo",1,1.) ;
1772 pc.defineInt("moveToBack","MoveToBack",0,0) ;
1773 pc.defineMutex("SliceVars","Project") ;
1774 pc.defineMutex("AddTo","Asymmetry") ;
1775 pc.defineMutex("Range","RangeWithName") ;
1776 pc.defineMutex("VisualizeError","VisualizeErrorData") ;
1777
1778 // Process & check varargs
1779 pc.process(argList) ;
1780 if (!pc.ok(kTRUE)) {
1781 return frame ;
1782 }
1783
1784 PlotOpt o ;
1785
1786 RooFitResult* errFR = (RooFitResult*) pc.getObject("errorFR") ;
1787 Double_t errZ = pc.getDouble("errorZ") ;
1788 RooArgSet* errPars = pc.getSet("errorPars") ;
1789 Bool_t linMethod = pc.getInt("linearMethod") ;
1790 if (errFR) {
1791 return plotOnWithErrorBand(frame,*errFR,errZ,errPars,argList,linMethod) ;
1792 }
1793
1794 // Extract values from named arguments
1795 o.numee = pc.getInt("numee") ;
1796 o.drawOptions = pc.getString("drawOption") ;
1797 o.curveNameSuffix = pc.getString("curveNameSuffix") ;
1798 o.scaleFactor = pc.getDouble("scaleFactor") ;
1799 o.projData = (const RooAbsData*) pc.getObject("projData") ;
1800 o.binProjData = pc.getInt("binProjData") ;
1801 o.projDataSet = (const RooArgSet*) pc.getObject("projDataSet") ;
1802 o.numCPU = pc.getInt("numCPU") ;
1803 o.interleave = (RooFit::MPSplit) pc.getInt("interleave") ;
1804 o.eeval = pc.getDouble("evalErrorVal") ;
1805 o.doeeval = pc.getInt("doEvalError") ;
1806
1807 const RooArgSet* sliceSetTmp = (const RooArgSet*) pc.getObject("sliceSet") ;
1808 RooArgSet* sliceSet = sliceSetTmp ? ((RooArgSet*) sliceSetTmp->Clone()) : 0 ;
1809 const RooArgSet* projSet = (const RooArgSet*) pc.getObject("projSet") ;
1810 const RooAbsCategoryLValue* asymCat = (const RooAbsCategoryLValue*) pc.getObject("asymCat") ;
1811
1812
1813 // Look for category slice arguments and add them to the master slice list if found
1814 const char* sliceCatState = pc.getString("sliceCatState",0,kTRUE) ;
1815 const RooLinkedList& sliceCatList = pc.getObjectList("sliceCatList") ;
1816 if (sliceCatState) {
1817
1818 // Make the master slice set if it doesnt exist
1819 if (!sliceSet) {
1820 sliceSet = new RooArgSet ;
1821 }
1822
1823 // Prepare comma separated label list for parsing
1824 char buf[1024] ;
1825 strlcpy(buf,sliceCatState,1024) ;
1826 const char* slabel = strtok(buf,",") ;
1827
1828 // Loop over all categories provided by (multiple) Slice() arguments
1829 TIterator* iter = sliceCatList.MakeIterator() ;
1830 RooCategory* scat ;
1831 while((scat=(RooCategory*)iter->Next())) {
1832 if (slabel) {
1833 // Set the slice position to the value indicate by slabel
1834 scat->setLabel(slabel) ;
1835 // Add the slice category to the master slice set
1836 sliceSet->add(*scat,kFALSE) ;
1837 }
1838 slabel = strtok(0,",") ;
1839 }
1840 delete iter ;
1841 }
1842
1843 o.precision = pc.getDouble("precision") ;
1844 o.shiftToZero = (pc.getInt("shiftToZero")!=0) ;
1845 Int_t vlines = pc.getInt("VLines");
1846 if (pc.hasProcessed("Range")) {
1847 o.rangeLo = pc.getDouble("rangeLo") ;
1848 o.rangeHi = pc.getDouble("rangeHi") ;
1849 o.postRangeFracScale = pc.getInt("rangeAdjustNorm") ;
1850 if (vlines==2) vlines=0 ; // Default is NoWings if range was specified
1851 } else if (pc.hasProcessed("RangeWithName")) {
1852 o.normRangeName = pc.getString("rangeName",0,kTRUE) ;
1853 o.rangeLo = frame->getPlotVar()->getMin(pc.getString("rangeName",0,kTRUE)) ;
1854 o.rangeHi = frame->getPlotVar()->getMax(pc.getString("rangeName",0,kTRUE)) ;
1855 o.postRangeFracScale = pc.getInt("rangeWNAdjustNorm") ;
1856 if (vlines==2) vlines=0 ; // Default is NoWings if range was specified
1857 }
1858
1859
1860 // If separate normalization range was specified this overrides previous settings
1861 if (pc.hasProcessed("NormRange")) {
1862 o.normRangeName = pc.getString("normRangeName") ;
1864 }
1865
1866 o.wmode = (vlines==2)?RooCurve::Extended:(vlines==1?RooCurve::Straight:RooCurve::NoWings) ;
1867 o.projectionRangeName = pc.getString("projectionRangeName",0,kTRUE) ;
1868 o.curveName = pc.getString("curveName",0,kTRUE) ;
1869 o.curveInvisible = pc.getInt("curveInvisible") ;
1870 o.progress = pc.getInt("showProg") ;
1871 o.addToCurveName = pc.getString("addToCurveName",0,kTRUE) ;
1872 o.addToWgtSelf = pc.getDouble("addToWgtSelf") ;
1873 o.addToWgtOther = pc.getDouble("addToWgtOther") ;
1874
1876 coutE(InputArguments) << "RooAbsReal::plotOn(" << GetName() << ") cannot find existing curve " << o.addToCurveName << " to add to in RooPlot" << endl ;
1877 return frame ;
1878 }
1879
1880 RooArgSet projectedVars ;
1881 if (sliceSet) {
1882 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have slice " << *sliceSet << endl ;
1883
1884 makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
1885
1886 // Take out the sliced variables
1887 TIterator* iter = sliceSet->createIterator() ;
1888 RooAbsArg* sliceArg ;
1889 while((sliceArg=(RooAbsArg*)iter->Next())) {
1890 RooAbsArg* arg = projectedVars.find(sliceArg->GetName()) ;
1891 if (arg) {
1892 projectedVars.remove(*arg) ;
1893 } else {
1894 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") slice variable "
1895 << sliceArg->GetName() << " was not projected anyway" << endl ;
1896 }
1897 }
1898 delete iter ;
1899 } else if (projSet) {
1900 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have projSet " << *projSet << endl ;
1901 makeProjectionSet(frame->getPlotVar(),projSet,projectedVars,kFALSE) ;
1902 } else {
1903 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have neither sliceSet nor projSet " << endl ;
1904 makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
1905 }
1906 o.projSet = &projectedVars ;
1907
1908 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: projectedVars = " << projectedVars << endl ;
1909
1910
1911 RooPlot* ret ;
1912 if (!asymCat) {
1913 // Forward to actual calculation
1914 ret = RooAbsReal::plotOn(frame,o) ;
1915 } else {
1916 // Forward to actual calculation
1917 ret = RooAbsReal::plotAsymOn(frame,*asymCat,o) ;
1918 }
1919
1920 delete sliceSet ;
1921
1922 // Optionally adjust line/fill attributes
1923 Int_t lineColor = pc.getInt("lineColor") ;
1924 Int_t lineStyle = pc.getInt("lineStyle") ;
1925 Int_t lineWidth = pc.getInt("lineWidth") ;
1926 Int_t fillColor = pc.getInt("fillColor") ;
1927 Int_t fillStyle = pc.getInt("fillStyle") ;
1928 if (lineColor!=-999) ret->getAttLine()->SetLineColor(lineColor) ;
1929 if (lineStyle!=-999) ret->getAttLine()->SetLineStyle(lineStyle) ;
1930 if (lineWidth!=-999) ret->getAttLine()->SetLineWidth(lineWidth) ;
1931 if (fillColor!=-999) ret->getAttFill()->SetFillColor(fillColor) ;
1932 if (fillStyle!=-999) ret->getAttFill()->SetFillStyle(fillStyle) ;
1933
1934 // Move last inserted object to back to drawing stack if requested
1935 if (pc.getInt("moveToBack") && frame->numItems()>1) {
1936 frame->drawBefore(frame->getObject(0)->GetName(), frame->getCurve()->GetName());
1937 }
1938
1939 return ret ;
1940}
1941
1942
1943
1944
1945//_____________________________________________________________________________
1946// coverity[PASS_BY_VALUE]
1948{
1949 // Plotting engine function for internal use
1950 //
1951 // Plot ourselves on given frame. If frame contains a histogram, all dimensions of the plotted
1952 // function that occur in the previously plotted dataset are projected via partial integration,
1953 // otherwise no projections are performed. Optionally, certain projections can be performed
1954 // by summing over the values present in a provided dataset ('projData'), to correctly
1955 // project out data dependents that are not properly described by the PDF (e.g. per-event errors).
1956 //
1957 // The functions value can be multiplied with an optional scale factor. The interpretation
1958 // of the scale factor is unique for generic real functions, for PDFs there are various interpretations
1959 // possible, which can be selection with 'stype' (see RooAbsPdf::plotOn() for details).
1960 //
1961 // The default projection behaviour can be overriden by supplying an optional set of dependents
1962 // to project. For most cases, plotSliceOn() and plotProjOn() provide a more intuitive interface
1963 // to modify the default projection behavour.
1964
1965 // Sanity checks
1966 if (plotSanityChecks(frame)) return frame ;
1967
1968 // ProjDataVars is either all projData observables, or the user indicated subset of it
1969 RooArgSet projDataVars ;
1970 if (o.projData) {
1971 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have ProjData with observables = " << *o.projData->get() << endl ;
1972 if (o.projDataSet) {
1974 projDataVars.add(*tmp) ;
1975 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have ProjDataSet = " << *o.projDataSet << " will only use this subset of projData" << endl ;
1976 delete tmp ;
1977 } else {
1978 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") using full ProjData" << endl ;
1979 projDataVars.add(*o.projData->get()) ;
1980 }
1981 }
1982
1983 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") ProjDataVars = " << projDataVars << endl ;
1984
1985 // Make list of variables to be projected
1986 RooArgSet projectedVars ;
1987 RooArgSet sliceSet ;
1988 if (o.projSet) {
1989 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have input projSet = " << *o.projSet << endl ;
1990 makeProjectionSet(frame->getPlotVar(),o.projSet,projectedVars,kFALSE) ;
1991 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") calculated projectedVars = " << *o.projSet << endl ;
1992
1993 // Print list of non-projected variables
1994 if (frame->getNormVars()) {
1995 RooArgSet *sliceSetTmp = getObservables(*frame->getNormVars()) ;
1996
1997 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") frame->getNormVars() that are also observables = " << *sliceSetTmp << endl ;
1998
1999 sliceSetTmp->remove(projectedVars,kTRUE,kTRUE) ;
2000 sliceSetTmp->remove(*frame->getPlotVar(),kTRUE,kTRUE) ;
2001
2002 if (o.projData) {
2003 RooArgSet* tmp = (RooArgSet*) projDataVars.selectCommon(*o.projSet) ;
2004 sliceSetTmp->remove(*tmp,kTRUE,kTRUE) ;
2005 delete tmp ;
2006 }
2007
2008 if (sliceSetTmp->getSize()) {
2009 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on "
2010 << frame->getPlotVar()->GetName() << " represents a slice in " << *sliceSetTmp << endl ;
2011 }
2012 sliceSet.add(*sliceSetTmp) ;
2013 delete sliceSetTmp ;
2014 }
2015 } else {
2016 makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2017 }
2018
2019 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") projectedVars = " << projectedVars << " sliceSet = " << sliceSet << endl ;
2020
2021
2022 RooArgSet* projDataNeededVars = 0 ;
2023 // Take out data-projected dependents from projectedVars
2024 if (o.projData) {
2025 projDataNeededVars = (RooArgSet*) projectedVars.selectCommon(projDataVars) ;
2026 projectedVars.remove(projDataVars,kTRUE,kTRUE) ;
2027 }
2028
2029 // Clone the plot variable
2030 RooAbsReal* realVar = (RooRealVar*) frame->getPlotVar() ;
2031 RooArgSet* plotCloneSet = (RooArgSet*) RooArgSet(*realVar).snapshot(kTRUE) ;
2032 if (!plotCloneSet) {
2033 coutE(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Couldn't deep-clone self, abort," << endl ;
2034 return frame ;
2035 }
2036 RooRealVar* plotVar = (RooRealVar*) plotCloneSet->find(realVar->GetName());
2037
2038 // Inform user about projections
2039 if (projectedVars.getSize()) {
2040 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2041 << " integrates over variables " << projectedVars
2042 << (o.projectionRangeName?Form(" in range %s",o.projectionRangeName):"") << endl;
2043 }
2044 if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2045 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2046 << " averages using data variables " << *projDataNeededVars << endl ;
2047 }
2048
2049 // Create projection integral
2050 RooArgSet* projectionCompList = 0 ;
2051
2052 RooArgSet* deps = getObservables(frame->getNormVars()) ;
2053 deps->remove(projectedVars,kTRUE,kTRUE) ;
2054 if (projDataNeededVars) {
2055 deps->remove(*projDataNeededVars,kTRUE,kTRUE) ;
2056 }
2057 deps->remove(*plotVar,kTRUE,kTRUE) ;
2058 deps->add(*plotVar) ;
2059
2060 // Now that we have the final set of dependents, call checkObservables()
2061
2062 // WVE take out conditional observables
2063 if (checkObservables(deps)) {
2064 coutE(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") error in checkObservables, abort" << endl ;
2065 delete deps ;
2066 delete plotCloneSet ;
2067 if (projDataNeededVars) delete projDataNeededVars ;
2068 return frame ;
2069 }
2070
2071 RooArgSet normSet(*deps) ;
2072 //normSet.add(projDataVars) ;
2073
2074 RooAbsReal *projection = (RooAbsReal*) createPlotProjection(normSet, &projectedVars, projectionCompList, o.projectionRangeName) ;
2075 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot projection object is " << projection->GetName() << endl ;
2076 if (dologD(Plotting)) {
2077 projection->printStream(ccoutD(Plotting),0,kVerbose) ;
2078 }
2079
2080 // Always fix RooAddPdf normalizations
2081 RooArgSet fullNormSet(*deps) ;
2082 fullNormSet.add(projectedVars) ;
2083 if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2084 fullNormSet.add(*projDataNeededVars) ;
2085 }
2086 RooArgSet* compSet = projection->getComponents() ;
2087 TIterator* iter = compSet->createIterator() ;
2088 RooAbsArg* arg ;
2089 while((arg=(RooAbsArg*)iter->Next())) {
2090 RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
2091 if (pdf) {
2092 pdf->selectNormalization(&fullNormSet) ;
2093 }
2094 }
2095 delete iter ;
2096 delete compSet ;
2097
2098
2099 // Apply data projection, if requested
2100 if (o.projData && projDataNeededVars && projDataNeededVars->getSize()>0) {
2101
2102 // If data set contains more rows than needed, make reduced copy first
2103 RooAbsData* projDataSel = (RooAbsData*)o.projData;
2104
2105 if (projDataNeededVars->getSize()<o.projData->get()->getSize()) {
2106
2107 // Determine if there are any slice variables in the projection set
2108 RooArgSet* sliceDataSet = (RooArgSet*) sliceSet.selectCommon(*o.projData->get()) ;
2109 TString cutString ;
2110 if (sliceDataSet->getSize()>0) {
2111 TIterator* iter2 = sliceDataSet->createIterator() ;
2112 RooAbsArg* sliceVar ;
2113 Bool_t first(kTRUE) ;
2114 while((sliceVar=(RooAbsArg*)iter2->Next())) {
2115 if (!first) {
2116 cutString.Append("&&") ;
2117 } else {
2118 first=kFALSE ;
2119 }
2120
2121 RooAbsRealLValue* real ;
2123 if ((real = dynamic_cast<RooAbsRealLValue*>(sliceVar))) {
2124 cutString.Append(Form("%s==%f",real->GetName(),real->getVal())) ;
2125 } else if ((cat = dynamic_cast<RooAbsCategoryLValue*>(sliceVar))) {
2126 cutString.Append(Form("%s==%d",cat->GetName(),cat->getIndex())) ;
2127 }
2128 }
2129 delete iter2 ;
2130 }
2131 delete sliceDataSet ;
2132
2133 if (!cutString.IsNull()) {
2134 projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars,cutString) ;
2135 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") reducing given projection dataset to entries with " << cutString << endl ;
2136 } else {
2137 projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars) ;
2138 }
2139 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName()
2140 << ") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2141 }
2142
2143 // Request binning of unbinned projection dataset that consists exclusively of category observables
2144 if (!o.binProjData && dynamic_cast<RooDataSet*>(projDataSel)!=0) {
2145
2146 // Determine if dataset contains only categories
2147 TIterator* iter2 = projDataSel->get()->createIterator() ;
2148 Bool_t allCat(kTRUE) ;
2149 RooAbsArg* arg2 ;
2150 while((arg2=(RooAbsArg*)iter2->Next())) {
2151 if (!dynamic_cast<RooCategory*>(arg2)) allCat = kFALSE ;
2152 }
2153 delete iter2 ;
2154 if (allCat) {
2155 o.binProjData = kTRUE ;
2156 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") unbinned projection dataset consist only of discrete variables,"
2157 << " performing projection with binned copy for optimization." << endl ;
2158
2159 }
2160 }
2161
2162 // Bin projection dataset if requested
2163 if (o.binProjData) {
2164 RooAbsData* tmp = new RooDataHist(Form("%s_binned",projDataSel->GetName()),"Binned projection data",*projDataSel->get(),*projDataSel) ;
2165 if (projDataSel!=o.projData) delete projDataSel ;
2166 projDataSel = tmp ;
2167 }
2168
2169
2170
2171 // Attach dataset
2172 projection->getVal(projDataSel->get()) ;
2173 projection->attachDataSet(*projDataSel) ;
2174
2175 // Construct optimized data weighted average
2176 RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*projection,*projDataSel,RooArgSet()/**projDataSel->get()*/,o.numCPU,o.interleave,kTRUE) ;
2177 //RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*projection,*projDataSel,*projDataSel->get(),o.numCPU,o.interleave,kTRUE) ;
2178
2179 // Do _not_ activate cache-and-track as necessary information to define normalization observables are not present in the underlying dataset
2181
2182 RooRealBinding projBind(dwa,*plotVar) ;
2183 RooScaledFunc scaleBind(projBind,o.scaleFactor);
2184
2185 // Set default range, if not specified
2186 if (o.rangeLo==0 && o.rangeHi==0) {
2187 o.rangeLo = frame->GetXaxis()->GetXmin() ;
2188 o.rangeHi = frame->GetXaxis()->GetXmax() ;
2189 }
2190
2191 // Construct name of curve for data weighed average
2192 TString curveName(projection->GetName()) ;
2193 curveName.Append(Form("_DataAvg[%s]",projDataSel->get()->contentsString().c_str())) ;
2194 // Append slice set specification if any
2195 if (sliceSet.getSize()>0) {
2196 curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2197 }
2198 // Append any suffixes imported from RooAbsPdf::plotOn
2199 if (o.curveNameSuffix) {
2200 curveName.Append(o.curveNameSuffix) ;
2201 }
2202
2203 // Curve constructor for data weighted average
2205 RooCurve *curve = new RooCurve(projection->GetName(),projection->GetTitle(),scaleBind,
2208
2209 curve->SetName(curveName.Data()) ;
2210
2211 // Add self to other curve if requested
2212 if (o.addToCurveName) {
2213 RooCurve* otherCurve = static_cast<RooCurve*>(frame->findObject(o.addToCurveName,RooCurve::Class())) ;
2214
2215 // Curve constructor for sum of curves
2216 RooCurve* sumCurve = new RooCurve(projection->GetName(),projection->GetTitle(),*curve,*otherCurve,o.addToWgtSelf,o.addToWgtOther) ;
2217 sumCurve->SetName(Form("%s_PLUS_%s",curve->GetName(),otherCurve->GetName())) ;
2218 delete curve ;
2219 curve = sumCurve ;
2220
2221 }
2222
2223 if (o.curveName) {
2224 curve->SetName(o.curveName) ;
2225 }
2226
2227 // add this new curve to the specified plot frame
2228 frame->addPlotable(curve, o.drawOptions, o.curveInvisible);
2229
2230 if (projDataSel!=o.projData) delete projDataSel ;
2231
2232 } else {
2233
2234 // Set default range, if not specified
2235 if (o.rangeLo==0 && o.rangeHi==0) {
2236 o.rangeLo = frame->GetXaxis()->GetXmin() ;
2237 o.rangeHi = frame->GetXaxis()->GetXmax() ;
2238 }
2239
2240 // Calculate a posteriori range fraction scaling if requested (2nd part of normalization correction for
2241 // result fit on subrange of data)
2242 if (o.postRangeFracScale) {
2243 if (!o.normRangeName) {
2244 o.normRangeName = "plotRange" ;
2245 plotVar->setRange("plotRange",o.rangeLo,o.rangeHi) ;
2246 }
2247
2248 // Evaluate fractional correction integral always on full p.d.f, not component.
2251 RooAbsReal* intFrac = projection->createIntegral(*plotVar,*plotVar,o.normRangeName) ;
2253 o.scaleFactor /= intFrac->getVal() ;
2254 globalSelectComp(tmp) ;
2255 delete intFrac ;
2256
2257 }
2258
2259 // create a new curve of our function using the clone to do the evaluations
2260 // Curve constructor for regular projections
2261
2263 RooCurve *curve = new RooCurve(*projection,*plotVar,o.rangeLo,o.rangeHi,frame->GetNbinsX(),
2266
2267
2268
2269 // Set default name of curve
2270 TString curveName(projection->GetName()) ;
2271 if (sliceSet.getSize()>0) {
2272 curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2273 }
2274 if (o.curveNameSuffix) {
2275 // Append any suffixes imported from RooAbsPdf::plotOn
2276 curveName.Append(o.curveNameSuffix) ;
2277 }
2278 curve->SetName(curveName.Data()) ;
2279
2280
2281 // Add self to other curve if requested
2282 if (o.addToCurveName) {
2283 RooCurve* otherCurve = static_cast<RooCurve*>(frame->findObject(o.addToCurveName,RooCurve::Class())) ;
2284 RooCurve* sumCurve = new RooCurve(projection->GetName(),projection->GetTitle(),*curve,*otherCurve,o.addToWgtSelf,o.addToWgtOther) ;
2285 sumCurve->SetName(Form("%s_PLUS_%s",curve->GetName(),otherCurve->GetName())) ;
2286 delete curve ;
2287 curve = sumCurve ;
2288 }
2289
2290 // Override name of curve by user name, if specified
2291 if (o.curveName) {
2292 curve->SetName(o.curveName) ;
2293 }
2294
2295 // add this new curve to the specified plot frame
2296 frame->addPlotable(curve, o.drawOptions, o.curveInvisible);
2297 }
2298
2299 if (projDataNeededVars) delete projDataNeededVars ;
2300 delete deps ;
2301 delete projectionCompList ;
2302 delete plotCloneSet ;
2303 return frame;
2304}
2305
2306
2307
2308
2309////////////////////////////////////////////////////////////////////////////////
2310/// \deprecated OBSOLETE -- RETAINED FOR BACKWARD COMPATIBILITY. Use plotOn() with Slice() instead
2311
2312RooPlot* RooAbsReal::plotSliceOn(RooPlot *frame, const RooArgSet& sliceSet, Option_t* drawOptions,
2313 Double_t scaleFactor, ScaleType stype, const RooAbsData* projData) const
2314{
2315 RooArgSet projectedVars ;
2316 makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2317
2318 // Take out the sliced variables
2319 TIterator* iter = sliceSet.createIterator() ;
2320 RooAbsArg* sliceArg ;
2321 while((sliceArg=(RooAbsArg*)iter->Next())) {
2322 RooAbsArg* arg = projectedVars.find(sliceArg->GetName()) ;
2323 if (arg) {
2324 projectedVars.remove(*arg) ;
2325 } else {
2326 coutI(Plotting) << "RooAbsReal::plotSliceOn(" << GetName() << ") slice variable "
2327 << sliceArg->GetName() << " was not projected anyway" << endl ;
2328 }
2329 }
2330 delete iter ;
2331
2332 PlotOpt o ;
2333 o.drawOptions = drawOptions ;
2334 o.scaleFactor = scaleFactor ;
2335 o.stype = stype ;
2336 o.projData = projData ;
2337 o.projSet = &projectedVars ;
2338 return plotOn(frame,o) ;
2339}
2340
2341
2342
2343
2344//_____________________________________________________________________________
2345// coverity[PASS_BY_VALUE]
2347
2348{
2349 // Plotting engine for asymmetries. Implements the functionality if plotOn(frame,Asymmetry(...)))
2350 //
2351 // Plot asymmetry of ourselves, defined as
2352 //
2353 // asym = f(asymCat=-1) - f(asymCat=+1) / ( f(asymCat=-1) + f(asymCat=+1) )
2354 //
2355 // on frame. If frame contains a histogram, all dimensions of the plotted
2356 // asymmetry function that occur in the previously plotted dataset are projected via partial integration.
2357 // Otherwise no projections are performed,
2358 //
2359 // The asymmetry function can be multiplied with an optional scale factor. The default projection
2360 // behaviour can be overriden by supplying an optional set of dependents to project.
2361
2362 // Sanity checks
2363 if (plotSanityChecks(frame)) return frame ;
2364
2365 // ProjDataVars is either all projData observables, or the user indicated subset of it
2366 RooArgSet projDataVars ;
2367 if (o.projData) {
2368 if (o.projDataSet) {
2370 projDataVars.add(*tmp) ;
2371 delete tmp ;
2372 } else {
2373 projDataVars.add(*o.projData->get()) ;
2374 }
2375 }
2376
2377 // Must depend on asymCat
2378 if (!dependsOn(asymCat)) {
2379 coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2380 << ") function doesn't depend on asymmetry category " << asymCat.GetName() << endl ;
2381 return frame ;
2382 }
2383
2384 // asymCat must be a signCat
2385 if (!asymCat.isSignType()) {
2386 coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2387 << ") asymmetry category must have 2 or 3 states with index values -1,0,1" << endl ;
2388 return frame ;
2389 }
2390
2391 // Make list of variables to be projected
2392 RooArgSet projectedVars ;
2393 RooArgSet sliceSet ;
2394 if (o.projSet) {
2395 makeProjectionSet(frame->getPlotVar(),o.projSet,projectedVars,kFALSE) ;
2396
2397 // Print list of non-projected variables
2398 if (frame->getNormVars()) {
2399 RooArgSet *sliceSetTmp = getObservables(*frame->getNormVars()) ;
2400 sliceSetTmp->remove(projectedVars,kTRUE,kTRUE) ;
2401 sliceSetTmp->remove(*frame->getPlotVar(),kTRUE,kTRUE) ;
2402
2403 if (o.projData) {
2404 RooArgSet* tmp = (RooArgSet*) projDataVars.selectCommon(*o.projSet) ;
2405 sliceSetTmp->remove(*tmp,kTRUE,kTRUE) ;
2406 delete tmp ;
2407 }
2408
2409 if (sliceSetTmp->getSize()) {
2410 coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") plot on "
2411 << frame->getPlotVar()->GetName() << " represents a slice in " << *sliceSetTmp << endl ;
2412 }
2413 sliceSet.add(*sliceSetTmp) ;
2414 delete sliceSetTmp ;
2415 }
2416 } else {
2417 makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2418 }
2419
2420
2421 // Take out data-projected dependens from projectedVars
2422 RooArgSet* projDataNeededVars = 0 ;
2423 if (o.projData) {
2424 projDataNeededVars = (RooArgSet*) projectedVars.selectCommon(projDataVars) ;
2425 projectedVars.remove(projDataVars,kTRUE,kTRUE) ;
2426 }
2427
2428 // Take out plotted asymmetry from projection
2429 if (projectedVars.find(asymCat.GetName())) {
2430 projectedVars.remove(*projectedVars.find(asymCat.GetName())) ;
2431 }
2432
2433 // Clone the plot variable
2434 RooAbsReal* realVar = (RooRealVar*) frame->getPlotVar() ;
2435 RooRealVar* plotVar = (RooRealVar*) realVar->Clone() ;
2436
2437 // Inform user about projections
2438 if (projectedVars.getSize()) {
2439 coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") plot on " << plotVar->GetName()
2440 << " projects variables " << projectedVars << endl ;
2441 }
2442 if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2443 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2444 << " averages using data variables "<< *projDataNeededVars << endl ;
2445 }
2446
2447
2448 // Customize two copies of projection with fixed negative and positive asymmetry
2449 RooAbsCategoryLValue* asymPos = (RooAbsCategoryLValue*) asymCat.Clone("asym_pos") ;
2450 RooAbsCategoryLValue* asymNeg = (RooAbsCategoryLValue*) asymCat.Clone("asym_neg") ;
2451 asymPos->setIndex(1) ;
2452 asymNeg->setIndex(-1) ;
2453 RooCustomizer* custPos = new RooCustomizer(*this,"pos") ;
2454 RooCustomizer* custNeg = new RooCustomizer(*this,"neg") ;
2455 //custPos->setOwning(kTRUE) ;
2456 //custNeg->setOwning(kTRUE) ;
2457 custPos->replaceArg(asymCat,*asymPos) ;
2458 custNeg->replaceArg(asymCat,*asymNeg) ;
2459 RooAbsReal* funcPos = (RooAbsReal*) custPos->build() ;
2460 RooAbsReal* funcNeg = (RooAbsReal*) custNeg->build() ;
2461
2462 // Create projection integral
2463 RooArgSet *posProjCompList, *negProjCompList ;
2464
2465 // Add projDataVars to normalized dependents of projection
2466 // This is needed only for asymmetries (why?)
2467 RooArgSet depPos(*plotVar,*asymPos) ;
2468 RooArgSet depNeg(*plotVar,*asymNeg) ;
2469 depPos.add(projDataVars) ;
2470 depNeg.add(projDataVars) ;
2471
2472 const RooAbsReal *posProj = funcPos->createPlotProjection(depPos, &projectedVars, posProjCompList, o.projectionRangeName) ;
2473 const RooAbsReal *negProj = funcNeg->createPlotProjection(depNeg, &projectedVars, negProjCompList, o.projectionRangeName) ;
2474 if (!posProj || !negProj) {
2475 coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") Unable to create projections, abort" << endl ;
2476 return frame ;
2477 }
2478
2479 // Create a RooFormulaVar representing the asymmetry
2480 TString asymName(GetName()) ;
2481 asymName.Append("_Asym[") ;
2482 asymName.Append(asymCat.GetName()) ;
2483 asymName.Append("]") ;
2484 TString asymTitle(asymCat.GetName()) ;
2485 asymTitle.Append(" Asymmetry of ") ;
2486 asymTitle.Append(GetTitle()) ;
2487 RooFormulaVar* funcAsym = new RooFormulaVar(asymName,asymTitle,"(@0-@1)/(@0+@1)",RooArgSet(*posProj,*negProj)) ;
2488
2489 if (o.projData) {
2490
2491 // If data set contains more rows than needed, make reduced copy first
2492 RooAbsData* projDataSel = (RooAbsData*)o.projData;
2493 if (projDataNeededVars && projDataNeededVars->getSize()<o.projData->get()->getSize()) {
2494
2495 // Determine if there are any slice variables in the projection set
2496 RooArgSet* sliceDataSet = (RooArgSet*) sliceSet.selectCommon(*o.projData->get()) ;
2497 TString cutString ;
2498 if (sliceDataSet->getSize()>0) {
2499 TIterator* iter = sliceDataSet->createIterator() ;
2500 RooAbsArg* sliceVar ;
2501 Bool_t first(kTRUE) ;
2502 while((sliceVar=(RooAbsArg*)iter->Next())) {
2503 if (!first) {
2504 cutString.Append("&&") ;
2505 } else {
2506 first=kFALSE ;
2507 }
2508
2509 RooAbsRealLValue* real ;
2511 if ((real = dynamic_cast<RooAbsRealLValue*>(sliceVar))) {
2512 cutString.Append(Form("%s==%f",real->GetName(),real->getVal())) ;
2513 } else if ((cat = dynamic_cast<RooAbsCategoryLValue*>(sliceVar))) {
2514 cutString.Append(Form("%s==%d",cat->GetName(),cat->getIndex())) ;
2515 }
2516 }
2517 delete iter ;
2518 }
2519 delete sliceDataSet ;
2520
2521 if (!cutString.IsNull()) {
2522 projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars,cutString) ;
2523 coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2524 << ") reducing given projection dataset to entries with " << cutString << endl ;
2525 } else {
2526 projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars) ;
2527 }
2528 coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2529 << ") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2530 }
2531
2532
2533 RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*funcAsym,*projDataSel,RooArgSet()/**projDataSel->get()*/,o.numCPU,o.interleave,kTRUE) ;
2534 //RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*funcAsym,*projDataSel,*projDataSel->get(),o.numCPU,o.interleave,kTRUE) ;
2536
2537 RooRealBinding projBind(dwa,*plotVar) ;
2538
2539 ((RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2540 ((RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2541
2542 RooScaledFunc scaleBind(projBind,o.scaleFactor);
2543
2544 // Set default range, if not specified
2545 if (o.rangeLo==0 && o.rangeHi==0) {
2546 o.rangeLo = frame->GetXaxis()->GetXmin() ;
2547 o.rangeHi = frame->GetXaxis()->GetXmax() ;
2548 }
2549
2550 // Construct name of curve for data weighed average
2551 TString curveName(funcAsym->GetName()) ;
2552 curveName.Append(Form("_DataAvg[%s]",projDataSel->get()->contentsString().c_str())) ;
2553 // Append slice set specification if any
2554 if (sliceSet.getSize()>0) {
2555 curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2556 }
2557 // Append any suffixes imported from RooAbsPdf::plotOn
2558 if (o.curveNameSuffix) {
2559 curveName.Append(o.curveNameSuffix) ;
2560 }
2561
2562
2564 RooCurve *curve = new RooCurve(funcAsym->GetName(),funcAsym->GetTitle(),scaleBind,
2567
2568 dynamic_cast<TAttLine*>(curve)->SetLineColor(2) ;
2569 // add this new curve to the specified plot frame
2570 frame->addPlotable(curve, o.drawOptions);
2571
2572 ccoutW(Eval) << endl ;
2573
2574 if (projDataSel!=o.projData) delete projDataSel ;
2575
2576 } else {
2577
2578 // Set default range, if not specified
2579 if (o.rangeLo==0 && o.rangeHi==0) {
2580 o.rangeLo = frame->GetXaxis()->GetXmin() ;
2581 o.rangeHi = frame->GetXaxis()->GetXmax() ;
2582 }
2583
2585 RooCurve* curve= new RooCurve(*funcAsym,*plotVar,o.rangeLo,o.rangeHi,frame->GetNbinsX(),
2588
2589 dynamic_cast<TAttLine*>(curve)->SetLineColor(2) ;
2590
2591
2592 // Set default name of curve
2593 TString curveName(funcAsym->GetName()) ;
2594 if (sliceSet.getSize()>0) {
2595 curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2596 }
2597 if (o.curveNameSuffix) {
2598 // Append any suffixes imported from RooAbsPdf::plotOn
2599 curveName.Append(o.curveNameSuffix) ;
2600 }
2601 curve->SetName(curveName.Data()) ;
2602
2603 // add this new curve to the specified plot frame
2604 frame->addPlotable(curve, o.drawOptions);
2605
2606 }
2607
2608 // Cleanup
2609 delete custPos ;
2610 delete custNeg ;
2611 delete funcPos ;
2612 delete funcNeg ;
2613 delete posProjCompList ;
2614 delete negProjCompList ;
2615 delete asymPos ;
2616 delete asymNeg ;
2617 delete funcAsym ;
2618
2619 delete plotVar ;
2620
2621 return frame;
2622}
2623
2624
2625
2626////////////////////////////////////////////////////////////////////////////////
2627/// Calculate error on self by propagated errors on parameters with correlations as given by fit result
2628/// The linearly propagated error is calculated as follows
2629/// \f[
2630/// \mathrm{error}(x) = F_a(x) * \mathrm{Corr}(a,a') * F_{a'}^{\mathrm{T}}(x)
2631/// \f]
2632/// where \f$ F_a(x) = \frac{ f(x, a + \mathrm{d}a) - f(x, a - \mathrm{d}a) }{2} \f$,
2633/// with \f$ f(x) \f$ this function and \f$ \mathrm{d}a \f$ taken from the fit result and
2634/// \f$ \mathrm{Corr}(a,a') \f$ = the correlation matrix from the fit result
2635///
2636
2638{
2639
2640 // Strip out parameters with zero error
2641 RooArgList fpf_stripped;
2643 RooRealVar *frv;
2644 while ((frv = (RooRealVar *)fi.next())) {
2645 if (frv->getError() > 1e-20) {
2646 fpf_stripped.add(*frv);
2647 }
2648 }
2649
2650 // Clone self for internal use
2651 RooAbsReal *cloneFunc = (RooAbsReal *)cloneTree();
2652 RooArgSet *errorParams = cloneFunc->getObservables(fpf_stripped);
2653
2654 RooArgSet *nset =
2655 nset_in.getSize() == 0 ? cloneFunc->getParameters(*errorParams) : cloneFunc->getObservables(nset_in);
2656
2657 // Make list of parameter instances of cloneFunc in order of error matrix
2658 RooArgList paramList;
2659 const RooArgList &fpf = fpf_stripped;
2660 vector<int> fpf_idx;
2661 for (Int_t i = 0; i < fpf.getSize(); i++) {
2662 RooAbsArg *par = errorParams->find(fpf[i].GetName());
2663 if (par) {
2664 paramList.add(*par);
2665 fpf_idx.push_back(i);
2666 }
2667 }
2668
2669 vector<Double_t> plusVar, minusVar ;
2670
2671 // Create vector of plus,minus variations for each parameter
2672 TMatrixDSym V(paramList.getSize()==fr.floatParsFinal().getSize()?
2673 fr.covarianceMatrix():
2674 fr.reducedCovarianceMatrix(paramList)) ;
2675
2676 for (Int_t ivar=0 ; ivar<paramList.getSize() ; ivar++) {
2677
2678 RooRealVar& rrv = (RooRealVar&)fpf[fpf_idx[ivar]] ;
2679
2680 Double_t cenVal = rrv.getVal() ;
2681 Double_t errVal = sqrt(V(ivar,ivar)) ;
2682
2683 // Make Plus variation
2684 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal+errVal) ;
2685 plusVar.push_back(cloneFunc->getVal(nset)) ;
2686
2687 // Make Minus variation
2688 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal-errVal) ;
2689 minusVar.push_back(cloneFunc->getVal(nset)) ;
2690
2691 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal) ;
2692 }
2693
2694 TMatrixDSym C(paramList.getSize()) ;
2695 vector<double> errVec(paramList.getSize()) ;
2696 for (int i=0 ; i<paramList.getSize() ; i++) {
2697 errVec[i] = sqrt(V(i,i)) ;
2698 for (int j=i ; j<paramList.getSize() ; j++) {
2699 C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2700 C(j,i) = C(i,j) ;
2701 }
2702 }
2703
2704 // Make vector of variations
2705 TVectorD F(plusVar.size()) ;
2706 for (unsigned int j=0 ; j<plusVar.size() ; j++) {
2707 F[j] = (plusVar[j]-minusVar[j])/2 ;
2708 }
2709
2710 // Calculate error in linear approximation from variations and correlation coefficient
2711 Double_t sum = F*(C*F) ;
2712
2713 delete cloneFunc ;
2714 delete errorParams ;
2715 delete nset ;
2716
2717 return sqrt(sum) ;
2718}
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729////////////////////////////////////////////////////////////////////////////////
2730/// Plot function or PDF on frame with support for visualization of the uncertainty encoded in the given fit result fr.
2731/// \param[in] frame RooPlot to plot on
2732/// \param[in] fr The RooFitResult, where errors can be extracted
2733/// \param[in] Z The desired significance (width) of the error band
2734/// \param[in] params If non-zero, consider only the subset of the parameters in fr for the error evaluation
2735/// \param[in] argList Optional RooCmdArg that can be applied to a regular plotOn() operation
2736/// \param[in] linMethod By default (linMethod=kTRUE) a linearized error is shown.
2737/// \return The RooPlot the band was plotted on (for chaining)
2738///
2739/// The linearized error is calculated as follows:
2740/// \f[
2741/// \mathrm{error}(x) = Z * F_a(x) * \mathrm{Corr}(a,a') * F_{a'}^\mathrm{T}(x),
2742/// \f]
2743///
2744/// where
2745/// \f[
2746/// F_a(x) = \frac{ f(x,a+\mathrm{d}a) - f(x,a-\mathrm{d}a) }{2},
2747/// \f]
2748/// with \f$ f(x) \f$ the plotted curve and \f$ \mathrm{d}a \f$ taken from the fit result, and
2749/// \f$ \mathrm{Corr}(a,a') \f$ = the correlation matrix from the fit result, and \f$ Z \f$ = requested signifance (\f$ Z \sigma \f$ band)
2750///
2751/// The linear method is fast (required 2*N evaluations of the curve, where N is the number of parameters), but may
2752/// not be accurate in the presence of strong correlations (~>0.9) and at Z>2 due to linear and Gaussian approximations made
2753///
2754/// Alternatively, a more robust error is calculated using a sampling method. In this method a number of curves
2755/// is calculated with variations of the parameter values, as drawn from a multi-variate Gaussian p.d.f. that is constructed
2756/// from the fit results covariance matrix. The error(x) is determined by calculating a central interval that capture N% of the variations
2757/// for each valye of x, where N% is controlled by Z (i.e. Z=1 gives N=68%). The number of sampling curves is chosen to be such
2758/// that at least 30 curves are expected to be outside the N% interval, and is minimally 100 (e.g. Z=1->Ncurve=100, Z=2->Ncurve=659, Z=3->Ncurve=11111)
2759/// Intervals from the sampling method can be asymmetric, and may perform better in the presence of strong correlations, but may take (much)
2760/// longer to calculate.
2761
2762RooPlot* RooAbsReal::plotOnWithErrorBand(RooPlot* frame,const RooFitResult& fr, Double_t Z,const RooArgSet* params, const RooLinkedList& argList, Bool_t linMethod) const
2763{
2764 RooLinkedList plotArgListTmp(argList) ;
2765 RooCmdConfig pc(Form("RooAbsPdf::plotOn(%s)",GetName())) ;
2766 pc.stripCmdList(plotArgListTmp,"VisualizeError,MoveToBack") ;
2767
2768 // Strip any 'internal normalization' arguments from list
2769 RooLinkedList plotArgList ;
2770 RooFIter iter = plotArgListTmp.fwdIterator() ;
2771 RooCmdArg* cmd ;
2772 while ((cmd=(RooCmdArg*)iter.next())) {
2773 if (std::string("Normalization")==cmd->GetName()) {
2774 if (((RooCmdArg*)cmd)->getInt(1)!=0) {
2775 } else {
2776 plotArgList.Add(cmd) ;
2777 }
2778 } else {
2779 plotArgList.Add(cmd) ;
2780 }
2781 }
2782
2783 // Generate central value curve
2784 RooLinkedList tmp(plotArgList) ;
2785 plotOn(frame,tmp) ;
2786 RooCurve* cenCurve = frame->getCurve() ;
2787 frame->remove(0,kFALSE) ;
2788
2789 RooCurve* band(0) ;
2790 if (!linMethod) {
2791
2792 // *** Interval method ***
2793 //
2794 // Make N variations of parameters samples from V and visualize N% central interval where N% is defined from Z
2795
2796 // Clone self for internal use
2797 RooAbsReal* cloneFunc = (RooAbsReal*) cloneTree() ;
2798 RooArgSet* cloneParams = cloneFunc->getObservables(fr.floatParsFinal()) ;
2799 RooArgSet* errorParams = params?((RooArgSet*)cloneParams->selectCommon(*params)):cloneParams ;
2800
2801 // Generate 100 random parameter points distributed according to fit result covariance matrix
2802 RooAbsPdf* paramPdf = fr.createHessePdf(*errorParams) ;
2803 Int_t n = Int_t(100./TMath::Erfc(Z/sqrt(2.))) ;
2804 if (n<100) n=100 ;
2805
2806 coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") INFO: visualizing " << Z << "-sigma uncertainties in parameters "
2807 << *errorParams << " from fit result " << fr.GetName() << " using " << n << " samplings." << endl ;
2808
2809 // Generate variation curves with above set of parameter values
2810 Double_t ymin = frame->GetMinimum() ;
2811 Double_t ymax = frame->GetMaximum() ;
2812 RooDataSet* d = paramPdf->generate(*errorParams,n) ;
2813 vector<RooCurve*> cvec ;
2814 for (int i=0 ; i<d->numEntries() ; i++) {
2815 *cloneParams = (*d->get(i)) ;
2816 RooLinkedList tmp2(plotArgList) ;
2817 cloneFunc->plotOn(frame,tmp2) ;
2818 cvec.push_back(frame->getCurve()) ;
2819 frame->remove(0,kFALSE) ;
2820 }
2821 frame->SetMinimum(ymin) ;
2822 frame->SetMaximum(ymax) ;
2823
2824
2825 // Generate upper and lower curve points from 68% interval around each point of central curve
2826 band = cenCurve->makeErrorBand(cvec,Z) ;
2827
2828 // Cleanup
2829 delete paramPdf ;
2830 delete cloneFunc ;
2831 for (vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2832 delete (*i) ;
2833 }
2834
2835 } else {
2836
2837 // *** Linear Method ***
2838 //
2839 // Make a one-sigma up- and down fluctation for each parameter and visualize
2840 // a from a linearized calculation as follows
2841 //
2842 // error(x) = F(a) C_aa' F(a')
2843 //
2844 // Where F(a) = (f(x,a+da) - f(x,a-da))/2
2845 // and C_aa' is the correlation matrix
2846
2847 // Strip out parameters with zero error
2848 RooArgList fpf_stripped;
2850 RooRealVar *frv;
2851 while ((frv = (RooRealVar *)fi.next())) {
2852 if (frv->getError() > 1e-20) {
2853 fpf_stripped.add(*frv);
2854 }
2855 }
2856
2857 // Clone self for internal use
2858 RooAbsReal* cloneFunc = (RooAbsReal*) cloneTree() ;
2859 RooArgSet *cloneParams = cloneFunc->getObservables(fpf_stripped);
2860 RooArgSet* errorParams = params?((RooArgSet*)cloneParams->selectCommon(*params)):cloneParams ;
2861
2862
2863 // Make list of parameter instances of cloneFunc in order of error matrix
2864 RooArgList paramList ;
2865 const RooArgList& fpf = fr.floatParsFinal() ;
2866 vector<int> fpf_idx ;
2867 for (Int_t i=0 ; i<fpf.getSize() ; i++) {
2868 RooAbsArg* par = errorParams->find(fpf[i].GetName()) ;
2869 if (par) {
2870 paramList.add(*par) ;
2871 fpf_idx.push_back(i) ;
2872 }
2873 }
2874
2875 vector<RooCurve*> plusVar, minusVar ;
2876
2877 // Create vector of plus,minus variations for each parameter
2878
2879 TMatrixDSym V(paramList.getSize()==fr.floatParsFinal().getSize()?
2880 fr.covarianceMatrix():
2881 fr.reducedCovarianceMatrix(paramList)) ;
2882
2883
2884 for (Int_t ivar=0 ; ivar<paramList.getSize() ; ivar++) {
2885
2886 RooRealVar& rrv = (RooRealVar&)fpf[fpf_idx[ivar]] ;
2887
2888 Double_t cenVal = rrv.getVal() ;
2889 Double_t errVal = sqrt(V(ivar,ivar)) ;
2890
2891 // Make Plus variation
2892 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal+Z*errVal) ;
2893
2894
2895 RooLinkedList tmp2(plotArgList) ;
2896 cloneFunc->plotOn(frame,tmp2) ;
2897 plusVar.push_back(frame->getCurve()) ;
2898 frame->remove(0,kFALSE) ;
2899
2900
2901 // Make Minus variation
2902 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal-Z*errVal) ;
2903 RooLinkedList tmp3(plotArgList) ;
2904 cloneFunc->plotOn(frame,tmp3) ;
2905 minusVar.push_back(frame->getCurve()) ;
2906 frame->remove(0,kFALSE) ;
2907
2908 ((RooRealVar*)paramList.at(ivar))->setVal(cenVal) ;
2909 }
2910
2911 TMatrixDSym C(paramList.getSize()) ;
2912 vector<double> errVec(paramList.getSize()) ;
2913 for (int i=0 ; i<paramList.getSize() ; i++) {
2914 errVec[i] = sqrt(V(i,i)) ;
2915 for (int j=i ; j<paramList.getSize() ; j++) {
2916 C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2917 C(j,i) = C(i,j) ;
2918 }
2919 }
2920
2921 band = cenCurve->makeErrorBand(plusVar,minusVar,C,Z) ;
2922
2923
2924 // Cleanup
2925 delete cloneFunc ;
2926 for (vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2927 delete (*i) ;
2928 }
2929 for (vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2930 delete (*i) ;
2931 }
2932
2933 }
2934
2935 delete cenCurve ;
2936 if (!band) return frame ;
2937
2938 // Define configuration for this method
2939 pc.defineString("drawOption","DrawOption",0,"F") ;
2940 pc.defineString("curveNameSuffix","CurveNameSuffix",0,"") ;
2941 pc.defineInt("lineColor","LineColor",0,-999) ;
2942 pc.defineInt("lineStyle","LineStyle",0,-999) ;
2943 pc.defineInt("lineWidth","LineWidth",0,-999) ;
2944 pc.defineInt("fillColor","FillColor",0,-999) ;
2945 pc.defineInt("fillStyle","FillStyle",0,-999) ;
2946 pc.defineString("curveName","Name",0,"") ;
2947 pc.defineInt("curveInvisible","Invisible",0,0) ;
2948 pc.defineInt("moveToBack","MoveToBack",0,0) ;
2949 pc.allowUndefined() ;
2950
2951 // Process & check varargs
2952 pc.process(argList) ;
2953 if (!pc.ok(kTRUE)) {
2954 return frame ;
2955 }
2956
2957 // Insert error band in plot frame
2958 frame->addPlotable(band,pc.getString("drawOption"),pc.getInt("curveInvisible")) ;
2959
2960
2961 // Optionally adjust line/fill attributes
2962 Int_t lineColor = pc.getInt("lineColor") ;
2963 Int_t lineStyle = pc.getInt("lineStyle") ;
2964 Int_t lineWidth = pc.getInt("lineWidth") ;
2965 Int_t fillColor = pc.getInt("fillColor") ;
2966 Int_t fillStyle = pc.getInt("fillStyle") ;
2967 if (lineColor!=-999) frame->getAttLine()->SetLineColor(lineColor) ;
2968 if (lineStyle!=-999) frame->getAttLine()->SetLineStyle(lineStyle) ;
2969 if (lineWidth!=-999) frame->getAttLine()->SetLineWidth(lineWidth) ;
2970 if (fillColor!=-999) frame->getAttFill()->SetFillColor(fillColor) ;
2971 if (fillStyle!=-999) frame->getAttFill()->SetFillStyle(fillStyle) ;
2972
2973 // Adjust name if requested
2974 if (pc.getString("curveName",0,kTRUE)) {
2975 band->SetName(pc.getString("curveName",0,kTRUE)) ;
2976 } else if (pc.getString("curveNameSuffix",0,kTRUE)) {
2977 TString name(band->GetName()) ;
2978 name.Append(pc.getString("curveNameSuffix",0,kTRUE)) ;
2979 band->SetName(name.Data()) ;
2980 }
2981
2982 // Move last inserted object to back to drawing stack if requested
2983 if (pc.getInt("moveToBack") && frame->numItems()>1) {
2984 frame->drawBefore(frame->getObject(0)->GetName(), frame->getCurve()->GetName());
2985 }
2986
2987
2988 return frame ;
2989}
2990
2991
2992
2993
2994////////////////////////////////////////////////////////////////////////////////
2995/// Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operations
2996
2998{
2999 // check that we are passed a valid plot frame to use
3000 if(0 == frame) {
3001 coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: frame is null" << endl;
3002 return kTRUE;
3003 }
3004
3005 // check that this frame knows what variable to plot
3006 RooAbsReal* var = frame->getPlotVar() ;
3007 if(!var) {
3008 coutE(Plotting) << ClassName() << "::" << GetName()
3009 << ":plotOn: frame does not specify a plot variable" << endl;
3010 return kTRUE;
3011 }
3012
3013 // check that the plot variable is not derived
3014 if(!dynamic_cast<RooAbsRealLValue*>(var)) {
3015 coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: cannot plot variable \""
3016 << var->GetName() << "\" of type " << var->ClassName() << endl;
3017 return kTRUE;
3018 }
3019
3020 // check if we actually depend on the plot variable
3021 if(!this->dependsOn(*var)) {
3022 coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: WARNING: variable is not an explicit dependent: "
3023 << var->GetName() << endl;
3024 }
3025
3026 return kFALSE ;
3027}
3028
3029
3030
3031
3032////////////////////////////////////////////////////////////////////////////////
3033/// Utility function for plotOn() that constructs the set of
3034/// observables to project when plotting ourselves as function of
3035/// 'plotVar'. 'allVars' is the list of variables that must be
3036/// projected, but may contain variables that we do not depend on. If
3037/// 'silent' is cleared, warnings about inconsistent input parameters
3038/// will be printed.
3039
3040void RooAbsReal::makeProjectionSet(const RooAbsArg* plotVar, const RooArgSet* allVars,
3041 RooArgSet& projectedVars, Bool_t silent) const
3042{
3043 cxcoutD(Plotting) << "RooAbsReal::makeProjectionSet(" << GetName() << ") plotVar = " << plotVar->GetName()
3044 << " allVars = " << (allVars?(*allVars):RooArgSet()) << endl ;
3045
3046 projectedVars.removeAll() ;
3047 if (!allVars) return ;
3048
3049 // Start out with suggested list of variables
3050 projectedVars.add(*allVars) ;
3051
3052 // Take out plot variable
3053 RooAbsArg *found= projectedVars.find(plotVar->GetName());
3054 if(found) {
3055 projectedVars.remove(*found);
3056
3057 // Take out eventual servers of plotVar
3058 RooArgSet* plotServers = plotVar->getObservables(&projectedVars) ;
3059 TIterator* psIter = plotServers->createIterator() ;
3060 RooAbsArg* ps ;
3061 while((ps=(RooAbsArg*)psIter->Next())) {
3062 RooAbsArg* tmp = projectedVars.find(ps->GetName()) ;
3063 if (tmp) {
3064 cxcoutD(Plotting) << "RooAbsReal::makeProjectionSet(" << GetName() << ") removing " << tmp->GetName()
3065 << " from projection set because it a server of " << plotVar->GetName() << endl ;
3066 projectedVars.remove(*tmp) ;
3067 }
3068 }
3069 delete psIter ;
3070 delete plotServers ;
3071
3072 if (!silent) {
3073 coutW(Plotting) << "RooAbsReal::plotOn(" << GetName()
3074 << ") WARNING: cannot project out frame variable ("
3075 << found->GetName() << "), ignoring" << endl ;
3076 }
3077 }
3078
3079 // Take out all non-dependents of function
3080 TIterator* iter = allVars->createIterator() ;
3081 RooAbsArg* arg ;
3082 while((arg=(RooAbsArg*)iter->Next())) {
3083 if (!dependsOnValue(*arg)) {
3084 projectedVars.remove(*arg,kTRUE) ;
3085
3086 cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName()
3087 << ") function doesn't depend on projection variable "
3088 << arg->GetName() << ", ignoring" << endl ;
3089 }
3090 }
3091 delete iter ;
3092}
3093
3094
3095
3096
3097////////////////////////////////////////////////////////////////////////////////
3098/// If true, the current pdf is a selected component (for use in plotting)
3099
3101{
3102 return _selectComp || _globalSelectComp ;
3103}
3104
3105
3106
3107////////////////////////////////////////////////////////////////////////////////
3108/// Global switch controlling the activation of the selectComp() functionality
3109
3111{
3112 _globalSelectComp = flag ;
3113}
3114
3115
3116
3117
3118////////////////////////////////////////////////////////////////////////////////
3119/// Create an interface adaptor f(vars) that binds us to the specified variables
3120/// (in arbitrary order). For example, calling bindVars({x1,x3}) on an object
3121/// F(x1,x2,x3,x4) returns an object f(x1,x3) that is evaluated using the
3122/// current values of x2 and x4. The caller takes ownership of the returned adaptor.
3123
3124RooAbsFunc *RooAbsReal::bindVars(const RooArgSet &vars, const RooArgSet* nset, Bool_t clipInvalid) const
3125{
3126 RooAbsFunc *binding= new RooRealBinding(*this,vars,nset,clipInvalid);
3127 if(binding && !binding->isValid()) {
3128 coutE(InputArguments) << ClassName() << "::" << GetName() << ":bindVars: cannot bind to " << vars << endl ;
3129 delete binding;
3130 binding= 0;
3131 }
3132 return binding;
3133}
3134
3135
3136
3137////////////////////////////////////////////////////////////////////////////////
3138/// Copy the cached value of another RooAbsArg to our cache.
3139/// Warning: This function copies the cached values of source,
3140/// it is the callers responsibility to make sure the cache is clean
3141
3142void RooAbsReal::copyCache(const RooAbsArg* source, Bool_t /*valueOnly*/, Bool_t setValDirty)
3143{
3144 RooAbsReal* other = static_cast<RooAbsReal*>(const_cast<RooAbsArg*>(source)) ;
3145
3146 if (!other->_treeVar) {
3147 _value = other->_value ;
3148 } else {
3149 if (source->getAttribute("FLOAT_TREE_BRANCH")) {
3150 _value = other->_floatValue ;
3151 } else if (source->getAttribute("INTEGER_TREE_BRANCH")) {
3152 _value = other->_intValue ;
3153 } else if (source->getAttribute("BYTE_TREE_BRANCH")) {
3154 _value = other->_byteValue ;
3155 } else if (source->getAttribute("BOOL_TREE_BRANCH")) {
3156 _value = other->_boolValue ;
3157 } else if (source->getAttribute("SIGNEDBYTE_TREE_BRANCH")) {
3158 _value = other->_sbyteValue ;
3159 } else if (source->getAttribute("UNSIGNED_INTEGER_TREE_BRANCH")) {
3160 _value = other->_uintValue ;
3161 }
3162 }
3163 if (setValDirty) {
3164 setValueDirty() ;
3165 }
3166}
3167
3168
3169
3170////////////////////////////////////////////////////////////////////////////////
3171
3173{
3174 RooVectorDataStore::RealVector* rv = vstore.addReal(this) ;
3175 rv->setBuffer(this,&_value) ;
3176}
3177
3178
3179
3180
3181////////////////////////////////////////////////////////////////////////////////
3182/// Attach object to a branch of given TTree. By default it will
3183/// register the internal value cache RooAbsReal::_value as branch
3184/// buffer for a Double_t tree branch with the same name as this
3185/// object. If no Double_t branch is found with the name of this
3186/// object, this method looks for a Float_t Int_t, UChar_t and UInt_t
3187/// branch in that order. If any of these are found the buffer for
3188/// that branch is set to a correctly typed conversion buffer in this
3189/// RooRealVar. A flag is set that will cause copyCache to copy the
3190/// object value from the appropriate conversion buffer instead of
3191/// the _value buffer.
3192
3193void RooAbsReal::attachToTree(TTree& t, Int_t bufSize)
3194{
3195 // First determine if branch is taken
3196 TString cleanName(cleanBranchName()) ;
3197 TBranch* branch = t.GetBranch(cleanName) ;
3198 if (branch) {
3199
3200 // Determine if existing branch is Float_t or Double_t
3201 TLeaf* leaf = (TLeaf*)branch->GetListOfLeaves()->At(0) ;
3202
3203 // Check that leaf is _not_ an array
3204 Int_t dummy ;
3205 TLeaf* counterLeaf = leaf->GetLeafCounter(dummy) ;
3206 if (counterLeaf) {
3207 coutE(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") ERROR: TTree branch " << GetName()
3208 << " is an array and cannot be attached to a RooAbsReal" << endl ;
3209 return ;
3210 }
3211
3212 TString typeName(leaf->GetTypeName()) ;
3213
3214 if (!typeName.CompareTo("Float_t")) {
3215 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Float_t branch " << GetName()
3216 << " will be converted to double precision" << endl ;
3217 setAttribute("FLOAT_TREE_BRANCH",kTRUE) ;
3218 _treeVar = kTRUE ;
3219 t.SetBranchAddress(cleanName,&_floatValue) ;
3220 } else if (!typeName.CompareTo("Int_t")) {
3221 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Int_t branch " << GetName()
3222 << " will be converted to double precision" << endl ;
3223 setAttribute("INTEGER_TREE_BRANCH",kTRUE) ;
3224 _treeVar = kTRUE ;
3225 t.SetBranchAddress(cleanName,&_intValue) ;
3226 } else if (!typeName.CompareTo("UChar_t")) {
3227 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree UChar_t branch " << GetName()
3228 << " will be converted to double precision" << endl ;
3229 setAttribute("BYTE_TREE_BRANCH",kTRUE) ;
3230 _treeVar = kTRUE ;
3231 t.SetBranchAddress(cleanName,&_byteValue) ;
3232 } else if (!typeName.CompareTo("Bool_t")) {
3233 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Bool_t branch " << GetName()
3234 << " will be converted to double precision" << endl ;
3235 setAttribute("BOOL_TREE_BRANCH",kTRUE) ;
3236 _treeVar = kTRUE ;
3237 t.SetBranchAddress(cleanName,&_boolValue) ;
3238 } else if (!typeName.CompareTo("Char_t")) {
3239 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Char_t branch " << GetName()
3240 << " will be converted to double precision" << endl ;
3241 setAttribute("SIGNEDBYTE_TREE_BRANCH",kTRUE) ;
3242 _treeVar = kTRUE ;
3243 t.SetBranchAddress(cleanName,&_sbyteValue) ;
3244 } else if (!typeName.CompareTo("UInt_t")) {
3245 coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree UInt_t branch " << GetName()
3246 << " will be converted to double precision" << endl ;
3247 setAttribute("UNSIGNED_INTEGER_TREE_BRANCH",kTRUE) ;
3248 _treeVar = kTRUE ;
3249 t.SetBranchAddress(cleanName,&_uintValue) ;
3250 } else if (!typeName.CompareTo("Double_t")) {
3251 t.SetBranchAddress(cleanName,&_value) ;
3252 } else {
3253 coutE(InputArguments) << "RooAbsReal::attachToTree(" << GetName() << ") data type " << typeName << " is not supported" << endl ;
3254 }
3255
3256 if (branch->GetCompressionLevel()<0) {
3257 // cout << "RooAbsReal::attachToTree(" << GetName() << ") Fixing compression level of branch " << cleanName << endl ;
3259 }
3260
3261// cout << "RooAbsReal::attachToTree(" << cleanName << "): branch already exists in tree " << (void*)&t << ", changing address" << endl ;
3262
3263 } else {
3264
3265 TString format(cleanName);
3266 format.Append("/D");
3267 branch = t.Branch(cleanName, &_value, (const Text_t*)format, bufSize);
3269 // cout << "RooAbsReal::attachToTree(" << cleanName << "): creating new branch in tree " << (void*)&t << endl ;
3270 }
3271
3272}
3273
3274
3275
3276////////////////////////////////////////////////////////////////////////////////
3277/// Fill the tree branch that associated with this object with its current value
3278
3280{
3281 // First determine if branch is taken
3282 TBranch* branch = t.GetBranch(cleanBranchName()) ;
3283 if (!branch) {
3284 coutE(Eval) << "RooAbsReal::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree: " << cleanBranchName() << endl ;
3285 assert(0) ;
3286 }
3287 branch->Fill() ;
3288
3289}
3290
3291
3292
3293////////////////////////////////////////////////////////////////////////////////
3294/// (De)Activate associated tree branch
3295
3297{
3298 TBranch* branch = t.GetBranch(cleanBranchName()) ;
3299 if (branch) {
3300 t.SetBranchStatus(cleanBranchName(),active?1:0) ;
3301 }
3302}
3303
3304
3305
3306////////////////////////////////////////////////////////////////////////////////
3307/// Create a RooRealVar fundamental object with our properties. The new
3308/// object will be created without any fit limits.
3309
3310RooAbsArg *RooAbsReal::createFundamental(const char* newname) const
3311{
3312 RooRealVar *fund= new RooRealVar(newname?newname:GetName(),GetTitle(),_value,getUnit());
3313 fund->removeRange();
3314 fund->setPlotLabel(getPlotLabel());
3315 fund->setAttribute("fundamentalCopy");
3316 return fund;
3317}
3318
3319
3320
3321////////////////////////////////////////////////////////////////////////////////
3322/// Utility function for use in getAnalyticalIntegral(). If the
3323/// content of proxy 'a' occurs in set 'allDeps' then the argument
3324/// held in 'a' is copied from allDeps to analDeps
3325
3327 const RooArgProxy& a) const
3328{
3329 TList nameList ;
3330 nameList.Add(new TObjString(a.absArg()->GetName())) ;
3331 Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3332 nameList.Delete() ;
3333 return result ;
3334}
3335
3336
3337
3338////////////////////////////////////////////////////////////////////////////////
3339/// Utility function for use in getAnalyticalIntegral(). If the
3340/// contents of proxies a,b occur in set 'allDeps' then the arguments
3341/// held in a,b are copied from allDeps to analDeps
3342
3344 const RooArgProxy& a, const RooArgProxy& b) const
3345{
3346 TList nameList ;
3347 nameList.Add(new TObjString(a.absArg()->GetName())) ;
3348 nameList.Add(new TObjString(b.absArg()->GetName())) ;
3349 Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3350 nameList.Delete() ;
3351 return result ;
3352}
3353
3354
3355
3356////////////////////////////////////////////////////////////////////////////////
3357/// Utility function for use in getAnalyticalIntegral(). If the
3358/// contents of proxies a,b,c occur in set 'allDeps' then the arguments
3359/// held in a,b,c are copied from allDeps to analDeps
3360
3362 const RooArgProxy& a, const RooArgProxy& b,
3363 const RooArgProxy& c) const
3364{
3365 TList nameList ;
3366 nameList.Add(new TObjString(a.absArg()->GetName())) ;
3367 nameList.Add(new TObjString(b.absArg()->GetName())) ;
3368 nameList.Add(new TObjString(c.absArg()->GetName())) ;
3369 Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3370 nameList.Delete() ;
3371 return result ;
3372}
3373
3374
3375
3376////////////////////////////////////////////////////////////////////////////////
3377/// Utility function for use in getAnalyticalIntegral(). If the
3378/// contents of proxies a,b,c,d occur in set 'allDeps' then the arguments
3379/// held in a,b,c,d are copied from allDeps to analDeps
3380
3382 const RooArgProxy& a, const RooArgProxy& b,
3383 const RooArgProxy& c, const RooArgProxy& d) const
3384{
3385 TList nameList ;
3386 nameList.Add(new TObjString(a.absArg()->GetName())) ;
3387 nameList.Add(new TObjString(b.absArg()->GetName())) ;
3388 nameList.Add(new TObjString(c.absArg()->GetName())) ;
3389 nameList.Add(new TObjString(d.absArg()->GetName())) ;
3390 Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3391 nameList.Delete() ;
3392 return result ;
3393}
3394
3395
3396////////////////////////////////////////////////////////////////////////////////
3397/// Utility function for use in getAnalyticalIntegral(). If the
3398/// contents of 'refset' occur in set 'allDeps' then the arguments
3399/// held in 'refset' are copied from allDeps to analDeps.
3400
3402 const RooArgSet& refset) const
3403{
3404 TList nameList ;
3405 TIterator* iter = refset.createIterator() ;
3406 RooAbsArg* arg ;
3407 while ((arg=(RooAbsArg*)iter->Next())) {
3408 nameList.Add(new TObjString(arg->GetName())) ;
3409 }
3410 delete iter ;
3411
3412 Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3413 nameList.Delete() ;
3414 return result ;
3415}
3416
3417
3418
3419////////////////////////////////////////////////////////////////////////////////
3420/// Check if allArgs contains matching elements for each name in nameList. If it does,
3421/// add the corresponding args from allArgs to matchedArgs and return kTRUE. Otherwise
3422/// return kFALSE and do not change matchedArgs.
3423
3425 const TList &nameList) const
3426{
3427 RooArgSet matched("matched");
3428 TIterator *iterator= nameList.MakeIterator();
3429 TObjString *name = 0;
3430 Bool_t isMatched(kTRUE);
3431 while((isMatched && (name= (TObjString*)iterator->Next()))) {
3432 RooAbsArg *found= allArgs.find(name->String().Data());
3433 if(found) {
3434 matched.add(*found);
3435 }
3436 else {
3437 isMatched= kFALSE;
3438 }
3439 }
3440
3441 // nameList may not contain multiple entries with the same name
3442 // that are both matched
3443 if (isMatched && (matched.getSize()!=nameList.GetSize())) {
3444 isMatched = kFALSE ;
3445 }
3446
3447 delete iterator;
3448 if(isMatched) matchedArgs.add(matched);
3449 return isMatched;
3450}
3451
3452
3453
3454////////////////////////////////////////////////////////////////////////////////
3455/// Returns the default numeric integration configuration for all RooAbsReals
3456
3458{
3460}
3461
3462
3463////////////////////////////////////////////////////////////////////////////////
3464/// Returns the specialized integrator configuration for _this_ RooAbsReal.
3465/// If this object has no specialized configuration, a null pointer is returned.
3466
3468{
3469 return _specIntegratorConfig ;
3470}
3471
3472
3473////////////////////////////////////////////////////////////////////////////////
3474/// Returns the specialized integrator configuration for _this_ RooAbsReal.
3475/// If this object has no specialized configuration, a null pointer is returned,
3476/// unless createOnTheFly is kTRUE in which case a clone of the default integrator
3477/// configuration is created, installed as specialized configuration, and returned
3478
3480{
3481 if (!_specIntegratorConfig && createOnTheFly) {
3483 }
3484 return _specIntegratorConfig ;
3485}
3486
3487
3488
3489////////////////////////////////////////////////////////////////////////////////
3490/// Return the numeric integration configuration used for this object. If
3491/// a specialized configuration was associated with this object, that configuration
3492/// is returned, otherwise the default configuration for all RooAbsReals is returned
3493
3495{
3496 const RooNumIntConfig* config = specialIntegratorConfig() ;
3497 if (config) return config ;
3498 return defaultIntegratorConfig() ;
3499}
3500
3501
3502////////////////////////////////////////////////////////////////////////////////
3503/// Return the numeric integration configuration used for this object. If
3504/// a specialized configuration was associated with this object, that configuration
3505/// is returned, otherwise the default configuration for all RooAbsReals is returned
3506
3508{
3510 if (config) return config ;
3511 return defaultIntegratorConfig() ;
3512}
3513
3514
3515
3516////////////////////////////////////////////////////////////////////////////////
3517/// Set the given integrator configuration as default numeric integration
3518/// configuration for this object
3519
3521{
3523 delete _specIntegratorConfig ;
3524 }
3526}
3527
3528
3529
3530////////////////////////////////////////////////////////////////////////////////
3531/// Remove the specialized numeric integration configuration associated
3532/// with this object
3533
3535{
3537 delete _specIntegratorConfig ;
3538 }
3540}
3541
3542
3543
3544
3545////////////////////////////////////////////////////////////////////////////////
3546/// Interface function to force use of a given set of observables
3547/// to interpret function value. Needed for functions or p.d.f.s
3548/// whose shape depends on the choice of normalization such as
3549/// RooAddPdf
3550
3552{
3553}
3554
3555
3556
3557
3558////////////////////////////////////////////////////////////////////////////////
3559/// Interface function to force use of a given normalization range
3560/// to interpret function value. Needed for functions or p.d.f.s
3561/// whose shape depends on the choice of normalization such as
3562/// RooAddPdf
3563
3565{
3566}
3567
3568
3569
3570////////////////////////////////////////////////////////////////////////////////
3571/// Activate cache validation mode
3572
3574{
3575 _cacheCheck = flag ;
3576}
3577
3578
3579
3580////////////////////////////////////////////////////////////////////////////////
3581/// Advertise capability to determine maximum value of function for given set of
3582/// observables. If no direct generator method is provided, this information
3583/// will assist the accept/reject generator to operate more efficiently as
3584/// it can skip the initial trial sampling phase to empirically find the function
3585/// maximum
3586
3588{
3589 return 0 ;
3590}
3591
3592
3593
3594////////////////////////////////////////////////////////////////////////////////
3595/// Return maximum value for set of observables identified by code assigned
3596/// in getMaxVal
3597
3599{
3600 assert(1) ;
3601 return 0 ;
3602}
3603
3604
3605
3606////////////////////////////////////////////////////////////////////////////////
3607/// Interface to insert remote error logging messages received by RooRealMPFE into current error loggin stream
3608
3609void RooAbsReal::logEvalError(const RooAbsReal* originator, const char* origName, const char* message, const char* serverValueString)
3610{
3611 if (_evalErrorMode==Ignore) {
3612 return ;
3613 }
3614
3616 _evalErrorCount++ ;
3617 return ;
3618 }
3619
3620 static Bool_t inLogEvalError = kFALSE ;
3621
3622 if (inLogEvalError) {
3623 return ;
3624 }
3625 inLogEvalError = kTRUE ;
3626
3627 EvalError ee ;
3628 ee.setMessage(message) ;
3629
3630 if (serverValueString) {
3631 ee.setServerValues(serverValueString) ;
3632 }
3633
3635 oocoutE((TObject*)0,Eval) << "RooAbsReal::logEvalError(" << "<STATIC>" << ") evaluation error, " << endl
3636 << " origin : " << origName << endl
3637 << " message : " << ee._msg << endl
3638 << " server values: " << ee._srvval << endl ;
3639 } else if (_evalErrorMode==CollectErrors) {
3640 _evalErrorList[originator].first = origName ;
3641 _evalErrorList[originator].second.push_back(ee) ;
3642 }
3643
3644
3645 inLogEvalError = kFALSE ;
3646}
3647
3648
3649
3650////////////////////////////////////////////////////////////////////////////////
3651/// Log evaluation error message. Evaluation errors may be routed through a different
3652/// protocol than generic RooFit warning message (which go straight through RooMsgService)
3653/// because evaluation errors can occur in very large numbers in the use of likelihood
3654/// evaluations. In logEvalError mode, controlled by global method enableEvalErrorLogging()
3655/// messages reported through this function are not printed but all stored in a list,
3656/// along with server values at the time of reporting. Error messages logged in this
3657/// way can be printed in a structured way, eliminating duplicates and with the ability
3658/// to truncate the list by printEvalErrors. This is the standard mode of error logging
3659/// during MINUIT operations. If enableEvalErrorLogging() is false, all errors
3660/// reported through this method are passed for immediate printing through RooMsgService.
3661/// A string with server names and values is constructed automatically for error logging
3662/// purposes, unless a custom string with similar information is passed as argument.
3663
3664void RooAbsReal::logEvalError(const char* message, const char* serverValueString) const
3665{
3666 if (_evalErrorMode==Ignore) {
3667 return ;
3668 }
3669
3671 _evalErrorCount++ ;
3672 return ;
3673 }
3674
3675 static Bool_t inLogEvalError = kFALSE ;
3676
3677 if (inLogEvalError) {
3678 return ;
3679 }
3680 inLogEvalError = kTRUE ;
3681
3682 EvalError ee ;
3683 ee.setMessage(message) ;
3684
3685 if (serverValueString) {
3686 ee.setServerValues(serverValueString) ;
3687 } else {
3688 string srvval ;
3689 ostringstream oss ;
3690 Bool_t first(kTRUE) ;
3691 for (Int_t i=0 ; i<numProxies() ; i++) {
3692 RooAbsProxy* p = getProxy(i) ;
3693 if (!p) continue ;
3694 //if (p->name()[0]=='!') continue ;
3695 if (first) {
3696 first=kFALSE ;
3697 } else {
3698 oss << ", " ;
3699 }
3700 p->print(oss,kTRUE) ;
3701 }
3702 ee.setServerValues(oss.str().c_str()) ;
3703 }
3704
3705 ostringstream oss2 ;
3707
3709 coutE(Eval) << "RooAbsReal::logEvalError(" << GetName() << ") evaluation error, " << endl
3710 << " origin : " << oss2.str() << endl
3711 << " message : " << ee._msg << endl
3712 << " server values: " << ee._srvval << endl ;
3713 } else if (_evalErrorMode==CollectErrors) {
3714 if (_evalErrorList[this].second.size() >= 2048) {
3715 // avoid overflowing the error list, so if there are very many, print
3716 // the oldest one first, and pop it off the list
3717 const EvalError& oee = _evalErrorList[this].second.front();
3718 // print to debug stream, since these would normally be suppressed, and
3719 // we do not want to increase the error count in the message service...
3720 ccoutD(Eval) << "RooAbsReal::logEvalError(" << GetName()
3721 << ") delayed evaluation error, " << endl
3722 << " origin : " << oss2.str() << endl
3723 << " message : " << oee._msg << endl
3724 << " server values: " << oee._srvval << endl ;
3725 _evalErrorList[this].second.pop_front();
3726 }
3727 _evalErrorList[this].first = oss2.str().c_str() ;
3728 _evalErrorList[this].second.push_back(ee) ;
3729 }
3730
3731 inLogEvalError = kFALSE ;
3732 //coutE(Tracing) << "RooAbsReal::logEvalError(" << GetName() << ") message = " << message << endl ;
3733}
3734
3735
3736
3737
3738////////////////////////////////////////////////////////////////////////////////
3739/// Clear the stack of evaluation error messages
3740
3742{
3744 return ;
3745 } else if (_evalErrorMode==CollectErrors) {
3746 _evalErrorList.clear() ;
3747 } else {
3748 _evalErrorCount = 0 ;
3749 }
3750}
3751
3752
3753
3754////////////////////////////////////////////////////////////////////////////////
3755/// Print all outstanding logged evaluation error on the given ostream. If maxPerNode
3756/// is zero, only the number of errors for each source (object with unique name) is listed.
3757/// If maxPerNode is greater than zero, up to maxPerNode detailed error messages are shown
3758/// per source of errors. A truncation message is shown if there were more errors logged
3759/// than shown.
3760
3761void RooAbsReal::printEvalErrors(ostream& os, Int_t maxPerNode)
3762{
3763 if (_evalErrorMode == CountErrors) {
3764 os << _evalErrorCount << " errors counted" << endl ;
3765 }
3766
3767 if (maxPerNode<0) return ;
3768
3769 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter = _evalErrorList.begin() ;
3770
3771 for(;iter!=_evalErrorList.end() ; ++iter) {
3772 if (maxPerNode==0) {
3773
3774 // Only print node name with total number of errors
3775 os << iter->second.first ;
3776 //iter->first->printStream(os,kName|kClassName|kArgs,kInline) ;
3777 os << " has " << iter->second.second.size() << " errors" << endl ;
3778
3779 } else {
3780
3781 // Print node name and details of 'maxPerNode' errors
3782 os << iter->second.first << endl ;
3783 //iter->first->printStream(os,kName|kClassName|kArgs,kSingleLine) ;
3784
3785 Int_t i(0) ;
3786 std::list<EvalError>::iterator iter2 = iter->second.second.begin() ;
3787 for(;iter2!=iter->second.second.end() ; ++iter2, i++) {
3788 os << " " << iter2->_msg << " @ " << iter2->_srvval << endl ;
3789 if (i>maxPerNode) {
3790 os << " ... (remaining " << iter->second.second.size() - maxPerNode << " messages suppressed)" << endl ;
3791 break ;
3792 }
3793 }
3794 }
3795 }
3796}
3797
3798
3799
3800////////////////////////////////////////////////////////////////////////////////
3801/// Return the number of logged evaluation errors since the last clearing.
3802
3804{
3806 return _evalErrorCount ;
3807 }
3808
3809 Int_t ntot(0) ;
3810 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter = _evalErrorList.begin() ;
3811 for(;iter!=_evalErrorList.end() ; ++iter) {
3812 ntot += iter->second.second.size() ;
3813 }
3814 return ntot ;
3815}
3816
3817
3818
3819////////////////////////////////////////////////////////////////////////////////
3820/// Fix the interpretation of the coefficient of any RooAddPdf component in
3821/// the expression tree headed by this object to the given set of observables.
3822///
3823/// If the force flag is false, the normalization choice is only fixed for those
3824/// RooAddPdf components that have the default 'automatic' interpretation of
3825/// coefficients (i.e. the interpretation is defined by the observables passed
3826/// to getVal()). If force is true, also RooAddPdf that already have a fixed
3827/// interpretation are changed to a new fixed interpretation.
3828
3830{
3831 RooArgSet* compSet = getComponents() ;
3832 TIterator* iter = compSet->createIterator() ;
3833 RooAbsArg* arg ;
3834 while((arg=(RooAbsArg*)iter->Next())) {
3835 RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
3836 if (pdf) {
3837 if (addNormSet.getSize()>0) {
3838 pdf->selectNormalization(&addNormSet,force) ;
3839 } else {
3840 pdf->selectNormalization(0,force) ;
3841 }
3842 }
3843 }
3844 delete iter ;
3845 delete compSet ;
3846}
3847
3848
3849
3850////////////////////////////////////////////////////////////////////////////////
3851/// Fix the interpretation of the coefficient of any RooAddPdf component in
3852/// the expression tree headed by this object to the given set of observables.
3853///
3854/// If the force flag is false, the normalization range choice is only fixed for those
3855/// RooAddPdf components that currently use the default full domain to interpret their
3856/// coefficients. If force is true, also RooAddPdf that already have a fixed
3857/// interpretation range are changed to a new fixed interpretation range.
3858
3859void RooAbsReal::fixAddCoefRange(const char* rangeName, Bool_t force)
3860{
3861 RooArgSet* compSet = getComponents() ;
3862 TIterator* iter = compSet->createIterator() ;
3863 RooAbsArg* arg ;
3864 while((arg=(RooAbsArg*)iter->Next())) {
3865 RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
3866 if (pdf) {
3867 pdf->selectNormalizationRange(rangeName,force) ;
3868 }
3869 }
3870 delete iter ;
3871 delete compSet ;
3872}
3873
3874
3875
3876////////////////////////////////////////////////////////////////////////////////
3877/// Interface method for function objects to indicate their prefferred order of observables
3878/// for scanning their values into a (multi-dimensional) histogram or RooDataSet. The observables
3879/// to be ordered are offered in argument 'obs' and should be copied in their preferred
3880/// order into argument 'orderdObs', This default implementation indicates no preference
3881/// and copies the original order of 'obs' into 'orderedObs'
3882
3884{
3885 // Dummy implementation, do nothing
3886 orderedObs.removeAll() ;
3887 orderedObs.add(obs) ;
3888}
3889
3890
3891
3892////////////////////////////////////////////////////////////////////////////////
3893/// Calls createRunningIntegral(const RooArgSet&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&)
3894
3896{
3897 return createRunningIntegral(iset,RooFit::SupNormSet(nset)) ;
3898}
3899
3900
3901
3902////////////////////////////////////////////////////////////////////////////////
3903/// Create an object that represents the running integral of the function over one or more observables listed in iset, i.e.
3904/// \f[
3905/// \int_{x_\mathrm{lo}}^x f(x') \, \mathrm{d}x'
3906/// \f]
3907///
3908/// The actual integration calculation is only performed when the return object is evaluated. The name
3909/// of the integral object is automatically constructed from the name of the input function, the variables
3910/// it integrates and the range integrates over. The default strategy to calculate the running integrals is
3911///
3912/// - If the integrand (this object) supports analytical integration, construct an integral object
3913/// that calculate the running integrals value by calculating the analytical integral each
3914/// time the running integral object is evaluated
3915///
3916/// - If the integrand (this object) requires numeric integration to construct the running integral
3917/// create an object of class RooNumRunningInt which first samples the entire function and integrates
3918/// the sampled function numerically. This method has superior performance as there is no need to
3919/// perform a full (numeric) integration for each evaluation of the running integral object, but
3920/// only when one of its parameters has changed.
3921///
3922/// The choice of strategy can be changed with the ScanAll() argument, which forces the use of the
3923/// scanning technique implemented in RooNumRunningInt for all use cases, and with the ScanNone()
3924/// argument which forces the 'integrate each evaluation' technique for all use cases. The sampling
3925/// granularity for the scanning technique can be controlled with the ScanParameters technique
3926/// which allows to specify the number of samples to be taken, and to which order the resulting
3927/// running integral should be interpolated. The default values are 1000 samples and 2nd order
3928/// interpolation.
3929///
3930/// The following named arguments are accepted
3931/// | | Effect on integral creation
3932/// |-|-------------------------------
3933/// | `SupNormSet(const RooArgSet&)` | Observables over which should be normalized _in addition_ to the integration observables
3934/// | `ScanParameters(Int_t nbins, Int_t intOrder)` | Parameters for scanning technique of making CDF: number of sampled bins and order of interpolation applied on numeric cdf
3935/// | `ScanNum()` | Apply scanning technique if cdf integral involves numeric integration
3936/// | `ScanAll()` | Always apply scanning technique
3937/// | `ScanNone()` | Never apply scanning technique
3938
3940 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
3941 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
3942{
3943 // Define configuration for this method
3944 RooCmdConfig pc(Form("RooAbsReal::createRunningIntegral(%s)",GetName())) ;
3945 pc.defineObject("supNormSet","SupNormSet",0,0) ;
3946 pc.defineInt("numScanBins","ScanParameters",0,1000) ;
3947 pc.defineInt("intOrder","ScanParameters",1,2) ;
3948 pc.defineInt("doScanNum","ScanNum",0,1) ;
3949 pc.defineInt("doScanAll","ScanAll",0,0) ;
3950 pc.defineInt("doScanNon","ScanNone",0,0) ;
3951 pc.defineMutex("ScanNum","ScanAll","ScanNone") ;
3952
3953 // Process & check varargs
3954 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3955 if (!pc.ok(kTRUE)) {
3956 return 0 ;
3957 }
3958
3959 // Extract values from named arguments
3960 const RooArgSet* snset = static_cast<const RooArgSet*>(pc.getObject("supNormSet",0)) ;
3961 RooArgSet nset ;
3962 if (snset) {
3963 nset.add(*snset) ;
3964 }
3965 Int_t numScanBins = pc.getInt("numScanBins") ;
3966 Int_t intOrder = pc.getInt("intOrder") ;
3967 Int_t doScanNum = pc.getInt("doScanNum") ;
3968 Int_t doScanAll = pc.getInt("doScanAll") ;
3969 Int_t doScanNon = pc.getInt("doScanNon") ;
3970
3971 // If scanning technique is not requested make integral-based cdf and return
3972 if (doScanNon) {
3973 return createIntRI(iset,nset) ;
3974 }
3975 if (doScanAll) {
3976 return createScanRI(iset,nset,numScanBins,intOrder) ;
3977 }
3978 if (doScanNum) {
3980 Int_t isNum= (tmp->numIntRealVars().getSize()==1) ;
3981 delete tmp ;
3982
3983 if (isNum) {
3984 coutI(NumIntegration) << "RooAbsPdf::createRunningIntegral(" << GetName() << ") integration over observable(s) " << iset << " involves numeric integration," << endl
3985 << " constructing cdf though numeric integration of sampled pdf in " << numScanBins << " bins and applying order "
3986 << intOrder << " interpolation on integrated histogram." << endl
3987 << " To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
3988 }
3989
3990 return isNum ? createScanRI(iset,nset,numScanBins,intOrder) : createIntRI(iset,nset) ;
3991 }
3992 return 0 ;
3993}
3994
3995
3996
3997////////////////////////////////////////////////////////////////////////////////
3998/// Utility function for createRunningIntegral that construct an object
3999/// implementing the numeric scanning technique for calculating the running integral
4000
4001RooAbsReal* RooAbsReal::createScanRI(const RooArgSet& iset, const RooArgSet& nset, Int_t numScanBins, Int_t intOrder)
4002{
4003 string name = string(GetName()) + "_NUMRUNINT_" + integralNameSuffix(iset,&nset).Data() ;
4004 RooRealVar* ivar = (RooRealVar*) iset.first() ;
4005 ivar->setBins(numScanBins,"numcdf") ;
4006 RooNumRunningInt* ret = new RooNumRunningInt(name.c_str(),name.c_str(),*this,*ivar,"numrunint") ;
4007 ret->setInterpolationOrder(intOrder) ;
4008 return ret ;
4009}
4010
4011
4012
4013////////////////////////////////////////////////////////////////////////////////
4014/// Utility function for createRunningIntegral that construct an
4015/// object implementing the standard (analytical) integration
4016/// technique for calculating the running integral
4017
4019{
4020 // Make list of input arguments keeping only RooRealVars
4021 RooArgList ilist ;
4022 TIterator* iter2 = iset.createIterator() ;
4023 RooAbsArg* arg ;
4024 while((arg=(RooAbsArg*)iter2->Next())) {
4025 if (dynamic_cast<RooRealVar*>(arg)) {
4026 ilist.add(*arg) ;
4027 } else {
4028 coutW(InputArguments) << "RooAbsPdf::createRunningIntegral(" << GetName() << ") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << endl ;
4029 }
4030 }
4031 delete iter2 ;
4032
4033 RooArgList cloneList ;
4034 RooArgList loList ;
4035 RooArgSet clonedBranchNodes ;
4036
4037 // Setup customizer that stores all cloned branches in our non-owning list
4038 RooCustomizer cust(*this,"cdf") ;
4039 cust.setCloneBranchSet(clonedBranchNodes) ;
4040 cust.setOwning(kFALSE) ;
4041
4042 // Make integration observable x_prime for each observable x as well as an x_lowbound
4043 TIterator* iter = ilist.createIterator() ;
4044 RooRealVar* rrv ;
4045 while((rrv=(RooRealVar*)iter->Next())) {
4046
4047 // Make clone x_prime of each c.d.f observable x represening running integral
4048 RooRealVar* cloneArg = (RooRealVar*) rrv->clone(Form("%s_prime",rrv->GetName())) ;
4049 cloneList.add(*cloneArg) ;
4050 cust.replaceArg(*rrv,*cloneArg) ;
4051
4052 // Make clone x_lowbound of each c.d.f observable representing low bound of x
4053 RooRealVar* cloneLo = (RooRealVar*) rrv->clone(Form("%s_lowbound",rrv->GetName())) ;
4054 cloneLo->setVal(rrv->getMin()) ;
4055 loList.add(*cloneLo) ;
4056
4057 // Make parameterized binning from [x_lowbound,x] for each x_prime
4058 RooParamBinning pb(*cloneLo,*rrv,100) ;
4059 cloneArg->setBinning(pb,"CDF") ;
4060
4061 }
4062 delete iter ;
4063
4064 RooAbsReal* tmp = (RooAbsReal*) cust.build() ;
4065
4066 // Construct final normalization set for c.d.f = integrated observables + any extra specified by user
4067 RooArgSet finalNset(nset) ;
4068 finalNset.add(cloneList,kTRUE) ;
4069 RooAbsReal* cdf = tmp->createIntegral(cloneList,finalNset,"CDF") ;
4070
4071 // Transfer ownership of cloned items to top-level c.d.f object
4072 cdf->addOwnedComponents(*tmp) ;
4073 cdf->addOwnedComponents(cloneList) ;
4074 cdf->addOwnedComponents(loList) ;
4075
4076 return cdf ;
4077}
4078
4079
4080////////////////////////////////////////////////////////////////////////////////
4081/// Return a RooFunctor object bound to this RooAbsReal with given definition of observables
4082/// and parameters
4083
4084RooFunctor* RooAbsReal::functor(const RooArgList& obs, const RooArgList& pars, const RooArgSet& nset) const
4085{
4086 RooArgSet* realObs = getObservables(obs) ;
4087 if (realObs->getSize() != obs.getSize()) {
4088 coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4089 delete realObs ;
4090 return 0 ;
4091 }
4092 RooArgSet* realPars = getObservables(pars) ;
4093 if (realPars->getSize() != pars.getSize()) {
4094 coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4095 delete realPars ;
4096 return 0 ;
4097 }
4098 delete realObs ;
4099 delete realPars ;
4100
4101 return new RooFunctor(*this,obs,pars,nset) ;
4102}
4103
4104
4105
4106////////////////////////////////////////////////////////////////////////////////
4107/// Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables
4108/// and parameters
4109
4110TF1* RooAbsReal::asTF(const RooArgList& obs, const RooArgList& pars, const RooArgSet& nset) const
4111{
4112 // Check that specified input are indeed variables of this function
4113 RooArgSet* realObs = getObservables(obs) ;
4114 if (realObs->getSize() != obs.getSize()) {
4115 coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4116 delete realObs ;
4117 return 0 ;
4118 }
4119 RooArgSet* realPars = getObservables(pars) ;
4120 if (realPars->getSize() != pars.getSize()) {
4121 coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4122 delete realPars ;
4123 return 0 ;
4124 }
4125 delete realObs ;
4126 delete realPars ;
4127
4128 // Check that all obs and par are of type RooRealVar
4129 for (int i=0 ; i<obs.getSize() ; i++) {
4130 if (dynamic_cast<RooRealVar*>(obs.at(i))==0) {
4131 coutE(ObjectHandling) << "RooAbsReal::asTF(" << GetName() << ") ERROR: proposed observable " << obs.at(0)->GetName() << " is not of type RooRealVar" << endl ;
4132 return 0 ;
4133 }
4134 }
4135 for (int i=0 ; i<pars.getSize() ; i++) {
4136 if (dynamic_cast<RooRealVar*>(pars.at(i))==0) {
4137 coutE(ObjectHandling) << "RooAbsReal::asTF(" << GetName() << ") ERROR: proposed parameter " << pars.at(0)->GetName() << " is not of type RooRealVar" << endl ;
4138 return 0 ;
4139 }
4140 }
4141
4142 // Create functor and TFx of matching dimension
4143 TF1* tf=0 ;
4144 RooFunctor* f ;
4145 switch(obs.getSize()) {
4146 case 1: {
4147 RooRealVar* x = (RooRealVar*)obs.at(0) ;
4148 f = functor(obs,pars,nset) ;
4149 tf = new TF1(GetName(),f,x->getMin(),x->getMax(),pars.getSize()) ;
4150 break ;
4151 }
4152 case 2: {
4153 RooRealVar* x = (RooRealVar*)obs.at(0) ;
4154 RooRealVar* y = (RooRealVar*)obs.at(1) ;
4155 f = functor(obs,pars,nset) ;
4156 tf = new TF2(GetName(),f,x->getMin(),x->getMax(),y->getMin(),y->getMax(),pars.getSize()) ;
4157 break ;
4158 }
4159 case 3: {
4160 RooRealVar* x = (RooRealVar*)obs.at(0) ;
4161 RooRealVar* y = (RooRealVar*)obs.at(1) ;
4162 RooRealVar* z = (RooRealVar*)obs.at(2) ;
4163 f = functor(obs,pars,nset) ;
4164 tf = new TF3(GetName(),f,x->getMin(),x->getMax(),y->getMin(),y->getMax(),z->getMin(),z->getMax(),pars.getSize()) ;
4165 break ;
4166 }
4167 default:
4168 coutE(InputArguments) << "RooAbsReal::asTF(" << GetName() << ") ERROR: " << obs.getSize()
4169 << " observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << endl ;
4170 return 0 ;
4171 }
4172
4173 // Set initial parameter values of TFx to those of RooRealVars
4174 for (int i=0 ; i<pars.getSize() ; i++) {
4175 RooRealVar* p = (RooRealVar*) pars.at(i) ;
4176 tf->SetParameter(i,p->getVal()) ;
4177 tf->SetParName(i,p->GetName()) ;
4178 //tf->SetParLimits(i,p->getMin(),p->getMax()) ;
4179 }
4180
4181 return tf ;
4182}
4183
4184
4185////////////////////////////////////////////////////////////////////////////////
4186/// Return function representing first, second or third order derivative of this function
4187
4189{
4190 string name=Form("%s_DERIV_%s",GetName(),obs.GetName()) ;
4191 string title=Form("Derivative of %s w.r.t %s ",GetName(),obs.GetName()) ;
4192 return new RooDerivative(name.c_str(),title.c_str(),*this,obs,order,eps) ;
4193}
4194
4195
4196
4197////////////////////////////////////////////////////////////////////////////////
4198/// Return function representing first, second or third order derivative of this function
4199
4201{
4202 string name=Form("%s_DERIV_%s",GetName(),obs.GetName()) ;
4203 string title=Form("Derivative of %s w.r.t %s ",GetName(),obs.GetName()) ;
4204 return new RooDerivative(name.c_str(),title.c_str(),*this,obs,normSet,order,eps) ;
4205}
4206
4207
4208
4209////////////////////////////////////////////////////////////////////////////////
4210/// Return function representing moment of function of given order.
4211/// \param[in] obs Observable to calculate the moments for
4212/// \param[in] order Order of the moment
4213/// \param[in] central If true, the central moment is given by \f$ \langle (x- \langle x \rangle )^2 \rangle \f$
4214/// \param[in] takeRoot Calculate the square root
4215
4217{
4218 string name=Form("%s_MOMENT_%d%s_%s",GetName(),order,(central?"C":""),obs.GetName()) ;
4219 string title=Form("%sMoment of order %d of %s w.r.t %s ",(central?"Central ":""),order,GetName(),obs.GetName()) ;
4220 if (order==1) return new RooFirstMoment(name.c_str(),title.c_str(),*this,obs) ;
4221 if (order==2) return new RooSecondMoment(name.c_str(),title.c_str(),*this,obs,central,takeRoot) ;
4222 return new RooMoment(name.c_str(),title.c_str(),*this,obs,order,central,takeRoot) ;
4223}
4224
4225
4226////////////////////////////////////////////////////////////////////////////////
4227/// Return function representing moment of p.d.f (normalized w.r.t given observables) of given order.
4228/// \param[in] obs Observable to calculate the moments for
4229/// \param[in] normObs Normalise w.r.t. these observables
4230/// \param[in] order Order of the moment
4231/// \param[in] central If true, the central moment is given by \f$ \langle (x- \langle x \rangle )^2 \rangle \f$
4232/// \param[in] takeRoot Calculate the square root
4233/// \param[in] intNormOb If true, the moment of the function integrated over all normalization observables is returned.
4234
4235RooAbsMoment* RooAbsReal::moment(RooRealVar& obs, const RooArgSet& normObs, Int_t order, Bool_t central, Bool_t takeRoot, Bool_t intNormObs)
4236{
4237 string name=Form("%s_MOMENT_%d%s_%s",GetName(),order,(central?"C":""),obs.GetName()) ;
4238 string title=Form("%sMoment of order %d of %s w.r.t %s ",(central?"Central ":""),order,GetName(),obs.GetName()) ;
4239
4240 if (order==1) return new RooFirstMoment(name.c_str(),title.c_str(),*this,obs,normObs,intNormObs) ;
4241 if (order==2) return new RooSecondMoment(name.c_str(),title.c_str(),*this,obs,normObs,central,takeRoot,intNormObs) ;
4242 return new RooMoment(name.c_str(),title.c_str(),*this,obs,normObs,order,central,takeRoot,intNormObs) ;
4243}
4244
4245
4246
4247////////////////////////////////////////////////////////////////////////////////
4248///
4249/// Return value of x (in range xmin,xmax) at which function equals yval.
4250/// (Calculation is performed with Brent root finding algorithm)
4251
4253{
4254 Double_t result(0) ;
4255 RooBrentRootFinder(RooRealBinding(*this,x)).findRoot(result,xmin,xmax,yval) ;
4256 return result ;
4257}
4258
4259
4260
4261
4262////////////////////////////////////////////////////////////////////////////////
4263
4265{
4266 return new RooGenFunction(*this,x,RooArgList(),nset.getSize()>0?nset:RooArgSet(x)) ;
4267}
4268
4269
4270
4271////////////////////////////////////////////////////////////////////////////////
4272
4274{
4275 return new RooMultiGenFunction(*this,observables,RooArgList(),nset.getSize()>0?nset:observables) ;
4276}
4277
4278
4279
4280
4281////////////////////////////////////////////////////////////////////////////////
4282/// Perform a \f$ \chi^2 \f$ fit to given histogram. By default the fit is executed through the MINUIT
4283/// commands MIGRAD, HESSE in succession
4284///
4285/// The following named arguments are supported
4286///
4287/// <table>
4288/// <tr><th> <th> Options to control construction of -log(L)
4289/// <tr><td> `Range(const char* name)` <td> Fit only data inside range with given name
4290/// <tr><td> `Range(Double_t lo, Double_t hi)` <td> Fit only data inside given range. A range named "fit" is created on the fly on all observables.
4291/// Multiple comma separated range names can be specified.
4292/// <tr><td> `NumCPU(int num)` <td> Parallelize NLL calculation on num CPUs
4293/// <tr><td> `Optimize(Bool_t flag)` <td> Activate constant term optimization (on by default)
4294///
4295/// <tr><th> <th> Options to control flow of fit procedure
4296/// <tr><td> `InitialHesse(Bool_t flag)` <td> Flag controls if HESSE before MIGRAD as well, off by default
4297/// <tr><td> `Hesse(Bool_t flag)` <td> Flag controls if HESSE is run after MIGRAD, on by default
4298/// <tr><td> `Minos(Bool_t flag)` <td> Flag controls if MINOS is run after HESSE, on by default
4299/// <tr><td> `Minos(const RooArgSet& set)` <td> Only run MINOS on given subset of arguments
4300/// <tr><td> `Save(Bool_t flag)` <td> Flac controls if RooFitResult object is produced and returned, off by default
4301/// <tr><td> `Strategy(Int_t flag)` <td> Set Minuit strategy (0 through 2, default is 1)
4302/// <tr><td> `FitOptions(const char* optStr)` <td> Steer fit with classic options string (for backward compatibility). Use of this option
4303/// excludes use of any of the new style steering options.
4304///
4305/// <tr><th> <th> Options to control informational output
4306/// <tr><td> `Verbose(Bool_t flag)` <td> Flag controls if verbose output is printed (NLL, parameter changes during fit
4307/// <tr><td> `Timer(Bool_t flag)` <td> Time CPU and wall clock consumption of fit steps, off by default
4308/// <tr><td> `PrintLevel(Int_t level)` <td> Set Minuit print level (-1 through 3, default is 1). At -1 all RooFit informational
4309/// messages are suppressed as well
4310/// <tr><td> `Warnings(Bool_t flag)` <td> Enable or disable MINUIT warnings (enabled by default)
4311/// <tr><td> `PrintEvalErrors(Int_t numErr)` <td> Control number of p.d.f evaluation errors printed per likelihood evaluation. A negative
4312/// value suppress output completely, a zero value will only print the error count per p.d.f component,
4313/// a positive value is will print details of each error up to numErr messages per p.d.f component.
4314/// </table>
4315///
4316
4318 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4319 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4320{
4322 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4323 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4324 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4325 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4326 return chi2FitTo(data,l) ;
4327
4328}
4329
4330
4331
4332////////////////////////////////////////////////////////////////////////////////
4333/// \copydoc RooAbsReal::chi2FitTo(RooDataHist&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&)
4334
4336{
4337 // Select the pdf-specific commands
4338 RooCmdConfig pc(Form("RooAbsPdf::chi2FitTo(%s)",GetName())) ;
4339
4340 // Pull arguments to be passed to chi2 construction from list
4341 RooLinkedList fitCmdList(cmdList) ;
4342 RooLinkedList chi2CmdList = pc.filterCmdList(fitCmdList,"Range,RangeWithName,NumCPU,Optimize") ;
4343
4344 RooAbsReal* chi2 = createChi2(data,chi2CmdList) ;
4345 RooFitResult* ret = chi2FitDriver(*chi2,fitCmdList) ;
4346
4347 // Cleanup
4348 delete chi2 ;
4349 return ret ;
4350}
4351
4352
4353
4354
4355////////////////////////////////////////////////////////////////////////////////
4356/// Create a \f$ \chi^2 \f$ variable from a histogram and this function.
4357///
4358/// The following named arguments are supported
4359///
4360/// | | Options to control construction of the \f$ \chi^2 \f$
4361/// |-|-----------------------------------------
4362/// | `DataError(RooAbsData::ErrorType)` | Choose between Poisson errors and Sum-of-weights errors
4363/// | `NumCPU(Int_t)` | Activate parallel processing feature on N processes
4364/// | `Range()` | Calculate \f$ \chi^2 \f$ only in selected region
4365///
4366/// \param data Histogram with data
4367/// \return \f$ \chi^2 \f$ variable
4368
4370 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4371 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4372{
4373 string name = Form("chi2_%s_%s",GetName(),data.GetName()) ;
4374
4375 return new RooChi2Var(name.c_str(),name.c_str(),*this,data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4376}
4377
4378
4379
4380
4381////////////////////////////////////////////////////////////////////////////////
4382/// \copydoc RooAbsReal::createChi2(RooDataHist&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&)
4383/// \param cmdList List with RooCmdArg() from the table
4384
4386{
4387 // Fill array of commands
4388 const RooCmdArg* cmds[8] ;
4389 TIterator* iter = cmdList.MakeIterator() ;
4390 Int_t i(0) ;
4391 RooCmdArg* arg ;
4392 while((arg=(RooCmdArg*)iter->Next())) {
4393 cmds[i++] = arg ;
4394 }
4395 for (;i<8 ; i++) {
4396 cmds[i] = &RooCmdArg::none() ;
4397 }
4398 delete iter ;
4399
4400 return createChi2(data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4401
4402}
4403
4404
4405
4406
4407
4408////////////////////////////////////////////////////////////////////////////////
4409/// Perform a 2-D \f$ \chi^2 \f$ fit using a series of x and y values stored in the dataset `xydata`.
4410/// The y values can either be the event weights, or can be another column designated
4411/// by the YVar() argument. The y value must have errors defined for the \f$ \chi^2 \f$ to
4412/// be well defined.
4413///
4414/// <table>
4415/// <tr><th><th> Options to control construction of the \f$ \chi^2 \f$
4416/// <tr><td> `YVar(RooRealVar& yvar)` <td> Designate given column in dataset as Y value
4417/// <tr><td> `Integrate(Bool_t flag)` <td> Integrate function over range specified by X errors
4418/// rather than take value at bin center.
4419///
4420/// <tr><th><th> Options to control flow of fit procedure
4421/// <tr><td> `InitialHesse(Bool_t flag)` <td> Flag controls if HESSE before MIGRAD as well, off by default
4422/// <tr><td> `Hesse(Bool_t flag)` <td> Flag controls if HESSE is run after MIGRAD, on by default
4423/// <tr><td> `Minos(Bool_t flag)` <td> Flag controls if MINOS is run after HESSE, on by default
4424/// <tr><td> `Minos(const RooArgSet& set)` <td> Only run MINOS on given subset of arguments
4425/// <tr><td> `Save(Bool_t flag)` <td> Flac controls if RooFitResult object is produced and returned, off by default
4426/// <tr><td> `Strategy(Int_t flag)` <td> Set Minuit strategy (0 through 2, default is 1)
4427/// <tr><td> `FitOptions(const char* optStr)` <td> Steer fit with classic options string (for backward compatibility). Use of this option
4428/// excludes use of any of the new style steering options.
4429///
4430/// <tr><th><th> Options to control informational output
4431/// <tr><td> `Verbose(Bool_t flag)` <td> Flag controls if verbose output is printed (NLL, parameter changes during fit
4432/// <tr><td> `Timer(Bool_t flag)` <td> Time CPU and wall clock consumption of fit steps, off by default
4433/// <tr><td> `PrintLevel(Int_t level)` <td> Set Minuit print level (-1 through 3, default is 1). At -1 all RooFit informational
4434/// messages are suppressed as well
4435/// <tr><td> `Warnings(Bool_t flag)` <td> Enable or disable MINUIT warnings (enabled by default)
4436/// <tr><td> `PrintEvalErrors(Int_t numErr)` <td> Control number of p.d.f evaluation errors printed per likelihood evaluation. A negative
4437/// value suppress output completely, a zero value will only print the error count per p.d.f component,
4438/// a positive value is will print details of each error up to numErr messages per p.d.f component.
4439/// </table>
4440
4442 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4443 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4444{
4446 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4447 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4448 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4449 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4450 return chi2FitTo(xydata,l) ;
4451}
4452
4453
4454
4455
4456////////////////////////////////////////////////////////////////////////////////
4457/// \copydoc RooAbsReal::chi2FitTo(RooDataSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&)
4458
4460{
4461 // Select the pdf-specific commands
4462 RooCmdConfig pc(Form("RooAbsPdf::chi2FitTo(%s)",GetName())) ;
4463
4464 // Pull arguments to be passed to chi2 construction from list
4465 RooLinkedList fitCmdList(cmdList) ;
4466 RooLinkedList chi2CmdList = pc.filterCmdList(fitCmdList,"YVar,Integrate") ;
4467
4468 RooAbsReal* xychi2 = createChi2(xydata,chi2CmdList) ;
4469 RooFitResult* ret = chi2FitDriver(*xychi2,fitCmdList) ;
4470
4471 // Cleanup
4472 delete xychi2 ;
4473 return ret ;
4474}
4475
4476
4477
4478
4479////////////////////////////////////////////////////////////////////////////////
4480/// Create a \f$ \chi^2 \f$ from a series of x and y values stored in a dataset.
4481/// The y values can either be the event weights (default), or can be another column designated
4482/// by the YVar() argument. The y value must have errors defined for the \f$ \chi^2 \f$ to
4483/// be well defined.
4484///
4485/// The following named arguments are supported
4486///
4487/// | | Options to control construction of the \f$ \chi^2 \f$
4488/// |-|-----------------------------------------
4489/// | `YVar(RooRealVar& yvar)` | Designate given column in dataset as Y value
4490/// | `Integrate(Bool_t flag)` | Integrate function over range specified by X errors rather than take value at bin center.
4491///
4492
4494 const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4495 const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4496{
4498 l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4499 l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4500 l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4501 l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4502 return createChi2(data,l) ;
4503}
4504
4505
4506
4507////////////////////////////////////////////////////////////////////////////////
4508/// See RooAbsReal::createChi2(RooDataSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&)
4509
4511{
4512 // Select the pdf-specific commands
4513 RooCmdConfig pc(Form("RooAbsPdf::fitTo(%s)",GetName())) ;
4514
4515 pc.defineInt("integrate","Integrate",0,0) ;
4516 pc.defineObject("yvar","YVar",0,0) ;
4517
4518 // Process and check varargs
4519 pc.process(cmdList) ;
4520 if (!pc.ok(kTRUE)) {
4521 return 0 ;
4522 }
4523
4524 // Decode command line arguments
4525 Bool_t integrate = pc.getInt("integrate") ;
4526 RooRealVar* yvar = (RooRealVar*) pc.getObject("yvar") ;
4527
4528 string name = Form("chi2_%s_%s",GetName(),data.GetName()) ;
4529
4530 if (yvar) {
4531 return new RooXYChi2Var(name.c_str(),name.c_str(),*this,data,*yvar,integrate) ;
4532 } else {
4533 return new RooXYChi2Var(name.c_str(),name.c_str(),*this,data,integrate) ;
4534 }
4535}
4536
4537
4538
4539
4540
4541
4542////////////////////////////////////////////////////////////////////////////////
4543/// Internal driver function for chi2 fits
4544
4546{
4547 // Select the pdf-specific commands
4548 RooCmdConfig pc(Form("RooAbsPdf::chi2FitDriver(%s)",GetName())) ;
4549
4550 pc.defineString("fitOpt","FitOptions",0,"") ;
4551
4552 pc.defineInt("optConst","Optimize",0,1) ;
4553 pc.defineInt("verbose","Verbose",0,0) ;
4554 pc.defineInt("doSave","Save",0,0) ;
4555 pc.defineInt("doTimer","Timer",0,0) ;
4556 pc.defineInt("plevel","PrintLevel",0,1) ;
4557 pc.defineInt("strat","Strategy",0,1) ;
4558 pc.defineInt("initHesse","InitialHesse",0,0) ;
4559 pc.defineInt("hesse","Hesse",0,1) ;
4560 pc.defineInt("minos","Minos",0,0) ;
4561 pc.defineInt("ext","Extended",0,2) ;
4562 pc.defineInt("numee","PrintEvalErrors",0,10) ;
4563 pc.defineInt("doWarn","Warnings",0,1) ;
4564 pc.defineString("mintype","Minimizer",0,"Minuit") ;
4565 pc.defineString("minalg","Minimizer",1,"minuit") ;
4566 pc.defineObject("minosSet","Minos",0,0) ;
4567
4568 pc.defineMutex("FitOptions","Verbose") ;
4569 pc.defineMutex("FitOptions","Save") ;
4570 pc.defineMutex("FitOptions","Timer") ;
4571 pc.defineMutex("FitOptions","Strategy") ;
4572 pc.defineMutex("FitOptions","InitialHesse") ;
4573 pc.defineMutex("FitOptions","Hesse") ;
4574 pc.defineMutex("FitOptions","Minos") ;
4575
4576 // Process and check varargs
4577 pc.process(cmdList) ;
4578 if (!pc.ok(kTRUE)) {
4579 return 0 ;
4580 }
4581
4582 // Decode command line arguments
4583 const char* fitOpt = pc.getString("fitOpt",0,kTRUE) ;
4584#ifdef __ROOFIT_NOROOMINIMIZER
4585 const char* minType =0 ;
4586#else
4587 const char* minType = pc.getString("mintype","Minuit") ;
4588 const char* minAlg = pc.getString("minalg","minuit") ;
4589#endif
4590 Int_t optConst = pc.getInt("optConst") ;
4591 Int_t verbose = pc.getInt("verbose") ;
4592 Int_t doSave = pc.getInt("doSave") ;
4593 Int_t doTimer = pc.getInt("doTimer") ;
4594 Int_t plevel = pc.getInt("plevel") ;
4595 Int_t strat = pc.getInt("strat") ;
4596 Int_t initHesse= pc.getInt("initHesse") ;
4597 Int_t hesse = pc.getInt("hesse") ;
4598 Int_t minos = pc.getInt("minos") ;
4599 Int_t numee = pc.getInt("numee") ;
4600 Int_t doWarn = pc.getInt("doWarn") ;
4601 const RooArgSet* minosSet = static_cast<RooArgSet*>(pc.getObject("minosSet")) ;
4602
4603 RooFitResult *ret = 0 ;
4604
4605#ifdef __ROOFIT_NOROOMINIMIZER
4606 if (true) {
4607#else
4608 if ("OldMinuit" == string(minType)) {
4609#endif
4610 // Instantiate MINUIT
4611 RooMinuit m(fcn) ;
4612
4613 if (doWarn==0) {
4614 m.setNoWarn() ;
4615 }
4616
4617 m.setPrintEvalErrors(numee) ;
4618 if (plevel!=1) {
4619 m.setPrintLevel(plevel) ;
4620 }
4621
4622 if (optConst) {
4623 // Activate constant term optimization
4624 m.optimizeConst(optConst);
4625 }
4626
4627 if (fitOpt) {
4628
4629 // Play fit options as historically defined
4630 ret = m.fit(fitOpt) ;
4631
4632 } else {
4633
4634 if (verbose) {
4635 // Activate verbose options
4636 m.setVerbose(1) ;
4637 }
4638 if (doTimer) {
4639 // Activate timer options
4640 m.setProfile(1) ;
4641 }
4642
4643 if (strat!=1) {
4644 // Modify fit strategy
4645 m.setStrategy(strat) ;
4646 }
4647
4648 if (initHesse) {
4649 // Initialize errors with hesse
4650 m.hesse() ;
4651 }
4652
4653 // Minimize using migrad
4654 m.migrad() ;
4655
4656 if (hesse) {
4657 // Evaluate errors with Hesse
4658 m.hesse() ;
4659 }
4660
4661 if (minos) {
4662 // Evaluate errs with Minos
4663 if (minosSet) {
4664 m.minos(*minosSet) ;
4665 } else {
4666 m.minos() ;
4667 }
4668 }
4669
4670 // Optionally return fit result
4671 if (doSave) {
4672 string name = Form("fitresult_%s",fcn.GetName()) ;
4673 string title = Form("Result of fit of %s ",GetName()) ;
4674 ret = m.save(name.c_str(),title.c_str()) ;
4675 }
4676
4677 }
4678 } else {
4679#ifndef __ROOFIT_NOROOMINIMIZER
4680 // Instantiate MINUIT
4681 RooMinimizer m(fcn) ;
4682 m.setMinimizerType(minType);
4683
4684 if (doWarn==0) {
4685 // m.setNoWarn() ; WVE FIX THIS
4686 }
4687
4688 m.setPrintEvalErrors(numee) ;
4689 if (plevel!=1) {
4690 m.setPrintLevel(plevel) ;
4691 }
4692
4693 if (optConst) {
4694 // Activate constant term optimization
4695 m.optimizeConst(optConst);
4696 }
4697
4698 if (fitOpt) {
4699
4700 // Play fit options as historically defined
4701 ret = m.fit(fitOpt) ;
4702
4703 } else {
4704
4705 if (verbose) {
4706 // Activate verbose options
4707 m.setVerbose(1) ;
4708 }
4709 if (doTimer) {
4710 // Activate timer options
4711 m.setProfile(1) ;
4712 }
4713
4714 if (strat!=1) {
4715 // Modify fit strategy
4716 m.setStrategy(strat) ;
4717 }
4718
4719 if (initHesse) {
4720 // Initialize errors with hesse
4721 m.hesse() ;
4722 }
4723
4724 // Minimize using migrad
4725 m.minimize(minType, minAlg) ;
4726
4727 if (hesse) {
4728 // Evaluate errors with Hesse
4729 m.hesse() ;
4730 }
4731
4732 if (minos) {
4733 // Evaluate errs with Minos
4734 if (minosSet) {
4735 m.minos(*minosSet) ;
4736 } else {
4737 m.minos() ;
4738 }
4739 }
4740
4741 // Optionally return fit result
4742 if (doSave) {
4743 string name = Form("fitresult_%s",fcn.GetName()) ;
4744 string title = Form("Result of fit of %s ",GetName()) ;
4745 ret = m.save(name.c_str(),title.c_str()) ;
4746 }
4747 }
4748#endif
4749 }
4750
4751 // Cleanup
4752 return ret ;
4753
4754}
4755
4756
4757////////////////////////////////////////////////////////////////////////////////
4758/// Return current evaluation error logging mode.
4759
4761{
4762 return _evalErrorMode ;
4763}
4764
4765////////////////////////////////////////////////////////////////////////////////
4766/// Set evaluation error logging mode. Options are
4767///
4768/// PrintErrors - Print each error through RooMsgService() as it occurs
4769/// CollectErrors - Accumulate errors, but do not print them. A subsequent call
4770/// to printEvalErrors() will print a summary
4771/// CountErrors - Accumulate error count, but do not print them.
4772///
4773
4775{
4776 _evalErrorMode = m;
4777}
4778
4779
4780////////////////////////////////////////////////////////////////////////////////
4781
4783{
4784 RooFIter iter = paramVars.fwdIterator() ;
4785 RooAbsArg* arg ;
4786 string plist ;
4787 while((arg=iter.next())) {
4788 if (!dependsOnValue(*arg)) {
4789 coutW(InputArguments) << "RooAbsReal::setParameterizeIntegral(" << GetName()
4790 << ") function does not depend on listed parameter " << arg->GetName() << ", ignoring" << endl ;
4791 continue ;
4792 }
4793 if (plist.size()>0) plist += ":" ;
4794 plist += arg->GetName() ;
4795 }
4796 setStringAttribute("CACHEPARAMINT",plist.c_str()) ;
4797}
void Class()
Definition: Class.C:29
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define c(i)
Definition: RSha256.hxx:101
#define e(i)
Definition: RSha256.hxx:103
static RooMathCoreReg dummy
#define coutI(a)
Definition: RooMsgService.h:31
#define cxcoutD(a)
Definition: RooMsgService.h:79
#define coutW(a)
Definition: RooMsgService.h:33
#define ccoutP(a)
Definition: RooMsgService.h:39
#define dologD(a)
Definition: RooMsgService.h:63
#define coutF(a)
Definition: RooMsgService.h:35
#define oocoutE(o, a)
Definition: RooMsgService.h:47
#define coutE(a)
Definition: RooMsgService.h:34
#define ccoutW(a)
Definition: RooMsgService.h:40
#define ccoutD(a)
Definition: RooMsgService.h:37
int Int_t
Definition: RtypesCore.h:41
char Text_t
Definition: RtypesCore.h:58
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:363
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
double sqrt(double)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
virtual Bool_t checkObservables(const RooArgSet *nset) const
Overloadable function in which derived classes can implement consistency checks of the variables.
Definition: RooAbsArg.cxx:701
virtual RooAbsArg * cloneTree(const char *newname=0) const
Clone tree expression of objects.
Definition: RooAbsArg.cxx:2288
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Definition: RooAbsArg.h:194
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
Definition: RooAbsArg.cxx:736
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
Definition: RooAbsArg.cxx:273
void leafNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all leaf nodes of the arg tree, starting with ourself as top node.
Definition: RooAbsArg.cxx:466
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multi-line detailed printing.
Definition: RooAbsArg.cxx:1377
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
Definition: RooAbsArg.h:75
friend class RooArgSet
Definition: RooAbsArg.h:471
virtual Bool_t isFundamental() const
Definition: RooAbsArg.h:157
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
Definition: RooAbsArg.cxx:286
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t doBranch=kTRUE, Bool_t doLeaf=kTRUE, Bool_t valueOnly=kFALSE, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
Definition: RooAbsArg.cxx:487
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
Definition: RooAbsArg.cxx:533
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:241
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2074
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Change cache operation mode to given mode.
Definition: RooAbsArg.cxx:1746
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2274
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
Definition: RooAbsArg.cxx:1864
Int_t numProxies() const
Return the number of registered proxies.
Definition: RooAbsArg.cxx:1259
void setShapeDirty() const
Definition: RooAbsArg.h:442
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Definition: RooAbsArg.cxx:264
friend class RooCustomizer
Definition: RooAbsArg.h:473
Bool_t dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
Definition: RooAbsArg.h:88
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
Definition: RooAbsArg.cxx:1246
Bool_t isValueDirtyAndClear() const
Definition: RooAbsArg.h:351
RooArgSet * getComponents() const
Definition: RooAbsArg.cxx:680
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
Definition: RooAbsArg.cxx:477
void setValueDirty() const
Definition: RooAbsArg.h:441
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Definition: RooAbsArg.cxx:1080
void attachDataSet(const RooAbsData &set)
Replace server nodes with names matching the dataset variable names with those data set variables,...
Definition: RooAbsArg.cxx:1489
void SetName(const char *name)
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2382
OperMode operMode() const
Definition: RooAbsArg.h:399
RooAbsBinning is the abstract base class for RooRealVar binning definitions This class defines the in...
Definition: RooAbsBinning.h:26
virtual Bool_t isParameterized() const
Definition: RooAbsBinning.h:79
virtual RooAbsReal * highBoundFunc() const
Definition: RooAbsBinning.h:87
virtual RooAbsReal * lowBoundFunc() const
Definition: RooAbsBinning.h:83
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)=0
virtual Int_t getIndex() const
Return index number of current state.
Bool_t isSignType(Bool_t mustHaveZero=kFALSE) const
Determine if category has 2 or 3 states with index values -1,0,1.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
virtual Bool_t replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return kTRUE for success.
Int_t getSize() const
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
RooFIter fwdIterator() const
void sort(Bool_t ascend=kTRUE)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsArg * first() const
RooAbsCollection * selectByName(const char *nameList, Bool_t verbose=kFALSE) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
Bool_t overlaps(const RooAbsCollection &otherColl) const
Check if this and other collection have common entries.
std::string contentsString() const
Return comma separated list of contained object names as STL string.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
virtual const RooArgSet * get() const
Definition: RooAbsData.h:79
RooAbsData * reduce(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg())
Create a reduced copy of this dataset.
Definition: RooAbsData.cxx:360
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition: RooAbsFunc.h:23
Bool_t isValid() const
Definition: RooAbsFunc.h:33
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
RooAbsMoment represents the first, second, or third order derivative of any RooAbsReal as calculated ...
Definition: RooAbsMoment.h:27
void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Driver function to propagate constant term optimizations in test statistic.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
@ CanNotBeExtended
Definition: RooAbsPdf.h:223
const char * normRange() const
Definition: RooAbsPdf.h:257
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
Definition: RooAbsPdf.cxx:2855
virtual ExtendMode extendMode() const
Definition: RooAbsPdf.h:224
RooAbsProxy is the abstact interface for proxy classes.
Definition: RooAbsProxy.h:31
virtual void print(std::ostream &os, Bool_t addContents=kFALSE) const
Print proxy name.
Definition: RooAbsProxy.cxx:75
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
virtual const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const =0
TH1 * createHistogram(const char *name, const RooCmdArg &arg1=RooCmdArg::none(), 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
virtual Double_t getMin(const char *name=0) const
void setServerValues(const char *tmp)
Definition: RooAbsReal.h:258
std::string _srvval
Definition: RooAbsReal.h:260
void setMessage(const char *tmp)
Definition: RooAbsReal.h:257
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
void plotOnCompSelect(RooArgSet *selNodes) const
Helper function for plotting of composite p.d.fs.
RooGenFunction * iGenFunction(RooRealVar &x, const RooArgSet &nset=RooArgSet())
virtual RooPlot * plotSliceOn(RooPlot *frame, const RooArgSet &sliceSet, Option_t *drawOptions="L", Double_t scaleFactor=1.0, ScaleType stype=Relative, const RooAbsData *projData=0) const
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from stream (dummy for now)
Definition: RooAbsReal.cxx:394
TString _label
Definition: RooAbsReal.h:393
virtual Bool_t isIdentical(const RooAbsArg &other, Bool_t assumeSameType=kFALSE)
Definition: RooAbsReal.cxx:215
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, Double_t scaleFactor=1, const RooArgSet *projectedVars=0, Bool_t scaling=kTRUE, const RooArgSet *condObs=0, Bool_t setError=kTRUE) const
Fill the ROOT histogram 'hist' with values sampled from this function at the bin centers.
virtual void selectNormalizationRange(const char *rangeName=0, Bool_t force=kFALSE)
Interface function to force use of a given normalization range to interpret function value.
TString getTitle(Bool_t appendUnit=kFALSE) const
Return this variable's title string.
Definition: RooAbsReal.cxx:230
static Int_t numEvalErrorItems()
Definition: RooAbsReal.cxx:270
static void setHideOffset(Bool_t flag)
Definition: RooAbsReal.cxx:117
RooAbsReal()
coverity[UNINIT_CTOR] Default constructor
Definition: RooAbsReal.cxx:129
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
Definition: RooAbsReal.cxx:319
Bool_t _forceNumInt
Definition: RooAbsReal.h:394
friend class RooRealBinding
Definition: RooAbsReal.h:387
RooAbsReal * createScanRI(const RooArgSet &iset, const RooArgSet &nset, Int_t numScanBins, Int_t intOrder)
Utility function for createRunningIntegral that construct an object implementing the numeric scanning...
UChar_t _byteValue
Transient cache for bool values from tree branches.
Definition: RooAbsReal.h:399
Bool_t isSelectedComp() const
If true, the current pdf is a selected component (for use in plotting)
virtual RooAbsReal * createChi2(RooDataHist &data, const RooLinkedList &cmdList)
Create a variable from a histogram and this function.
RooArgSet * _lastNSet
Definition: RooAbsReal.h:484
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, Double_t eps=0.001)
Return function representing first, second or third order derivative of this function.
Float_t _floatValue
Definition: RooAbsReal.h:396
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Interface function to check if given value is a valid value for this object.
Definition: RooAbsReal.cxx:449
static Bool_t _cacheCheck
Definition: RooAbsReal.h:411
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
void setParameterizeIntegral(const RooArgSet &paramVars)
static Bool_t hideOffset()
Definition: RooAbsReal.cxx:118
virtual Double_t evaluate() const =0
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
virtual void setTreeBranchStatus(TTree &t, Bool_t active)
(De)Activate associated tree branch
virtual RooAbsReal * createProfile(const RooArgSet &paramsOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
Definition: RooAbsReal.cxx:462
TString integralNameSuffix(const RooArgSet &iset, const RooArgSet *nset=0, const char *rangeName=0, Bool_t omitEmpty=kFALSE) const
Construct string with unique suffix name to give to integral object that encodes integrated observabl...
Definition: RooAbsReal.cxx:756
virtual Double_t getValV(const RooArgSet *set=0) const
Return value of object.
Definition: RooAbsReal.cxx:248
Double_t traceEval(const RooArgSet *set) const
Calculate current value of object, with error tracing wrapper.
Definition: RooAbsReal.cxx:287
Int_t _intValue
Transient cache for floating point values from tree branches.
Definition: RooAbsReal.h:397
Double_t getPropagatedError(const RooFitResult &fr, const RooArgSet &nset=RooArgSet())
Calculate error on self by propagated errors on parameters with correlations as given by fit result T...
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
Copy the cached value of another RooAbsArg to our cache.
virtual void fixAddCoefRange(const char *rangeName=0, Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
TH1 * createHistogram(const char *varNameList, Int_t xbins=0, Int_t ybins=0, Int_t zbins=0) const
Create and fill a ROOT histogram TH1, TH2 or TH3 with the values of this function for the variables w...
static EvalErrorIter evalErrorIter()
Definition: RooAbsReal.cxx:278
Double_t findRoot(RooRealVar &x, Double_t xmin, Double_t xmax, Double_t yval)
Return value of x (in range xmin,xmax) at which function equals yval.
RooAbsReal * createIntRI(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Utility function for createRunningIntegral that construct an object implementing the standard (analyt...
TF1 * asTF(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables and parame...
virtual Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:348
virtual void attachToVStore(RooVectorDataStore &vstore)
TString _unit
Definition: RooAbsReal.h:392
static RooNumIntConfig * defaultIntegratorConfig()
Returns the default numeric integration configuration for all RooAbsReals.
RooFitResult * chi2FitDriver(RooAbsReal &fcn, RooLinkedList &cmdList)
Internal driver function for chi2 fits.
Double_t _value
Definition: RooAbsReal.h:391
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Definition: RooAbsReal.h:279
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Attach object to a branch of given TTree.
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
RooNumIntConfig * _specIntegratorConfig
Definition: RooAbsReal.h:407
virtual RooPlot * plotAsymOn(RooPlot *frame, const RooAbsCategoryLValue &asymCat, PlotOpt o) const
static ErrorLoggingMode evalErrorLoggingMode()
Return current evaluation error logging mode.
void setIntegratorConfig()
Remove the specialized numeric integration configuration associated with this object.
static void setCacheCheck(Bool_t flag)
Activate cache validation mode.
virtual void selectNormalization(const RooArgSet *depSet=0, Bool_t force=kFALSE)
Interface function to force use of a given set of observables to interpret function value.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Definition: RooAbsReal.cxx:423
friend class RooRealIntegral
Definition: RooAbsReal.h:378
RooAbsMoment * moment(RooRealVar &obs, Int_t order, Bool_t central, Bool_t takeRoot)
Return function representing moment of function of given order.
static ErrorLoggingMode _evalErrorMode
Definition: RooAbsReal.h:463
static Int_t _evalErrorCount
Definition: RooAbsReal.h:465
virtual Bool_t isValid() const
Check if current value is valid.
Definition: RooAbsReal.cxx:438
static void globalSelectComp(Bool_t flag)
Global switch controlling the activation of the selectComp() functionality.
RooAbsArg * createFundamental(const char *newname=0) const
Create a RooRealVar fundamental object with our properties.
Double_t getVal(const RooArgSet *set=0) const
Evaluate object. Returns either cached value or triggers a recalculation.
Definition: RooAbsReal.h:64
std::map< constRooAbsArg *, std::pair< std::string, std::list< EvalError > > >::const_iterator EvalErrorIter
Definition: RooAbsReal.h:273
virtual Double_t maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
static Bool_t _globalSelectComp
Component selection flag for RooAbsPdf::plotCompOn.
Definition: RooAbsReal.h:482
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 ...
Definition: RooAbsReal.cxx:502
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
RooAbsReal * createIntObj(const RooArgSet &iset, const RooArgSet *nset, const RooNumIntConfig *cfg, const char *rangeName) const
Utility function for createIntegral that creates the actual integreal object.
Definition: RooAbsReal.cxx:577
static std::map< const RooAbsArg *, std::pair< std::string, std::list< EvalError > > > _evalErrorList
Definition: RooAbsReal.h:464
Bool_t plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
Char_t _sbyteValue
Transient cache for byte values from tree branches.
Definition: RooAbsReal.h:400
const char * getPlotLabel() const
Get the label associated with the variable.
Definition: RooAbsReal.cxx:374
virtual RooFitResult * chi2FitTo(RooDataHist &data, const RooCmdArg &arg1=RooCmdArg::none(), 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())
Perform a fit to given histogram.
virtual void fillTreeBranch(TTree &t)
Fill the tree branch that associated with this object with its current value.
Bool_t operator==(Double_t value) const
Equality operator comparing to a Double_t.
Definition: RooAbsReal.cxx:195
RooAbsFunc * bindVars(const RooArgSet &vars, const RooArgSet *nset=0, Bool_t clipInvalid=kFALSE) const
Create an interface adaptor f(vars) that binds us to the specified variables (in arbitrary order).
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
Bool_t matchArgsByName(const RooArgSet &allArgs, RooArgSet &matchedArgs, const TList &nameList) const
Check if allArgs contains matching elements for each name in nameList.
virtual Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooAbsReal.cxx:362
virtual Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
Definition: RooAbsReal.cxx:336
virtual void preferredObservableScanOrder(const RooArgSet &obs, RooArgSet &orderedObs) const
Interface method for function objects to indicate their prefferred order of observables for scanning ...
void findInnerMostIntegration(const RooArgSet &allObs, RooArgSet &innerObs, const char *rangeName) const
Utility function for createIntObj() that aids in the construct of recursive integrals over functions ...
Definition: RooAbsReal.cxx:698
static Bool_t _hideOffset
Definition: RooAbsReal.h:485
const Text_t * getUnit() const
Definition: RooAbsReal.h:84
virtual void printValue(std::ostream &os) const
Print object value.
Definition: RooAbsReal.cxx:413
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
Bool_t _boolValue
Transient cache for integer values from tree branches.
Definition: RooAbsReal.h:398
RooPlot * plotOnWithErrorBand(RooPlot *frame, const RooFitResult &fr, Double_t Z, const RooArgSet *params, const RooLinkedList &argList, Bool_t method1) const
Plot function or PDF on frame with support for visualization of the uncertainty encoded in the given ...
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), Bool_t force=kTRUE)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
Bool_t _selectComp
Definition: RooAbsReal.h:481
Bool_t _treeVar
Definition: RooAbsReal.h:409
RooFunctor * functor(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a RooFunctor object bound to this RooAbsReal with given definition of observables and paramete...
UInt_t _uintValue
Transient cache for signed byte values from tree branches.
Definition: RooAbsReal.h:401
void makeProjectionSet(const RooAbsArg *plotVar, const RooArgSet *allVars, RooArgSet &projectedVars, Bool_t silent) const
Utility function for plotOn() that constructs the set of observables to project when plotting ourselv...
void setPlotLabel(const char *label)
Set the label associated with this variable.
Definition: RooAbsReal.cxx:384
virtual ~RooAbsReal()
Destructor.
Definition: RooAbsReal.cxx:185
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to stream (dummy for now)
Definition: RooAbsReal.cxx:404
const RooAbsReal * createPlotProjection(const RooArgSet &depVars, const RooArgSet &projVars) const
Utility function for plotOn() that creates a projection of a function or p.d.f to be plotted on a Roo...
Definition: RooAbsReal.cxx:835
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
Fill a RooDataHist with values sampled from this function at the bin centers.
virtual Double_t offset() const
Definition: RooAbsReal.h:310
RooAbsReal * createRunningIntegral(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Calls createRunningIntegral(const RooArgSet&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&,...
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
Definition: RooAddition.h:26
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
RooArgProxy is the abstact interface for RooAbsArg proxy classes.
Definition: RooArgProxy.h:24
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:92
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:96
Class RooBinning is an implements RooAbsBinning in terms of an array of boundary values,...
Definition: RooBinning.h:29
Implement the abstract 1-dimensional root finding interface using the Brent-Decker method.
virtual Bool_t findRoot(Double_t &result, Double_t xlo, Double_t xhi, Double_t value=0) const
Do the root finding using the Brent-Decker method.
RooCachedReal is an implementation of RooAbsCachedReal that can cache any external RooAbsReal input f...
Definition: RooCachedReal.h:20
void setCacheSource(Bool_t flag)
Definition: RooCachedReal.h:44
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:50
const char * getString(Int_t idx) const
Definition: RooCmdArg.h:88
void setString(Int_t idx, const char *value)
Definition: RooCmdArg.h:72
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
Definition: RooCmdArg.h:51
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Definition: RooCurve.h:32
RooCurve * makeErrorBand(const std::vector< RooCurve * > &variations, Double_t Z=1) const
Construct filled RooCurve represented error band that captures alpha% of the variations of the curves...
Definition: RooCurve.cxx:728
@ Extended
Definition: RooCurve.h:35
@ NoWings
Definition: RooCurve.h:35
@ Straight
Definition: RooCurve.h:35
void setCloneBranchSet(RooArgSet &cloneBranchSet)
Install the input RooArgSet as container in which all cloned branches will be stored.
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurence of arg 'orig' with arg 'subst'.
void setOwning(Bool_t flag)
Definition: RooCustomizer.h:41
RooAbsArg * build(const char *masterCatState, Bool_t verbose=kFALSE)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooDataSet is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
void set(Double_t weight, Double_t wgtErr=-1)
Increment the weight of the bin enclosing the coordinates given by 'row' by the specified amount.
virtual Int_t numEntries() const
Return the number of bins.
virtual const RooArgSet * get() const
Definition: RooDataHist.h:77
Double_t binVolume() const
Definition: RooDataHist.h:102
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
Class RooDataWeightedAverage calculate a weighted average of a function or p.d.f given a dataset with...
RooDerivative represents the first, second, or third order derivative of any RooAbsReal as calculated...
Definition: RooDerivative.h:31
RooAbsArg * next()
RooFirstMoment represents the first, second, or third order derivative of any RooAbsReal as calculate...
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
TMatrixDSym reducedCovarianceMatrix(const RooArgList &params) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
const RooArgList & floatParsFinal() const
Definition: RooFitResult.h:110
RooAbsPdf * createHessePdf(const RooArgSet &params) const
Return a p.d.f that represents the fit result as a multi-variate probability densisty function on the...
Lightweight interface adaptor that exports a RooAbsPdf as a functor.
Definition: RooFunctor.h:25
Lightweight interface adaptor that exports a RooAbsReal as a ROOT::Math::IGenFunction.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
RooFIter fwdIterator() const
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:62
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
Definition: RooMinimizer.h:38
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Definition: RooMinuit.h:39
RooMoment represents the first, second, or third order derivative of any RooAbsReal as calculated (nu...
Definition: RooMoment.h:27
Lightweight interface adaptor that exports a RooAbsReal as a ROOT::Math::IMultiGenFunction.
RooNameSet is a utility class that stores the names the objects in a RooArget.
Definition: RooNameSet.h:24
RooArgSet * select(const RooArgSet &list) const
Construct a RooArgSet of objects in input 'list' whose names match to those in the internal name list...
Definition: RooNameSet.cxx:187
void setNameList(const char *givenList)
Definition: RooNameSet.cxx:144
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
static RooNumIntConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
Class RooNumRunningInt is an implementation of RooAbsCachedReal that represents a running integral.
Class RooParamBinning is an implementation of RooAbsBinning that constructs a binning with a range de...
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:41
Bool_t drawBefore(const char *before, const char *target)
Change the order in which our contained objects are drawn so that the target object is drawn just bef...
Definition: RooPlot.cxx:821
Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Definition: RooPlot.cxx:1126
const RooArgSet * getNormVars() const
Definition: RooPlot.h:141
Stat_t numItems() const
Definition: RooPlot.h:109
TAttFill * getAttFill(const char *name=0) const
Return a pointer to the fill attributes of the named object in this plot, or zero if the named object...
Definition: RooPlot.cxx:743
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:958
TObject * getObject(Int_t idx) const
Return the name of the object at slot 'idx' in this RooPlot.
Definition: RooPlot.cxx:717
RooAbsRealLValue * getPlotVar() const
Definition: RooPlot.h:132
TAttLine * getAttLine(const char *name=0) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
Definition: RooPlot.cxx:733
TAxis * GetXaxis() const
Definition: RooPlot.cxx:1122
Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Definition: RooPlot.cxx:1127
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", Bool_t invisible=kFALSE, Bool_t refreshNorm=kFALSE)
Add the specified plotable object to our plot.
Definition: RooPlot.cxx:446
Int_t GetNbinsX() const
Definition: RooPlot.cxx:1124
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:948
TObject * findObject(const char *name, const TClass *clas=0) const
Find the named object in our list of items and return a pointer to it.
Definition: RooPlot.cxx:849
RooCurve * getCurve(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition: RooPlot.cxx:774
void remove(const char *name=0, Bool_t deleteToo=kTRUE)
Remove object with given name, or last object added if no name is given.
Definition: RooPlot.cxx:796
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Class RooProfileLL implements the profile likelihood estimator for a given likelihood and set of para...
Definition: RooProfileLL.h:26
Lightweight interface adaptor that binds a RooAbsReal object to a subset of its servers and present i...
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
const RooArgSet & numIntRealVars() const
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
void setBins(Int_t nBins, const char *name=0)
Definition: RooRealVar.h:77
void setRange(const char *name, Double_t min, Double_t max)
Set range named 'name to [min,max].
Definition: RooRealVar.cxx:448
void removeRange(const char *name=0)
Definition: RooRealVar.h:89
Double_t getError() const
Definition: RooRealVar.h:53
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
Definition: RooRealVar.cxx:345
virtual TObject * clone(const char *newname) const
Definition: RooRealVar.h:47
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:204
Lightweight RooAbsFunction implementation that applies a constant scale factor to another RooAbsFunc.
Definition: RooScaledFunc.h:21
RooSecondMoment represents the first, second, or third order derivative of any RooAbsReal as calculat...
void setBuffer(RooAbsReal *real, Double_t *newBuf)
RooVectorDataStore is the abstract base class for data collection that use a TTree as internal storag...
RealVector * addReal(RooAbsReal *real)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
Line Attributes class.
Definition: TAttLine.h:18
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
Class to manage histogram axis.
Definition: TAxis.h:30
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
Double_t GetXmax() const
Definition: TAxis.h:134
Double_t GetXmin() const
Definition: TAxis.h:133
A TTree is a list of TBranches.
Definition: TBranch.h:64
Int_t GetCompressionLevel() const
Definition: TBranch.h:261
TObjArray * GetListOfLeaves()
Definition: TBranch.h:204
Int_t Fill()
Definition: TBranch.h:164
void SetCompressionLevel(Int_t level=ROOT::RCompressionSetting::ELevel::kUseMin)
Set compression level.
Definition: TBranch.cxx:2366
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
1-Dim function class
Definition: TF1.h:211
virtual void SetParName(Int_t ipar, const char *name)
Set name of parameter number ipar.
Definition: TF1.cxx:3443
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:618
A 2-Dim function with parameters.
Definition: TF2.h:29
A 3-Dim function with parameters.
Definition: TF3.h:28
virtual void SetName(const char *name="")
Set graph name.
Definition: TGraph.cxx:2223
The TH1 histogram class.
Definition: TH1.h:56
TAxis * GetZaxis()
Definition: TH1.h:318
virtual Int_t GetNbinsY() const
Definition: TH1.h:293
virtual Int_t GetNbinsZ() const
Definition: TH1.h:294
virtual Int_t GetDimension() const
Definition: TH1.h:278
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
virtual Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
Definition: TH1.cxx:4692
virtual Int_t GetNbinsX() const
Definition: TH1.h:292
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
Definition: TH1.cxx:8526
TAxis * GetYaxis()
Definition: TH1.h:317
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8542
Iterator abstract base class.
Definition: TIterator.h:30
virtual void Reset()=0
virtual TObject * Next()=0
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
Definition: TLeaf.h:32
virtual const char * GetTypeName() const
Definition: TLeaf.h:93
virtual TLeaf * GetLeafCounter(Int_t &countval) const
Return a pointer to the counter of this leaf (if any) or store the number of elements that the leaf c...
Definition: TLeaf.cxx:198
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:718
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
TString fName
Definition: TNamed.h:32
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
An array of TObjects.
Definition: TObjArray.h:37
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:522
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Collectable string class.
Definition: TObjString.h:28
const TString & GetString() const
Definition: TObjString.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
#define F(x, y, z)
static double C[]
RooCmdArg Binning(const RooAbsBinning &binning)
RooCmdArg NormRange(const char *rangeNameList)
RooCmdArg YVar(const RooAbsRealLValue &var, const RooCmdArg &arg=RooCmdArg::none())
RooCmdArg ZVar(const RooAbsRealLValue &var, const RooCmdArg &arg=RooCmdArg::none())
@ NumIntegration
Definition: RooGlobalFunc.h:59
@ InputArguments
Definition: RooGlobalFunc.h:58
@ ObjectHandling
Definition: RooGlobalFunc.h:58
@ Integration
Definition: RooGlobalFunc.h:57
RooCmdArg SupNormSet(const RooArgSet &nset)
static constexpr double second
static constexpr double pc
static constexpr double ps
Bool_t IsNaN(Double_t x)
Definition: TMath.h:880
Double_t Erfc(Double_t x)
Compute the complementary error function erfc(x).
Definition: TMath.cxx:194
Definition: first.py:1
STL namespace.
@ kUseGlobal
Use the global compression setting for this process; may be affected by rootrc.
Definition: Compression.h:47
Bool_t postRangeFracScale
Definition: RooAbsReal.h:433
RooCurve::WingMode wmode
Definition: RooAbsReal.h:434
const char * normRangeName
Definition: RooAbsReal.h:430
RooFit::MPSplit interleave
Definition: RooAbsReal.h:442
const char * projectionRangeName
Definition: RooAbsReal.h:435
Double_t scaleFactor
Definition: RooAbsReal.h:422
const RooArgSet * projDataSet
Definition: RooAbsReal.h:429
Double_t addToWgtSelf
Definition: RooAbsReal.h:439
const char * curveNameSuffix
Definition: RooAbsReal.h:443
Double_t addToWgtOther
Definition: RooAbsReal.h:440
const char * addToCurveName
Definition: RooAbsReal.h:438
const RooArgSet * projSet
Definition: RooAbsReal.h:426
const char * curveName
Definition: RooAbsReal.h:437
const RooAbsData * projData
Definition: RooAbsReal.h:424
Option_t * drawOptions
Definition: RooAbsReal.h:420
lv SetLineColor(kBlue)
auto * m
Definition: textangle.C:8
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12
static long int sum(long int i)
Definition: Factory.cxx:2258