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