Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMCStudy.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\file RooMCStudy.cxx
19\class RooMCStudy
20\ingroup Roofitcore
21
22RooMCStudy is a helper class to facilitate Monte Carlo studies
23such as 'goodness-of-fit' studies, that involve fitting a PDF
24to multiple toy Monte Carlo sets. These may be generated from either same PDF
25or from a different PDF with similar parameters.
26
27Given a fit and a generator PDF (they might be identical), RooMCStudy can produce
28toyMC samples and/or fit these.
29It accumulates the post-fit parameters of each iteration in a dataset. These can be
30retrieved using fitParams() or fitParDataSet(). This dataset additionally contains the
31variables
32- NLL: The value of the negative log-likelihood for each run.
33- ngen: The number of events generated for each run.
34
35Additional plotting routines simplify the task of plotting
36the distribution of the minimized likelihood, the fitted parameter values,
37fitted error and pull distribution.
38
39RooMCStudy provides the option to insert add-in modules
40that modify the generate-and-fit cycle and allow to perform
41extra steps in the cycle. Output of these modules can be stored
42alongside the fit results in the aggregate results dataset.
43These study modules should derive from the class RooAbsMCStudyModule.
44
45Check the RooFit tutorials
46- rf801_mcstudy.C
47- rf802_mcstudy_addons.C
48- rf803_mcstudy_addons2.C
49- rf804_mcstudy_constr.C
50for usage examples.
51**/
52
53#include "snprintf.h"
54#include <iostream>
55
56#include "RooMCStudy.h"
57#include "RooAbsMCStudyModule.h"
58
59#include "RooGenContext.h"
60#include "RooAbsPdf.h"
61#include "RooDataSet.h"
62#include "RooDataHist.h"
63#include "RooRealVar.h"
64#include "RooFitResult.h"
65#include "RooErrorVar.h"
66#include "RooFormulaVar.h"
67#include "RooArgList.h"
68#include "RooPlot.h"
69#include "RooRandom.h"
70#include "RooCmdConfig.h"
71#include "RooGlobalFunc.h"
72#include "RooPullVar.h"
73#include "RooMsgService.h"
74#include "RooProdPdf.h"
75#include "RooWorkspace.h"
76
77using namespace std ;
78
80 ;
81
82
83/**
84Construct Monte Carlo Study Manager. This class automates generating data from a given PDF,
85fitting the PDF to data and accumulating the fit statistics.
86
87\param[in] model The PDF to be studied
88\param[in] observables The variables of the PDF to be considered observables
89\param[in] arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8 Optional arguments according to table below.
90
91<table>
92<tr><th> Optional arguments <th>
93<tr><td> Silence() <td> Suppress all RooFit messages during running below PROGRESS level
94<tr><td> FitModel(const RooAbsPdf&) <td> The PDF for fitting if it is different from the PDF for generating.
95<tr><td> ConditionalObservables(const RooArgSet& set) <td> The set of observables that the PDF should _not_ be normalized over
96<tr><td> Binned(bool flag) <td> Bin the dataset before fitting it. Speeds up fitting of large data samples
97<tr><td> FitOptions(....) <td> Options to be used for fitting. All named arguments inside FitOptions() are passed to RooAbsPdf::fitTo().
98 `Save()` is especially interesting to be able to retrieve fit results of each run using fitResult().
99<tr><td> Verbose(bool flag) <td> Activate informational messages in event generation phase
100<tr><td> Extended(bool flag) <td> Determine number of events for each sample anew from a Poisson distribution
101<tr><td> Constrain(const RooArgSet& pars) <td> Apply internal constraints on given parameters in fit and sample constrained parameter values from constraint p.d.f for each toy.
102<tr><td> ExternalConstraints(const RooArgSet& ) <td> Apply internal constraints on given parameters in fit and sample constrained parameter values from constraint p.d.f for each toy.
103<tr><td> ProtoData(const RooDataSet&, bool randOrder)
104 <td> Prototype data for the event generation. If the randOrder flag is set, the order of the dataset will be re-randomized for each generation
105 cycle to protect against systematic biases if the number of generated events does not exactly match the number of events in the prototype dataset
106 at the cost of reduced precision with mu equal to the specified number of events
107</table>
108*/
109RooMCStudy::RooMCStudy(const RooAbsPdf& model, const RooArgSet& observables,
110 const RooCmdArg& arg1, const RooCmdArg& arg2,
111 const RooCmdArg& arg3,const RooCmdArg& arg4,const RooCmdArg& arg5,
112 const RooCmdArg& arg6,const RooCmdArg& arg7,const RooCmdArg& arg8) : TNamed("mcstudy","mcstudy")
113
114{
115 // Stuff all arguments in a list
116 RooLinkedList cmdList;
117 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
118 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
119 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
120 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
121
122 // Select the pdf-specific commands
123 RooCmdConfig pc(Form("RooMCStudy::RooMCStudy(%s)",model.GetName())) ;
124
125 pc.defineObject("fitModel","FitModel",0,0) ;
126 pc.defineSet("condObs","ProjectedObservables",0,0) ;
127 pc.defineObject("protoData","PrototypeData",0,0) ;
128 pc.defineSet("cPars","Constrain",0,0) ;
129 pc.defineSet("extCons","ExternalConstraints",0,0) ;
130 pc.defineInt("silence","Silence",0,0) ;
131 pc.defineInt("randProtoData","PrototypeData",0,0) ;
132 pc.defineInt("verboseGen","Verbose",0,0) ;
133 pc.defineInt("extendedGen","Extended",0,0) ;
134 pc.defineInt("binGenData","Binned",0,0) ;
135 pc.defineInt("dummy","FitOptArgs",0,0) ;
136
137 // Process and check varargs
138 pc.process(cmdList) ;
139 if (!pc.ok(true)) {
140 // WVE do something here
141 throw std::string("RooMCStudy::RooMCStudy() Error in parsing arguments passed to contructor") ;
142 return ;
143 }
144
145 // Save fit command options
146 if (pc.hasProcessed("FitOptArgs")) {
147 RooCmdArg* fitOptArg = static_cast<RooCmdArg*>(cmdList.FindObject("FitOptArgs")) ;
148 for (Int_t i=0 ; i<fitOptArg->subArgs().GetSize() ;i++) {
149 _fitOptList.Add(new RooCmdArg(static_cast<RooCmdArg&>(*fitOptArg->subArgs().At(i)))) ;
150 }
151 }
152
153 // Decode command line arguments
154 _silence = pc.getInt("silence") ;
155 _verboseGen = pc.getInt("verboseGen") ;
156 _extendedGen = pc.getInt("extendedGen") ;
157 _binGenData = pc.getInt("binGenData") ;
158 _randProto = pc.getInt("randProtoData") ;
159
160 // Process constraints specifications
161 const RooArgSet* cParsTmp = pc.getSet("cPars") ;
162 const RooArgSet* extCons = pc.getSet("extCons") ;
163
164 RooArgSet* cPars = new RooArgSet ;
165 if (cParsTmp) {
166 cPars->add(*cParsTmp) ;
167 }
168
169 // If constraints are specified, add to fit options
170 if (cPars) {
172 }
173 if (extCons) {
175 }
176
177 // Make list of all constraints
178 RooArgSet allConstraints ;
179 RooArgSet consPars ;
180 if (cPars) {
181 if (std::unique_ptr<RooArgSet> constraints{model.getAllConstraints(observables,*cPars,true)}) {
182 allConstraints.add(*constraints) ;
183 }
184 }
185
186 // Construct constraint p.d.f
187 if (!allConstraints.empty()) {
188 _constrPdf = std::make_unique<RooProdPdf>("mcs_constr_prod","RooMCStudy constraints product",allConstraints);
189
190 if (cPars) {
191 consPars.add(*cPars) ;
192 } else {
193 RooArgSet params;
194 model.getParameters(&observables, params);
195 RooArgSet cparams;
196 _constrPdf->getObservables(&params, cparams);
197 consPars.add(cparams) ;
198 }
199 _constrGenContext.reset(_constrPdf->genContext(consPars,0,0,_verboseGen));
200
201 _perExptGenParams = true ;
202
203 coutI(Generation) << "RooMCStudy::RooMCStudy: INFO have pdf with constraints, will generate parameters from constraint pdf for each experiment" << endl ;
204 }
205
206
207 // Extract generator and fit models
208 _genModel = const_cast<RooAbsPdf*>(&model) ;
209 _genSample = 0 ;
210 RooAbsPdf* fitModel = static_cast<RooAbsPdf*>(pc.getObject("fitModel",0)) ;
211 _fitModel = fitModel ? fitModel : _genModel ;
212
213 // Extract conditional observables and prototype data
214 _genProtoData = static_cast<RooDataSet*>(pc.getObject("protoData",0)) ;
215 if (auto condObs = pc.getSet("condObs",0)) {
216 _projDeps.add(*condObs);
217 }
218
219 _dependents.add(observables) ;
220
222 _canAddFitResults = true ;
223
225 oocoutW(_fitModel,Generation) << "RooMCStudy::RooMCStudy: WARNING Using generator option 'e' (Poisson distribution of #events) together " << endl
226 << " with a prototype dataset implies incomplete sampling or oversampling of proto data." << endl
227 << " Use option \"r\" to randomize prototype dataset order and thus to randomize" << endl
228 << " the set of over/undersampled prototype events for each generation cycle." << endl ;
229 }
230
232 if (!_binGenData) {
234 _genContext->attach(_genParams) ;
235 }
236
238
239 // Store list of parameters and save initial values separately
242
244
245 // Place holder for NLL
246 _nllVar = std::make_unique<RooRealVar>("NLL","-log(Likelihood)",0);
247
248 // Place holder for number of generated events
249 _ngenVar = std::make_unique<RooRealVar>("ngen","number of generated events",0);
250
251 // Create data set containing parameter values, errors and pulls
252 RooArgSet tmp2(_fitParams) ;
253 tmp2.add(*_nllVar) ;
254 tmp2.add(*_ngenVar) ;
255
256 // Mark all variable to store their errors in the dataset
257 tmp2.setAttribAll("StoreError",true) ;
258 tmp2.setAttribAll("StoreAsymError",true) ;
259 TString fpdName ;
260 if (_fitModel==_genModel) {
261 fpdName = Form("fitParData_%s",_fitModel->GetName()) ;
262 } else {
263 fpdName= Form("fitParData_%s_%s",_fitModel->GetName(),_genModel->GetName()) ;
264 }
265
266 _fitParData = std::make_unique<RooDataSet>(fpdName.Data(),"Fit Parameters DataSet",tmp2);
267 tmp2.setAttribAll("StoreError",false) ;
268 tmp2.setAttribAll("StoreAsymError",false) ;
269
270 if (_perExptGenParams) {
271 _genParData = std::make_unique<RooDataSet>("genParData","Generated Parameters dataset",_genParams);
272 }
273
274 // Append proto variables to allDependents
275 if (_genProtoData) {
277 }
278
279 // Call module initializers
280 list<RooAbsMCStudyModule*>::iterator iter ;
281 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
282 bool ok = (*iter)->doInitializeInstance(*this) ;
283 if (!ok) {
284 oocoutE(_fitModel,Generation) << "RooMCStudy::ctor: removing study module " << (*iter)->GetName() << " from analysis chain because initialization failed" << endl ;
285 iter = _modList.erase(iter) ;
286 }
287 }
288
289}
290
291
292////////////////////////////////////////////////////////////////////////////////
293
295{
298}
299
300
301
302////////////////////////////////////////////////////////////////////////////////
303/// Insert given RooMCStudy add-on module to the processing chain
304/// of this MCStudy object
305
307{
308 module.doInitializeInstance(*this) ;
309 _modList.push_back(&module) ;
310}
311
312
313
314////////////////////////////////////////////////////////////////////////////////
315/// Run engine method. Generate and/or fit, according to flags, 'nSamples' samples of 'nEvtPerSample' events.
316/// If keepGenData is set, all generated data sets will be kept in memory and can be accessed
317/// later via genData().
318///
319/// When generating, data sets will be written out in ascii form if the pattern string is supplied
320/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
321/// and should contain one integer field that encodes the sample serial number.
322///
323/// When fitting only, data sets may optionally be read from ascii files, using the same file
324/// pattern.
325///
326
327bool RooMCStudy::run(bool doGenerate, bool DoFit, Int_t nSamples, Int_t nEvtPerSample, bool keepGenData, const char* asciiFilePat)
328{
330 if (_silence) {
333 }
334
335 list<RooAbsMCStudyModule*>::iterator iter ;
336 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
337 (*iter)->initializeRun(nSamples) ;
338 }
339
340 Int_t prescale = nSamples>100 ? Int_t(nSamples/100) : 1 ;
341
342 while(nSamples--) {
343
344 if (nSamples%prescale==0) {
345 oocoutP(_fitModel,Generation) << "RooMCStudy::run: " ;
346 if (doGenerate) ooccoutI(_fitModel,Generation) << "Generating " ;
347 if (doGenerate && DoFit) ooccoutI(_fitModel,Generation) << "and " ;
348 if (DoFit) ooccoutI(_fitModel,Generation) << "fitting " ;
349 ooccoutP(_fitModel,Generation) << "sample " << nSamples << endl ;
350 }
351
352 _genSample = 0;
353 bool existingData = false ;
354 if (doGenerate) {
355 // Generate sample
356 Int_t nEvt(nEvtPerSample) ;
357
358 // Reset generator parameters to initial values
360
361 // If constraints are present, sample generator values from constraints
362 if (_constrPdf) {
363 _genParams.assign(*std::unique_ptr<RooDataSet>{_constrGenContext->generate(1)}->get());
364 }
365
366 // Save generated parameters if required
367 if (_genParData) {
368 _genParData->add(_genParams) ;
369 }
370
371 // Call module before-generation hook
372 list<RooAbsMCStudyModule*>::iterator iter2 ;
373 for (iter2=_modList.begin() ; iter2!= _modList.end() ; ++iter2) {
374 (*iter2)->processBeforeGen(nSamples) ;
375 }
376
377 if (_binGenData) {
378
379 // Calculate the number of (extended) events for this run
380 if (_extendedGen) {
382 nEvt = RooRandom::randomGenerator()->Poisson(nEvtPerSample==0?_nExpGen:nEvtPerSample) ;
383 }
384
385 // Binned generation
386 _genSample = std::unique_ptr<RooDataHist>{_genModel->generateBinned(_dependents,nEvt)}.release();
387
388 } else {
389
390 // Calculate the number of (extended) events for this run
391 if (_extendedGen) {
393 nEvt = RooRandom::randomGenerator()->Poisson(nEvtPerSample==0?_nExpGen:nEvtPerSample) ;
394 }
395
396 // Optional randomization of protodata for this run
398 oocoutI(_fitModel,Generation) << "RooMCStudy: (Re)randomizing event order in prototype dataset (Nevt=" << nEvt << ")" << endl ;
400 _genContext->setProtoDataOrder(newOrder) ;
401 delete[] newOrder ;
402 }
403
404 coutP(Generation) << "RooMCStudy: now generating " << nEvt << " events" << endl ;
405
406 // Actual generation of events
407 if (nEvt>0) {
408 _genSample = _genContext->generate(nEvt) ;
409 } else {
410 // Make empty dataset
411 _genSample = new RooDataSet("emptySample","emptySample",_dependents) ;
412 }
413 }
414
415
416 //} else if (asciiFilePat && &asciiFilePat) { //warning: the address of 'asciiFilePat' will always evaluate as 'true'
417 } else if (asciiFilePat) {
418
419 // Load sample from ASCII file
420 char asciiFile[1024] ;
421 snprintf(asciiFile,1024,asciiFilePat,nSamples) ;
422 RooArgList depList(_allDependents) ;
423 _genSample = RooDataSet::read(asciiFile,depList,"q") ;
424
425 } else {
426
427 // Load sample from internal list
428 _genSample = (RooDataSet*) _genDataList.At(nSamples) ;
429 existingData = true ;
430 if (!_genSample) {
431 oocoutW(_fitModel,Generation) << "RooMCStudy::run: WARNING: Sample #" << nSamples << " not loaded, skipping" << endl ;
432 continue ;
433 }
434 }
435
436 // Save number of generated events
437 _ngenVar->setVal(_genSample->sumEntries()) ;
438
439 // Call module between generation and fitting hook
440 list<RooAbsMCStudyModule*>::iterator iter3 ;
441 for (iter3=_modList.begin() ; iter3!= _modList.end() ; ++iter3) {
442 (*iter3)->processBetweenGenAndFit(nSamples) ;
443 }
444
445 if (DoFit) fitSample(_genSample) ;
446
447 // Call module between generation and fitting hook
448 for (iter3=_modList.begin() ; iter3!= _modList.end() ; ++iter3) {
449 (*iter3)->processAfterFit(nSamples) ;
450 }
451
452 // Optionally write to ascii file
453 if (doGenerate && asciiFilePat && *asciiFilePat) {
454 char asciiFile[1024] ;
455 snprintf(asciiFile,1024,asciiFilePat,nSamples) ;
456 RooDataSet* unbinnedData = dynamic_cast<RooDataSet*>(_genSample) ;
457 if (unbinnedData) {
458 unbinnedData->write(asciiFile) ;
459 } else {
460 coutE(InputArguments) << "RooMCStudy::run(" << GetName() << ") ERROR: ASCII writing of binned datasets is not supported" << endl ;
461 }
462 }
463
464 // Add to list or delete
465 if (!existingData) {
466 if (keepGenData) {
468 } else {
469 delete _genSample ;
470 }
471 }
472 }
473
474 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
475 if (RooDataSet* auxData = (*iter)->finalizeRun()) {
476 _fitParData->merge(auxData) ;
477 }
478 }
479
480 _canAddFitResults = false ;
481
482 if (_genParData) {
483 for(RooAbsArg * arg : *_genParData->get()) {
484 _genParData->changeObservableName(arg->GetName(),Form("%s_gen",arg->GetName())) ;
485 }
486
487 _fitParData->merge(_genParData.get());
488 }
489
490 if (DoFit) calcPulls() ;
491
492 if (_silence) {
494 }
495
496 return false ;
497}
498
499
500
501
502
503
504////////////////////////////////////////////////////////////////////////////////
505/// Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
506/// If keepGenData is set, all generated data sets will be kept in memory and can be accessed
507/// later via genData().
508///
509/// Data sets will be written out in ascii form if the pattern string is supplied.
510/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
511/// and should contain one integer field that encodes the sample serial number.
512///
513
514bool RooMCStudy::generateAndFit(Int_t nSamples, Int_t nEvtPerSample, bool keepGenData, const char* asciiFilePat)
515{
516 // Clear any previous data in memory
517 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
519 _fitParData->reset() ;
520
521 return run(true,true,nSamples,nEvtPerSample,keepGenData,asciiFilePat) ;
522}
523
524
525
526////////////////////////////////////////////////////////////////////////////////
527/// Generate 'nSamples' samples of 'nEvtPerSample' events.
528/// If keepGenData is set, all generated data sets will be kept in memory
529/// and can be accessed later via genData().
530///
531/// Data sets will be written out in ascii form if the pattern string is supplied.
532/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
533/// and should contain one integer field that encodes the sample serial number.
534///
535
536bool RooMCStudy::generate(Int_t nSamples, Int_t nEvtPerSample, bool keepGenData, const char* asciiFilePat)
537{
538 // Clear any previous data in memory
540
541 return run(true,false,nSamples,nEvtPerSample,keepGenData,asciiFilePat) ;
542}
543
544
545
546////////////////////////////////////////////////////////////////////////////////
547/// Fit 'nSamples' datasets, which are read from ASCII files.
548///
549/// The ascii file pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
550/// and should contain one integer field that encodes the sample serial number.
551///
552
553bool RooMCStudy::fit(Int_t nSamples, const char* asciiFilePat)
554{
555 // Clear any previous data in memory
556 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
557 _fitParData->reset() ;
558
559 return run(false,true,nSamples,0,false,asciiFilePat) ;
560}
561
562
563
564////////////////////////////////////////////////////////////////////////////////
565/// Fit 'nSamples' datasets, as supplied in 'dataSetList'
566///
567
568bool RooMCStudy::fit(Int_t nSamples, TList& dataSetList)
569{
570 // Clear any previous data in memory
571 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
573 _fitParData->reset() ;
574
575 // Load list of data sets
576 for(auto * gset : static_range_cast<RooAbsData*>(dataSetList)) {
577 _genDataList.Add(gset) ;
578 }
579
580 return run(false,true,nSamples,0,true,0) ;
581}
582
583
584
585////////////////////////////////////////////////////////////////////////////////
586/// Reset all fit parameters to the initial model
587/// parameters at the time of the RooMCStudy constructor
588
590{
592}
593
594
595
596////////////////////////////////////////////////////////////////////////////////
597/// Internal function. Performs actual fit according to specifications
598
600{
601 // Optionally bin dataset before fitting
602 std::unique_ptr<RooDataHist> ownedDataHist;
604 if (_binGenData) {
605 RooArgSet depList;
606 _fitModel->getObservables(genSample->get(), depList);
607 ownedDataHist = std::make_unique<RooDataHist>(genSample->GetName(),genSample->GetTitle(),depList,*genSample) ;
608 data = ownedDataHist.get();
609 } else {
610 data = genSample ;
611 }
612
615 RooCmdArg plevel = RooFit::PrintLevel(_silence ? -1 : 1) ;
616
617 RooLinkedList fitOptList(_fitOptList) ;
618 fitOptList.Add(&save) ;
619 if (!_projDeps.empty()) {
620 fitOptList.Add(&condo) ;
621 }
622 fitOptList.Add(&plevel) ;
623 return _fitModel->fitTo(*data,fitOptList);
624}
625
626
627
628////////////////////////////////////////////////////////////////////////////////
629/// Redo fit on 'current' toy sample, or if genSample is not nullptr
630/// do fit on given sample instead
631
633{
634 if (!genSample) {
635 genSample = _genSample ;
636 }
637
638 std::unique_ptr<RooFitResult> fr;
639 if (genSample->sumEntries()>0) {
640 fr = std::unique_ptr<RooFitResult>{doFit(genSample)};
641 }
642
643 return RooFit::Detail::owningPtr(std::move(fr));
644}
645
646
647
648////////////////////////////////////////////////////////////////////////////////
649/// Internal method. Fit given dataset with fit model. If fit
650/// converges (TMinuit status code zero) The fit results are appended
651/// to the fit results dataset
652///
653/// If the fit option "r" is supplied, the RooFitResult
654/// objects will always be saved, regardless of the
655/// fit status. RooFitResults objects can be retrieved
656/// later via fitResult().
657///
658
660{
661 // Reset all fit parameters to their initial values
663
664 // Perform actual fit
665 bool ok ;
666 std::unique_ptr<RooFitResult> fr;
667 if (genSample->sumEntries()>0) {
668 fr = std::unique_ptr<RooFitResult>{doFit(genSample)};
669 ok = (fr->status()==0) ;
670 } else {
671 ok = false ;
672 }
673
674 // If fit converged, store parameters and NLL
675 if (ok) {
676 _nllVar->setVal(fr->minNll()) ;
677 RooArgSet tmp(_fitParams) ;
678 tmp.add(*_nllVar) ;
679 tmp.add(*_ngenVar) ;
680
681 _fitParData->add(tmp) ;
682 }
683
684 // Store fit result if requested by user
685 if (_fitOptList.FindObject("Save")) {
686 _fitResList.Add(fr.release()) ;
687 }
688
689 return !ok ;
690}
691
692
693
694////////////////////////////////////////////////////////////////////////////////
695/// Utility function to add fit result from external fit to this RooMCStudy
696/// and process its results through the standard RooMCStudy statistics gathering tools.
697/// This function allows users to run the toy MC generation and/or fitting
698/// in a distributed way and to collect and analyze the results in a RooMCStudy
699/// as if they were run locally.
700///
701/// This method is only functional if this RooMCStudy object is cleanm, i.e. it was not used
702/// to generate and/or fit any samples.
703
705{
706 if (!_canAddFitResults) {
707 oocoutE(_fitModel,InputArguments) << "RooMCStudy::addFitResult: ERROR cannot add fit results in current state" << endl ;
708 return true ;
709 }
710
711 // Transfer contents of fit result to fitParams ;
713
714 // If fit converged, store parameters and NLL
715 bool ok = (fr.status()==0) ;
716 if (ok) {
717 _nllVar->setVal(fr.minNll()) ;
718 RooArgSet tmp(_fitParams) ;
719 tmp.add(*_nllVar) ;
720 tmp.add(*_ngenVar) ;
721 _fitParData->add(tmp) ;
722 }
723
724 // Store fit result if requested by user
725 if (_fitOptList.FindObject("Save")) {
726 _fitResList.Add((TObject*)&fr) ;
727 }
728
729 return false ;
730}
731
732
733
734////////////////////////////////////////////////////////////////////////////////
735/// Calculate the pulls for all fit parameters in
736/// the fit results data set, and add them to that dataset.
737
739{
740 for (auto it = _fitParams.begin(); it != _fitParams.end(); ++it) {
741 const auto par = static_cast<RooRealVar*>(*it);
742 _fitParData->addColumn(*std::unique_ptr<RooErrorVar>{par->errorVar()});
743
744 TString name(par->GetName()), title(par->GetTitle()) ;
745 name.Append("pull") ;
746 title.Append(" Pull") ;
747
748 if (!par->hasError(false)) {
749 coutW(Generation) << "Fit parameter '" << par->GetName() << "' does not have an error."
750 " A pull distribution cannot be generated. This might be caused by the parameter being constant or"
751 " because the fits were not run." << std::endl;
752 continue;
753 }
754
755 // First look in fitParDataset to see if per-experiment generated value has been stored
756 auto genParOrig = static_cast<RooAbsReal*>(_fitParData->get()->find(Form("%s_gen",par->GetName())));
757 if (genParOrig && _perExptGenParams) {
758
759 RooPullVar pull(name,title,*par,*genParOrig) ;
760 _fitParData->addColumn(pull,false) ;
761
762 } else {
763 // If not use fixed generator value
764 genParOrig = static_cast<RooAbsReal*>(_genInitParams.find(par->GetName()));
765
766 if (!genParOrig) {
767 std::size_t index = it - _fitParams.begin();
768 genParOrig = index < _genInitParams.size() ?
769 static_cast<RooAbsReal*>(_genInitParams[index]) :
770 nullptr;
771
772 if (genParOrig) {
773 coutW(Generation) << "The fit parameter '" << par->GetName() << "' is not in the model that was used to generate toy data. "
774 "The parameter '" << genParOrig->GetName() << "'=" << genParOrig->getVal() << " was found at the same position in the generator model."
775 " It will be used to compute pulls."
776 "\nIf this is not desired, the parameters of the generator model need to be renamed or reordered." << std::endl;
777 }
778 }
779
780 if (genParOrig) {
781 std::unique_ptr<RooAbsReal> genPar(static_cast<RooAbsReal*>(genParOrig->Clone("truth")));
782 RooPullVar pull(name,title,*par,*genPar);
783
784 _fitParData->addColumn(pull,false) ;
785 } else {
786 coutE(Generation) << "Cannot generate pull distribution for the fit parameter '" << par->GetName() << "'."
787 "\nNo similar parameter was found in the set of parameters that were used to generate toy data." << std::endl;
788 }
789 }
790 }
791}
792
793
794
795
796////////////////////////////////////////////////////////////////////////////////
797/// Return a RooDataSet containing the post-fit parameters of each toy cycle.
798/// This dataset also contains any additional output that was generated
799/// by study modules that were added to this RooMCStudy.
800/// By default, the two following variables are added (apart from fit parameters):
801/// - NLL: The value of the negative log-likelihood for each run.
802/// - ngen: Number of events generated for each run.
804{
805 if (_canAddFitResults) {
806 calcPulls() ;
807 _canAddFitResults = false ;
808 }
809
810 return *_fitParData ;
811}
812
813
814
815////////////////////////////////////////////////////////////////////////////////
816/// Return an argset with the fit parameters for the given sample number
817///
818/// NB: The fit parameters are only stored for successfull fits,
819/// thus the maximum sampleNum can be less that the number
820/// of generated samples and if so, the indeces will
821/// be out of synch with genData() and fitResult()
822
823const RooArgSet* RooMCStudy::fitParams(Int_t sampleNum) const
824{
825 // Check if sampleNum is in range
826 if (sampleNum<0 || sampleNum>=_fitParData->numEntries()) {
827 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitParams: ERROR, invalid sample number: " << sampleNum << endl ;
828 return 0 ;
829 }
830
831 return _fitParData->get(sampleNum) ;
832}
833
834
835
836////////////////////////////////////////////////////////////////////////////////
837/// Return the RooFitResult of the fit with the given run number.
838///
839/// \note Fit results are not saved by default. This requires passing `FitOptions(Save(), ...)`
840/// to the constructor.
842{
843 // Check if sampleNum is in range
844 if (sampleNum<0 || sampleNum>=_fitResList.GetSize()) {
845 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, invalid sample number: " << sampleNum << endl ;
846 return 0 ;
847 }
848
849 // Retrieve fit result object
850 const RooFitResult* fr = (RooFitResult*) _fitResList.At(sampleNum) ;
851 if (fr) {
852 return fr ;
853 } else {
854 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, no fit result saved for sample "
855 << sampleNum << ", did you use the 'r; fit option?" << endl ;
856 }
857 return 0 ;
858}
859
860
861
862////////////////////////////////////////////////////////////////////////////////
863/// Return the given generated dataset. This method will only return datasets
864/// if during the run cycle it was indicated that generator data should be saved.
865
867{
868 // Check that generated data was saved
869 if (_genDataList.GetSize()==0) {
870 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, generated data was not saved" << endl ;
871 return 0 ;
872 }
873
874 // Check if sampleNum is in range
875 if (sampleNum<0 || sampleNum>=_genDataList.GetSize()) {
876 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, invalid sample number: " << sampleNum << endl ;
877 return 0 ;
878 }
879
880 return (RooAbsData*) _genDataList.At(sampleNum) ;
881}
882
883
884
885////////////////////////////////////////////////////////////////////////////////
886/// Plot the distribution of fitted values of a parameter. The parameter shown is the one from which the RooPlot
887/// was created, e.g.
888///
889/// RooPlot* frame = param.frame(100,-10,10) ;
890/// mcstudy.paramOn(frame,LineStyle(kDashed)) ;
891///
892/// Any named arguments passed to plotParamOn() are forwarded to the underlying plotOn() call
893
894RooPlot* RooMCStudy::plotParamOn(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
895 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
896{
897 _fitParData->plotOn(frame,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
898 return frame ;
899}
900
901
902
903////////////////////////////////////////////////////////////////////////////////
904/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
905///
906/// <table>
907/// <tr><th> Optional arguments <th>
908/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
909/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
910/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
911/// for list of allowed arguments
912/// </table>
913/// If no frame specifications are given, the AutoRange() feature will be used to set the range
914/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
915
916RooPlot* RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
917 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
918{
919
920 // Find parameter in fitParDataSet
921 RooRealVar* param = static_cast<RooRealVar*>(_fitParData->get()->find(paramName)) ;
922 if (!param) {
923 oocoutE(_fitModel,InputArguments) << "RooMCStudy::plotParam: ERROR: no parameter defined with name " << paramName << endl ;
924 return 0 ;
925 }
926
927 // Forward to implementation below
928 return plotParam(*param,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
929}
930
931
932
933////////////////////////////////////////////////////////////////////////////////
934/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
935/// \copydetails RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
936/// const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
937
938RooPlot* RooMCStudy::plotParam(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
939 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
940{
941 // Stuff all arguments in a list
942 RooLinkedList cmdList;
943 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
944 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
945 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
946 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
947
948 RooPlot* frame = makeFrameAndPlotCmd(param, cmdList) ;
949 if (frame) {
950 _fitParData->plotOn(frame, cmdList) ;
951 }
952
953 return frame ;
954}
955
956
957
958////////////////////////////////////////////////////////////////////////////////
959/// Plot the distribution of the -log(L) values on a newly created frame.
960///
961/// <table>
962/// <tr><th> Optional arguments <th>
963/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
964/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
965/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
966/// for list of allowed arguments
967/// </table>
968///
969/// If no frame specifications are given, the AutoRange() feature will be used to set the range.
970/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
971
973 const RooCmdArg& arg3, const RooCmdArg& arg4,
974 const RooCmdArg& arg5, const RooCmdArg& arg6,
975 const RooCmdArg& arg7, const RooCmdArg& arg8)
976{
977 return plotParam(*_nllVar,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
978}
979
980
981
982////////////////////////////////////////////////////////////////////////////////
983/// Plot the distribution of the fit errors for the specified parameter on a newly created frame.
984///
985/// <table>
986/// <tr><th> Optional arguments <th>
987/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
988/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
989/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
990/// for list of allowed arguments
991/// </table>
992///
993/// If no frame specifications are given, the AutoRange() feature will be used to set a default range.
994/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options.
995
996RooPlot* RooMCStudy::plotError(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
997 const RooCmdArg& arg3, const RooCmdArg& arg4,
998 const RooCmdArg& arg5, const RooCmdArg& arg6,
999 const RooCmdArg& arg7, const RooCmdArg& arg8)
1000{
1001 if (_canAddFitResults) {
1002 calcPulls() ;
1003 _canAddFitResults=false ;
1004 }
1005
1006 std::unique_ptr<RooErrorVar> evar{param.errorVar()};
1007 std::unique_ptr<RooRealVar> evar_rrv{static_cast<RooRealVar*>(evar->createFundamental())};
1008 RooPlot* frame = plotParam(*evar_rrv,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1009
1010 // To make sure the frame has no dangling pointer to evar_rrv.
1012
1013 return frame ;
1014}
1015
1016namespace {
1017
1018// Fits a Gaussian to the pull distribution, plots the fit and prints the fit
1019// parameters on the canvas. Implementation detail of RooMCStudy::plotPull().
1020void fitGaussToPulls(RooPlot& frame, RooDataSet& fitParData)
1021{
1022 // Build the Gaussian fit mode for the pulls, then fit it and plot it. We
1023 // have to use the RooWorkspace factory here, because different from the
1024 // RooMCStudy class, the RooGaussian is not in RooFitCore.
1025 RooWorkspace ws;
1026 auto plotVar = frame.getPlotVar();
1027 const std::string plotVarName = plotVar->GetName();
1028 ws.import(*plotVar);
1029 ws.factory("Gaussian::pullGauss(" + plotVarName + ", pullMean[0.0, -10.0, 10.0], pullSigma[1.0, 0.1, 5.0])");
1030
1031 RooRealVar& pullMean = *ws.var("pullMean");
1032 RooRealVar& pullSigma = *ws.var("pullSigma");
1033 RooAbsPdf& pullGauss = *ws.pdf("pullGauss");
1034
1035 pullGauss.fitTo(fitParData, RooFit::Minos(0), RooFit::PrintLevel(-1)) ;
1036 pullGauss.plotOn(&frame) ;
1037
1038 // Instead of using paramOn() without command arguments to plot the fit
1039 // parameters, we are building the parameter label ourselves for more
1040 // flexibility and pass this together with an appropriate layout
1041 // parametrization to paramOn().
1042 const int sigDigits = 2;
1043 const char * options = "ELU";
1044 std::stringstream ss;
1045 ss << "Fit parameters:\n"
1046 << "#mu: " << *std::unique_ptr<TString>{pullMean.format(sigDigits, options)}
1047 << "\n#sigma: " << *std::unique_ptr<TString>{pullSigma.format(sigDigits, options)};
1048 // We set the parameters constant to disable the default label. Still, we
1049 // use param() on as a wrapper for the text box generation.
1050 pullMean.setConstant(true);
1051 pullSigma.setConstant(true);
1052 pullGauss.paramOn(&frame, RooFit::Label(ss.str().c_str()), RooFit::Layout(0.60, 0.9, 0.9));
1053}
1054
1055} // namespace
1056
1057
1058////////////////////////////////////////////////////////////////////////////////
1059/// Plot the distribution of pull values for the specified parameter on a newly created frame. If asymmetric
1060/// errors are calculated in the fit (by MINOS) those will be used in the pull calculation.
1061///
1062/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1063/// corresponding parameters:
1064/// - Parameters have the same name: They will be used to compute pulls.
1065/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1066/// computed. The parameter at the same position in the set of generator parameters will be used.
1067///
1068/// Further options:
1069/// <table>
1070/// <tr><th> Arguments <th> Effect
1071/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1072/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1073/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1074/// for list of allowed arguments
1075/// <tr><td> FitGauss(bool flag) <td> Add a gaussian fit to the frame
1076/// </table>
1077///
1078/// If no frame specifications are given, the AutoSymRange() feature will be used to set a default range.
1079/// Any other named argument is passed to the RooAbsData::plotOn(). See that function for allowed options.
1080///
1081/// If you want to have more control over the Gaussian fit to the pull
1082/// distribution, you can also do it after the call to plotPull():
1083///
1084/// ~~~ {.cpp}
1085/// RooPlot *frame = mcstudy->plotPull(myVariable, RooFit::Bins(40), RooFit::FitGauss(false));
1086/// RooRealVar pullMean("pullMean","Mean of pull",0,-10,10) ;
1087/// RooRealVar pullSigma("pullSigma","Width of pull",1,0.1,5) ;
1088/// pullMean.setPlotLabel("pull #mu"); // optional (to get nicer plot labels if you want)
1089/// pullSigma.setPlotLabel("pull #sigma"); // optional
1090/// RooGaussian pullGauss("pullGauss","Gaussian of pull", *frame->getPlotVar(), pullMean, pullSigma);
1091/// pullGauss.fitTo(const_cast<RooDataSet&>(mcstudy->fitParDataSet()),
1092/// RooFit::Minos(0), RooFit::PrintLevel(-1)) ;
1093/// pullGauss.plotOn(frame) ;
1094/// pullGauss.paramOn(frame, RooFit::Layout(0.65, 0.9, 0.9)); // optionally specify label position (xmin, xmax, ymax)
1095/// ~~~
1096
1097RooPlot* RooMCStudy::plotPull(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
1098 const RooCmdArg& arg3, const RooCmdArg& arg4,
1099 const RooCmdArg& arg5, const RooCmdArg& arg6,
1100 const RooCmdArg& arg7, const RooCmdArg& arg8)
1101{
1102 // Stuff all arguments in a list
1103 RooLinkedList cmdList;
1104 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
1105 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
1106 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
1107 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
1108
1109 TString name(param.GetName()), title(param.GetTitle()) ;
1110 name.Append("pull") ; title.Append(" Pull") ;
1111 RooRealVar pvar(name,title,-100,100) ;
1112 pvar.setBins(100) ;
1113
1114
1115 RooPlot* frame = makeFrameAndPlotCmd(pvar, cmdList, true) ;
1116 if (frame) {
1117
1118 // Pick up optonal FitGauss command from list
1119 RooCmdConfig pc(Form("RooMCStudy::plotPull(%s)",_genModel->GetName())) ;
1120 pc.defineInt("fitGauss","FitGauss",0,0) ;
1121 pc.allowUndefined() ;
1122 pc.process(cmdList) ;
1123 bool fitGauss=pc.getInt("fitGauss") ;
1124
1125 // Pass stripped command list to plotOn()
1126 RooCmdConfig::stripCmdList(cmdList,"FitGauss") ;
1127 const bool success = _fitParData->plotOn(frame,cmdList) ;
1128
1129 if (!success) {
1130 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1131 return frame;
1132 }
1133
1134 // Add Gaussian fit if requested
1135 if (fitGauss) {
1136 fitGaussToPulls(*frame, *_fitParData);
1137 }
1138
1139 // To make sure the frame has no dangling pointer to pvar.
1141 }
1142 return frame;
1143}
1144
1145
1146
1147////////////////////////////////////////////////////////////////////////////////
1148/// Internal function. Construct RooPlot from given parameter and modify the list of named
1149/// arguments 'cmdList' to only contain the plot arguments that should be forwarded to
1150/// RooAbsData::plotOn()
1151
1152RooPlot* RooMCStudy::makeFrameAndPlotCmd(const RooRealVar& param, RooLinkedList& cmdList, bool symRange) const
1153{
1154 // Select the frame-specific commands
1155 RooCmdConfig pc(Form("RooMCStudy::plotParam(%s)",_genModel->GetName())) ;
1156 pc.defineInt("nbins","Bins",0,0) ;
1157 pc.defineDouble("xlo","Range",0,0) ;
1158 pc.defineDouble("xhi","Range",1,0) ;
1159 pc.defineInt("dummy","FrameArgs",0,0) ;
1160 pc.defineMutex("Bins","FrameArgs") ;
1161 pc.defineMutex("Range","FrameArgs") ;
1162
1163 // Process and check varargs
1164 pc.allowUndefined() ;
1165 pc.process(cmdList) ;
1166 if (!pc.ok(true)) {
1167 return 0 ;
1168 }
1169
1170 // Make frame according to specs
1171 Int_t nbins = pc.getInt("nbins") ;
1172 double xlo = pc.getDouble("xlo") ;
1173 double xhi = pc.getDouble("xhi") ;
1174 RooPlot* frame ;
1175
1176 if (pc.hasProcessed("FrameArgs")) {
1177 // Explicit frame arguments are given, pass them on
1178 RooCmdArg* frameArg = static_cast<RooCmdArg*>(cmdList.FindObject("FrameArgs")) ;
1179 frame = param.frame(frameArg->subArgs()) ;
1180 } else {
1181 // FrameBins, FrameRange or none are given, build custom frame command list
1182 RooCmdArg bins = RooFit::Bins(nbins) ;
1183 RooCmdArg range = RooFit::Range(xlo,xhi) ;
1185 RooLinkedList frameCmdList ;
1186
1187 if (pc.hasProcessed("Bins")) frameCmdList.Add(&bins) ;
1188 if (pc.hasProcessed("Range")) {
1189 frameCmdList.Add(&range) ;
1190 } else {
1191 frameCmdList.Add(&autor) ;
1192 }
1193 frame = param.frame(frameCmdList) ;
1194 }
1195
1196 // Filter frame command from list and pass on to plotOn()
1197 RooCmdConfig::stripCmdList(cmdList,"FrameArgs,Bins,Range") ;
1198
1199 return frame ;
1200}
1201
1202
1203
1204////////////////////////////////////////////////////////////////////////////////
1205/// Create a RooPlot of the -log(L) distribution in the range lo-hi
1206/// with 'nBins' bins
1207
1208RooPlot* RooMCStudy::plotNLL(double lo, double hi, Int_t nBins)
1209{
1210 RooPlot* frame = _nllVar->frame(lo,hi,nBins) ;
1211
1212 _fitParData->plotOn(frame) ;
1213 return frame ;
1214}
1215
1216
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// Create a RooPlot of the distribution of the fitted errors of the given parameter.
1220/// The frame is created with a range [lo,hi] and plotted data will be binned in 'nbins' bins
1221
1222RooPlot* RooMCStudy::plotError(const RooRealVar& param, double lo, double hi, Int_t nbins)
1223{
1224 if (_canAddFitResults) {
1225 calcPulls() ;
1226 _canAddFitResults=false ;
1227 }
1228
1229 std::unique_ptr<RooErrorVar> evar{param.errorVar()};
1230 RooPlot* frame = evar->frame(lo,hi,nbins) ;
1231 _fitParData->plotOn(frame) ;
1232
1233 return frame ;
1234}
1235
1236
1237
1238////////////////////////////////////////////////////////////////////////////////
1239/// Create a RooPlot of the pull distribution for the given
1240/// parameter. The range lo-hi is plotted in nbins. If fitGauss is
1241/// set, an unbinned ML fit of the distribution to a Gaussian p.d.f
1242/// is performed. The fit result is overlaid on the returned RooPlot
1243/// and a box with the fitted mean and sigma is added.
1244///
1245/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1246/// corresponding parameters:
1247/// - Parameters have the same name: They will be used to compute pulls.
1248/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1249/// computed. The parameter at the same position in the set of generator parameters will be used.
1250
1251RooPlot* RooMCStudy::plotPull(const RooRealVar& param, double lo, double hi, Int_t nbins, bool fitGauss)
1252{
1253 if (_canAddFitResults) {
1254 calcPulls() ;
1255 _canAddFitResults=false ;
1256 }
1257
1258
1259 TString name(param.GetName()), title(param.GetTitle()) ;
1260 name.Append("pull") ; title.Append(" Pull") ;
1261 RooRealVar pvar(name,title,lo,hi) ;
1262 pvar.setBins(nbins) ;
1263
1264 RooPlot* frame = pvar.frame() ;
1265 const bool success = _fitParData->plotOn(frame);
1266
1267 if (!success) {
1268 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1269 return frame;
1270 }
1271
1272 if (fitGauss) {
1273 fitGaussToPulls(*frame, *_fitParData);
1274 }
1275
1276 return frame ;
1277}
1278
1279
1280////////////////////////////////////////////////////////////////////////////////
1281/// If one of the TObject we have a referenced to is deleted, remove the
1282/// reference.
1283
1285{
1289 if (_ngenVar.get() == obj) _ngenVar.reset();
1290
1291 if (_fitParData) _fitParData->RecursiveRemove(obj);
1292 if (_fitParData.get() == obj) _fitParData.reset();
1293
1294 if (_genParData) _genParData->RecursiveRemove(obj);
1295 if (_genParData.get() == obj) _genParData.reset();
1296}
1297
RooFitResult * save(const char *name=nullptr, const char *title=nullptr)
#define coutI(a)
#define coutP(a)
#define oocoutW(o, a)
#define coutW(a)
#define coutF(a)
#define oocoutE(o, a)
#define oocoutI(o, a)
#define coutE(a)
#define ooccoutI(o, a)
#define ooccoutP(o, a)
#define oocoutP(o, a)
int Int_t
Definition RtypesCore.h:45
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Definition TGX11.cxx:110
#define hi
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
#define snprintf
Definition civetweb.c:1540
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:74
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void setAttribAll(const Text_t *name, bool value=true)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
const_iterator end() const
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
Storage_t::size_type size() const
const_iterator begin() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:59
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual const RooArgSet * get() const
Definition RooAbsData.h:103
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooAbsMCStudyModule is a base class for add-on modules to RooMCStudy that can perform additional calc...
bool doInitializeInstance(RooMCStudy &)
Initializer method called upon attachement to given RooMCStudy object.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
Int_t * randomizeProtoOrder(Int_t nProto, Int_t nGen, bool resample=false) const
Return lookup table with randomized order for nProto prototype events.
virtual RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, const RooLinkedList &cmdList={})
Fit PDF to given dataset.
virtual RooPlot * paramOn(RooPlot *frame, 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())
Add a box with parameter values (and errors) to the specified frame.
virtual RooFit::OwningPtr< RooDataHist > generateBinned(const RooArgSet &whatVars, double nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none()) const
As RooAbsPdf::generateBinned(const RooArgSet&, const RooCmdArg&,const RooCmdArg&, const RooCmdArg&,...
Definition RooAbsPdf.h:112
RooArgSet * getAllConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, bool stripDisconnected=true, bool removeConstraintsFromPdf=false) const
This helper function finds and collects all constraints terms of all component p.d....
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const
Interface function to create a generator context from a p.d.f.
RooPlot * plotOn(RooPlot *frame, 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 RooCmdArg &arg9=RooCmdArg::none(), const RooCmdArg &arg10=RooCmdArg::none()) const override
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
Definition RooAbsPdf.h:126
void setConstant(bool value=true)
RooPlot * frame(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 a new RooPlot on the heap with a drawing frame initialized for this object,...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:178
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:26
RooLinkedList const & subArgs() const
Return list of sub-arguments in this RooCmdArg.
Definition RooCmdArg.h:52
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooCmdArg.h:57
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
bool defineObject(const char *name, const char *argName, Int_t setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
double getDouble(const char *name, double defaultValue=0.0)
Return double property registered with name 'name'.
RooArgSet * getSet(const char *name, RooArgSet *set=nullptr)
Return RooArgSet property registered with name 'name'.
void defineMutex(const char *head, Args_t &&... tail)
Define arguments where any pair is mutually exclusive.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
bool hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
static void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
bool defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
bool ok(bool verbose) const
Return true of parsing was successful.
TObject * getObject(const char *name, TObject *obj=nullptr)
Return TObject property registered with name 'name'.
void allowUndefined(bool flag=true)
If flag is true the processing of unrecognized RooCmdArgs is not considered an error.
bool defineSet(const char *name, const char *argName, Int_t setNum, const RooArgSet *set=nullptr)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
bool defineDouble(const char *name, const char *argName, Int_t doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
RooDataSet is a container class to hold unbinned data.
Definition RooDataSet.h:57
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
bool write(const char *filename) const
Write the contents of this dataset to an ASCII file with the specified name.
static RooDataSet * read(const char *filename, const RooArgList &variables, const char *opts="", const char *commonPath="", const char *indexCatName=nullptr)
Read data from a text file and create a dataset from it.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Int_t status() const
Return MINUIT status code.
double minNll() const
Return minimized -log(L) value.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Int_t GetSize() const
TObject * At(int index) const
Return object stored in sequential position given by index.
void RecursiveRemove(TObject *obj) override
If one of the TObject we have a referenced to is deleted, remove the reference.
void Delete(Option_t *o=nullptr) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
TObject * FindObject(const char *name) const override
Return pointer to obejct with given name.
RooMCStudy is a helper class to facilitate Monte Carlo studies such as 'goodness-of-fit' studies,...
Definition RooMCStudy.h:32
bool addFitResult(const RooFitResult &fr)
Utility function to add fit result from external fit to this RooMCStudy and process its results throu...
RooAbsData * _genSample
Currently generated sample.
Definition RooMCStudy.h:107
RooPlot * makeFrameAndPlotCmd(const RooRealVar &param, RooLinkedList &cmdList, bool symRange=false) const
Internal function.
RooArgSet _projDeps
List of projected dependents in fit.
Definition RooMCStudy.h:113
RooArgSet _genParams
List of actual generator parameters.
Definition RooMCStudy.h:111
RooPlot * plotNLL(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())
Plot the distribution of the -log(L) values on a newly created frame.
const RooArgSet * fitParams(Int_t sampleNum) const
Return an argset with the fit parameters for the given sample number.
void calcPulls()
Calculate the pulls for all fit parameters in the fit results data set, and add them to that dataset.
~RooMCStudy() override
RooArgSet _dependents
List of dependents.
Definition RooMCStudy.h:118
RooMCStudy(const RooAbsPdf &model, const RooArgSet &observables, 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())
Construct Monte Carlo Study Manager.
bool _verboseGen
Verbose generation?
Definition RooMCStudy.h:137
std::list< RooAbsMCStudyModule * > _modList
List of additional study modules ;.
Definition RooMCStudy.h:141
std::unique_ptr< RooDataSet > _genParData
Definition RooMCStudy.h:128
RooArgSet _genInitParams
List of original generator parameters.
Definition RooMCStudy.h:110
TList _fitResList
Definition RooMCStudy.h:127
double _nExpGen
Definition RooMCStudy.h:133
bool fitSample(RooAbsData *genSample)
Internal method.
std::unique_ptr< RooDataSet > _fitParData
Definition RooMCStudy.h:129
bool generate(Int_t nSamples, Int_t nEvtPerSample=0, bool keepGenData=false, const char *asciiFilePat=nullptr)
Generate 'nSamples' samples of 'nEvtPerSample' events.
bool _extendedGen
Definition RooMCStudy.h:131
const RooDataSet * _genProtoData
Generator prototype data set.
Definition RooMCStudy.h:112
bool _canAddFitResults
Allow adding of external fit results?
Definition RooMCStudy.h:136
const RooFitResult * fitResult(Int_t sampleNum) const
Return the RooFitResult of the fit with the given run number.
RooFit::OwningPtr< RooFitResult > doFit(RooAbsData *genSample)
Internal function. Performs actual fit according to specifications.
std::unique_ptr< RooAbsGenContext > _constrGenContext
Generator context for constraints p.d.f.
Definition RooMCStudy.h:116
bool _perExptGenParams
Do generation parameter change per event?
Definition RooMCStudy.h:138
bool _binGenData
Definition RooMCStudy.h:132
bool _silence
Silent running mode?
Definition RooMCStudy.h:139
RooPlot * plotError(const RooRealVar &param, 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())
Plot the distribution of the fit errors for the specified parameter on a newly created frame.
RooArgSet _fitParams
List of actual fit parameters.
Definition RooMCStudy.h:122
std::unique_ptr< RooAbsGenContext > _genContext
Generator context.
Definition RooMCStudy.h:109
RooFit::OwningPtr< RooFitResult > refit(RooAbsData *genSample=nullptr)
Redo fit on 'current' toy sample, or if genSample is not nullptr do fit on given sample instead.
RooAbsData * genData(Int_t sampleNum) const
Return the given generated dataset.
void RecursiveRemove(TObject *obj) override
If one of the TObject we have a referenced to is deleted, remove the reference.
RooAbsPdf * _genModel
Generator model.
Definition RooMCStudy.h:108
const RooDataSet & fitParDataSet()
Return a RooDataSet containing the post-fit parameters of each toy cycle.
RooPlot * plotParamOn(RooPlot *frame, 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())
Plot the distribution of fitted values of a parameter.
std::unique_ptr< RooRealVar > _nllVar
Definition RooMCStudy.h:123
RooLinkedList _fitOptList
Definition RooMCStudy.h:130
std::unique_ptr< RooAbsPdf > _constrPdf
Constraints p.d.f.
Definition RooMCStudy.h:115
RooArgSet _allDependents
List of generate + prototype dependents.
Definition RooMCStudy.h:119
bool run(bool generate, bool fit, Int_t nSamples, Int_t nEvtPerSample, bool keepGenData, const char *asciiFilePat)
Run engine method.
void resetFitParams()
Reset all fit parameters to the initial model parameters at the time of the RooMCStudy constructor.
RooAbsPdf * _fitModel
Fit model.
Definition RooMCStudy.h:120
bool fit(Int_t nSamples, const char *asciiFilePat)
Fit 'nSamples' datasets, which are read from ASCII files.
bool generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, bool keepGenData=false, const char *asciiFilePat=nullptr)
Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
TList _genDataList
Definition RooMCStudy.h:126
bool _randProto
Definition RooMCStudy.h:134
RooPlot * plotParam(const RooRealVar &param, 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())
Plot the distribution of the fitted value of the given parameter on a newly created frame.
void addModule(RooAbsMCStudyModule &module)
Insert given RooMCStudy add-on module to the processing chain of this MCStudy object.
RooArgSet _fitInitParams
List of initial values of fit parameters.
Definition RooMCStudy.h:121
RooPlot * plotPull(const RooRealVar &param, 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())
Plot the distribution of pull values for the specified parameter on a newly created frame.
std::unique_ptr< RooRealVar > _ngenVar
Definition RooMCStudy.h:124
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:43
static RooPlot * frame(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nBins)
Create a new frame for a given variable in x.
Definition RooPlot.cxx:239
RooAbsRealLValue * getPlotVar() const
Definition RooPlot.h:137
void createInternalPlotVarClone()
Replaces the pointer to the plot variable with a pointer to a clone of the plot variable that is owne...
Definition RooPlot.cxx:1448
RooPullVar represents the pull of a measurement w.r.t.
Definition RooPullVar.h:24
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition RooRandom.cxx:51
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:40
RooErrorVar * errorVar() const
Return a RooAbsRealLValue representing the error associated with this variable.
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
The RooWorkspace is a persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
bool import(const RooAbsArg &arg, 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())
Import a RooAbsArg object, e.g.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
A doubly linked list.
Definition TList.h:38
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:764
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:470
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:357
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
Mother of all ROOT objects.
Definition TObject.h:41
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Definition TRandom.cxx:402
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:380
TString & Append(const char *cs)
Definition TString.h:576
RooCmdArg AutoRange(const RooAbsData &data, double marginFactor=0.1)
RooCmdArg Label(const char *str)
RooCmdArg AutoSymRange(const RooAbsData &data, double marginFactor=0.1)
RooCmdArg Bins(Int_t nbin)
RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95)
RooCmdArg Constrain(const RooArgSet &params)
RooCmdArg Save(bool flag=true)
RooCmdArg ExternalConstraints(const RooArgSet &constraintPdfs)
RooCmdArg Minos(bool flag=true)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
RooCmdArg Range(const char *rangeName, bool adjustNorm=true)
OwningPtr< T > owningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
Definition Config.h:50
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Definition Config.h:43