Logo ROOT   6.12/07
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  projected->SetName(name.Data()) ;
972  projected->SetTitle(title.Data()) ;
973 
974  // Add the projection integral to the cloneSet so that it eventually gets cleaned up by the caller.
975  cloneSet->addOwned(*projected);
976 
977  // cleanup
978  delete dependentIterator;
979 
980  // return a const pointer to remind the caller that they do not delete the returned object
981  // directly (it is contained in the cloneSet instead).
982  return projected;
983 }
984 
985 
986 
987 
988 ////////////////////////////////////////////////////////////////////////////////
989 /// Fill the ROOT histogram 'hist' with values sampled from this
990 /// function at the bin centers. Our value is calculated by first
991 /// integrating out any variables in projectedVars and then scaling
992 /// the result by scaleFactor. Returns a pointer to the input
993 /// histogram, or zero in case of an error. The input histogram can
994 /// be any TH1 subclass, and therefore of arbitrary
995 /// dimension. Variables are matched with the (x,y,...) dimensions of
996 /// the input histogram according to the order in which they appear
997 /// in the input plotVars list. If scaleForDensity is true the
998 /// histogram is filled with a the functions density rather than
999 /// the functions value (i.e. the value at the bin center is multiplied
1000 /// with bin volume)
1001 
1003  Double_t scaleFactor, const RooArgSet *projectedVars, Bool_t scaleForDensity,
1004  const RooArgSet* condObs, Bool_t setError) const
1005 {
1006  // Do we have a valid histogram to use?
1007  if(0 == hist) {
1008  coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: no valid histogram to fill" << endl;
1009  return 0;
1010  }
1011 
1012  // Check that the number of plotVars matches the input histogram's dimension
1013  Int_t hdim= hist->GetDimension();
1014  if(hdim != plotVars.getSize()) {
1015  coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: plotVars has the wrong dimension" << endl;
1016  return 0;
1017  }
1018 
1019 
1020  // Check that the plot variables are all actually RooRealVars and print a warning if we do not
1021  // explicitly depend on one of them. Fill a set (not list!) of cloned plot variables.
1022  RooArgSet plotClones;
1023  for(Int_t index= 0; index < plotVars.getSize(); index++) {
1024  const RooAbsArg *var= plotVars.at(index);
1025  const RooRealVar *realVar= dynamic_cast<const RooRealVar*>(var);
1026  if(0 == realVar) {
1027  coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: cannot plot variable \"" << var->GetName()
1028  << "\" of type " << var->ClassName() << endl;
1029  return 0;
1030  }
1031  if(!this->dependsOn(*realVar)) {
1032  coutE(InputArguments) << ClassName() << "::" << GetName()
1033  << ":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->GetName() << endl;
1034  }
1035  plotClones.addClone(*realVar,kTRUE); // do not complain about duplicates
1036  }
1037 
1038  // Reconnect all plotClones to each other, imported when plotting N-dim integrals with entangled parameterized ranges
1039  TIterator* pciter= plotClones.createIterator() ;
1040  RooAbsArg* pc ;
1041  while((pc=(RooAbsArg*)pciter->Next())) {
1042  pc->recursiveRedirectServers(plotClones,kFALSE,kFALSE,kTRUE) ;
1043  }
1044 
1045  delete pciter ;
1046 
1047  // Call checkObservables
1048  RooArgSet allDeps(plotClones) ;
1049  if (projectedVars) {
1050  allDeps.add(*projectedVars) ;
1051  }
1052  if (checkObservables(&allDeps)) {
1053  coutE(InputArguments) << "RooAbsReal::fillHistogram(" << GetName() << ") error in checkObservables, abort" << endl ;
1054  return hist ;
1055  }
1056 
1057  // Create a standalone projection object to use for calculating bin contents
1058  RooArgSet *cloneSet = 0;
1059  const RooAbsReal *projected= createPlotProjection(plotClones,projectedVars,cloneSet,0,condObs);
1060 
1061  cxcoutD(Plotting) << "RooAbsReal::fillHistogram(" << GetName() << ") plot projection object is " << projected->GetName() << endl ;
1062 
1063  // Prepare to loop over the histogram bins
1064  Int_t xbins(0),ybins(1),zbins(1);
1065  RooRealVar *xvar = 0;
1066  RooRealVar *yvar = 0;
1067  RooRealVar *zvar = 0;
1068  TAxis *xaxis = 0;
1069  TAxis *yaxis = 0;
1070  TAxis *zaxis = 0;
1071  switch(hdim) {
1072  case 3:
1073  zbins= hist->GetNbinsZ();
1074  zvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(2)->GetName()));
1075  zaxis= hist->GetZaxis();
1076  assert(0 != zvar && 0 != zaxis);
1077  if (scaleForDensity) {
1078  scaleFactor*= (zaxis->GetXmax() - zaxis->GetXmin())/zbins;
1079  }
1080  // fall through to next case...
1081  case 2:
1082  ybins= hist->GetNbinsY();
1083  yvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(1)->GetName()));
1084  yaxis= hist->GetYaxis();
1085  assert(0 != yvar && 0 != yaxis);
1086  if (scaleForDensity) {
1087  scaleFactor*= (yaxis->GetXmax() - yaxis->GetXmin())/ybins;
1088  }
1089  // fall through to next case...
1090  case 1:
1091  xbins= hist->GetNbinsX();
1092  xvar= dynamic_cast<RooRealVar*>(plotClones.find(plotVars.at(0)->GetName()));
1093  xaxis= hist->GetXaxis();
1094  assert(0 != xvar && 0 != xaxis);
1095  if (scaleForDensity) {
1096  scaleFactor*= (xaxis->GetXmax() - xaxis->GetXmin())/xbins;
1097  }
1098  break;
1099  default:
1100  coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillHistogram: cannot fill histogram with "
1101  << hdim << " dimensions" << endl;
1102  break;
1103  }
1104 
1105  // Loop over the input histogram's bins and fill each one with our projection's
1106  // value, calculated at the center.
1108  Int_t xbin(0),ybin(0),zbin(0);
1109  Int_t bins= xbins*ybins*zbins;
1110  for(Int_t bin= 0; bin < bins; bin++) {
1111  switch(hdim) {
1112  case 3:
1113  if(bin % (xbins*ybins) == 0) {
1114  zbin++;
1115  zvar->setVal(zaxis->GetBinCenter(zbin));
1116  }
1117  // fall through to next case...
1118  case 2:
1119  if(bin % xbins == 0) {
1120  ybin= (ybin%ybins) + 1;
1121  yvar->setVal(yaxis->GetBinCenter(ybin));
1122  }
1123  // fall through to next case...
1124  case 1:
1125  xbin= (xbin%xbins) + 1;
1126  xvar->setVal(xaxis->GetBinCenter(xbin));
1127  break;
1128  default:
1129  coutE(InputArguments) << "RooAbsReal::fillHistogram: Internal Error!" << endl;
1130  break;
1131  }
1132 
1133  Double_t result= scaleFactor*projected->getVal();
1134  if (RooAbsReal::numEvalErrors()>0) {
1135  coutW(Plotting) << "WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->getVal() ;
1136  if (hdim==2) ccoutW(Plotting) << " [y]=" << yvar->getVal() ;
1137  if (hdim==3) ccoutW(Plotting) << " [z]=" << zvar->getVal() ;
1138  ccoutW(Plotting) << endl ;
1139  // RooAbsReal::printEvalErrors(ccoutW(Plotting),10) ;
1140  result = 0 ;
1141  }
1143 
1144  hist->SetBinContent(hist->GetBin(xbin,ybin,zbin),result);
1145  if (setError) {
1146  hist->SetBinError(hist->GetBin(xbin,ybin,zbin),sqrt(result)) ;
1147  }
1148 
1149  //cout << "bin " << bin << " -> (" << xbin << "," << ybin << "," << zbin << ") = " << result << endl;
1150  }
1152 
1153  // cleanup
1154  delete cloneSet;
1155 
1156  return hist;
1157 }
1158 
1159 
1160 
1161 ////////////////////////////////////////////////////////////////////////////////
1162 /// Fill a RooDataHist with values sampled from this function at the
1163 /// bin centers. If extendedMode is true, the p.d.f. values is multiplied
1164 /// by the number of expected events in each bin
1165 ///
1166 /// An optional scaling by a given scaleFactor can be performed.
1167 /// Returns a pointer to the input RooDataHist, or zero
1168 /// in case of an error.
1169 ///
1170 /// If correctForBinSize is true the RooDataHist
1171 /// is filled with the functions density (function value times the
1172 /// bin volume) rather than function value.
1173 ///
1174 /// If showProgress is true
1175 /// a process indicator is printed on stdout in steps of one percent,
1176 /// which is mostly useful for the sampling of expensive functions
1177 /// such as likelihoods
1178 
1180  Bool_t correctForBinSize, Bool_t showProgress) const
1181 {
1182  // Do we have a valid histogram to use?
1183  if(0 == hist) {
1184  coutE(InputArguments) << ClassName() << "::" << GetName() << ":fillDataHist: no valid RooDataHist to fill" << endl;
1185  return 0;
1186  }
1187 
1188  // Call checkObservables
1189  RooArgSet allDeps(*hist->get()) ;
1190  if (checkObservables(&allDeps)) {
1191  coutE(InputArguments) << "RooAbsReal::fillDataHist(" << GetName() << ") error in checkObservables, abort" << endl ;
1192  return hist ;
1193  }
1194 
1195  // Make deep clone of self and attach to dataset observables
1196  //RooArgSet* origObs = getObservables(hist) ;
1197  RooArgSet* cloneSet = (RooArgSet*) RooArgSet(*this).snapshot(kTRUE) ;
1198  RooAbsReal* theClone = (RooAbsReal*) cloneSet->find(GetName()) ;
1199  theClone->recursiveRedirectServers(*hist->get()) ;
1200  //const_cast<RooAbsReal*>(this)->recursiveRedirectServers(*hist->get()) ;
1201 
1202  // Iterator over all bins of RooDataHist and fill weights
1203  Int_t onePct = hist->numEntries()/100 ;
1204  if (onePct==0) {
1205  onePct++ ;
1206  }
1207  for (Int_t i=0 ; i<hist->numEntries() ; i++) {
1208  if (showProgress && (i%onePct==0)) {
1209  ccoutP(Eval) << "." << flush ;
1210  }
1211  const RooArgSet* obs = hist->get(i) ;
1212  Double_t binVal = theClone->getVal(normSet?normSet:obs)*scaleFactor ;
1213  if (correctForBinSize) {
1214  binVal*= hist->binVolume() ;
1215  }
1216  hist->set(binVal) ;
1217  }
1218 
1219  delete cloneSet ;
1220  //const_cast<RooAbsReal*>(this)->recursiveRedirectServers(*origObs) ;
1221  //delete origObs ;
1222 
1223  return hist;
1224 }
1225 
1226 
1227 
1228 
1229 ////////////////////////////////////////////////////////////////////////////////
1230 /// Create and fill a ROOT histogram TH1,TH2 or TH3 with the values of this function for the variables with given names
1231 /// The number of bins can be controlled using the [xyz]bins parameters. For a greater degree of control
1232 /// use the createHistogram() method below with named arguments
1233 ///
1234 /// The caller takes ownership of the returned histogram
1235 
1236 TH1* RooAbsReal::createHistogram(const char* varNameList, Int_t xbins, Int_t ybins, Int_t zbins) const
1237 {
1238  // Parse list of variable names
1239  char buf[1024] ;
1240  strlcpy(buf,varNameList,1024) ;
1241  char* varName = strtok(buf,",:") ;
1242 
1243  RooArgSet* vars = getVariables() ;
1244 
1245  RooRealVar* xvar = (RooRealVar*) vars->find(varName) ;
1246  varName = strtok(0,",") ;
1247  RooRealVar* yvar = varName ? (RooRealVar*) vars->find(varName) : 0 ;
1248  varName = strtok(0,",") ;
1249  RooRealVar* zvar = varName ? (RooRealVar*) vars->find(varName) : 0 ;
1250 
1251  delete vars ;
1252 
1253  // Construct list of named arguments to pass to the implementation version of createHistogram()
1254 
1255  RooLinkedList argList ;
1256  if (xbins>0) {
1257  argList.Add(RooFit::Binning(xbins).Clone()) ;
1258  }
1259 
1260  if (yvar) {
1261  if (ybins>0) {
1262  argList.Add(RooFit::YVar(*yvar,RooFit::Binning(ybins)).Clone()) ;
1263  } else {
1264  argList.Add(RooFit::YVar(*yvar).Clone()) ;
1265  }
1266  }
1267 
1268 
1269  if (zvar) {
1270  if (zbins>0) {
1271  argList.Add(RooFit::ZVar(*zvar,RooFit::Binning(zbins)).Clone()) ;
1272  } else {
1273  argList.Add(RooFit::ZVar(*zvar).Clone()) ;
1274  }
1275  }
1276 
1277 
1278  // Call implementation function
1279  TH1* result = createHistogram(GetName(),*xvar,argList) ;
1280 
1281  // Delete temporary list of RooCmdArgs
1282  argList.Delete() ;
1283 
1284  return result ;
1285 }
1286 
1287 
1288 
1289 ////////////////////////////////////////////////////////////////////////////////
1290 /// Create and fill a ROOT histogram TH1,TH2 or TH3 with the values of this function.
1291 ///
1292 /// This function accepts the following arguments
1293 ///
1294 /// name -- Name of the ROOT histogram
1295 /// xvar -- Observable to be mapped on x axis of ROOT histogram
1296 ///
1297 /// IntrinsicBinning() -- Apply binning defined by function or pdf (as advertised via binBoundaries() method)
1298 /// Binning(const char* name) -- Apply binning with given name to x axis of histogram
1299 /// Binning(RooAbsBinning& binning) -- Apply specified binning to x axis of histogram
1300 /// Binning(int nbins, [double lo, double hi]) -- Apply specified binning to x axis of histogram
1301 /// ConditionalObservables(const RooArgSet& set) -- Do not normalized PDF over following observables when projecting PDF into histogram
1302 /// Scaling(Bool_t) -- Apply density-correction scaling (multiply by bin volume), default is kTRUE
1303 /// Extended(Bool_t) -- Plot event yield instead of probability density (for extended pdfs only)
1304 ///
1305 /// YVar(const RooAbsRealLValue& var,...) -- Observable to be mapped on y axis of ROOT histogram
1306 /// ZVar(const RooAbsRealLValue& var,...) -- Observable to be mapped on z axis of ROOT histogram
1307 ///
1308 /// The YVar() and ZVar() arguments can be supplied with optional Binning() arguments to control the binning of the Y and Z axes, e.g.
1309 /// createHistogram("histo",x,Binning(-1,1,20), YVar(y,Binning(-1,1,30)), ZVar(z,Binning("zbinning")))
1310 ///
1311 /// The caller takes ownership of the returned histogram
1312 
1314  const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1315  const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8) const
1316 {
1317 
1318  RooLinkedList l ;
1319  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
1320  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
1321  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
1322  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
1323 
1324  return createHistogram(name,xvar,l) ;
1325 }
1326 
1327 
1328 ////////////////////////////////////////////////////////////////////////////////
1329 /// Internal method implementing createHistogram
1330 
1331 TH1* RooAbsReal::createHistogram(const char *name, const RooAbsRealLValue& xvar, RooLinkedList& argList) const
1332 {
1333 
1334  // Define configuration for this method
1335  RooCmdConfig pc(Form("RooAbsReal::createHistogram(%s)",GetName())) ;
1336  pc.defineInt("scaling","Scaling",0,1) ;
1337  pc.defineInt("intBinning","IntrinsicBinning",0,2) ;
1338  pc.defineInt("extended","Extended",0,2) ;
1339 
1340  pc.defineObject("compSet","SelectCompSet",0) ;
1341  pc.defineString("compSpec","SelectCompSpec",0) ;
1342  pc.defineSet("projObs","ProjectedObservables",0,0) ;
1343  pc.defineObject("yvar","YVar",0,0) ;
1344  pc.defineObject("zvar","ZVar",0,0) ;
1345  pc.defineMutex("SelectCompSet","SelectCompSpec") ;
1346  pc.defineMutex("IntrinsicBinning","Binning") ;
1347  pc.defineMutex("IntrinsicBinning","BinningName") ;
1348  pc.defineMutex("IntrinsicBinning","BinningSpec") ;
1349  pc.allowUndefined() ;
1350 
1351  // Process & check varargs
1352  pc.process(argList) ;
1353  if (!pc.ok(kTRUE)) {
1354  return 0 ;
1355  }
1356 
1357  RooArgList vars(xvar) ;
1358  RooAbsArg* yvar = static_cast<RooAbsArg*>(pc.getObject("yvar")) ;
1359  if (yvar) {
1360  vars.add(*yvar) ;
1361  }
1362  RooAbsArg* zvar = static_cast<RooAbsArg*>(pc.getObject("zvar")) ;
1363  if (zvar) {
1364  vars.add(*zvar) ;
1365  }
1366 
1367  RooArgSet* projObs = pc.getSet("projObs") ;
1368  RooArgSet* intObs = 0 ;
1369 
1370  Bool_t doScaling = pc.getInt("scaling") ;
1371  Int_t doIntBinning = pc.getInt("intBinning") ;
1372  Int_t doExtended = pc.getInt("extended") ;
1373 
1374  // If doExtended is two, selection is automatic, set to 1 of pdf is extended, to zero otherwise
1375  const RooAbsPdf* pdfSelf = dynamic_cast<const RooAbsPdf*>(this) ;
1376  if (!pdfSelf && doExtended>0) {
1377  coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName() << ") WARNING extended mode requested for a non-pdf object, ignored" << endl ;
1378  doExtended=0 ;
1379  }
1380  if (pdfSelf && doExtended==1 && pdfSelf->extendMode()==RooAbsPdf::CanNotBeExtended) {
1381  coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName() << ") WARNING extended mode requested for a non-extendable pdf, ignored" << endl ;
1382  doExtended=0 ;
1383  }
1384  if (pdfSelf && doExtended==2) {
1385  doExtended = pdfSelf->extendMode()==RooAbsPdf::CanNotBeExtended ? 0 : 1 ;
1386  }
1387 
1388  const char* compSpec = pc.getString("compSpec") ;
1389  const RooArgSet* compSet = (const RooArgSet*) pc.getObject("compSet") ;
1390  Bool_t haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1391 
1392  RooBinning* intBinning(0) ;
1393  if (doIntBinning>0) {
1394  // Given RooAbsPdf* pdf and RooRealVar* obs
1395  list<Double_t>* bl = binBoundaries((RooRealVar&)xvar,xvar.getMin(),xvar.getMax()) ;
1396  if (!bl) {
1397  // Only emit warning when intrinsic binning is explicitly requested
1398  if (doIntBinning==1) {
1399  coutW(InputArguments) << "RooAbsReal::createHistogram(" << GetName()
1400  << ") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< endl ;
1401  }
1402  } else {
1403  if (doIntBinning==2) {
1404  coutI(InputArguments) << "RooAbsReal::createHistogram(" << GetName()
1405  << ") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< endl ;
1406  }
1407  Double_t* ba = new Double_t[bl->size()] ; int i=0 ;
1408  for (list<double>::iterator it=bl->begin() ; it!=bl->end() ; ++it) { ba[i++] = *it ; }
1409  intBinning = new RooBinning(bl->size()-1,ba) ;
1410  delete[] ba ;
1411  }
1412  }
1413 
1414  RooLinkedList argListCreate(argList) ;
1415  pc.stripCmdList(argListCreate,"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1416 
1417  TH1* histo(0) ;
1418  if (intBinning) {
1419  RooCmdArg tmp = RooFit::Binning(*intBinning) ;
1420  argListCreate.Add(&tmp) ;
1421  histo = xvar.createHistogram(name,argListCreate) ;
1422  delete intBinning ;
1423  } else {
1424  histo = xvar.createHistogram(name,argListCreate) ;
1425  }
1426 
1427  // Do component selection here
1428  if (haveCompSel) {
1429 
1430  // Get complete set of tree branch nodes
1431  RooArgSet branchNodeSet ;
1432  branchNodeServerList(&branchNodeSet) ;
1433 
1434  // Discard any non-RooAbsReal nodes
1435  TIterator* iter = branchNodeSet.createIterator() ;
1436  RooAbsArg* arg ;
1437  while((arg=(RooAbsArg*)iter->Next())) {
1438  if (!dynamic_cast<RooAbsReal*>(arg)) {
1439  branchNodeSet.remove(*arg) ;
1440  }
1441  }
1442  delete iter ;
1443 
1444  RooArgSet* dirSelNodes ;
1445  if (compSet) {
1446  dirSelNodes = (RooArgSet*) branchNodeSet.selectCommon(*compSet) ;
1447  } else {
1448  dirSelNodes = (RooArgSet*) branchNodeSet.selectByName(compSpec) ;
1449  }
1450  if (dirSelNodes->getSize()>0) {
1451  coutI(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") directly selected PDF components: " << *dirSelNodes << endl ;
1452 
1453  // Do indirect selection and activate both
1454  plotOnCompSelect(dirSelNodes) ;
1455  } else {
1456  if (compSet) {
1457  coutE(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") ERROR: component selection set " << *compSet << " does not match any components of p.d.f." << endl ;
1458  } else {
1459  coutE(Plotting) << "RooAbsPdf::createHistogram(" << GetName() << ") ERROR: component selection expression '" << compSpec << "' does not select any components of p.d.f." << endl ;
1460  }
1461  return 0 ;
1462  }
1463  delete dirSelNodes ;
1464  }
1465 
1466  Double_t scaleFactor(1.0) ;
1467  if (doExtended) {
1468  scaleFactor = pdfSelf->expectedEvents(vars) ;
1469  doScaling=kFALSE ;
1470  }
1471 
1472  fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,kFALSE) ;
1473 
1474  // Deactivate component selection
1475  if (haveCompSel) {
1476  plotOnCompSelect(0) ;
1477  }
1478 
1479 
1480  return histo ;
1481 }
1482 
1483 
1484 ////////////////////////////////////////////////////////////////////////////////
1485 /// Helper function for plotting of composite p.d.fs. Given
1486 /// a set of selected components that should be plotted,
1487 /// find all nodes that (in)directly depend on these selected
1488 /// nodes. Mark all directly and indirecty selected nodes
1489 /// as 'selected' using the selectComp() method
1490 
1492 {
1493  // Get complete set of tree branch nodes
1494  RooArgSet branchNodeSet ;
1495  branchNodeServerList(&branchNodeSet) ;
1496 
1497  // Discard any non-PDF nodes
1498  TIterator* iter = branchNodeSet.createIterator() ;
1499  RooAbsArg* arg ;
1500  while((arg=(RooAbsArg*)iter->Next())) {
1501  if (!dynamic_cast<RooAbsReal*>(arg)) {
1502  branchNodeSet.remove(*arg) ;
1503  }
1504  }
1505 
1506  // If no set is specified, restored all selection bits to kTRUE
1507  if (!selNodes) {
1508  // Reset PDF selection bits to kTRUE
1509  iter->Reset() ;
1510  while((arg=(RooAbsArg*)iter->Next())) {
1511  ((RooAbsReal*)arg)->selectComp(kTRUE) ;
1512  }
1513  delete iter ;
1514  return ;
1515  }
1516 
1517 
1518  // Add all nodes below selected nodes
1519  iter->Reset() ;
1520  TIterator* sIter = selNodes->createIterator() ;
1521  RooArgSet tmp ;
1522  while((arg=(RooAbsArg*)iter->Next())) {
1523  sIter->Reset() ;
1524  RooAbsArg* selNode ;
1525  while((selNode=(RooAbsArg*)sIter->Next())) {
1526  if (selNode->dependsOn(*arg)) {
1527  tmp.add(*arg,kTRUE) ;
1528  }
1529  }
1530  }
1531  delete sIter ;
1532 
1533  // Add all nodes that depend on selected nodes
1534  iter->Reset() ;
1535  while((arg=(RooAbsArg*)iter->Next())) {
1536  if (arg->dependsOn(*selNodes)) {
1537  tmp.add(*arg,kTRUE) ;
1538  }
1539  }
1540 
1541  tmp.remove(*selNodes,kTRUE) ;
1542  tmp.remove(*this) ;
1543  selNodes->add(tmp) ;
1544  coutI(Plotting) << "RooAbsPdf::plotOn(" << GetName() << ") indirectly selected PDF components: " << tmp << endl ;
1545 
1546  // Set PDF selection bits according to selNodes
1547  iter->Reset() ;
1548  while((arg=(RooAbsArg*)iter->Next())) {
1549  Bool_t select = selNodes->find(arg->GetName()) ? kTRUE : kFALSE ;
1550  ((RooAbsReal*)arg)->selectComp(select) ;
1551  }
1552 
1553  delete iter ;
1554 }
1555 
1556 
1557 
1558 ////////////////////////////////////////////////////////////////////////////////
1559 /// Plot (project) PDF on specified frame. If a PDF is plotted in an empty frame, it
1560 /// will show a unit normalized curve in the frame variable, taken at the present value
1561 /// of other observables defined for this PDF
1562 ///
1563 /// If a PDF is plotted in a frame in which a dataset has already been plotted, it will
1564 /// show a projected curve integrated over all variables that were present in the shown
1565 /// dataset except for the one on the x-axis. The normalization of the curve will also
1566 /// be adjusted to the event count of the plotted dataset. An informational message
1567 /// will be printed for each projection step that is performed
1568 ///
1569 /// This function takes the following named arguments
1570 ///
1571 /// Projection control
1572 /// ------------------
1573 /// Slice(const RooArgSet& set) -- Override default projection behaviour by omittting observables listed
1574 /// in set from the projection, resulting a 'slice' plot. Slicing is usually
1575 /// only sensible in discrete observables. The slice is position at the 'current'
1576 /// value of the observable objects
1577 ///
1578 /// Slice(RooCategory& cat, -- Override default projection behaviour by omittting specified category
1579 /// const char* label) observable from the projection, resulting in a 'slice' plot. The slice is positioned
1580 /// at the given label value. Multiple Slice() commands can be given to specify slices
1581 /// in multiple observables
1582 ///
1583 /// Project(const RooArgSet& set) -- Override default projection behaviour by projecting over observables
1584 /// given in set and complete ignoring the default projection behavior. Advanced use only.
1585 ///
1586 /// ProjWData(const RooAbsData& d) -- Override default projection _technique_ (integration). For observables present in given dataset
1587 /// projection of PDF is achieved by constructing an average over all observable values in given set.
1588 /// Consult RooFit plotting tutorial for further explanation of meaning & use of this technique
1589 ///
1590 /// ProjWData(const RooArgSet& s, -- As above but only consider subset 's' of observables in dataset 'd' for projection through data averaging
1591 /// const RooAbsData& d)
1592 ///
1593 /// ProjectionRange(const char* rn) -- Override default range of projection integrals to a different range speficied by given range name.
1594 /// This technique allows you to project a finite width slice in a real-valued observable
1595 ///
1596 /// NumCPU(Int_t ncpu) -- Number of CPUs to use simultaneously to calculate data-weighted projections (only in combination with ProjWData)
1597 ///
1598 ///
1599 /// Misc content control
1600 /// --------------------
1601 /// PrintEvalErrors(Int_t numErr) -- Control number of p.d.f evaluation errors printed per curve. A negative
1602 /// value suppress output completely, a zero value will only print the error count per p.d.f component,
1603 /// a positive value is will print details of each error up to numErr messages per p.d.f component.
1604 ///
1605 /// EvalErrorValue(Double_t value) -- Set curve points at which (pdf) evaluation error occur to specified value. By default the
1606 /// function value is plotted.
1607 ///
1608 /// Normalization(Double_t scale, -- Adjust normalization by given scale factor. Interpretation of number depends on code: Relative:
1609 /// ScaleType code) relative adjustment factor, NumEvent: scale to match given number of events.
1610 ///
1611 /// Name(const chat* name) -- Give curve specified name in frame. Useful if curve is to be referenced later
1612 ///
1613 /// Asymmetry(const RooCategory& c) -- Show the asymmetry of the PDF in given two-state category [F(+)-F(-)] / [F(+)+F(-)] rather than
1614 /// the PDF projection. Category must have two states with indices -1 and +1 or three states with
1615 /// indeces -1,0 and +1.
1616 ///
1617 /// ShiftToZero(Bool_t flag) -- Shift entire curve such that lowest visible point is at exactly zero. Mostly useful when
1618 /// plotting -log(L) or chi^2 distributions
1619 ///
1620 /// AddTo(const char* name, -- Add constructed projection to already existing curve with given name and relative weight factors
1621 /// double_t wgtSelf, double_t wgtOther)
1622 ///
1623 /// Plotting control
1624 /// ----------------
1625 /// DrawOption(const char* opt) -- Select ROOT draw option for resulting TGraph object
1626 ///
1627 /// LineStyle(Int_t style) -- Select line style by ROOT line style code, default is solid
1628 ///
1629 /// LineColor(Int_t color) -- Select line color by ROOT color code, default is blue
1630 ///
1631 /// LineWidth(Int_t width) -- Select line with in pixels, default is 3
1632 ///
1633 /// FillStyle(Int_t style) -- Select fill style, default is not filled. If a filled style is selected, also use VLines()
1634 /// to add vertical downward lines at end of curve to ensure proper closure
1635 /// FillColor(Int_t color) -- Select fill color by ROOT color code
1636 ///
1637 /// Range(const char* name) -- Only draw curve in range defined by given name
1638 ///
1639 /// Range(double lo, double hi) -- Only draw curve in specified range
1640 ///
1641 /// VLines() -- Add vertical lines to y=0 at end points of curve
1642 ///
1643 /// Precision(Double_t eps) -- Control precision of drawn curve w.r.t to scale of plot, default is 1e-3. Higher precision
1644 /// will result in more and more densely spaced curve points
1645 ///
1646 /// Invisible(Bool_t flag) -- Add curve to frame, but do not display. Useful in combination AddTo()
1647 ///
1648 /// VisualizeError(const RooFitResult& fitres, Double_t Z=1, Bool_t linearMethod=kTRUE)
1649 /// -- Visualize the uncertainty on the parameters, as given in fitres, at 'Z' sigma'
1650 ///
1651 /// VisualizeError(const RooFitResult& fitres, const RooArgSet& param, Double_t Z=1, Bool_t linearMethod=kTRUE) ;
1652 /// -- Visualize the uncertainty on the subset of parameters 'param', as given in fitres, at 'Z' sigma'
1653 ///
1654 ///
1655 /// Details on error band visualization
1656 /// -----------------------------------
1657 ///
1658 /// By default (linMethod=kTRUE) a linearized error is shown which is calculated as follows
1659 /// T
1660 /// error(x) = Z* F_a(x) * Corr(a,a') F_a'(x)
1661 ///
1662 /// 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
1663 /// Corr(a,a') = the correlation matrix from the fit result
1664 /// Z = requested significance 'Z sigma band'
1665 ///
1666 /// The linear method is fast (required 2*N evaluations of the curve, where N is the number of parameters), but may
1667 /// not be accurate in the presence of strong correlations (~>0.9) and at Z>2 due to linear and Gaussian approximations made
1668 ///
1669 /// Alternatively (linMethod=kFALSE), a more robust error is calculated using a sampling method. In this method a number of curves
1670 /// is calculated with variations of the parameter values, as drawn from a multi-variate Gaussian p.d.f. that is constructed
1671 /// from the fit results covariance matrix. The error(x) is determined by calculating a central interval that capture N% of the variations
1672 /// 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
1673 /// 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)
1674 /// Intervals from the sampling method can be asymmetric, and may perform better in the presence of strong correlations, but may take (much)
1675 /// longer to calculate
1676 
1677 RooPlot* RooAbsReal::plotOn(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2,
1678  const RooCmdArg& arg3, const RooCmdArg& arg4,
1679  const RooCmdArg& arg5, const RooCmdArg& arg6,
1680  const RooCmdArg& arg7, const RooCmdArg& arg8,
1681  const RooCmdArg& arg9, const RooCmdArg& arg10) const
1682 {
1683  RooLinkedList l ;
1684  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
1685  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
1686  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
1687  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
1688  l.Add((TObject*)&arg9) ; l.Add((TObject*)&arg10) ;
1689  return plotOn(frame,l) ;
1690 }
1691 
1692 
1693 
1694 ////////////////////////////////////////////////////////////////////////////////
1695 /// Internal back-end function of plotOn() with named arguments
1696 
1698 {
1699  // Special handling here if argList contains RangeWithName argument with multiple
1700  // range names -- Need to translate this call into multiple calls
1701 
1702  RooCmdArg* rcmd = (RooCmdArg*) argList.FindObject("RangeWithName") ;
1703  if (rcmd && TString(rcmd->getString(0)).Contains(",")) {
1704 
1705  // List joint ranges as choice of normalization for all later processing
1706  RooCmdArg rnorm = RooFit::NormRange(rcmd->getString(0)) ;
1707  argList.Add(&rnorm) ;
1708 
1709  list<string> rlist ;
1710 
1711  // Separate named ranges using strtok
1712  char buf[1024] ;
1713  strlcpy(buf,rcmd->getString(0),1024) ;
1714  char* oneRange = strtok(buf,",") ;
1715  while(oneRange) {
1716  rlist.push_back(oneRange) ;
1717  oneRange = strtok(0,",") ;
1718  }
1719 
1720  for (list<string>::iterator riter=rlist.begin() ; riter!=rlist.end() ; ++riter) {
1721  // Process each range with a separate command with a single range to be plotted
1722  rcmd->setString(0,riter->c_str()) ;
1723  RooAbsReal::plotOn(frame,argList) ;
1724  }
1725  return frame ;
1726 
1727  }
1728 
1729  // Define configuration for this method
1730  RooCmdConfig pc(Form("RooAbsReal::plotOn(%s)",GetName())) ;
1731  pc.defineString("drawOption","DrawOption",0,"L") ;
1732  pc.defineString("projectionRangeName","ProjectionRange",0,"",kTRUE) ;
1733  pc.defineString("curveNameSuffix","CurveNameSuffix",0,"") ;
1734  pc.defineString("sliceCatState","SliceCat",0,"",kTRUE) ;
1735  pc.defineDouble("scaleFactor","Normalization",0,1.0) ;
1736  pc.defineObject("sliceSet","SliceVars",0) ;
1737  pc.defineObject("sliceCatList","SliceCat",0,0,kTRUE) ;
1738  pc.defineObject("projSet","Project",0) ;
1739  pc.defineObject("asymCat","Asymmetry",0) ;
1740  pc.defineDouble("precision","Precision",0,1e-3) ;
1741  pc.defineDouble("evalErrorVal","EvalErrorValue",0,0) ;
1742  pc.defineInt("doEvalError","EvalErrorValue",0,0) ;
1743  pc.defineInt("shiftToZero","ShiftToZero",0,0) ;
1744  pc.defineObject("projDataSet","ProjData",0) ;
1745  pc.defineObject("projData","ProjData",1) ;
1746  pc.defineObject("errorFR","VisualizeError",0) ;
1747  pc.defineDouble("errorZ","VisualizeError",0,1.) ;
1748  pc.defineSet("errorPars","VisualizeError",0) ;
1749  pc.defineInt("linearMethod","VisualizeError",0,0) ;
1750  pc.defineInt("binProjData","ProjData",0,0) ;
1751  pc.defineDouble("rangeLo","Range",0,-999.) ;
1752  pc.defineDouble("rangeHi","Range",1,-999.) ;
1753  pc.defineInt("numee","PrintEvalErrors",0,10) ;
1754  pc.defineInt("rangeAdjustNorm","Range",0,0) ;
1755  pc.defineInt("rangeWNAdjustNorm","RangeWithName",0,0) ;
1756  pc.defineInt("VLines","VLines",0,2) ; // 2==ExtendedWings
1757  pc.defineString("rangeName","RangeWithName",0,"") ;
1758  pc.defineString("normRangeName","NormRange",0,"") ;
1759  pc.defineInt("lineColor","LineColor",0,-999) ;
1760  pc.defineInt("lineStyle","LineStyle",0,-999) ;
1761  pc.defineInt("lineWidth","LineWidth",0,-999) ;
1762  pc.defineInt("fillColor","FillColor",0,-999) ;
1763  pc.defineInt("fillStyle","FillStyle",0,-999) ;
1764  pc.defineString("curveName","Name",0,"") ;
1765  pc.defineInt("curveInvisible","Invisible",0,0) ;
1766  pc.defineInt("showProg","ShowProgress",0,0) ;
1767  pc.defineInt("numCPU","NumCPU",0,1) ;
1768  pc.defineInt("interleave","NumCPU",1,0) ;
1769  pc.defineString("addToCurveName","AddTo",0,"") ;
1770  pc.defineDouble("addToWgtSelf","AddTo",0,1.) ;
1771  pc.defineDouble("addToWgtOther","AddTo",1,1.) ;
1772  pc.defineInt("moveToBack","MoveToBack",0,0) ;
1773  pc.defineMutex("SliceVars","Project") ;
1774  pc.defineMutex("AddTo","Asymmetry") ;
1775  pc.defineMutex("Range","RangeWithName") ;
1776  pc.defineMutex("VisualizeError","VisualizeErrorData") ;
1777 
1778  // Process & check varargs
1779  pc.process(argList) ;
1780  if (!pc.ok(kTRUE)) {
1781  return frame ;
1782  }
1783 
1784  PlotOpt o ;
1785 
1786  RooFitResult* errFR = (RooFitResult*) pc.getObject("errorFR") ;
1787  Double_t errZ = pc.getDouble("errorZ") ;
1788  RooArgSet* errPars = pc.getSet("errorPars") ;
1789  Bool_t linMethod = pc.getInt("linearMethod") ;
1790  if (errFR) {
1791  return plotOnWithErrorBand(frame,*errFR,errZ,errPars,argList,linMethod) ;
1792  }
1793 
1794  // Extract values from named arguments
1795  o.numee = pc.getInt("numee") ;
1796  o.drawOptions = pc.getString("drawOption") ;
1797  o.curveNameSuffix = pc.getString("curveNameSuffix") ;
1798  o.scaleFactor = pc.getDouble("scaleFactor") ;
1799  o.projData = (const RooAbsData*) pc.getObject("projData") ;
1800  o.binProjData = pc.getInt("binProjData") ;
1801  o.projDataSet = (const RooArgSet*) pc.getObject("projDataSet") ;
1802  o.numCPU = pc.getInt("numCPU") ;
1803  o.interleave = (RooFit::MPSplit) pc.getInt("interleave") ;
1804  o.eeval = pc.getDouble("evalErrorVal") ;
1805  o.doeeval = pc.getInt("doEvalError") ;
1806 
1807  const RooArgSet* sliceSetTmp = (const RooArgSet*) pc.getObject("sliceSet") ;
1808  RooArgSet* sliceSet = sliceSetTmp ? ((RooArgSet*) sliceSetTmp->Clone()) : 0 ;
1809  const RooArgSet* projSet = (const RooArgSet*) pc.getObject("projSet") ;
1810  const RooAbsCategoryLValue* asymCat = (const RooAbsCategoryLValue*) pc.getObject("asymCat") ;
1811 
1812 
1813  // Look for category slice arguments and add them to the master slice list if found
1814  const char* sliceCatState = pc.getString("sliceCatState",0,kTRUE) ;
1815  const RooLinkedList& sliceCatList = pc.getObjectList("sliceCatList") ;
1816  if (sliceCatState) {
1817 
1818  // Make the master slice set if it doesnt exist
1819  if (!sliceSet) {
1820  sliceSet = new RooArgSet ;
1821  }
1822 
1823  // Prepare comma separated label list for parsing
1824  char buf[1024] ;
1825  strlcpy(buf,sliceCatState,1024) ;
1826  const char* slabel = strtok(buf,",") ;
1827 
1828  // Loop over all categories provided by (multiple) Slice() arguments
1829  TIterator* iter = sliceCatList.MakeIterator() ;
1830  RooCategory* scat ;
1831  while((scat=(RooCategory*)iter->Next())) {
1832  if (slabel) {
1833  // Set the slice position to the value indicate by slabel
1834  scat->setLabel(slabel) ;
1835  // Add the slice category to the master slice set
1836  sliceSet->add(*scat,kFALSE) ;
1837  }
1838  slabel = strtok(0,",") ;
1839  }
1840  delete iter ;
1841  }
1842 
1843  o.precision = pc.getDouble("precision") ;
1844  o.shiftToZero = (pc.getInt("shiftToZero")!=0) ;
1845  Int_t vlines = pc.getInt("VLines");
1846  if (pc.hasProcessed("Range")) {
1847  o.rangeLo = pc.getDouble("rangeLo") ;
1848  o.rangeHi = pc.getDouble("rangeHi") ;
1849  o.postRangeFracScale = pc.getInt("rangeAdjustNorm") ;
1850  if (vlines==2) vlines=0 ; // Default is NoWings if range was specified
1851  } else if (pc.hasProcessed("RangeWithName")) {
1852  o.normRangeName = pc.getString("rangeName",0,kTRUE) ;
1853  o.rangeLo = frame->getPlotVar()->getMin(pc.getString("rangeName",0,kTRUE)) ;
1854  o.rangeHi = frame->getPlotVar()->getMax(pc.getString("rangeName",0,kTRUE)) ;
1855  o.postRangeFracScale = pc.getInt("rangeWNAdjustNorm") ;
1856  if (vlines==2) vlines=0 ; // Default is NoWings if range was specified
1857  }
1858 
1859 
1860  // If separate normalization range was specified this overrides previous settings
1861  if (pc.hasProcessed("NormRange")) {
1862  o.normRangeName = pc.getString("normRangeName") ;
1864  }
1865 
1866  o.wmode = (vlines==2)?RooCurve::Extended:(vlines==1?RooCurve::Straight:RooCurve::NoWings) ;
1867  o.projectionRangeName = pc.getString("projectionRangeName",0,kTRUE) ;
1868  o.curveName = pc.getString("curveName",0,kTRUE) ;
1869  o.curveInvisible = pc.getInt("curveInvisible") ;
1870  o.progress = pc.getInt("showProg") ;
1871  o.addToCurveName = pc.getString("addToCurveName",0,kTRUE) ;
1872  o.addToWgtSelf = pc.getDouble("addToWgtSelf") ;
1873  o.addToWgtOther = pc.getDouble("addToWgtOther") ;
1874 
1875  if (o.addToCurveName && !frame->findObject(o.addToCurveName,RooCurve::Class())) {
1876  coutE(InputArguments) << "RooAbsReal::plotOn(" << GetName() << ") cannot find existing curve " << o.addToCurveName << " to add to in RooPlot" << endl ;
1877  return frame ;
1878  }
1879 
1880  RooArgSet projectedVars ;
1881  if (sliceSet) {
1882  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have slice " << *sliceSet << endl ;
1883 
1884  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
1885 
1886  // Take out the sliced variables
1887  TIterator* iter = sliceSet->createIterator() ;
1888  RooAbsArg* sliceArg ;
1889  while((sliceArg=(RooAbsArg*)iter->Next())) {
1890  RooAbsArg* arg = projectedVars.find(sliceArg->GetName()) ;
1891  if (arg) {
1892  projectedVars.remove(*arg) ;
1893  } else {
1894  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") slice variable "
1895  << sliceArg->GetName() << " was not projected anyway" << endl ;
1896  }
1897  }
1898  delete iter ;
1899  } else if (projSet) {
1900  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have projSet " << *projSet << endl ;
1901  makeProjectionSet(frame->getPlotVar(),projSet,projectedVars,kFALSE) ;
1902  } else {
1903  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: have neither sliceSet nor projSet " << endl ;
1904  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
1905  }
1906  o.projSet = &projectedVars ;
1907 
1908  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Preprocessing: projectedVars = " << projectedVars << endl ;
1909 
1910 
1911  RooPlot* ret ;
1912  if (!asymCat) {
1913  // Forward to actual calculation
1914  ret = RooAbsReal::plotOn(frame,o) ;
1915  } else {
1916  // Forward to actual calculation
1917  ret = RooAbsReal::plotAsymOn(frame,*asymCat,o) ;
1918  }
1919 
1920  delete sliceSet ;
1921 
1922  // Optionally adjust line/fill attributes
1923  Int_t lineColor = pc.getInt("lineColor") ;
1924  Int_t lineStyle = pc.getInt("lineStyle") ;
1925  Int_t lineWidth = pc.getInt("lineWidth") ;
1926  Int_t fillColor = pc.getInt("fillColor") ;
1927  Int_t fillStyle = pc.getInt("fillStyle") ;
1928  if (lineColor!=-999) ret->getAttLine()->SetLineColor(lineColor) ;
1929  if (lineStyle!=-999) ret->getAttLine()->SetLineStyle(lineStyle) ;
1930  if (lineWidth!=-999) ret->getAttLine()->SetLineWidth(lineWidth) ;
1931  if (fillColor!=-999) ret->getAttFill()->SetFillColor(fillColor) ;
1932  if (fillStyle!=-999) ret->getAttFill()->SetFillStyle(fillStyle) ;
1933 
1934  // Move last inserted object to back to drawing stack if requested
1935  if (pc.getInt("moveToBack") && frame->numItems()>1) {
1936  frame->drawBefore(frame->getObject(0)->GetName(), frame->getCurve()->GetName());
1937  }
1938 
1939  return ret ;
1940 }
1941 
1942 
1943 
1944 
1945 //_____________________________________________________________________________
1946 // coverity[PASS_BY_VALUE]
1948 {
1949  // Plotting engine function for internal use
1950  //
1951  // Plot ourselves on given frame. If frame contains a histogram, all dimensions of the plotted
1952  // function that occur in the previously plotted dataset are projected via partial integration,
1953  // otherwise no projections are performed. Optionally, certain projections can be performed
1954  // by summing over the values present in a provided dataset ('projData'), to correctly
1955  // project out data dependents that are not properly described by the PDF (e.g. per-event errors).
1956  //
1957  // The functions value can be multiplied with an optional scale factor. The interpretation
1958  // of the scale factor is unique for generic real functions, for PDFs there are various interpretations
1959  // possible, which can be selection with 'stype' (see RooAbsPdf::plotOn() for details).
1960  //
1961  // The default projection behaviour can be overriden by supplying an optional set of dependents
1962  // to project. For most cases, plotSliceOn() and plotProjOn() provide a more intuitive interface
1963  // to modify the default projection behavour.
1964 
1965  // Sanity checks
1966  if (plotSanityChecks(frame)) return frame ;
1967 
1968  // ProjDataVars is either all projData observables, or the user indicated subset of it
1969  RooArgSet projDataVars ;
1970  if (o.projData) {
1971  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have ProjData with observables = " << *o.projData->get() << endl ;
1972  if (o.projDataSet) {
1973  RooArgSet* tmp = (RooArgSet*) o.projData->get()->selectCommon(*o.projDataSet) ;
1974  projDataVars.add(*tmp) ;
1975  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have ProjDataSet = " << *o.projDataSet << " will only use this subset of projData" << endl ;
1976  delete tmp ;
1977  } else {
1978  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") using full ProjData" << endl ;
1979  projDataVars.add(*o.projData->get()) ;
1980  }
1981  }
1982 
1983  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") ProjDataVars = " << projDataVars << endl ;
1984 
1985  // Make list of variables to be projected
1986  RooArgSet projectedVars ;
1987  RooArgSet sliceSet ;
1988  if (o.projSet) {
1989  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") have input projSet = " << *o.projSet << endl ;
1990  makeProjectionSet(frame->getPlotVar(),o.projSet,projectedVars,kFALSE) ;
1991  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") calculated projectedVars = " << *o.projSet << endl ;
1992 
1993  // Print list of non-projected variables
1994  if (frame->getNormVars()) {
1995  RooArgSet *sliceSetTmp = getObservables(*frame->getNormVars()) ;
1996 
1997  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") frame->getNormVars() that are also observables = " << *sliceSetTmp << endl ;
1998 
1999  sliceSetTmp->remove(projectedVars,kTRUE,kTRUE) ;
2000  sliceSetTmp->remove(*frame->getPlotVar(),kTRUE,kTRUE) ;
2001 
2002  if (o.projData) {
2003  RooArgSet* tmp = (RooArgSet*) projDataVars.selectCommon(*o.projSet) ;
2004  sliceSetTmp->remove(*tmp,kTRUE,kTRUE) ;
2005  delete tmp ;
2006  }
2007 
2008  if (sliceSetTmp->getSize()) {
2009  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on "
2010  << frame->getPlotVar()->GetName() << " represents a slice in " << *sliceSetTmp << endl ;
2011  }
2012  sliceSet.add(*sliceSetTmp) ;
2013  delete sliceSetTmp ;
2014  }
2015  } else {
2016  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2017  }
2018 
2019  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") projectedVars = " << projectedVars << " sliceSet = " << sliceSet << endl ;
2020 
2021 
2022  RooArgSet* projDataNeededVars = 0 ;
2023  // Take out data-projected dependents from projectedVars
2024  if (o.projData) {
2025  projDataNeededVars = (RooArgSet*) projectedVars.selectCommon(projDataVars) ;
2026  projectedVars.remove(projDataVars,kTRUE,kTRUE) ;
2027  }
2028 
2029  // Clone the plot variable
2030  RooAbsReal* realVar = (RooRealVar*) frame->getPlotVar() ;
2031  RooArgSet* plotCloneSet = (RooArgSet*) RooArgSet(*realVar).snapshot(kTRUE) ;
2032  if (!plotCloneSet) {
2033  coutE(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") Couldn't deep-clone self, abort," << endl ;
2034  return frame ;
2035  }
2036  RooRealVar* plotVar = (RooRealVar*) plotCloneSet->find(realVar->GetName());
2037 
2038  // Inform user about projections
2039  if (projectedVars.getSize()) {
2040  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2041  << " integrates over variables " << projectedVars
2042  << (o.projectionRangeName?Form(" in range %s",o.projectionRangeName):"") << endl;
2043  }
2044  if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2045  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2046  << " averages using data variables " << *projDataNeededVars << endl ;
2047  }
2048 
2049  // Create projection integral
2050  RooArgSet* projectionCompList = 0 ;
2051 
2052  RooArgSet* deps = getObservables(frame->getNormVars()) ;
2053  deps->remove(projectedVars,kTRUE,kTRUE) ;
2054  if (projDataNeededVars) {
2055  deps->remove(*projDataNeededVars,kTRUE,kTRUE) ;
2056  }
2057  deps->remove(*plotVar,kTRUE,kTRUE) ;
2058  deps->add(*plotVar) ;
2059 
2060  // Now that we have the final set of dependents, call checkObservables()
2061 
2062  // WVE take out conditional observables
2063  if (checkObservables(deps)) {
2064  coutE(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") error in checkObservables, abort" << endl ;
2065  delete deps ;
2066  delete plotCloneSet ;
2067  if (projDataNeededVars) delete projDataNeededVars ;
2068  return frame ;
2069  }
2070 
2071  RooArgSet normSet(*deps) ;
2072  //normSet.add(projDataVars) ;
2073 
2074  RooAbsReal *projection = (RooAbsReal*) createPlotProjection(normSet, &projectedVars, projectionCompList, o.projectionRangeName) ;
2075  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot projection object is " << projection->GetName() << endl ;
2076  if (dologD(Plotting)) {
2077  projection->printStream(ccoutD(Plotting),0,kVerbose) ;
2078  }
2079 
2080  // Always fix RooAddPdf normalizations
2081  RooArgSet fullNormSet(*deps) ;
2082  fullNormSet.add(projectedVars) ;
2083  if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2084  fullNormSet.add(*projDataNeededVars) ;
2085  }
2086  RooArgSet* compSet = projection->getComponents() ;
2087  TIterator* iter = compSet->createIterator() ;
2088  RooAbsArg* arg ;
2089  while((arg=(RooAbsArg*)iter->Next())) {
2090  RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
2091  if (pdf) {
2092  pdf->selectNormalization(&fullNormSet) ;
2093  }
2094  }
2095  delete iter ;
2096  delete compSet ;
2097 
2098 
2099  // Apply data projection, if requested
2100  if (o.projData && projDataNeededVars && projDataNeededVars->getSize()>0) {
2101 
2102  // If data set contains more rows than needed, make reduced copy first
2103  RooAbsData* projDataSel = (RooAbsData*)o.projData;
2104 
2105  if (projDataNeededVars->getSize()<o.projData->get()->getSize()) {
2106 
2107  // Determine if there are any slice variables in the projection set
2108  RooArgSet* sliceDataSet = (RooArgSet*) sliceSet.selectCommon(*o.projData->get()) ;
2109  TString cutString ;
2110  if (sliceDataSet->getSize()>0) {
2111  TIterator* iter2 = sliceDataSet->createIterator() ;
2112  RooAbsArg* sliceVar ;
2113  Bool_t first(kTRUE) ;
2114  while((sliceVar=(RooAbsArg*)iter2->Next())) {
2115  if (!first) {
2116  cutString.Append("&&") ;
2117  } else {
2118  first=kFALSE ;
2119  }
2120 
2121  RooAbsRealLValue* real ;
2122  RooAbsCategoryLValue* cat ;
2123  if ((real = dynamic_cast<RooAbsRealLValue*>(sliceVar))) {
2124  cutString.Append(Form("%s==%f",real->GetName(),real->getVal())) ;
2125  } else if ((cat = dynamic_cast<RooAbsCategoryLValue*>(sliceVar))) {
2126  cutString.Append(Form("%s==%d",cat->GetName(),cat->getIndex())) ;
2127  }
2128  }
2129  delete iter2 ;
2130  }
2131  delete sliceDataSet ;
2132 
2133  if (!cutString.IsNull()) {
2134  projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars,cutString) ;
2135  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") reducing given projection dataset to entries with " << cutString << endl ;
2136  } else {
2137  projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars) ;
2138  }
2139  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName()
2140  << ") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2141  }
2142 
2143  // Request binning of unbinned projection dataset that consists exclusively of category observables
2144  if (!o.binProjData && dynamic_cast<RooDataSet*>(projDataSel)!=0) {
2145 
2146  // Determine if dataset contains only categories
2147  TIterator* iter2 = projDataSel->get()->createIterator() ;
2148  Bool_t allCat(kTRUE) ;
2149  RooAbsArg* arg2 ;
2150  while((arg2=(RooAbsArg*)iter2->Next())) {
2151  if (!dynamic_cast<RooCategory*>(arg2)) allCat = kFALSE ;
2152  }
2153  delete iter2 ;
2154  if (allCat) {
2155  o.binProjData = kTRUE ;
2156  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") unbinned projection dataset consist only of discrete variables,"
2157  << " performing projection with binned copy for optimization." << endl ;
2158 
2159  }
2160  }
2161 
2162  // Bin projection dataset if requested
2163  if (o.binProjData) {
2164  RooAbsData* tmp = new RooDataHist(Form("%s_binned",projDataSel->GetName()),"Binned projection data",*projDataSel->get(),*projDataSel) ;
2165  if (projDataSel!=o.projData) delete projDataSel ;
2166  projDataSel = tmp ;
2167  }
2168 
2169 
2170 
2171  // Attach dataset
2172  projection->getVal(projDataSel->get()) ;
2173  projection->attachDataSet(*projDataSel) ;
2174 
2175  // Construct optimized data weighted average
2176  RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*projection,*projDataSel,RooArgSet()/**projDataSel->get()*/,o.numCPU,o.interleave,kTRUE) ;
2177  //RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*projection,*projDataSel,*projDataSel->get(),o.numCPU,o.interleave,kTRUE) ;
2178 
2179  // Do _not_ activate cache-and-track as necessary information to define normalization observables are not present in the underlying dataset
2181 
2182  RooRealBinding projBind(dwa,*plotVar) ;
2183  RooScaledFunc scaleBind(projBind,o.scaleFactor);
2184 
2185  // Set default range, if not specified
2186  if (o.rangeLo==0 && o.rangeHi==0) {
2187  o.rangeLo = frame->GetXaxis()->GetXmin() ;
2188  o.rangeHi = frame->GetXaxis()->GetXmax() ;
2189  }
2190 
2191  // Construct name of curve for data weighed average
2192  TString curveName(projection->GetName()) ;
2193  curveName.Append(Form("_DataAvg[%s]",projDataSel->get()->contentsString().c_str())) ;
2194  // Append slice set specification if any
2195  if (sliceSet.getSize()>0) {
2196  curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2197  }
2198  // Append any suffixes imported from RooAbsPdf::plotOn
2199  if (o.curveNameSuffix) {
2200  curveName.Append(o.curveNameSuffix) ;
2201  }
2202 
2203  // Curve constructor for data weighted average
2205  RooCurve *curve = new RooCurve(projection->GetName(),projection->GetTitle(),scaleBind,
2208 
2209  curve->SetName(curveName.Data()) ;
2210 
2211  // Add self to other curve if requested
2212  if (o.addToCurveName) {
2213  RooCurve* otherCurve = static_cast<RooCurve*>(frame->findObject(o.addToCurveName,RooCurve::Class())) ;
2214 
2215  // Curve constructor for sum of curves
2216  RooCurve* sumCurve = new RooCurve(projection->GetName(),projection->GetTitle(),*curve,*otherCurve,o.addToWgtSelf,o.addToWgtOther) ;
2217  sumCurve->SetName(Form("%s_PLUS_%s",curve->GetName(),otherCurve->GetName())) ;
2218  delete curve ;
2219  curve = sumCurve ;
2220 
2221  }
2222 
2223  if (o.curveName) {
2224  curve->SetName(o.curveName) ;
2225  }
2226 
2227  // add this new curve to the specified plot frame
2228  frame->addPlotable(curve, o.drawOptions, o.curveInvisible);
2229 
2230  if (projDataSel!=o.projData) delete projDataSel ;
2231 
2232  } else {
2233 
2234  // Set default range, if not specified
2235  if (o.rangeLo==0 && o.rangeHi==0) {
2236  o.rangeLo = frame->GetXaxis()->GetXmin() ;
2237  o.rangeHi = frame->GetXaxis()->GetXmax() ;
2238  }
2239 
2240  // Calculate a posteriori range fraction scaling if requested (2nd part of normalization correction for
2241  // result fit on subrange of data)
2242  if (o.postRangeFracScale) {
2243  if (!o.normRangeName) {
2244  o.normRangeName = "plotRange" ;
2245  plotVar->setRange("plotRange",o.rangeLo,o.rangeHi) ;
2246  }
2247 
2248  // Evaluate fractional correction integral always on full p.d.f, not component.
2249  Bool_t tmp = _globalSelectComp ;
2251  RooAbsReal* intFrac = projection->createIntegral(*plotVar,*plotVar,o.normRangeName) ;
2253  o.scaleFactor /= intFrac->getVal() ;
2254  globalSelectComp(tmp) ;
2255  delete intFrac ;
2256 
2257  }
2258 
2259  // create a new curve of our function using the clone to do the evaluations
2260  // Curve constructor for regular projections
2261 
2263  RooCurve *curve = new RooCurve(*projection,*plotVar,o.rangeLo,o.rangeHi,frame->GetNbinsX(),
2266 
2267 
2268 
2269  // Set default name of curve
2270  TString curveName(projection->GetName()) ;
2271  if (sliceSet.getSize()>0) {
2272  curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2273  }
2274  if (o.curveNameSuffix) {
2275  // Append any suffixes imported from RooAbsPdf::plotOn
2276  curveName.Append(o.curveNameSuffix) ;
2277  }
2278  curve->SetName(curveName.Data()) ;
2279 
2280 
2281  // Add self to other curve if requested
2282  if (o.addToCurveName) {
2283  RooCurve* otherCurve = static_cast<RooCurve*>(frame->findObject(o.addToCurveName,RooCurve::Class())) ;
2284  RooCurve* sumCurve = new RooCurve(projection->GetName(),projection->GetTitle(),*curve,*otherCurve,o.addToWgtSelf,o.addToWgtOther) ;
2285  sumCurve->SetName(Form("%s_PLUS_%s",curve->GetName(),otherCurve->GetName())) ;
2286  delete curve ;
2287  curve = sumCurve ;
2288  }
2289 
2290  // Override name of curve by user name, if specified
2291  if (o.curveName) {
2292  curve->SetName(o.curveName) ;
2293  }
2294 
2295  // add this new curve to the specified plot frame
2296  frame->addPlotable(curve, o.drawOptions, o.curveInvisible);
2297  }
2298 
2299  if (projDataNeededVars) delete projDataNeededVars ;
2300  delete deps ;
2301  delete projectionCompList ;
2302  delete plotCloneSet ;
2303  return frame;
2304 }
2305 
2306 
2307 
2308 
2309 ////////////////////////////////////////////////////////////////////////////////
2310 /// OBSOLETE -- RETAINED FOR BACKWARD COMPATIBILITY. Use the plotOn(frame,Slice(...)) instead
2311 
2312 RooPlot* RooAbsReal::plotSliceOn(RooPlot *frame, const RooArgSet& sliceSet, Option_t* drawOptions,
2313  Double_t scaleFactor, ScaleType stype, const RooAbsData* projData) const
2314 {
2315  RooArgSet projectedVars ;
2316  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2317 
2318  // Take out the sliced variables
2319  TIterator* iter = sliceSet.createIterator() ;
2320  RooAbsArg* sliceArg ;
2321  while((sliceArg=(RooAbsArg*)iter->Next())) {
2322  RooAbsArg* arg = projectedVars.find(sliceArg->GetName()) ;
2323  if (arg) {
2324  projectedVars.remove(*arg) ;
2325  } else {
2326  coutI(Plotting) << "RooAbsReal::plotSliceOn(" << GetName() << ") slice variable "
2327  << sliceArg->GetName() << " was not projected anyway" << endl ;
2328  }
2329  }
2330  delete iter ;
2331 
2332  PlotOpt o ;
2333  o.drawOptions = drawOptions ;
2334  o.scaleFactor = scaleFactor ;
2335  o.stype = stype ;
2336  o.projData = projData ;
2337  o.projSet = &projectedVars ;
2338  return plotOn(frame,o) ;
2339 }
2340 
2341 
2342 
2343 
2344 //_____________________________________________________________________________
2345 // coverity[PASS_BY_VALUE]
2347 
2348 {
2349  // Plotting engine for asymmetries. Implements the functionality if plotOn(frame,Asymmetry(...)))
2350  //
2351  // Plot asymmetry of ourselves, defined as
2352  //
2353  // asym = f(asymCat=-1) - f(asymCat=+1) / ( f(asymCat=-1) + f(asymCat=+1) )
2354  //
2355  // on frame. If frame contains a histogram, all dimensions of the plotted
2356  // asymmetry function that occur in the previously plotted dataset are projected via partial integration.
2357  // Otherwise no projections are performed,
2358  //
2359  // The asymmetry function can be multiplied with an optional scale factor. The default projection
2360  // behaviour can be overriden by supplying an optional set of dependents to project.
2361 
2362  // Sanity checks
2363  if (plotSanityChecks(frame)) return frame ;
2364 
2365  // ProjDataVars is either all projData observables, or the user indicated subset of it
2366  RooArgSet projDataVars ;
2367  if (o.projData) {
2368  if (o.projDataSet) {
2369  RooArgSet* tmp = (RooArgSet*) o.projData->get()->selectCommon(*o.projDataSet) ;
2370  projDataVars.add(*tmp) ;
2371  delete tmp ;
2372  } else {
2373  projDataVars.add(*o.projData->get()) ;
2374  }
2375  }
2376 
2377  // Must depend on asymCat
2378  if (!dependsOn(asymCat)) {
2379  coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2380  << ") function doesn't depend on asymmetry category " << asymCat.GetName() << endl ;
2381  return frame ;
2382  }
2383 
2384  // asymCat must be a signCat
2385  if (!asymCat.isSignType()) {
2386  coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2387  << ") asymmetry category must have 2 or 3 states with index values -1,0,1" << endl ;
2388  return frame ;
2389  }
2390 
2391  // Make list of variables to be projected
2392  RooArgSet projectedVars ;
2393  RooArgSet sliceSet ;
2394  if (o.projSet) {
2395  makeProjectionSet(frame->getPlotVar(),o.projSet,projectedVars,kFALSE) ;
2396 
2397  // Print list of non-projected variables
2398  if (frame->getNormVars()) {
2399  RooArgSet *sliceSetTmp = getObservables(*frame->getNormVars()) ;
2400  sliceSetTmp->remove(projectedVars,kTRUE,kTRUE) ;
2401  sliceSetTmp->remove(*frame->getPlotVar(),kTRUE,kTRUE) ;
2402 
2403  if (o.projData) {
2404  RooArgSet* tmp = (RooArgSet*) projDataVars.selectCommon(*o.projSet) ;
2405  sliceSetTmp->remove(*tmp,kTRUE,kTRUE) ;
2406  delete tmp ;
2407  }
2408 
2409  if (sliceSetTmp->getSize()) {
2410  coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") plot on "
2411  << frame->getPlotVar()->GetName() << " represents a slice in " << *sliceSetTmp << endl ;
2412  }
2413  sliceSet.add(*sliceSetTmp) ;
2414  delete sliceSetTmp ;
2415  }
2416  } else {
2417  makeProjectionSet(frame->getPlotVar(),frame->getNormVars(),projectedVars,kTRUE) ;
2418  }
2419 
2420 
2421  // Take out data-projected dependens from projectedVars
2422  RooArgSet* projDataNeededVars = 0 ;
2423  if (o.projData) {
2424  projDataNeededVars = (RooArgSet*) projectedVars.selectCommon(projDataVars) ;
2425  projectedVars.remove(projDataVars,kTRUE,kTRUE) ;
2426  }
2427 
2428  // Take out plotted asymmetry from projection
2429  if (projectedVars.find(asymCat.GetName())) {
2430  projectedVars.remove(*projectedVars.find(asymCat.GetName())) ;
2431  }
2432 
2433  // Clone the plot variable
2434  RooAbsReal* realVar = (RooRealVar*) frame->getPlotVar() ;
2435  RooRealVar* plotVar = (RooRealVar*) realVar->Clone() ;
2436 
2437  // Inform user about projections
2438  if (projectedVars.getSize()) {
2439  coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") plot on " << plotVar->GetName()
2440  << " projects variables " << projectedVars << endl ;
2441  }
2442  if (projDataNeededVars && projDataNeededVars->getSize()>0) {
2443  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") plot on " << plotVar->GetName()
2444  << " averages using data variables "<< *projDataNeededVars << endl ;
2445  }
2446 
2447 
2448  // Customize two copies of projection with fixed negative and positive asymmetry
2449  RooAbsCategoryLValue* asymPos = (RooAbsCategoryLValue*) asymCat.Clone("asym_pos") ;
2450  RooAbsCategoryLValue* asymNeg = (RooAbsCategoryLValue*) asymCat.Clone("asym_neg") ;
2451  asymPos->setIndex(1) ;
2452  asymNeg->setIndex(-1) ;
2453  RooCustomizer* custPos = new RooCustomizer(*this,"pos") ;
2454  RooCustomizer* custNeg = new RooCustomizer(*this,"neg") ;
2455  //custPos->setOwning(kTRUE) ;
2456  //custNeg->setOwning(kTRUE) ;
2457  custPos->replaceArg(asymCat,*asymPos) ;
2458  custNeg->replaceArg(asymCat,*asymNeg) ;
2459  RooAbsReal* funcPos = (RooAbsReal*) custPos->build() ;
2460  RooAbsReal* funcNeg = (RooAbsReal*) custNeg->build() ;
2461 
2462  // Create projection integral
2463  RooArgSet *posProjCompList, *negProjCompList ;
2464 
2465  // Add projDataVars to normalized dependents of projection
2466  // This is needed only for asymmetries (why?)
2467  RooArgSet depPos(*plotVar,*asymPos) ;
2468  RooArgSet depNeg(*plotVar,*asymNeg) ;
2469  depPos.add(projDataVars) ;
2470  depNeg.add(projDataVars) ;
2471 
2472  const RooAbsReal *posProj = funcPos->createPlotProjection(depPos, &projectedVars, posProjCompList, o.projectionRangeName) ;
2473  const RooAbsReal *negProj = funcNeg->createPlotProjection(depNeg, &projectedVars, negProjCompList, o.projectionRangeName) ;
2474  if (!posProj || !negProj) {
2475  coutE(Plotting) << "RooAbsReal::plotAsymOn(" << GetName() << ") Unable to create projections, abort" << endl ;
2476  return frame ;
2477  }
2478 
2479  // Create a RooFormulaVar representing the asymmetry
2480  TString asymName(GetName()) ;
2481  asymName.Append("_Asym[") ;
2482  asymName.Append(asymCat.GetName()) ;
2483  asymName.Append("]") ;
2484  TString asymTitle(asymCat.GetName()) ;
2485  asymTitle.Append(" Asymmetry of ") ;
2486  asymTitle.Append(GetTitle()) ;
2487  RooFormulaVar* funcAsym = new RooFormulaVar(asymName,asymTitle,"(@0-@1)/(@0+@1)",RooArgSet(*posProj,*negProj)) ;
2488 
2489  if (o.projData) {
2490 
2491  // If data set contains more rows than needed, make reduced copy first
2492  RooAbsData* projDataSel = (RooAbsData*)o.projData;
2493  if (projDataNeededVars && projDataNeededVars->getSize()<o.projData->get()->getSize()) {
2494 
2495  // Determine if there are any slice variables in the projection set
2496  RooArgSet* sliceDataSet = (RooArgSet*) sliceSet.selectCommon(*o.projData->get()) ;
2497  TString cutString ;
2498  if (sliceDataSet->getSize()>0) {
2499  TIterator* iter = sliceDataSet->createIterator() ;
2500  RooAbsArg* sliceVar ;
2501  Bool_t first(kTRUE) ;
2502  while((sliceVar=(RooAbsArg*)iter->Next())) {
2503  if (!first) {
2504  cutString.Append("&&") ;
2505  } else {
2506  first=kFALSE ;
2507  }
2508 
2509  RooAbsRealLValue* real ;
2510  RooAbsCategoryLValue* cat ;
2511  if ((real = dynamic_cast<RooAbsRealLValue*>(sliceVar))) {
2512  cutString.Append(Form("%s==%f",real->GetName(),real->getVal())) ;
2513  } else if ((cat = dynamic_cast<RooAbsCategoryLValue*>(sliceVar))) {
2514  cutString.Append(Form("%s==%d",cat->GetName(),cat->getIndex())) ;
2515  }
2516  }
2517  delete iter ;
2518  }
2519  delete sliceDataSet ;
2520 
2521  if (!cutString.IsNull()) {
2522  projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars,cutString) ;
2523  coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2524  << ") reducing given projection dataset to entries with " << cutString << endl ;
2525  } else {
2526  projDataSel = ((RooAbsData*)o.projData)->reduce(*projDataNeededVars) ;
2527  }
2528  coutI(Plotting) << "RooAbsReal::plotAsymOn(" << GetName()
2529  << ") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2530  }
2531 
2532 
2533  RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*funcAsym,*projDataSel,RooArgSet()/**projDataSel->get()*/,o.numCPU,o.interleave,kTRUE) ;
2534  //RooDataWeightedAverage dwa(Form("%sDataWgtAvg",GetName()),"Data Weighted average",*funcAsym,*projDataSel,*projDataSel->get(),o.numCPU,o.interleave,kTRUE) ;
2536 
2537  RooRealBinding projBind(dwa,*plotVar) ;
2538 
2539  ((RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2540  ((RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2541 
2542  RooScaledFunc scaleBind(projBind,o.scaleFactor);
2543 
2544  // Set default range, if not specified
2545  if (o.rangeLo==0 && o.rangeHi==0) {
2546  o.rangeLo = frame->GetXaxis()->GetXmin() ;
2547  o.rangeHi = frame->GetXaxis()->GetXmax() ;
2548  }
2549 
2550  // Construct name of curve for data weighed average
2551  TString curveName(funcAsym->GetName()) ;
2552  curveName.Append(Form("_DataAvg[%s]",projDataSel->get()->contentsString().c_str())) ;
2553  // Append slice set specification if any
2554  if (sliceSet.getSize()>0) {
2555  curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2556  }
2557  // Append any suffixes imported from RooAbsPdf::plotOn
2558  if (o.curveNameSuffix) {
2559  curveName.Append(o.curveNameSuffix) ;
2560  }
2561 
2562 
2564  RooCurve *curve = new RooCurve(funcAsym->GetName(),funcAsym->GetTitle(),scaleBind,
2567 
2568  dynamic_cast<TAttLine*>(curve)->SetLineColor(2) ;
2569  // add this new curve to the specified plot frame
2570  frame->addPlotable(curve, o.drawOptions);
2571 
2572  ccoutW(Eval) << endl ;
2573 
2574  if (projDataSel!=o.projData) delete projDataSel ;
2575 
2576  } else {
2577 
2578  // Set default range, if not specified
2579  if (o.rangeLo==0 && o.rangeHi==0) {
2580  o.rangeLo = frame->GetXaxis()->GetXmin() ;
2581  o.rangeHi = frame->GetXaxis()->GetXmax() ;
2582  }
2583 
2585  RooCurve* curve= new RooCurve(*funcAsym,*plotVar,o.rangeLo,o.rangeHi,frame->GetNbinsX(),
2588 
2589  dynamic_cast<TAttLine*>(curve)->SetLineColor(2) ;
2590 
2591 
2592  // Set default name of curve
2593  TString curveName(funcAsym->GetName()) ;
2594  if (sliceSet.getSize()>0) {
2595  curveName.Append(Form("_Slice[%s]",sliceSet.contentsString().c_str())) ;
2596  }
2597  if (o.curveNameSuffix) {
2598  // Append any suffixes imported from RooAbsPdf::plotOn
2599  curveName.Append(o.curveNameSuffix) ;
2600  }
2601  curve->SetName(curveName.Data()) ;
2602 
2603  // add this new curve to the specified plot frame
2604  frame->addPlotable(curve, o.drawOptions);
2605 
2606  }
2607 
2608  // Cleanup
2609  delete custPos ;
2610  delete custNeg ;
2611  delete funcPos ;
2612  delete funcNeg ;
2613  delete posProjCompList ;
2614  delete negProjCompList ;
2615  delete asymPos ;
2616  delete asymNeg ;
2617  delete funcAsym ;
2618 
2619  delete plotVar ;
2620 
2621  return frame;
2622 }
2623 
2624 
2625 
2626 ////////////////////////////////////////////////////////////////////////////////
2627 /// Calculate error on self by propagated errors on parameters with correlations as given by fit result
2628 /// The linearly propagated error is calculated as follows
2629 /// T
2630 /// error(x) = F_a(x) * Corr(a,a') F_a'(x)
2631 ///
2632 /// 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
2633 /// Corr(a,a') = the correlation matrix from the fit result
2634 ///
2635 
2637 {
2638 
2639  // Strip out parameters with zero error
2640  RooArgList fpf_stripped;
2641  RooFIter fi = fr.floatParsFinal().fwdIterator();
2642  RooRealVar *frv;
2643  while ((frv = (RooRealVar *)fi.next())) {
2644  if (frv->getError() > 1e-20) {
2645  fpf_stripped.add(*frv);
2646  }
2647  }
2648 
2649  // Clone self for internal use
2650  RooAbsReal *cloneFunc = (RooAbsReal *)cloneTree();
2651  RooArgSet *errorParams = cloneFunc->getObservables(fpf_stripped);
2652 
2653  RooArgSet *nset =
2654  nset_in.getSize() == 0 ? cloneFunc->getParameters(*errorParams) : cloneFunc->getObservables(nset_in);
2655 
2656  // Make list of parameter instances of cloneFunc in order of error matrix
2657  RooArgList paramList;
2658  const RooArgList &fpf = fpf_stripped;
2659  vector<int> fpf_idx;
2660  for (Int_t i = 0; i < fpf.getSize(); i++) {
2661  RooAbsArg *par = errorParams->find(fpf[i].GetName());
2662  if (par) {
2663  paramList.add(*par);
2664  fpf_idx.push_back(i);
2665  }
2666  }
2667 
2668  vector<Double_t> plusVar, minusVar ;
2669 
2670  // Create vector of plus,minus variations for each parameter
2671  TMatrixDSym V(paramList.getSize()==fr.floatParsFinal().getSize()?
2672  fr.covarianceMatrix():
2673  fr.reducedCovarianceMatrix(paramList)) ;
2674 
2675  for (Int_t ivar=0 ; ivar<paramList.getSize() ; ivar++) {
2676 
2677  RooRealVar& rrv = (RooRealVar&)fpf[fpf_idx[ivar]] ;
2678 
2679  Double_t cenVal = rrv.getVal() ;
2680  Double_t errVal = sqrt(V(ivar,ivar)) ;
2681 
2682  // Make Plus variation
2683  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal+errVal) ;
2684  plusVar.push_back(cloneFunc->getVal(nset)) ;
2685 
2686  // Make Minus variation
2687  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal-errVal) ;
2688  minusVar.push_back(cloneFunc->getVal(nset)) ;
2689 
2690  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal) ;
2691  }
2692 
2693  TMatrixDSym C(paramList.getSize()) ;
2694  vector<double> errVec(paramList.getSize()) ;
2695  for (int i=0 ; i<paramList.getSize() ; i++) {
2696  errVec[i] = sqrt(V(i,i)) ;
2697  for (int j=i ; j<paramList.getSize() ; j++) {
2698  C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2699  C(j,i) = C(i,j) ;
2700  }
2701  }
2702 
2703  // Make vector of variations
2704  TVectorD F(plusVar.size()) ;
2705  for (unsigned int j=0 ; j<plusVar.size() ; j++) {
2706  F[j] = (plusVar[j]-minusVar[j])/2 ;
2707  }
2708 
2709  // Calculate error in linear approximation from variations and correlation coefficient
2710  Double_t sum = F*(C*F) ;
2711 
2712  delete cloneFunc ;
2713  delete errorParams ;
2714  delete nset ;
2715 
2716  return sqrt(sum) ;
2717 }
2718 
2719 
2720 
2721 
2722 
2723 
2724 
2725 
2726 
2727 
2728 ////////////////////////////////////////////////////////////////////////////////
2729 /// Plot function or p.d.f. on frame with support for visualization of the uncertainty encoded in the given fit result fr.
2730 /// If params is non-zero, only the subset of the parameters in fr that occur in params is considered for the error evaluation
2731 /// Argument argList can contain any RooCmdArg named argument that can be applied to a regular plotOn() operation
2732 ///
2733 /// By default (linMethod=kTRUE) a linearized error is shown which is calculated as follows
2734 /// T
2735 /// error(x) = Z* F_a(x) * Corr(a,a') F_a'(x)
2736 ///
2737 /// 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
2738 /// Corr(a,a') = the correlation matrix from the fit result
2739 /// Z = requested signifance 'Z sigma band'
2740 ///
2741 /// The linear method is fast (required 2*N evaluations of the curve, where N is the number of parameters), but may
2742 /// not be accurate in the presence of strong correlations (~>0.9) and at Z>2 due to linear and Gaussian approximations made
2743 ///
2744 /// Alternatively, a more robust error is calculated using a sampling method. In this method a number of curves
2745 /// is calculated with variations of the parameter values, as drawn from a multi-variate Gaussian p.d.f. that is constructed
2746 /// from the fit results covariance matrix. The error(x) is determined by calculating a central interval that capture N% of the variations
2747 /// 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
2748 /// 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)
2749 /// Intervals from the sampling method can be asymmetric, and may perform better in the presence of strong correlations
2750 
2751 RooPlot* RooAbsReal::plotOnWithErrorBand(RooPlot* frame,const RooFitResult& fr, Double_t Z,const RooArgSet* params, const RooLinkedList& argList, Bool_t linMethod) const
2752 {
2753  RooLinkedList plotArgListTmp(argList) ;
2754  RooCmdConfig pc(Form("RooAbsPdf::plotOn(%s)",GetName())) ;
2755  pc.stripCmdList(plotArgListTmp,"VisualizeError,MoveToBack") ;
2756 
2757  // Strip any 'internal normalization' arguments from list
2758  RooLinkedList plotArgList ;
2759  RooFIter iter = plotArgListTmp.fwdIterator() ;
2760  RooCmdArg* cmd ;
2761  while ((cmd=(RooCmdArg*)iter.next())) {
2762  if (std::string("Normalization")==cmd->GetName()) {
2763  if (((RooCmdArg*)cmd)->getInt(1)!=0) {
2764  } else {
2765  plotArgList.Add(cmd) ;
2766  }
2767  } else {
2768  plotArgList.Add(cmd) ;
2769  }
2770  }
2771 
2772  // Generate central value curve
2773  RooLinkedList tmp(plotArgList) ;
2774  plotOn(frame,tmp) ;
2775  RooCurve* cenCurve = frame->getCurve() ;
2776  frame->remove(0,kFALSE) ;
2777 
2778  RooCurve* band(0) ;
2779  if (!linMethod) {
2780 
2781  // *** Interval method ***
2782  //
2783  // Make N variations of parameters samples from V and visualize N% central interval where N% is defined from Z
2784 
2785  // Clone self for internal use
2786  RooAbsReal* cloneFunc = (RooAbsReal*) cloneTree() ;
2787  RooArgSet* cloneParams = cloneFunc->getObservables(fr.floatParsFinal()) ;
2788  RooArgSet* errorParams = params?((RooArgSet*)cloneParams->selectCommon(*params)):cloneParams ;
2789 
2790  // Generate 100 random parameter points distributed according to fit result covariance matrix
2791  RooAbsPdf* paramPdf = fr.createHessePdf(*errorParams) ;
2792  Int_t n = Int_t(100./TMath::Erfc(Z/sqrt(2.))) ;
2793  if (n<100) n=100 ;
2794 
2795  coutI(Plotting) << "RooAbsReal::plotOn(" << GetName() << ") INFO: visualizing " << Z << "-sigma uncertainties in parameters "
2796  << *errorParams << " from fit result " << fr.GetName() << " using " << n << " samplings." << endl ;
2797 
2798  // Generate variation curves with above set of parameter values
2799  Double_t ymin = frame->GetMinimum() ;
2800  Double_t ymax = frame->GetMaximum() ;
2801  RooDataSet* d = paramPdf->generate(*errorParams,n) ;
2802  vector<RooCurve*> cvec ;
2803  for (int i=0 ; i<d->numEntries() ; i++) {
2804  *cloneParams = (*d->get(i)) ;
2805  RooLinkedList tmp2(plotArgList) ;
2806  cloneFunc->plotOn(frame,tmp2) ;
2807  cvec.push_back(frame->getCurve()) ;
2808  frame->remove(0,kFALSE) ;
2809  }
2810  frame->SetMinimum(ymin) ;
2811  frame->SetMaximum(ymax) ;
2812 
2813 
2814  // Generate upper and lower curve points from 68% interval around each point of central curve
2815  band = cenCurve->makeErrorBand(cvec,Z) ;
2816 
2817  // Cleanup
2818  delete paramPdf ;
2819  delete cloneFunc ;
2820  for (vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; i++) {
2821  delete (*i) ;
2822  }
2823 
2824  } else {
2825 
2826  // *** Linear Method ***
2827  //
2828  // Make a one-sigma up- and down fluctation for each parameter and visualize
2829  // a from a linearized calculation as follows
2830  //
2831  // error(x) = F(a) C_aa' F(a')
2832  //
2833  // Where F(a) = (f(x,a+da) - f(x,a-da))/2
2834  // and C_aa' is the correlation matrix
2835 
2836  // Strip out parameters with zero error
2837  RooArgList fpf_stripped;
2838  RooFIter fi = fr.floatParsFinal().fwdIterator();
2839  RooRealVar *frv;
2840  while ((frv = (RooRealVar *)fi.next())) {
2841  if (frv->getError() > 1e-20) {
2842  fpf_stripped.add(*frv);
2843  }
2844  }
2845 
2846  // Clone self for internal use
2847  RooAbsReal* cloneFunc = (RooAbsReal*) cloneTree() ;
2848  RooArgSet *cloneParams = cloneFunc->getObservables(fpf_stripped);
2849  RooArgSet* errorParams = params?((RooArgSet*)cloneParams->selectCommon(*params)):cloneParams ;
2850 
2851 
2852  // Make list of parameter instances of cloneFunc in order of error matrix
2853  RooArgList paramList ;
2854  const RooArgList& fpf = fr.floatParsFinal() ;
2855  vector<int> fpf_idx ;
2856  for (Int_t i=0 ; i<fpf.getSize() ; i++) {
2857  RooAbsArg* par = errorParams->find(fpf[i].GetName()) ;
2858  if (par) {
2859  paramList.add(*par) ;
2860  fpf_idx.push_back(i) ;
2861  }
2862  }
2863 
2864  vector<RooCurve*> plusVar, minusVar ;
2865 
2866  // Create vector of plus,minus variations for each parameter
2867 
2868  TMatrixDSym V(paramList.getSize()==fr.floatParsFinal().getSize()?
2869  fr.covarianceMatrix():
2870  fr.reducedCovarianceMatrix(paramList)) ;
2871 
2872 
2873  for (Int_t ivar=0 ; ivar<paramList.getSize() ; ivar++) {
2874 
2875  RooRealVar& rrv = (RooRealVar&)fpf[fpf_idx[ivar]] ;
2876 
2877  Double_t cenVal = rrv.getVal() ;
2878  Double_t errVal = sqrt(V(ivar,ivar)) ;
2879 
2880  // Make Plus variation
2881  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal+Z*errVal) ;
2882 
2883 
2884  RooLinkedList tmp2(plotArgList) ;
2885  cloneFunc->plotOn(frame,tmp2) ;
2886  plusVar.push_back(frame->getCurve()) ;
2887  frame->remove(0,kFALSE) ;
2888 
2889 
2890  // Make Minus variation
2891  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal-Z*errVal) ;
2892  RooLinkedList tmp3(plotArgList) ;
2893  cloneFunc->plotOn(frame,tmp3) ;
2894  minusVar.push_back(frame->getCurve()) ;
2895  frame->remove(0,kFALSE) ;
2896 
2897  ((RooRealVar*)paramList.at(ivar))->setVal(cenVal) ;
2898  }
2899 
2900  TMatrixDSym C(paramList.getSize()) ;
2901  vector<double> errVec(paramList.getSize()) ;
2902  for (int i=0 ; i<paramList.getSize() ; i++) {
2903  errVec[i] = sqrt(V(i,i)) ;
2904  for (int j=i ; j<paramList.getSize() ; j++) {
2905  C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2906  C(j,i) = C(i,j) ;
2907  }
2908  }
2909 
2910  band = cenCurve->makeErrorBand(plusVar,minusVar,C,Z) ;
2911 
2912 
2913  // Cleanup
2914  delete cloneFunc ;
2915  for (vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; i++) {
2916  delete (*i) ;
2917  }
2918  for (vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; i++) {
2919  delete (*i) ;
2920  }
2921 
2922  }
2923 
2924  delete cenCurve ;
2925  if (!band) return frame ;
2926 
2927  // Define configuration for this method
2928  pc.defineString("drawOption","DrawOption",0,"F") ;
2929  pc.defineString("curveNameSuffix","CurveNameSuffix",0,"") ;
2930  pc.defineInt("lineColor","LineColor",0,-999) ;
2931  pc.defineInt("lineStyle","LineStyle",0,-999) ;
2932  pc.defineInt("lineWidth","LineWidth",0,-999) ;
2933  pc.defineInt("fillColor","FillColor",0,-999) ;
2934  pc.defineInt("fillStyle","FillStyle",0,-999) ;
2935  pc.defineString("curveName","Name",0,"") ;
2936  pc.defineInt("curveInvisible","Invisible",0,0) ;
2937  pc.defineInt("moveToBack","MoveToBack",0,0) ;
2938  pc.allowUndefined() ;
2939 
2940  // Process & check varargs
2941  pc.process(argList) ;
2942  if (!pc.ok(kTRUE)) {
2943  return frame ;
2944  }
2945 
2946  // Insert error band in plot frame
2947  frame->addPlotable(band,pc.getString("drawOption"),pc.getInt("curveInvisible")) ;
2948 
2949 
2950  // Optionally adjust line/fill attributes
2951  Int_t lineColor = pc.getInt("lineColor") ;
2952  Int_t lineStyle = pc.getInt("lineStyle") ;
2953  Int_t lineWidth = pc.getInt("lineWidth") ;
2954  Int_t fillColor = pc.getInt("fillColor") ;
2955  Int_t fillStyle = pc.getInt("fillStyle") ;
2956  if (lineColor!=-999) frame->getAttLine()->SetLineColor(lineColor) ;
2957  if (lineStyle!=-999) frame->getAttLine()->SetLineStyle(lineStyle) ;
2958  if (lineWidth!=-999) frame->getAttLine()->SetLineWidth(lineWidth) ;
2959  if (fillColor!=-999) frame->getAttFill()->SetFillColor(fillColor) ;
2960  if (fillStyle!=-999) frame->getAttFill()->SetFillStyle(fillStyle) ;
2961 
2962  // Adjust name if requested
2963  if (pc.getString("curveName",0,kTRUE)) {
2964  band->SetName(pc.getString("curveName",0,kTRUE)) ;
2965  } else if (pc.getString("curveNameSuffix",0,kTRUE)) {
2966  TString name(band->GetName()) ;
2967  name.Append(pc.getString("curveNameSuffix",0,kTRUE)) ;
2968  band->SetName(name.Data()) ;
2969  }
2970 
2971  // Move last inserted object to back to drawing stack if requested
2972  if (pc.getInt("moveToBack") && frame->numItems()>1) {
2973  frame->drawBefore(frame->getObject(0)->GetName(), frame->getCurve()->GetName());
2974  }
2975 
2976 
2977  return frame ;
2978 }
2979 
2980 
2981 
2982 
2983 ////////////////////////////////////////////////////////////////////////////////
2984 /// Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operations
2985 
2987 {
2988  // check that we are passed a valid plot frame to use
2989  if(0 == frame) {
2990  coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: frame is null" << endl;
2991  return kTRUE;
2992  }
2993 
2994  // check that this frame knows what variable to plot
2995  RooAbsReal* var = frame->getPlotVar() ;
2996  if(!var) {
2997  coutE(Plotting) << ClassName() << "::" << GetName()
2998  << ":plotOn: frame does not specify a plot variable" << endl;
2999  return kTRUE;
3000  }
3001 
3002  // check that the plot variable is not derived
3003  if(!dynamic_cast<RooAbsRealLValue*>(var)) {
3004  coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: cannot plot variable \""
3005  << var->GetName() << "\" of type " << var->ClassName() << endl;
3006  return kTRUE;
3007  }
3008 
3009  // check if we actually depend on the plot variable
3010  if(!this->dependsOn(*var)) {
3011  coutE(Plotting) << ClassName() << "::" << GetName() << ":plotOn: WARNING: variable is not an explicit dependent: "
3012  << var->GetName() << endl;
3013  }
3014 
3015  return kFALSE ;
3016 }
3017 
3018 
3019 
3020 
3021 ////////////////////////////////////////////////////////////////////////////////
3022 /// Utility function for plotOn() that constructs the set of
3023 /// observables to project when plotting ourselves as function of
3024 /// 'plotVar'. 'allVars' is the list of variables that must be
3025 /// projected, but may contain variables that we do not depend on. If
3026 /// 'silent' is cleared, warnings about inconsistent input parameters
3027 /// will be printed.
3028 
3029 void RooAbsReal::makeProjectionSet(const RooAbsArg* plotVar, const RooArgSet* allVars,
3030  RooArgSet& projectedVars, Bool_t silent) const
3031 {
3032  cxcoutD(Plotting) << "RooAbsReal::makeProjectionSet(" << GetName() << ") plotVar = " << plotVar->GetName()
3033  << " allVars = " << (allVars?(*allVars):RooArgSet()) << endl ;
3034 
3035  projectedVars.removeAll() ;
3036  if (!allVars) return ;
3037 
3038  // Start out with suggested list of variables
3039  projectedVars.add(*allVars) ;
3040 
3041  // Take out plot variable
3042  RooAbsArg *found= projectedVars.find(plotVar->GetName());
3043  if(found) {
3044  projectedVars.remove(*found);
3045 
3046  // Take out eventual servers of plotVar
3047  RooArgSet* plotServers = plotVar->getObservables(&projectedVars) ;
3048  TIterator* psIter = plotServers->createIterator() ;
3049  RooAbsArg* ps ;
3050  while((ps=(RooAbsArg*)psIter->Next())) {
3051  RooAbsArg* tmp = projectedVars.find(ps->GetName()) ;
3052  if (tmp) {
3053  cxcoutD(Plotting) << "RooAbsReal::makeProjectionSet(" << GetName() << ") removing " << tmp->GetName()
3054  << " from projection set because it a server of " << plotVar->GetName() << endl ;
3055  projectedVars.remove(*tmp) ;
3056  }
3057  }
3058  delete psIter ;
3059  delete plotServers ;
3060 
3061  if (!silent) {
3062  coutW(Plotting) << "RooAbsReal::plotOn(" << GetName()
3063  << ") WARNING: cannot project out frame variable ("
3064  << found->GetName() << "), ignoring" << endl ;
3065  }
3066  }
3067 
3068  // Take out all non-dependents of function
3069  TIterator* iter = allVars->createIterator() ;
3070  RooAbsArg* arg ;
3071  while((arg=(RooAbsArg*)iter->Next())) {
3072  if (!dependsOnValue(*arg)) {
3073  projectedVars.remove(*arg,kTRUE) ;
3074 
3075  cxcoutD(Plotting) << "RooAbsReal::plotOn(" << GetName()
3076  << ") function doesn't depend on projection variable "
3077  << arg->GetName() << ", ignoring" << endl ;
3078  }
3079  }
3080  delete iter ;
3081 }
3082 
3083 
3084 
3085 
3086 ////////////////////////////////////////////////////////////////////////////////
3087 /// If true, the current pdf is a selected component (for use in plotting)
3088 
3090 {
3091  return _selectComp || _globalSelectComp ;
3092 }
3093 
3094 
3095 
3096 ////////////////////////////////////////////////////////////////////////////////
3097 /// Global switch controlling the activation of the selectComp() functionality
3098 
3100 {
3101  _globalSelectComp = flag ;
3102 }
3103 
3104 
3105 
3106 
3107 ////////////////////////////////////////////////////////////////////////////////
3108 /// Create an interface adaptor f(vars) that binds us to the specified variables
3109 /// (in arbitrary order). For example, calling bindVars({x1,x3}) on an object
3110 /// F(x1,x2,x3,x4) returns an object f(x1,x3) that is evaluated using the
3111 /// current values of x2 and x4. The caller takes ownership of the returned adaptor.
3112 
3113 RooAbsFunc *RooAbsReal::bindVars(const RooArgSet &vars, const RooArgSet* nset, Bool_t clipInvalid) const
3114 {
3115  RooAbsFunc *binding= new RooRealBinding(*this,vars,nset,clipInvalid);
3116  if(binding && !binding->isValid()) {
3117  coutE(InputArguments) << ClassName() << "::" << GetName() << ":bindVars: cannot bind to " << vars << endl ;
3118  delete binding;
3119  binding= 0;
3120  }
3121  return binding;
3122 }
3123 
3124 
3125 
3126 ////////////////////////////////////////////////////////////////////////////////
3127 /// Copy the cached value of another RooAbsArg to our cache.
3128 /// Warning: This function copies the cached values of source,
3129 /// it is the callers responsibility to make sure the cache is clean
3130 
3131 void RooAbsReal::copyCache(const RooAbsArg* source, Bool_t /*valueOnly*/, Bool_t setValDirty)
3132 {
3133  RooAbsReal* other = static_cast<RooAbsReal*>(const_cast<RooAbsArg*>(source)) ;
3134 
3135  if (!other->_treeVar) {
3136  _value = other->_value ;
3137  } else {
3138  if (source->getAttribute("FLOAT_TREE_BRANCH")) {
3139  _value = other->_floatValue ;
3140  } else if (source->getAttribute("INTEGER_TREE_BRANCH")) {
3141  _value = other->_intValue ;
3142  } else if (source->getAttribute("BYTE_TREE_BRANCH")) {
3143  _value = other->_byteValue ;
3144  } else if (source->getAttribute("BOOL_TREE_BRANCH")) {
3145  _value = other->_boolValue ;
3146  } else if (source->getAttribute("SIGNEDBYTE_TREE_BRANCH")) {
3147  _value = other->_sbyteValue ;
3148  } else if (source->getAttribute("UNSIGNED_INTEGER_TREE_BRANCH")) {
3149  _value = other->_uintValue ;
3150  }
3151  }
3152  if (setValDirty) {
3153  setValueDirty() ;
3154  }
3155 }
3156 
3157 
3158 
3159 ////////////////////////////////////////////////////////////////////////////////
3160 
3162 {
3163  RooVectorDataStore::RealVector* rv = vstore.addReal(this) ;
3164  rv->setBuffer(this,&_value) ;
3165 }
3166 
3167 
3168 
3169 
3170 ////////////////////////////////////////////////////////////////////////////////
3171 /// Attach object to a branch of given TTree. By default it will
3172 /// register the internal value cache RooAbsReal::_value as branch
3173 /// buffer for a Double_t tree branch with the same name as this
3174 /// object. If no Double_t branch is found with the name of this
3175 /// object, this method looks for a Float_t Int_t, UChar_t and UInt_t
3176 /// branch in that order. If any of these are found the buffer for
3177 /// that branch is set to a correctly typed conversion buffer in this
3178 /// RooRealVar. A flag is set that will cause copyCache to copy the
3179 /// object value from the appropriate conversion buffer instead of
3180 /// the _value buffer.
3181 
3182 void RooAbsReal::attachToTree(TTree& t, Int_t bufSize)
3183 {
3184  // First determine if branch is taken
3185  TString cleanName(cleanBranchName()) ;
3186  TBranch* branch = t.GetBranch(cleanName) ;
3187  if (branch) {
3188 
3189  // Determine if existing branch is Float_t or Double_t
3190  TLeaf* leaf = (TLeaf*)branch->GetListOfLeaves()->At(0) ;
3191 
3192  // Check that leaf is _not_ an array
3193  Int_t dummy ;
3194  TLeaf* counterLeaf = leaf->GetLeafCounter(dummy) ;
3195  if (counterLeaf) {
3196  coutE(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") ERROR: TTree branch " << GetName()
3197  << " is an array and cannot be attached to a RooAbsReal" << endl ;
3198  return ;
3199  }
3200 
3201  TString typeName(leaf->GetTypeName()) ;
3202 
3203  if (!typeName.CompareTo("Float_t")) {
3204  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Float_t branch " << GetName()
3205  << " will be converted to double precision" << endl ;
3206  setAttribute("FLOAT_TREE_BRANCH",kTRUE) ;
3207  _treeVar = kTRUE ;
3208  t.SetBranchAddress(cleanName,&_floatValue) ;
3209  } else if (!typeName.CompareTo("Int_t")) {
3210  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Int_t branch " << GetName()
3211  << " will be converted to double precision" << endl ;
3212  setAttribute("INTEGER_TREE_BRANCH",kTRUE) ;
3213  _treeVar = kTRUE ;
3214  t.SetBranchAddress(cleanName,&_intValue) ;
3215  } else if (!typeName.CompareTo("UChar_t")) {
3216  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree UChar_t branch " << GetName()
3217  << " will be converted to double precision" << endl ;
3218  setAttribute("BYTE_TREE_BRANCH",kTRUE) ;
3219  _treeVar = kTRUE ;
3220  t.SetBranchAddress(cleanName,&_byteValue) ;
3221  } else if (!typeName.CompareTo("Bool_t")) {
3222  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Bool_t branch " << GetName()
3223  << " will be converted to double precision" << endl ;
3224  setAttribute("BOOL_TREE_BRANCH",kTRUE) ;
3225  _treeVar = kTRUE ;
3226  t.SetBranchAddress(cleanName,&_boolValue) ;
3227  } else if (!typeName.CompareTo("Char_t")) {
3228  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree Char_t branch " << GetName()
3229  << " will be converted to double precision" << endl ;
3230  setAttribute("SIGNEDBYTE_TREE_BRANCH",kTRUE) ;
3231  _treeVar = kTRUE ;
3232  t.SetBranchAddress(cleanName,&_sbyteValue) ;
3233  } else if (!typeName.CompareTo("UInt_t")) {
3234  coutI(Eval) << "RooAbsReal::attachToTree(" << GetName() << ") TTree UInt_t branch " << GetName()
3235  << " will be converted to double precision" << endl ;
3236  setAttribute("UNSIGNED_INTEGER_TREE_BRANCH",kTRUE) ;
3237  _treeVar = kTRUE ;
3238  t.SetBranchAddress(cleanName,&_uintValue) ;
3239  } else if (!typeName.CompareTo("Double_t")) {
3240  t.SetBranchAddress(cleanName,&_value) ;
3241  } else {
3242  coutE(InputArguments) << "RooAbsReal::attachToTree(" << GetName() << ") data type " << typeName << " is not supported" << endl ;
3243  }
3244 
3245  if (branch->GetCompressionLevel()<0) {
3246  // cout << "RooAbsReal::attachToTree(" << GetName() << ") Fixing compression level of branch " << cleanName << endl ;
3247  branch->SetCompressionLevel(1) ;
3248  }
3249 
3250 // cout << "RooAbsReal::attachToTree(" << cleanName << "): branch already exists in tree " << (void*)&t << ", changing address" << endl ;
3251 
3252  } else {
3253 
3254  TString format(cleanName);
3255  format.Append("/D");
3256  branch = t.Branch(cleanName, &_value, (const Text_t*)format, bufSize);
3257  branch->SetCompressionLevel(1) ;
3258  // cout << "RooAbsReal::attachToTree(" << cleanName << "): creating new branch in tree " << (void*)&t << endl ;
3259  }
3260 
3261 }
3262 
3263 
3264 
3265 ////////////////////////////////////////////////////////////////////////////////
3266 /// Fill the tree branch that associated with this object with its current value
3267 
3269 {
3270  // First determine if branch is taken
3271  TBranch* branch = t.GetBranch(cleanBranchName()) ;
3272  if (!branch) {
3273  coutE(Eval) << "RooAbsReal::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree: " << cleanBranchName() << endl ;
3274  assert(0) ;
3275  }
3276  branch->Fill() ;
3277 
3278 }
3279 
3280 
3281 
3282 ////////////////////////////////////////////////////////////////////////////////
3283 /// (De)Activate associated tree branch
3284 
3286 {
3287  TBranch* branch = t.GetBranch(cleanBranchName()) ;
3288  if (branch) {
3289  t.SetBranchStatus(cleanBranchName(),active?1:0) ;
3290  }
3291 }
3292 
3293 
3294 
3295 ////////////////////////////////////////////////////////////////////////////////
3296 /// Create a RooRealVar fundamental object with our properties. The new
3297 /// object will be created without any fit limits.
3298 
3299 RooAbsArg *RooAbsReal::createFundamental(const char* newname) const
3300 {
3301  RooRealVar *fund= new RooRealVar(newname?newname:GetName(),GetTitle(),_value,getUnit());
3302  fund->removeRange();
3303  fund->setPlotLabel(getPlotLabel());
3304  fund->setAttribute("fundamentalCopy");
3305  return fund;
3306 }
3307 
3308 
3309 
3310 ////////////////////////////////////////////////////////////////////////////////
3311 /// Utility function for use in getAnalyticalIntegral(). If the
3312 /// content of proxy 'a' occurs in set 'allDeps' then the argument
3313 /// held in 'a' is copied from allDeps to analDeps
3314 
3316  const RooArgProxy& a) const
3317 {
3318  TList nameList ;
3319  nameList.Add(new TObjString(a.absArg()->GetName())) ;
3320  Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3321  nameList.Delete() ;
3322  return result ;
3323 }
3324 
3325 
3326 
3327 ////////////////////////////////////////////////////////////////////////////////
3328 /// Utility function for use in getAnalyticalIntegral(). If the
3329 /// contents of proxies a,b occur in set 'allDeps' then the arguments
3330 /// held in a,b are copied from allDeps to analDeps
3331 
3333  const RooArgProxy& a, const RooArgProxy& b) const
3334 {
3335  TList nameList ;
3336  nameList.Add(new TObjString(a.absArg()->GetName())) ;
3337  nameList.Add(new TObjString(b.absArg()->GetName())) ;
3338  Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3339  nameList.Delete() ;
3340  return result ;
3341 }
3342 
3343 
3344 
3345 ////////////////////////////////////////////////////////////////////////////////
3346 /// Utility function for use in getAnalyticalIntegral(). If the
3347 /// contents of proxies a,b,c occur in set 'allDeps' then the arguments
3348 /// held in a,b,c are copied from allDeps to analDeps
3349 
3351  const RooArgProxy& a, const RooArgProxy& b,
3352  const RooArgProxy& c) const
3353 {
3354  TList nameList ;
3355  nameList.Add(new TObjString(a.absArg()->GetName())) ;
3356  nameList.Add(new TObjString(b.absArg()->GetName())) ;
3357  nameList.Add(new TObjString(c.absArg()->GetName())) ;
3358  Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3359  nameList.Delete() ;
3360  return result ;
3361 }
3362 
3363 
3364 
3365 ////////////////////////////////////////////////////////////////////////////////
3366 /// Utility function for use in getAnalyticalIntegral(). If the
3367 /// contents of proxies a,b,c,d occur in set 'allDeps' then the arguments
3368 /// held in a,b,c,d are copied from allDeps to analDeps
3369 
3371  const RooArgProxy& a, const RooArgProxy& b,
3372  const RooArgProxy& c, const RooArgProxy& d) const
3373 {
3374  TList nameList ;
3375  nameList.Add(new TObjString(a.absArg()->GetName())) ;
3376  nameList.Add(new TObjString(b.absArg()->GetName())) ;
3377  nameList.Add(new TObjString(c.absArg()->GetName())) ;
3378  nameList.Add(new TObjString(d.absArg()->GetName())) ;
3379  Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3380  nameList.Delete() ;
3381  return result ;
3382 }
3383 
3384 
3385 ////////////////////////////////////////////////////////////////////////////////
3386 /// Utility function for use in getAnalyticalIntegral(). If the
3387 /// contents of 'refset' occur in set 'allDeps' then the arguments
3388 /// held in 'refset' are copied from allDeps to analDeps.
3389 
3391  const RooArgSet& refset) const
3392 {
3393  TList nameList ;
3394  TIterator* iter = refset.createIterator() ;
3395  RooAbsArg* arg ;
3396  while ((arg=(RooAbsArg*)iter->Next())) {
3397  nameList.Add(new TObjString(arg->GetName())) ;
3398  }
3399  delete iter ;
3400 
3401  Bool_t result = matchArgsByName(allDeps,analDeps,nameList) ;
3402  nameList.Delete() ;
3403  return result ;
3404 }
3405 
3406 
3407 
3408 ////////////////////////////////////////////////////////////////////////////////
3409 /// Check if allArgs contains matching elements for each name in nameList. If it does,
3410 /// add the corresponding args from allArgs to matchedArgs and return kTRUE. Otherwise
3411 /// return kFALSE and do not change matchedArgs.
3412 
3414  const TList &nameList) const
3415 {
3416  RooArgSet matched("matched");
3417  TIterator *iterator= nameList.MakeIterator();
3418  TObjString *name = 0;
3419  Bool_t isMatched(kTRUE);
3420  while((isMatched && (name= (TObjString*)iterator->Next()))) {
3421  RooAbsArg *found= allArgs.find(name->String().Data());
3422  if(found) {
3423  matched.add(*found);
3424  }
3425  else {
3426  isMatched= kFALSE;
3427  }
3428  }
3429 
3430  // nameList may not contain multiple entries with the same name
3431  // that are both matched
3432  if (isMatched && (matched.getSize()!=nameList.GetSize())) {
3433  isMatched = kFALSE ;
3434  }
3435 
3436  delete iterator;
3437  if(isMatched) matchedArgs.add(matched);
3438  return isMatched;
3439 }
3440 
3441 
3442 
3443 ////////////////////////////////////////////////////////////////////////////////
3444 /// Returns the default numeric integration configuration for all RooAbsReals
3445 
3447 {
3448  return &RooNumIntConfig::defaultConfig() ;
3449 }
3450 
3451 
3452 ////////////////////////////////////////////////////////////////////////////////
3453 /// Returns the specialized integrator configuration for _this_ RooAbsReal.
3454 /// If this object has no specialized configuration, a null pointer is returned.
3455 
3457 {
3458  return _specIntegratorConfig ;
3459 }
3460 
3461 
3462 ////////////////////////////////////////////////////////////////////////////////
3463 /// Returns the specialized integrator configuration for _this_ RooAbsReal.
3464 /// If this object has no specialized configuration, a null pointer is returned,
3465 /// unless createOnTheFly is kTRUE in which case a clone of the default integrator
3466 /// configuration is created, installed as specialized configuration, and returned
3467 
3469 {
3470  if (!_specIntegratorConfig && createOnTheFly) {
3472  }
3473  return _specIntegratorConfig ;
3474 }
3475 
3476 
3477 
3478 ////////////////////////////////////////////////////////////////////////////////
3479 /// Return the numeric integration configuration used for this object. If
3480 /// a specialized configuration was associated with this object, that configuration
3481 /// is returned, otherwise the default configuration for all RooAbsReals is returned
3482 
3484 {
3485  const RooNumIntConfig* config = specialIntegratorConfig() ;
3486  if (config) return config ;
3487  return defaultIntegratorConfig() ;
3488 }
3489 
3490 
3491 ////////////////////////////////////////////////////////////////////////////////
3492 /// Return the numeric integration configuration used for this object. If
3493 /// a specialized configuration was associated with this object, that configuration
3494 /// is returned, otherwise the default configuration for all RooAbsReals is returned
3495 
3497 {
3499  if (config) return config ;
3500  return defaultIntegratorConfig() ;
3501 }
3502 
3503 
3504 
3505 ////////////////////////////////////////////////////////////////////////////////
3506 /// Set the given integrator configuration as default numeric integration
3507 /// configuration for this object
3508 
3510 {
3511  if (_specIntegratorConfig) {
3512  delete _specIntegratorConfig ;
3513  }
3514  _specIntegratorConfig = new RooNumIntConfig(config) ;
3515 }
3516 
3517 
3518 
3519 ////////////////////////////////////////////////////////////////////////////////
3520 /// Remove the specialized numeric integration configuration associated
3521 /// with this object
3522 
3524 {
3525  if (_specIntegratorConfig) {
3526  delete _specIntegratorConfig ;
3527  }
3528  _specIntegratorConfig = 0 ;
3529 }
3530 
3531 
3532 
3533 
3534 ////////////////////////////////////////////////////////////////////////////////
3535 /// Interface function to force use of a given set of observables
3536 /// to interpret function value. Needed for functions or p.d.f.s
3537 /// whose shape depends on the choice of normalization such as
3538 /// RooAddPdf
3539 
3541 {
3542 }
3543 
3544 
3545 
3546 
3547 ////////////////////////////////////////////////////////////////////////////////
3548 /// Interface function to force use of a given normalization range
3549 /// to interpret function value. Needed for functions or p.d.f.s
3550 /// whose shape depends on the choice of normalization such as
3551 /// RooAddPdf
3552 
3554 {
3555 }
3556 
3557 
3558 
3559 ////////////////////////////////////////////////////////////////////////////////
3560 /// Activate cache validation mode
3561 
3563 {
3564  _cacheCheck = flag ;
3565 }
3566 
3567 
3568 
3569 ////////////////////////////////////////////////////////////////////////////////
3570 /// Advertise capability to determine maximum value of function for given set of
3571 /// observables. If no direct generator method is provided, this information
3572 /// will assist the accept/reject generator to operate more efficiently as
3573 /// it can skip the initial trial sampling phase to empirically find the function
3574 /// maximum
3575 
3576 Int_t RooAbsReal::getMaxVal(const RooArgSet& /*vars*/) const
3577 {
3578  return 0 ;
3579 }
3580 
3581 
3582 
3583 ////////////////////////////////////////////////////////////////////////////////
3584 /// Return maximum value for set of observables identified by code assigned
3585 /// in getMaxVal
3586 
3588 {
3589  assert(1) ;
3590  return 0 ;
3591 }
3592 
3593 
3594 
3595 ////////////////////////////////////////////////////////////////////////////////
3596 /// Interface to insert remote error logging messages received by RooRealMPFE into current error loggin stream
3597 
3598 void RooAbsReal::logEvalError(const RooAbsReal* originator, const char* origName, const char* message, const char* serverValueString)
3599 {
3600  if (_evalErrorMode==Ignore) {
3601  return ;
3602  }
3603 
3604  if (_evalErrorMode==CountErrors) {
3605  _evalErrorCount++ ;
3606  return ;
3607  }
3608 
3609  static Bool_t inLogEvalError = kFALSE ;
3610 
3611  if (inLogEvalError) {
3612  return ;
3613  }
3614  inLogEvalError = kTRUE ;
3615 
3616  EvalError ee ;
3617  ee.setMessage(message) ;
3618 
3619  if (serverValueString) {
3620  ee.setServerValues(serverValueString) ;
3621  }
3622 
3623  if (_evalErrorMode==PrintErrors) {
3624  oocoutE((TObject*)0,Eval) << "RooAbsReal::logEvalError(" << "<STATIC>" << ") evaluation error, " << endl
3625  << " origin : " << origName << endl
3626  << " message : " << ee._msg << endl
3627  << " server values: " << ee._srvval << endl ;
3628  } else if (_evalErrorMode==CollectErrors) {
3629  _evalErrorList[originator].first = origName ;
3630  _evalErrorList[originator].second.push_back(ee) ;
3631  }
3632 
3633 
3634  inLogEvalError = kFALSE ;
3635 }
3636 
3637 
3638 
3639 ////////////////////////////////////////////////////////////////////////////////
3640 /// Log evaluation error message. Evaluation errors may be routed through a different
3641 /// protocol than generic RooFit warning message (which go straight through RooMsgService)
3642 /// because evaluation errors can occur in very large numbers in the use of likelihood
3643 /// evaluations. In logEvalError mode, controlled by global method enableEvalErrorLogging()
3644 /// messages reported through this function are not printed but all stored in a list,
3645 /// along with server values at the time of reporting. Error messages logged in this
3646 /// way can be printed in a structured way, eliminating duplicates and with the ability
3647 /// to truncate the list by printEvalErrors. This is the standard mode of error logging
3648 /// during MINUIT operations. If enableEvalErrorLogging() is false, all errors
3649 /// reported through this method are passed for immediate printing through RooMsgService.
3650 /// A string with server names and values is constructed automatically for error logging
3651 /// purposes, unless a custom string with similar information is passed as argument.
3652 
3653 void RooAbsReal::logEvalError(const char* message, const char* serverValueString) const
3654 {
3655  if (_evalErrorMode==Ignore) {
3656  return ;
3657  }
3658 
3659  if (_evalErrorMode==CountErrors) {
3660  _evalErrorCount++ ;
3661  return ;
3662  }
3663 
3664  static Bool_t inLogEvalError = kFALSE ;
3665 
3666  if (inLogEvalError) {
3667  return ;
3668  }
3669  inLogEvalError = kTRUE ;
3670 
3671  EvalError ee ;
3672  ee.setMessage(message) ;
3673 
3674  if (serverValueString) {
3675  ee.setServerValues(serverValueString) ;
3676  } else {
3677  string srvval ;
3678  ostringstream oss ;
3679  Bool_t first(kTRUE) ;
3680  for (Int_t i=0 ; i<numProxies() ; i++) {
3681  RooAbsProxy* p = getProxy(i) ;
3682  if (!p) continue ;
3683  //if (p->name()[0]=='!') continue ;
3684  if (first) {
3685  first=kFALSE ;
3686  } else {
3687  oss << ", " ;
3688  }
3689  p->print(oss,kTRUE) ;
3690  }
3691  ee.setServerValues(oss.str().c_str()) ;
3692  }
3693 
3694  ostringstream oss2 ;
3696 
3697  if (_evalErrorMode==PrintErrors) {
3698  coutE(Eval) << "RooAbsReal::logEvalError(" << GetName() << ") evaluation error, " << endl
3699  << " origin : " << oss2.str() << endl
3700  << " message : " << ee._msg << endl
3701  << " server values: " << ee._srvval << endl ;
3702  } else if (_evalErrorMode==CollectErrors) {
3703  if (_evalErrorList[this].second.size() >= 2048) {
3704  // avoid overflowing the error list, so if there are very many, print
3705  // the oldest one first, and pop it off the list
3706  const EvalError& oee = _evalErrorList[this].second.front();
3707  // print to debug stream, since these would normally be suppressed, and
3708  // we do not want to increase the error count in the message service...
3709  ccoutD(Eval) << "RooAbsReal::logEvalError(" << GetName()
3710  << ") delayed evaluation error, " << endl
3711  << " origin : " << oss2.str() << endl
3712  << " message : " << oee._msg << endl
3713  << " server values: " << oee._srvval << endl ;
3714  _evalErrorList[this].second.pop_front();
3715  }
3716  _evalErrorList[this].first = oss2.str().c_str() ;
3717  _evalErrorList[this].second.push_back(ee) ;
3718  }
3719 
3720  inLogEvalError = kFALSE ;
3721  //coutE(Tracing) << "RooAbsReal::logEvalError(" << GetName() << ") message = " << message << endl ;
3722 }
3723 
3724 
3725 
3726 
3727 ////////////////////////////////////////////////////////////////////////////////
3728 /// Clear the stack of evaluation error messages
3729 
3731 {
3732  if (_evalErrorMode==PrintErrors) {
3733  return ;
3734  } else if (_evalErrorMode==CollectErrors) {
3735  _evalErrorList.clear() ;
3736  } else {
3737  _evalErrorCount = 0 ;
3738  }
3739 }
3740 
3741 
3742 
3743 ////////////////////////////////////////////////////////////////////////////////
3744 /// Print all outstanding logged evaluation error on the given ostream. If maxPerNode
3745 /// is zero, only the number of errors for each source (object with unique name) is listed.
3746 /// If maxPerNode is greater than zero, up to maxPerNode detailed error messages are shown
3747 /// per source of errors. A truncation message is shown if there were more errors logged
3748 /// than shown.
3749 
3750 void RooAbsReal::printEvalErrors(ostream& os, Int_t maxPerNode)
3751 {
3752  if (_evalErrorMode == CountErrors) {
3753  os << _evalErrorCount << " errors counted" << endl ;
3754  }
3755 
3756  if (maxPerNode<0) return ;
3757 
3758  map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter = _evalErrorList.begin() ;
3759 
3760  for(;iter!=_evalErrorList.end() ; ++iter) {
3761  if (maxPerNode==0) {
3762 
3763  // Only print node name with total number of errors
3764  os << iter->second.first ;
3765  //iter->first->printStream(os,kName|kClassName|kArgs,kInline) ;
3766  os << " has " << iter->second.second.size() << " errors" << endl ;
3767 
3768  } else {
3769 
3770  // Print node name and details of 'maxPerNode' errors
3771  os << iter->second.first << endl ;
3772  //iter->first->printStream(os,kName|kClassName|kArgs,kSingleLine) ;
3773 
3774  Int_t i(0) ;
3775  std::list<EvalError>::iterator iter2 = iter->second.second.begin() ;
3776  for(;iter2!=iter->second.second.end() ; ++iter2, i++) {
3777  os << " " << iter2->_msg << " @ " << iter2->_srvval << endl ;
3778  if (i>maxPerNode) {
3779  os << " ... (remaining " << iter->second.second.size() - maxPerNode << " messages suppressed)" << endl ;
3780  break ;
3781  }
3782  }
3783  }
3784  }
3785 }
3786 
3787 
3788 
3789 ////////////////////////////////////////////////////////////////////////////////
3790 /// Return the number of logged evaluation errors since the last clearing.
3791 
3793 {
3794  if (_evalErrorMode==CountErrors) {
3795  return _evalErrorCount ;
3796  }
3797 
3798  Int_t ntot(0) ;
3799  map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter = _evalErrorList.begin() ;
3800  for(;iter!=_evalErrorList.end() ; ++iter) {
3801  ntot += iter->second.second.size() ;
3802  }
3803  return ntot ;
3804 }
3805 
3806 
3807 
3808 ////////////////////////////////////////////////////////////////////////////////
3809 /// Fix the interpretation of the coefficient of any RooAddPdf component in
3810 /// the expression tree headed by this object to the given set of observables.
3811 ///
3812 /// If the force flag is false, the normalization choice is only fixed for those
3813 /// RooAddPdf components that have the default 'automatic' interpretation of
3814 /// coefficients (i.e. the interpretation is defined by the observables passed
3815 /// to getVal()). If force is true, also RooAddPdf that already have a fixed
3816 /// interpretation are changed to a new fixed interpretation.
3817 
3819 {
3820  RooArgSet* compSet = getComponents() ;
3821  TIterator* iter = compSet->createIterator() ;
3822  RooAbsArg* arg ;
3823  while((arg=(RooAbsArg*)iter->Next())) {
3824  RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
3825  if (pdf) {
3826  if (addNormSet.getSize()>0) {
3827  pdf->selectNormalization(&addNormSet,force) ;
3828  } else {
3829  pdf->selectNormalization(0,force) ;
3830  }
3831  }
3832  }
3833  delete iter ;
3834  delete compSet ;
3835 }
3836 
3837 
3838 
3839 ////////////////////////////////////////////////////////////////////////////////
3840 /// Fix the interpretation of the coefficient of any RooAddPdf component in
3841 /// the expression tree headed by this object to the given set of observables.
3842 ///
3843 /// If the force flag is false, the normalization range choice is only fixed for those
3844 /// RooAddPdf components that currently use the default full domain to interpret their
3845 /// coefficients. If force is true, also RooAddPdf that already have a fixed
3846 /// interpretation range are changed to a new fixed interpretation range.
3847 
3848 void RooAbsReal::fixAddCoefRange(const char* rangeName, Bool_t force)
3849 {
3850  RooArgSet* compSet = getComponents() ;
3851  TIterator* iter = compSet->createIterator() ;
3852  RooAbsArg* arg ;
3853  while((arg=(RooAbsArg*)iter->Next())) {
3854  RooAbsPdf* pdf = dynamic_cast<RooAbsPdf*>(arg) ;
3855  if (pdf) {
3856  pdf->selectNormalizationRange(rangeName,force) ;
3857  }
3858  }
3859  delete iter ;
3860  delete compSet ;
3861 }
3862 
3863 
3864 
3865 ////////////////////////////////////////////////////////////////////////////////
3866 /// Interface method for function objects to indicate their prefferred order of observables
3867 /// for scanning their values into a (multi-dimensional) histogram or RooDataSet. The observables
3868 /// to be ordered are offered in argument 'obs' and should be copied in their preferred
3869 /// order into argument 'orderdObs', This default implementation indicates no preference
3870 /// and copies the original order of 'obs' into 'orderedObs'
3871 
3873 {
3874  // Dummy implementation, do nothing
3875  orderedObs.removeAll() ;
3876  orderedObs.add(obs) ;
3877 }
3878 
3879 
3880 
3881 ////////////////////////////////////////////////////////////////////////////////
3882 /// Create a running integral over this function, i.e. given a f(x), create an object
3883 /// representing 'int[x_lo,x] f(x_prime) dx_prime'
3884 
3886 {
3887  return createRunningIntegral(iset,RooFit::SupNormSet(nset)) ;
3888 }
3889 
3890 
3891 
3892 ////////////////////////////////////////////////////////////////////////////////
3893 /// Create an object that represents the running integral of the function over one or more observables listed in iset, i.e.
3894 ///
3895 /// int[x_lo,x] f(x_prime) dx_prime
3896 ///
3897 /// The actual integration calculation is only performed when the return object is evaluated. The name
3898 /// of the integral object is automatically constructed from the name of the input function, the variables
3899 /// it integrates and the range integrates over. The default strategy to calculate the running integrals is
3900 ///
3901 /// - If the integrand (this object) supports analytical integration, construct an integral object
3902 /// that calculate the running integrals value by calculating the analytical integral each
3903 /// time the running integral object is evaluated
3904 ///
3905 /// - If the integrand (this object) requires numeric integration to construct the running integral
3906 /// create an object of class RooNumRunningInt which first samples the entire function and integrates
3907 /// the sampled function numerically. This method has superior performance as there is no need to
3908 /// perform a full (numeric) integration for each evaluation of the running integral object, but
3909 /// only when one of its parameters has changed.
3910 ///
3911 /// The choice of strategy can be changed with the ScanAll() argument, which forces the use of the
3912 /// scanning technique implemented in RooNumRunningInt for all use cases, and with the ScanNone()
3913 /// argument which forces the 'integrate each evaluation' technique for all use cases. The sampling
3914 /// granularity for the scanning technique can be controlled with the ScanParameters technique
3915 /// which allows to specify the number of samples to be taken, and to which order the resulting
3916 /// running integral should be interpolated. The default values are 1000 samples and 2nd order
3917 /// interpolation.
3918 ///
3919 /// The following named arguments are accepted
3920 ///
3921 /// SupNormSet(const RooArgSet&) -- Observables over which should be normalized _in_addition_ to the
3922 /// integration observables
3923 /// ScanParameters(Int_t nbins, -- Parameters for scanning technique of making CDF: number
3924 /// Int_t intOrder) of sampled bins and order of interpolation applied on numeric cdf
3925 /// ScanNum() -- Apply scanning technique if cdf integral involves numeric integration
3926 /// ScanAll() -- Always apply scanning technique
3927 /// ScanNone() -- Never apply scanning technique
3928 
3930  const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
3931  const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
3932 {
3933  // Define configuration for this method
3934  RooCmdConfig pc(Form("RooAbsReal::createRunningIntegral(%s)",GetName())) ;
3935  pc.defineObject("supNormSet","SupNormSet",0,0) ;
3936  pc.defineInt("numScanBins","ScanParameters",0,1000) ;
3937  pc.defineInt("intOrder","ScanParameters",1,2) ;
3938  pc.defineInt("doScanNum","ScanNum",0,1) ;
3939  pc.defineInt("doScanAll","ScanAll",0,0) ;
3940  pc.defineInt("doScanNon","ScanNone",0,0) ;
3941  pc.defineMutex("ScanNum","ScanAll","ScanNone") ;
3942 
3943  // Process & check varargs
3944  pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3945  if (!pc.ok(kTRUE)) {
3946  return 0 ;
3947  }
3948 
3949  // Extract values from named arguments
3950  const RooArgSet* snset = static_cast<const RooArgSet*>(pc.getObject("supNormSet",0)) ;
3951  RooArgSet nset ;
3952  if (snset) {
3953  nset.add(*snset) ;
3954  }
3955  Int_t numScanBins = pc.getInt("numScanBins") ;
3956  Int_t intOrder = pc.getInt("intOrder") ;
3957  Int_t doScanNum = pc.getInt("doScanNum") ;
3958  Int_t doScanAll = pc.getInt("doScanAll") ;
3959  Int_t doScanNon = pc.getInt("doScanNon") ;
3960 
3961  // If scanning technique is not requested make integral-based cdf and return
3962  if (doScanNon) {
3963  return createIntRI(iset,nset) ;
3964  }
3965  if (doScanAll) {
3966  return createScanRI(iset,nset,numScanBins,intOrder) ;
3967  }
3968  if (doScanNum) {
3970  Int_t isNum= (tmp->numIntRealVars().getSize()==1) ;
3971  delete tmp ;
3972 
3973  if (isNum) {
3974  coutI(NumIntegration) << "RooAbsPdf::createRunningIntegral(" << GetName() << ") integration over observable(s) " << iset << " involves numeric integration," << endl
3975  << " constructing cdf though numeric integration of sampled pdf in " << numScanBins << " bins and applying order "
3976  << intOrder << " interpolation on integrated histogram." << endl
3977  << " To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
3978  }
3979 
3980  return isNum ? createScanRI(iset,nset,numScanBins,intOrder) : createIntRI(iset,nset) ;
3981  }
3982  return 0 ;
3983 }
3984 
3985 
3986 
3987 ////////////////////////////////////////////////////////////////////////////////
3988 /// Utility function for createRunningIntegral that construct an object
3989 /// implementing the numeric scanning technique for calculating the running integral
3990 
3991 RooAbsReal* RooAbsReal::createScanRI(const RooArgSet& iset, const RooArgSet& nset, Int_t numScanBins, Int_t intOrder)
3992 {
3993  string name = string(GetName()) + "_NUMRUNINT_" + integralNameSuffix(iset,&nset).Data() ;
3994  RooRealVar* ivar = (RooRealVar*) iset.first() ;
3995  ivar->setBins(numScanBins,"numcdf") ;
3996  RooNumRunningInt* ret = new RooNumRunningInt(name.c_str(),name.c_str(),*this,*ivar,"numrunint") ;
3997  ret->setInterpolationOrder(intOrder) ;
3998  return ret ;
3999 }
4000 
4001 
4002 
4003 ////////////////////////////////////////////////////////////////////////////////
4004 /// Utility function for createRunningIntegral that construct an
4005 /// object implementing the standard (analytical) integration
4006 /// technique for calculating the running integral
4007 
4009 {
4010  // Make list of input arguments keeping only RooRealVars
4011  RooArgList ilist ;
4012  TIterator* iter2 = iset.createIterator() ;
4013  RooAbsArg* arg ;
4014  while((arg=(RooAbsArg*)iter2->Next())) {
4015  if (dynamic_cast<RooRealVar*>(arg)) {
4016  ilist.add(*arg) ;
4017  } else {
4018  coutW(InputArguments) << "RooAbsPdf::createRunningIntegral(" << GetName() << ") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << endl ;
4019  }
4020  }
4021  delete iter2 ;
4022 
4023  RooArgList cloneList ;
4024  RooArgList loList ;
4025  RooArgSet clonedBranchNodes ;
4026 
4027  // Setup customizer that stores all cloned branches in our non-owning list
4028  RooCustomizer cust(*this,"cdf") ;
4029  cust.setCloneBranchSet(clonedBranchNodes) ;
4030  cust.setOwning(kFALSE) ;
4031 
4032  // Make integration observable x_prime for each observable x as well as an x_lowbound
4033  TIterator* iter = ilist.createIterator() ;
4034  RooRealVar* rrv ;
4035  while((rrv=(RooRealVar*)iter->Next())) {
4036 
4037  // Make clone x_prime of each c.d.f observable x represening running integral
4038  RooRealVar* cloneArg = (RooRealVar*) rrv->clone(Form("%s_prime",rrv->GetName())) ;
4039  cloneList.add(*cloneArg) ;
4040  cust.replaceArg(*rrv,*cloneArg) ;
4041 
4042  // Make clone x_lowbound of each c.d.f observable representing low bound of x
4043  RooRealVar* cloneLo = (RooRealVar*) rrv->clone(Form("%s_lowbound",rrv->GetName())) ;
4044  cloneLo->setVal(rrv->getMin()) ;
4045  loList.add(*cloneLo) ;
4046 
4047  // Make parameterized binning from [x_lowbound,x] for each x_prime
4048  RooParamBinning pb(*cloneLo,*rrv,100) ;
4049  cloneArg->setBinning(pb,"CDF") ;
4050 
4051  }
4052  delete iter ;
4053 
4054  RooAbsReal* tmp = (RooAbsReal*) cust.build() ;
4055 
4056  // Construct final normalization set for c.d.f = integrated observables + any extra specified by user
4057  RooArgSet finalNset(nset) ;
4058  finalNset.add(cloneList,kTRUE) ;
4059  RooAbsReal* cdf = tmp->createIntegral(cloneList,finalNset,"CDF") ;
4060 
4061  // Transfer ownership of cloned items to top-level c.d.f object
4062  cdf->addOwnedComponents(*tmp) ;
4063  cdf->addOwnedComponents(cloneList) ;
4064  cdf->addOwnedComponents(loList) ;
4065 
4066  return cdf ;
4067 }
4068 
4069 
4070 ////////////////////////////////////////////////////////////////////////////////
4071 /// Return a RooFunctor object bound to this RooAbsReal with given definition of observables
4072 /// and parameters
4073 
4074 RooFunctor* RooAbsReal::functor(const RooArgList& obs, const RooArgList& pars, const RooArgSet& nset) const
4075 {
4076  RooArgSet* realObs = getObservables(obs) ;
4077  if (realObs->getSize() != obs.getSize()) {
4078  coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4079  delete realObs ;
4080  return 0 ;
4081  }
4082  RooArgSet* realPars = getObservables(pars) ;
4083  if (realPars->getSize() != pars.getSize()) {
4084  coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4085  delete realPars ;
4086  return 0 ;
4087  }
4088  delete realObs ;
4089  delete realPars ;
4090 
4091  return new RooFunctor(*this,obs,pars,nset) ;
4092 }
4093 
4094 
4095 
4096 ////////////////////////////////////////////////////////////////////////////////
4097 /// Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables
4098 /// and parameters
4099 
4100 TF1* RooAbsReal::asTF(const RooArgList& obs, const RooArgList& pars, const RooArgSet& nset) const
4101 {
4102  // Check that specified input are indeed variables of this function
4103  RooArgSet* realObs = getObservables(obs) ;
4104  if (realObs->getSize() != obs.getSize()) {
4105  coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4106  delete realObs ;
4107  return 0 ;
4108  }
4109  RooArgSet* realPars = getObservables(pars) ;
4110  if (realPars->getSize() != pars.getSize()) {
4111  coutE(InputArguments) << "RooAbsReal::functor(" << GetName() << ") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4112  delete realPars ;
4113  return 0 ;
4114  }
4115  delete realObs ;
4116  delete realPars ;
4117 
4118  // Check that all obs and par are of type RooRealVar
4119  for (int i=0 ; i<obs.getSize() ; i++) {
4120  if (dynamic_cast<RooRealVar*>(obs.at(i))==0) {
4121  coutE(ObjectHandling) << "RooAbsReal::asTF(" << GetName() << ") ERROR: proposed observable " << obs.at(0)->GetName() << " is not of type RooRealVar" << endl ;
4122  return 0 ;
4123  }
4124  }
4125  for (int i=0 ; i<pars.getSize() ; i++) {
4126  if (dynamic_cast<RooRealVar*>(pars.at(i))==0) {
4127  coutE(ObjectHandling) << "RooAbsReal::asTF(" << GetName() << ") ERROR: proposed parameter " << pars.at(0)->GetName() << " is not of type RooRealVar" << endl ;
4128  return 0 ;
4129  }
4130  }
4131 
4132  // Create functor and TFx of matching dimension
4133  TF1* tf=0 ;
4134  RooFunctor* f ;
4135  switch(obs.getSize()) {
4136  case 1: {
4137  RooRealVar* x = (RooRealVar*)obs.at(0) ;
4138  f = functor(obs,pars,nset) ;
4139  tf = new TF1(GetName(),f,x->getMin(),x->getMax(),pars.getSize()) ;
4140  break ;
4141  }
4142  case 2: {
4143  RooRealVar* x = (RooRealVar*)obs.at(0) ;
4144  RooRealVar* y = (RooRealVar*)obs.at(1) ;
4145  f = functor(obs,pars,nset) ;
4146  tf = new TF2(GetName(),f,x->getMin(),x->getMax(),y->getMin(),y->getMax(),pars.getSize()) ;
4147  break ;
4148  }
4149  case 3: {
4150  RooRealVar* x = (RooRealVar*)obs.at(0) ;
4151  RooRealVar* y = (RooRealVar*)obs.at(1) ;
4152  RooRealVar* z = (RooRealVar*)obs.at(2) ;
4153  f = functor(obs,pars,nset) ;
4154  tf = new TF3(GetName(),f,x->getMin(),x->getMax(),y->getMin(),y->getMax(),z->getMin(),z->getMax(),pars.getSize()) ;
4155  break ;
4156  }
4157  default:
4158  coutE(InputArguments) << "RooAbsReal::asTF(" << GetName() << ") ERROR: " << obs.getSize()
4159  << " observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << endl ;
4160  return 0 ;
4161  }
4162 
4163  // Set initial parameter values of TFx to those of RooRealVars
4164  for (int i=0 ; i<pars.getSize() ; i++) {
4165  RooRealVar* p = (RooRealVar*) pars.at(i) ;
4166  tf->SetParameter(i,p->getVal()) ;
4167  tf->SetParName(i,p->GetName()) ;
4168  //tf->SetParLimits(i,p->getMin(),p->getMax()) ;
4169  }
4170 
4171  return tf ;
4172 }
4173 
4174 
4175 ////////////////////////////////////////////////////////////////////////////////
4176 /// Return function representing first, second or third order derivative of this function
4177 
4179 {
4180  string name=Form("%s_DERIV_%s",GetName(),obs.GetName()) ;
4181  string title=Form("Derivative of %s w.r.t %s ",GetName(),obs.GetName()) ;
4182  return new RooDerivative(name.c_str(),title.c_str(),*this,obs,order,eps) ;
4183 }
4184 
4185 
4186 
4187 ////////////////////////////////////////////////////////////////////////////////
4188 /// Return function representing first, second or third order derivative of this function
4189 
4191 {
4192  string name=Form("%s_DERIV_%s",GetName(),obs.GetName()) ;
4193  string title=Form("Derivative of %s w.r.t %s ",GetName(),obs.GetName()) ;
4194  return new RooDerivative(name.c_str(),title.c_str(),*this,obs,normSet,order,eps) ;
4195 }
4196 
4197 
4198 
4199 ////////////////////////////////////////////////////////////////////////////////
4200 /// Return function representing moment of function of given order. If central is
4201 /// true, the central moment is given <(x-<x>)^2>
4202 
4204 {
4205  string name=Form("%s_MOMENT_%d%s_%s",GetName(),order,(central?"C":""),obs.GetName()) ;
4206  string title=Form("%sMoment of order %d of %s w.r.t %s ",(central?"Central ":""),order,GetName(),obs.GetName()) ;
4207  if (order==1) return new RooFirstMoment(name.c_str(),title.c_str(),*this,obs) ;
4208  if (order==2) return new RooSecondMoment(name.c_str(),title.c_str(),*this,obs,central,takeRoot) ;
4209  return new RooMoment(name.c_str(),title.c_str(),*this,obs,order,central,takeRoot) ;
4210 }
4211 
4212 
4213 ////////////////////////////////////////////////////////////////////////////////
4214 /// Return function representing moment of p.d.f (normalized w.r.t given observables) of given order. If central is
4215 /// true, the central moment is given <(x-<x>)^2>. If intNormObs is true, the moment of the function integrated over
4216 /// all normalization observables is returned.
4217 
4218 RooAbsMoment* RooAbsReal::moment(RooRealVar& obs, const RooArgSet& normObs, Int_t order, Bool_t central, Bool_t takeRoot, Bool_t intNormObs)
4219 {
4220  string name=Form("%s_MOMENT_%d%s_%s",GetName(),order,(central?"C":""),obs.GetName()) ;
4221  string title=Form("%sMoment of order %d of %s w.r.t %s ",(central?"Central ":""),order,GetName(),obs.GetName()) ;
4222 
4223  if (order==1) return new RooFirstMoment(name.c_str(),title.c_str(),*this,obs,normObs,intNormObs) ;
4224  if (order==2) return new RooSecondMoment(name.c_str(),title.c_str(),*this,obs,normObs,central,takeRoot,intNormObs) ;
4225  return new RooMoment(name.c_str(),title.c_str(),*this,obs,normObs,order,central,takeRoot,intNormObs) ;
4226 }
4227 
4228 
4229 
4230 ////////////////////////////////////////////////////////////////////////////////
4231 ///
4232 /// Return value of x (in range xmin,xmax) at which function equals yval.
4233 /// (Calculation is performed with Brent root finding algorithm)
4234 
4236 {
4237  Double_t result(0) ;
4238  RooBrentRootFinder(RooRealBinding(*this,x)).findRoot(result,xmin,xmax,yval) ;
4239  return result ;
4240 }
4241 
4242 
4243 
4244 
4245 ////////////////////////////////////////////////////////////////////////////////
4246 
4248 {
4249  return new RooGenFunction(*this,x,RooArgList(),nset.getSize()>0?nset:RooArgSet(x)) ;
4250 }
4251 
4252 
4253 
4254 ////////////////////////////////////////////////////////////////////////////////
4255 
4257 {
4258  return new RooMultiGenFunction(*this,observables,RooArgList(),nset.getSize()>0?nset:observables) ;
4259 }
4260 
4261 
4262 
4263 
4264 ////////////////////////////////////////////////////////////////////////////////
4265 /// Perform a chi^2 fit to given histogram By default the fit is executed through the MINUIT
4266 /// commands MIGRAD, HESSE in succession
4267 ///
4268 /// The following named arguments are supported
4269 ///
4270 /// Options to control construction of -log(L)
4271 /// ------------------------------------------
4272 /// Range(const char* name) -- Fit only data inside range with given name
4273 /// 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.
4274 /// Multiple comma separated range names can be specified.
4275 /// NumCPU(int num) -- Parallelize NLL calculation on num CPUs
4276 /// Optimize(Bool_t flag) -- Activate constant term optimization (on by default)
4277 ///
4278 /// Options to control flow of fit procedure
4279 /// ----------------------------------------
4280 /// InitialHesse(Bool_t flag) -- Flag controls if HESSE before MIGRAD as well, off by default
4281 /// Hesse(Bool_t flag) -- Flag controls if HESSE is run after MIGRAD, on by default
4282 /// Minos(Bool_t flag) -- Flag controls if MINOS is run after HESSE, on by default
4283 /// Minos(const RooArgSet& set) -- Only run MINOS on given subset of arguments
4284 /// Save(Bool_t flag) -- Flac controls if RooFitResult object is produced and returned, off by default
4285 /// Strategy(Int_t flag) -- Set Minuit strategy (0 through 2, default is 1)
4286 /// FitOptions(const char* optStr) -- Steer fit with classic options string (for backward compatibility). Use of this option
4287 /// excludes use of any of the new style steering options.
4288 ///
4289 /// Options to control informational output
4290 /// ---------------------------------------
4291 /// Verbose(Bool_t flag) -- Flag controls if verbose output is printed (NLL, parameter changes during fit
4292 /// Timer(Bool_t flag) -- Time CPU and wall clock consumption of fit steps, off by default
4293 /// PrintLevel(Int_t level) -- Set Minuit print level (-1 through 3, default is 1). At -1 all RooFit informational
4294 /// messages are suppressed as well
4295 /// Warnings(Bool_t flag) -- Enable or disable MINUIT warnings (enabled by default)
4296 /// PrintEvalErrors(Int_t numErr) -- Control number of p.d.f evaluation errors printed per likelihood evaluation. A negative
4297 /// value suppress output completely, a zero value will only print the error count per p.d.f component,
4298 /// a positive value is will print details of each error up to numErr messages per p.d.f component.
4299 ///
4300 ///
4301 
4303  const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4304  const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4305 {
4306  RooLinkedList l ;
4307  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4308  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4309  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4310  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4311  return chi2FitTo(data,l) ;
4312 
4313 }
4314 
4315 
4316 
4317 ////////////////////////////////////////////////////////////////////////////////
4318 /// Internal back-end function to steer chi2 fits
4319 
4321 {
4322  // Select the pdf-specific commands
4323  RooCmdConfig pc(Form("RooAbsPdf::chi2FitTo(%s)",GetName())) ;
4324 
4325  // Pull arguments to be passed to chi2 construction from list
4326  RooLinkedList fitCmdList(cmdList) ;
4327  RooLinkedList chi2CmdList = pc.filterCmdList(fitCmdList,"Range,RangeWithName,NumCPU,Optimize") ;
4328 
4329  RooAbsReal* chi2 = createChi2(data,chi2CmdList) ;
4330  RooFitResult* ret = chi2FitDriver(*chi2,fitCmdList) ;
4331 
4332  // Cleanup
4333  delete chi2 ;
4334  return ret ;
4335 }
4336 
4337 
4338 
4339 
4340 ////////////////////////////////////////////////////////////////////////////////
4341 /// Create a chi-2 from a histogram and this function.
4342 ///
4343 /// The following named arguments are supported
4344 ///
4345 /// Options to control construction of the chi^2
4346 /// ------------------------------------------
4347 /// DataError(RooAbsData::ErrorType) -- Choose between Poisson errors and Sum-of-weights errors
4348 /// NumCPU(Int_t) -- Activate parallel processing feature on N processes
4349 /// Range() -- Calculate Chi2 only in selected region
4350 
4352  const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4353  const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4354 {
4355  string name = Form("chi2_%s_%s",GetName(),data.GetName()) ;
4356 
4357  return new RooChi2Var(name.c_str(),name.c_str(),*this,data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4358 }
4359 
4360 
4361 
4362 
4363 ////////////////////////////////////////////////////////////////////////////////
4364 /// Internal back-end function to create a chi2
4365 
4367 {
4368  // Fill array of commands
4369  const RooCmdArg* cmds[8] ;
4370  TIterator* iter = cmdList.MakeIterator() ;
4371  Int_t i(0) ;
4372  RooCmdArg* arg ;
4373  while((arg=(RooCmdArg*)iter->Next())) {
4374  cmds[i++] = arg ;
4375  }
4376  for (;i<8 ; i++) {
4377  cmds[i] = &RooCmdArg::none() ;
4378  }
4379  delete iter ;
4380 
4381  return createChi2(data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4382 
4383 }
4384 
4385 
4386 
4387 
4388 
4389 ////////////////////////////////////////////////////////////////////////////////
4390 /// Create a chi-2 from a series of x and y value stored in a dataset.
4391 /// The y values can either be the event weights, or can be another column designated
4392 /// by the YVar() argument. The y value must have errors defined for the chi-2 to
4393 /// be well defined.
4394 ///
4395 /// The following named arguments are supported
4396 ///
4397 /// Options to control construction of the chi^2
4398 /// ------------------------------------------
4399 /// YVar(RooRealVar& yvar) -- Designate given column in dataset as Y value
4400 /// Integrate(Bool_t flag) -- Integrate function over range specified by X errors
4401 /// rather than take value at bin center.
4402 ///
4403 /// Options to control flow of fit procedure
4404 /// ----------------------------------------
4405 /// InitialHesse(Bool_t flag) -- Flag controls if HESSE before MIGRAD as well, off by default
4406 /// Hesse(Bool_t flag) -- Flag controls if HESSE is run after MIGRAD, on by default
4407 /// Minos(Bool_t flag) -- Flag controls if MINOS is run after HESSE, on by default
4408 /// Minos(const RooArgSet& set) -- Only run MINOS on given subset of arguments
4409 /// Save(Bool_t flag) -- Flac controls if RooFitResult object is produced and returned, off by default
4410 /// Strategy(Int_t flag) -- Set Minuit strategy (0 through 2, default is 1)
4411 /// FitOptions(const char* optStr) -- Steer fit with classic options string (for backward compatibility). Use of this option
4412 /// excludes use of any of the new style steering options.
4413 ///
4414 /// Options to control informational output
4415 /// ---------------------------------------
4416 /// Verbose(Bool_t flag) -- Flag controls if verbose output is printed (NLL, parameter changes during fit
4417 /// Timer(Bool_t flag) -- Time CPU and wall clock consumption of fit steps, off by default
4418 /// PrintLevel(Int_t level) -- Set Minuit print level (-1 through 3, default is 1). At -1 all RooFit informational
4419 /// messages are suppressed as well
4420 /// Warnings(Bool_t flag) -- Enable or disable MINUIT warnings (enabled by default)
4421 /// PrintEvalErrors(Int_t numErr) -- Control number of p.d.f evaluation errors printed per likelihood evaluation. A negative
4422 /// value suppress output completely, a zero value will only print the error count per p.d.f component,
4423 /// a positive value is will print details of each error up to numErr messages per p.d.f component.
4424 
4426  const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4427  const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4428 {
4429  RooLinkedList l ;
4430  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4431  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4432  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4433  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4434  return chi2FitTo(xydata,l) ;
4435 }
4436 
4437 
4438 
4439 
4440 ////////////////////////////////////////////////////////////////////////////////
4441 /// Internal back-end function to steer chi2 fits
4442 
4444 {
4445  // Select the pdf-specific commands
4446  RooCmdConfig pc(Form("RooAbsPdf::chi2FitTo(%s)",GetName())) ;
4447 
4448  // Pull arguments to be passed to chi2 construction from list
4449  RooLinkedList fitCmdList(cmdList) ;
4450  RooLinkedList chi2CmdList = pc.filterCmdList(fitCmdList,"YVar,Integrate") ;
4451 
4452  RooAbsReal* xychi2 = createChi2(xydata,chi2CmdList) ;
4453  RooFitResult* ret = chi2FitDriver(*xychi2,fitCmdList) ;
4454 
4455  // Cleanup
4456  delete xychi2 ;
4457  return ret ;
4458 }
4459 
4460 
4461 
4462 
4463 ////////////////////////////////////////////////////////////////////////////////
4464 /// Create a chi-2 from a series of x and y value stored in a dataset.
4465 /// The y values can either be the event weights (default), or can be another column designated
4466 /// by the YVar() argument. The y value must have errors defined for the chi-2 to
4467 /// be well defined.
4468 ///
4469 /// The following named arguments are supported
4470 ///
4471 /// Options to control construction of the chi^2
4472 /// ------------------------------------------
4473 /// YVar(RooRealVar& yvar) -- Designate given column in dataset as Y value
4474 /// Integrate(Bool_t flag) -- Integrate function over range specified by X errors
4475 /// rather than take value at bin center.
4476 ///
4477 
4479  const RooCmdArg& arg3, const RooCmdArg& arg4, const RooCmdArg& arg5,
4480  const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
4481 {
4482  RooLinkedList l ;
4483  l.Add((TObject*)&arg1) ; l.Add((TObject*)&arg2) ;
4484  l.Add((TObject*)&arg3) ; l.Add((TObject*)&arg4) ;
4485  l.Add((TObject*)&arg5) ; l.Add((TObject*)&arg6) ;
4486  l.Add((TObject*)&arg7) ; l.Add((TObject*)&arg8) ;
4487  return createChi2(data,l) ;
4488 }
4489 
4490 
4491 
4492 ////////////////////////////////////////////////////////////////////////////////
4493 /// Internal back-end function to create a chi^2 from a function and a dataset
4494 
4496 {
4497  // Select the pdf-specific commands
4498  RooCmdConfig pc(Form("RooAbsPdf::fitTo(%s)",GetName())) ;
4499 
4500  pc.defineInt("integrate","Integrate",0,0) ;
4501  pc.defineObject("yvar","YVar",0,0) ;
4502 
4503  // Process and check varargs
4504  pc.process(cmdList) ;
4505  if (!pc.ok(kTRUE)) {
4506  return 0 ;
4507  }
4508 
4509  // Decode command line arguments
4510  Bool_t integrate = pc.getInt("integrate") ;
4511  RooRealVar* yvar = (RooRealVar*) pc.getObject("yvar") ;
4512 
4513  string name = Form("chi2_%s_%s",GetName(),data.GetName()) ;
4514 
4515  if (yvar) {
4516  return new RooXYChi2Var(name.c_str(),name.c_str(),*this,data,*yvar,integrate) ;
4517  } else {
4518  return new RooXYChi2Var(name.c_str(),name.c_str(),*this,data,integrate) ;
4519  }
4520 }
4521 
4522 
4523 
4524 
4525 
4526 
4527 ////////////////////////////////////////////////////////////////////////////////
4528 /// Internal driver function for chi2 fits
4529 
4531 {
4532  // Select the pdf-specific commands
4533  RooCmdConfig pc(Form("RooAbsPdf::chi2FitDriver(%s)",GetName())) ;
4534 
4535  pc.defineString("fitOpt","FitOptions",0,"") ;
4536 
4537  pc.defineInt("optConst","Optimize",0,1) ;
4538  pc.defineInt("verbose","Verbose",0,0) ;
4539  pc.defineInt("doSave","Save",0,0) ;
4540  pc.defineInt("doTimer","Timer",0,0) ;
4541  pc.defineInt("plevel","PrintLevel",0,1) ;
4542  pc.defineInt("strat","Strategy",0,1) ;
4543  pc.defineInt("initHesse","InitialHesse",0,0) ;
4544  pc.defineInt("hesse","Hesse",0,1) ;
4545  pc.defineInt("minos","Minos",0,0) ;
4546  pc.defineInt("ext","Extended",0,2) ;
4547  pc.defineInt("numee","PrintEvalErrors",0,10) ;
4548  pc.defineInt("doWarn","Warnings",0,1) ;
4549  pc.defineString("mintype","Minimizer",0,"Minuit") ;
4550  pc.defineString("minalg","Minimizer",1,"minuit") ;
4551  pc.defineObject("minosSet","Minos",0,0) ;
4552 
4553  pc.defineMutex("FitOptions","Verbose") ;
4554  pc.defineMutex("FitOptions","Save") ;
4555  pc.defineMutex("FitOptions","Timer") ;
4556  pc.defineMutex("FitOptions","Strategy") ;
4557  pc.defineMutex("FitOptions","InitialHesse") ;
4558  pc.defineMutex("FitOptions","Hesse") ;
4559  pc.defineMutex("FitOptions","Minos") ;
4560 
4561  // Process and check varargs
4562  pc.process(cmdList) ;
4563  if (!pc.ok(kTRUE)) {
4564  return 0 ;
4565  }
4566 
4567  // Decode command line arguments
4568  const char* fitOpt = pc.getString("fitOpt",0,kTRUE) ;
4569 #ifdef __ROOFIT_NOROOMINIMIZER
4570  const char* minType =0 ;
4571 #else
4572  const char* minType = pc.getString("mintype","Minuit") ;
4573  const char* minAlg = pc.getString("minalg","minuit") ;
4574 #endif
4575  Int_t optConst = pc.getInt("optConst") ;
4576  Int_t verbose = pc.getInt("verbose") ;
4577  Int_t doSave = pc.getInt("doSave") ;
4578  Int_t doTimer = pc.getInt("doTimer") ;
4579  Int_t plevel = pc.getInt("plevel") ;
4580  Int_t strat = pc.getInt("strat") ;
4581  Int_t initHesse= pc.getInt("initHesse") ;
4582  Int_t hesse = pc.getInt("hesse") ;
4583  Int_t minos = pc.getInt("minos") ;
4584  Int_t numee = pc.getInt("numee") ;
4585  Int_t doWarn = pc.getInt("doWarn") ;
4586  const RooArgSet* minosSet = static_cast<RooArgSet*>(pc.getObject("minosSet")) ;
4587 
4588  RooFitResult *ret = 0 ;
4589 
4590 #ifdef __ROOFIT_NOROOMINIMIZER
4591  if (true) {
4592 #else
4593  if ("OldMinuit" == string(minType)) {
4594 #endif
4595  // Instantiate MINUIT
4596  RooMinuit m(fcn) ;
4597 
4598  if (doWarn==0) {
4599  m.setNoWarn() ;
4600  }
4601 
4602  m.setPrintEvalErrors(numee) ;
4603  if (plevel!=1) {
4604  m.setPrintLevel(plevel) ;
4605  }
4606 
4607  if (optConst) {
4608  // Activate constant term optimization
4609  m.optimizeConst(optConst);
4610  }
4611 
4612  if (fitOpt) {
4613 
4614  // Play fit options as historically defined
4615  ret = m.fit(fitOpt) ;
4616 
4617  } else {
4618 
4619  if (verbose) {
4620  // Activate verbose options
4621  m.setVerbose(1) ;
4622  }
4623  if (doTimer) {
4624  // Activate timer options
4625  m.setProfile(1) ;
4626  }
4627 
4628  if (strat!=1) {
4629  // Modify fit strategy
4630  m.setStrategy(strat) ;
4631  }
4632 
4633  if (initHesse) {
4634  // Initialize errors with hesse
4635  m.hesse() ;
4636  }
4637 
4638  // Minimize using migrad
4639  m.migrad() ;
4640 
4641  if (hesse) {
4642  // Evaluate errors with Hesse
4643  m.hesse() ;
4644  }
4645 
4646  if (minos) {
4647  // Evaluate errs with Minos
4648  if (minosSet) {
4649  m.minos(*minosSet) ;
4650  } else {
4651  m.minos() ;
4652  }
4653  }
4654 
4655  // Optionally return fit result
4656  if (doSave) {
4657  string name = Form("fitresult_%s",fcn.GetName()) ;
4658  string title = Form("Result of fit of %s ",GetName()) ;
4659  ret = m.save(name.c_str(),title.c_str()) ;
4660  }
4661 
4662  }
4663  } else {
4664 #ifndef __ROOFIT_NOROOMINIMIZER
4665  // Instantiate MINUIT
4666  RooMinimizer m(fcn) ;
4667  m.setMinimizerType(minType);
4668 
4669  if (doWarn==0) {
4670  // m.setNoWarn() ; WVE FIX THIS
4671  }
4672 
4673  m.setPrintEvalErrors(numee) ;
4674  if (plevel!=1) {
4675  m.setPrintLevel(plevel) ;
4676  }
4677 
4678  if (optConst) {
4679  // Activate constant term optimization
4680  m.optimizeConst(optConst);
4681  }
4682 
4683  if (fitOpt) {
4684 
4685  // Play fit options as historically defined
4686  ret = m.fit(fitOpt) ;
4687 
4688  } else {
4689 
4690  if (verbose) {
4691  // Activate verbose options
4692  m.setVerbose(1) ;
4693  }
4694  if (doTimer) {
4695  // Activate timer options
4696  m.setProfile(1) ;
4697  }
4698 
4699  if (strat!=1) {
4700  // Modify fit strategy
4701  m.setStrategy(strat) ;
4702  }
4703 
4704  if (initHesse) {
4705  // Initialize errors with hesse
4706  m.hesse() ;
4707  }
4708 
4709  // Minimize using migrad
4710  m.minimize(minType, minAlg) ;
4711 
4712  if (hesse) {
4713  // Evaluate errors with Hesse
4714  m.hesse() ;
4715  }
4716 
4717  if (minos) {
4718  // Evaluate errs with Minos
4719  if (minosSet) {
4720  m.minos(*minosSet) ;
4721  } else {
4722  m.minos() ;
4723  }
4724  }
4725 
4726  // Optionally return fit result
4727  if (doSave) {
4728  string name = Form("fitresult_%s",fcn.GetName()) ;
4729  string title = Form("Result of fit of %s ",GetName()) ;
4730  ret = m.save(name.c_str(),title.c_str()) ;
4731  }
4732  }
4733 #endif
4734  }
4735 
4736  // Cleanup
4737  return ret ;
4738 
4739 }
4740 
4741 
4742 ////////////////////////////////////////////////////////////////////////////////
4743 /// Return current evaluation error logging mode.
4744 
4746 {
4747  return _evalErrorMode ;
4748 }
4749 
4750 ////////////////////////////////////////////////////////////////////////////////
4751 /// Set evaluation error logging mode. Options are
4752 ///
4753 /// PrintErrors - Print each error through RooMsgService() as it occurs
4754 /// CollectErrors - Accumulate errors, but do not print them. A subsequent call
4755 /// to printEvalErrors() will print a summary
4756 /// CountErrors - Accumulate error count, but do not print them.
4757 ///
4758 
4760 {
4761  _evalErrorMode = m;
4762 }
4763 
4764 
4765 ////////////////////////////////////////////////////////////////////////////////
4766 
4768 {
4769  RooFIter iter = paramVars.fwdIterator() ;
4770  RooAbsArg* arg ;
4771  string plist ;
4772  while((arg=iter.next())) {
4773  if (!dependsOnValue(*arg)) {
4774  coutW(InputArguments) << "RooAbsReal::setParameterizeIntegral(" << GetName()
4775  << ") function does not depend on listed parameter " << arg->GetName() << ", ignoring" << endl ;
4776  continue ;
4777  }
4778  if (plist.size()>0) plist += ":" ;
4779  plist += arg->GetName() ;
4780  }
4781  setStringAttribute("CACHEPARAMINT",plist.c_str()) ;
4782 }
4783 
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:243
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2078
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:2292
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:2173
#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:491
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:740
virtual void SetParName(Int_t ipar, const char *name)
Set name of parameter number ipar.
Definition: TF1.cxx:3337
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:1117
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:251
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:470
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 void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
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:82
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.
Definition: TLeaf.cxx:196
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:447
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:2341
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:146
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.
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:744
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:777
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:2278
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:1493
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:275
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:959
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name &#39;name&#39; with this variable.
Definition: RooRealVar.cxx:346
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.
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:1121
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:8461
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:197
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:155
virtual void setVal(Double_t value)
Set value of variable to &#39;value&#39;.
Definition: RooRealVar.cxx:205
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:266
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:1868
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:949
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:684
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:481
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:8477
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:2386
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key &#39;key&#39;.
Definition: RooAbsArg.cxx:290
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:822
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multi-line detailed printing.
Definition: RooAbsArg.cxx:1381
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:4665
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;.
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:775
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:537
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:705
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:718
TObjArray * GetListOfLeaves()
Definition: TBranch.h:195
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:189
Int_t minimize(const char *type, const char *alg=0)
Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Definition: RooPlot.cxx:1122
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:1119
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:1250
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:734
void setRange(const char *name, Double_t min, Double_t max)
Set range named &#39;name to [min,max].
Definition: RooRealVar.cxx:449
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:1263
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
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
Definition: TCollection.h:180
A TTree is a list of TBranches.
Definition: TBranch.h:59
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Definition: RooAbsArg.cxx:1084
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:797
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:732
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:850
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