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