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