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