Logo ROOT  
Reference Guide
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
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
613 RooCmdArg save = RooFit::Save() ;
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 RooFitResult* fr = _fitModel->fitTo(*data,fitOptList) ;
624
625 return fr ;
626}
627
628
629
630////////////////////////////////////////////////////////////////////////////////
631/// Redo fit on 'current' toy sample, or if genSample is not nullptr
632/// do fit on given sample instead
633
635{
636 if (!genSample) {
637 genSample = _genSample ;
638 }
639
640 RooFitResult* fr(0) ;
641 if (genSample->sumEntries()>0) {
642 fr = doFit(genSample) ;
643 }
644
645 return fr ;
646}
647
648
649
650////////////////////////////////////////////////////////////////////////////////
651/// Internal method. Fit given dataset with fit model. If fit
652/// converges (TMinuit status code zero) The fit results are appended
653/// to the fit results dataset
654///
655/// If the fit option "r" is supplied, the RooFitResult
656/// objects will always be saved, regardless of the
657/// fit status. RooFitResults objects can be retrieved
658/// later via fitResult().
659///
660
662{
663 // Reset all fit parameters to their initial values
665
666 // Perform actual fit
667 bool ok ;
668 std::unique_ptr<RooFitResult> fr;
669 if (genSample->sumEntries()>0) {
670 fr.reset(doFit(genSample));
671 ok = (fr->status()==0) ;
672 } else {
673 ok = false ;
674 }
675
676 // If fit converged, store parameters and NLL
677 if (ok) {
678 _nllVar->setVal(fr->minNll()) ;
679 RooArgSet tmp(_fitParams) ;
680 tmp.add(*_nllVar) ;
681 tmp.add(*_ngenVar) ;
682
683 _fitParData->add(tmp) ;
684 }
685
686 // Store fit result if requested by user
687 if (_fitOptList.FindObject("Save")) {
688 _fitResList.Add(fr.release()) ;
689 }
690
691 return !ok ;
692}
693
694
695
696////////////////////////////////////////////////////////////////////////////////
697/// Utility function to add fit result from external fit to this RooMCStudy
698/// and process its results through the standard RooMCStudy statistics gathering tools.
699/// This function allows users to run the toy MC generation and/or fitting
700/// in a distributed way and to collect and analyze the results in a RooMCStudy
701/// as if they were run locally.
702///
703/// This method is only functional if this RooMCStudy object is cleanm, i.e. it was not used
704/// to generate and/or fit any samples.
705
707{
708 if (!_canAddFitResults) {
709 oocoutE(_fitModel,InputArguments) << "RooMCStudy::addFitResult: ERROR cannot add fit results in current state" << endl ;
710 return true ;
711 }
712
713 // Transfer contents of fit result to fitParams ;
715
716 // If fit converged, store parameters and NLL
717 bool ok = (fr.status()==0) ;
718 if (ok) {
719 _nllVar->setVal(fr.minNll()) ;
720 RooArgSet tmp(_fitParams) ;
721 tmp.add(*_nllVar) ;
722 tmp.add(*_ngenVar) ;
723 _fitParData->add(tmp) ;
724 }
725
726 // Store fit result if requested by user
727 if (_fitOptList.FindObject("Save")) {
728 _fitResList.Add((TObject*)&fr) ;
729 }
730
731 return false ;
732}
733
734
735
736////////////////////////////////////////////////////////////////////////////////
737/// Calculate the pulls for all fit parameters in
738/// the fit results data set, and add them to that dataset.
739
741{
742 for (auto it = _fitParams.begin(); it != _fitParams.end(); ++it) {
743 const auto par = static_cast<RooRealVar*>(*it);
744 _fitParData->addColumn(*std::unique_ptr<RooErrorVar>{par->errorVar()});
745
746 TString name(par->GetName()), title(par->GetTitle()) ;
747 name.Append("pull") ;
748 title.Append(" Pull") ;
749
750 if (!par->hasError(false)) {
751 coutW(Generation) << "Fit parameter '" << par->GetName() << "' does not have an error."
752 " A pull distribution cannot be generated. This might be caused by the parameter being constant or"
753 " because the fits were not run." << std::endl;
754 continue;
755 }
756
757 // First look in fitParDataset to see if per-experiment generated value has been stored
758 auto genParOrig = static_cast<RooAbsReal*>(_fitParData->get()->find(Form("%s_gen",par->GetName())));
759 if (genParOrig && _perExptGenParams) {
760
761 RooPullVar pull(name,title,*par,*genParOrig) ;
762 _fitParData->addColumn(pull,false) ;
763
764 } else {
765 // If not use fixed generator value
766 genParOrig = static_cast<RooAbsReal*>(_genInitParams.find(par->GetName()));
767
768 if (!genParOrig) {
769 std::size_t index = it - _fitParams.begin();
770 genParOrig = index < _genInitParams.size() ?
771 static_cast<RooAbsReal*>(_genInitParams[index]) :
772 nullptr;
773
774 if (genParOrig) {
775 coutW(Generation) << "The fit parameter '" << par->GetName() << "' is not in the model that was used to generate toy data. "
776 "The parameter '" << genParOrig->GetName() << "'=" << genParOrig->getVal() << " was found at the same position in the generator model."
777 " It will be used to compute pulls."
778 "\nIf this is not desired, the parameters of the generator model need to be renamed or reordered." << std::endl;
779 }
780 }
781
782 if (genParOrig) {
783 std::unique_ptr<RooAbsReal> genPar(static_cast<RooAbsReal*>(genParOrig->Clone("truth")));
784 RooPullVar pull(name,title,*par,*genPar);
785
786 _fitParData->addColumn(pull,false) ;
787 } else {
788 coutE(Generation) << "Cannot generate pull distribution for the fit parameter '" << par->GetName() << "'."
789 "\nNo similar parameter was found in the set of parameters that were used to generate toy data." << std::endl;
790 }
791 }
792 }
793}
794
795
796
797
798////////////////////////////////////////////////////////////////////////////////
799/// Return a RooDataSet containing the post-fit parameters of each toy cycle.
800/// This dataset also contains any additional output that was generated
801/// by study modules that were added to this RooMCStudy.
802/// By default, the two following variables are added (apart from fit parameters):
803/// - NLL: The value of the negative log-likelihood for each run.
804/// - ngen: Number of events generated for each run.
806{
807 if (_canAddFitResults) {
808 calcPulls() ;
809 _canAddFitResults = false ;
810 }
811
812 return *_fitParData ;
813}
814
815
816
817////////////////////////////////////////////////////////////////////////////////
818/// Return an argset with the fit parameters for the given sample number
819///
820/// NB: The fit parameters are only stored for successfull fits,
821/// thus the maximum sampleNum can be less that the number
822/// of generated samples and if so, the indeces will
823/// be out of synch with genData() and fitResult()
824
825const RooArgSet* RooMCStudy::fitParams(Int_t sampleNum) const
826{
827 // Check if sampleNum is in range
828 if (sampleNum<0 || sampleNum>=_fitParData->numEntries()) {
829 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitParams: ERROR, invalid sample number: " << sampleNum << endl ;
830 return 0 ;
831 }
832
833 return _fitParData->get(sampleNum) ;
834}
835
836
837
838////////////////////////////////////////////////////////////////////////////////
839/// Return the RooFitResult of the fit with the given run number.
840///
841/// \note Fit results are not saved by default. This requires passing `FitOptions(Save(), ...)`
842/// to the constructor.
844{
845 // Check if sampleNum is in range
846 if (sampleNum<0 || sampleNum>=_fitResList.GetSize()) {
847 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, invalid sample number: " << sampleNum << endl ;
848 return 0 ;
849 }
850
851 // Retrieve fit result object
852 const RooFitResult* fr = (RooFitResult*) _fitResList.At(sampleNum) ;
853 if (fr) {
854 return fr ;
855 } else {
856 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, no fit result saved for sample "
857 << sampleNum << ", did you use the 'r; fit option?" << endl ;
858 }
859 return 0 ;
860}
861
862
863
864////////////////////////////////////////////////////////////////////////////////
865/// Return the given generated dataset. This method will only return datasets
866/// if during the run cycle it was indicated that generator data should be saved.
867
869{
870 // Check that generated data was saved
871 if (_genDataList.GetSize()==0) {
872 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, generated data was not saved" << endl ;
873 return 0 ;
874 }
875
876 // Check if sampleNum is in range
877 if (sampleNum<0 || sampleNum>=_genDataList.GetSize()) {
878 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, invalid sample number: " << sampleNum << endl ;
879 return 0 ;
880 }
881
882 return (RooAbsData*) _genDataList.At(sampleNum) ;
883}
884
885
886
887////////////////////////////////////////////////////////////////////////////////
888/// Plot the distribution of fitted values of a parameter. The parameter shown is the one from which the RooPlot
889/// was created, e.g.
890///
891/// RooPlot* frame = param.frame(100,-10,10) ;
892/// mcstudy.paramOn(frame,LineStyle(kDashed)) ;
893///
894/// Any named arguments passed to plotParamOn() are forwarded to the underlying plotOn() call
895
896RooPlot* RooMCStudy::plotParamOn(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
897 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
898{
899 _fitParData->plotOn(frame,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
900 return frame ;
901}
902
903
904
905////////////////////////////////////////////////////////////////////////////////
906/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
907///
908/// <table>
909/// <tr><th> Optional arguments <th>
910/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
911/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
912/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
913/// for list of allowed arguments
914/// </table>
915/// If no frame specifications are given, the AutoRange() feature will be used to set the range
916/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
917
918RooPlot* RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
919 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
920{
921
922 // Find parameter in fitParDataSet
923 RooRealVar* param = static_cast<RooRealVar*>(_fitParData->get()->find(paramName)) ;
924 if (!param) {
925 oocoutE(_fitModel,InputArguments) << "RooMCStudy::plotParam: ERROR: no parameter defined with name " << paramName << endl ;
926 return 0 ;
927 }
928
929 // Forward to implementation below
930 return plotParam(*param,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
931}
932
933
934
935////////////////////////////////////////////////////////////////////////////////
936/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
937/// \copydetails RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
938/// const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
939
940RooPlot* RooMCStudy::plotParam(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
941 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
942{
943 // Stuff all arguments in a list
944 RooLinkedList cmdList;
945 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
946 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
947 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
948 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
949
950 RooPlot* frame = makeFrameAndPlotCmd(param, cmdList) ;
951 if (frame) {
952 _fitParData->plotOn(frame, cmdList) ;
953 }
954
955 return frame ;
956}
957
958
959
960////////////////////////////////////////////////////////////////////////////////
961/// Plot the distribution of the -log(L) values on a newly created frame.
962///
963/// <table>
964/// <tr><th> Optional arguments <th>
965/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
966/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
967/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
968/// for list of allowed arguments
969/// </table>
970///
971/// If no frame specifications are given, the AutoRange() feature will be used to set the range.
972/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
973
975 const RooCmdArg& arg3, const RooCmdArg& arg4,
976 const RooCmdArg& arg5, const RooCmdArg& arg6,
977 const RooCmdArg& arg7, const RooCmdArg& arg8)
978{
979 return plotParam(*_nllVar,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
980}
981
982
983
984////////////////////////////////////////////////////////////////////////////////
985/// Plot the distribution of the fit errors for the specified parameter on a newly created frame.
986///
987/// <table>
988/// <tr><th> Optional arguments <th>
989/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
990/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
991/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
992/// for list of allowed arguments
993/// </table>
994///
995/// If no frame specifications are given, the AutoRange() feature will be used to set a default range.
996/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options.
997
998RooPlot* RooMCStudy::plotError(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
999 const RooCmdArg& arg3, const RooCmdArg& arg4,
1000 const RooCmdArg& arg5, const RooCmdArg& arg6,
1001 const RooCmdArg& arg7, const RooCmdArg& arg8)
1002{
1003 if (_canAddFitResults) {
1004 calcPulls() ;
1005 _canAddFitResults=false ;
1006 }
1007
1008 std::unique_ptr<RooErrorVar> evar{param.errorVar()};
1009 std::unique_ptr<RooRealVar> evar_rrv{static_cast<RooRealVar*>(evar->createFundamental())};
1010 RooPlot* frame = plotParam(*evar_rrv,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1011
1012 // To make sure the frame has no dangling pointer to evar_rrv.
1014
1015 return frame ;
1016}
1017
1018namespace {
1019
1020// Fits a Gaussian to the pull distribution, plots the fit and prints the fit
1021// parameters on the canvas. Implementation detail of RooMCStudy::plotPull().
1022void fitGaussToPulls(RooPlot& frame, RooDataSet& fitParData)
1023{
1024 // Build the Gaussian fit mode for the pulls, then fit it and plot it. We
1025 // have to use the RooWorkspace factory here, because different from the
1026 // RooMCStudy class, the RooGaussian is not in RooFitCore.
1027 RooWorkspace ws;
1028 auto plotVar = frame.getPlotVar();
1029 const std::string plotVarName = plotVar->GetName();
1030 ws.import(*plotVar);
1031 ws.factory("Gaussian::pullGauss(" + plotVarName + ", pullMean[0.0, -10.0, 10.0], pullSigma[1.0, 0.1, 5.0])");
1032
1033 RooRealVar& pullMean = *ws.var("pullMean");
1034 RooRealVar& pullSigma = *ws.var("pullSigma");
1035 RooAbsPdf& pullGauss = *ws.pdf("pullGauss");
1036
1037 pullGauss.fitTo(fitParData, RooFit::Minos(0), RooFit::PrintLevel(-1)) ;
1038 pullGauss.plotOn(&frame) ;
1039
1040 // Instead of using paramOn() without command arguments to plot the fit
1041 // parameters, we are building the parameter label ourselves for more
1042 // flexibility and pass this together with an appropriate layout
1043 // parametrization to paramOn().
1044 const int sigDigits = 2;
1045 const char * options = "ELU";
1046 std::stringstream ss;
1047 ss << "Fit parameters:\n"
1048 << "#mu: " << *std::unique_ptr<TString>{pullMean.format(sigDigits, options)}
1049 << "\n#sigma: " << *std::unique_ptr<TString>{pullSigma.format(sigDigits, options)};
1050 // We set the parameters constant to disable the default label. Still, we
1051 // use param() on as a wrapper for the text box generation.
1052 pullMean.setConstant(true);
1053 pullSigma.setConstant(true);
1054 pullGauss.paramOn(&frame, RooFit::Label(ss.str().c_str()), RooFit::Layout(0.60, 0.9, 0.9));
1055}
1056
1057} // namespace
1058
1059
1060////////////////////////////////////////////////////////////////////////////////
1061/// Plot the distribution of pull values for the specified parameter on a newly created frame. If asymmetric
1062/// errors are calculated in the fit (by MINOS) those will be used in the pull calculation.
1063///
1064/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1065/// corresponding parameters:
1066/// - Parameters have the same name: They will be used to compute pulls.
1067/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1068/// computed. The parameter at the same position in the set of generator parameters will be used.
1069///
1070/// Further options:
1071/// <table>
1072/// <tr><th> Arguments <th> Effect
1073/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1074/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1075/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1076/// for list of allowed arguments
1077/// <tr><td> FitGauss(bool flag) <td> Add a gaussian fit to the frame
1078/// </table>
1079///
1080/// If no frame specifications are given, the AutoSymRange() feature will be used to set a default range.
1081/// Any other named argument is passed to the RooAbsData::plotOn(). See that function for allowed options.
1082///
1083/// If you want to have more control over the Gaussian fit to the pull
1084/// distribution, you can also do it after the call to plotPull():
1085///
1086/// ~~~ {.cpp}
1087/// RooPlot *frame = mcstudy->plotPull(myVariable, RooFit::Bins(40), RooFit::FitGauss(false));
1088/// RooRealVar pullMean("pullMean","Mean of pull",0,-10,10) ;
1089/// RooRealVar pullSigma("pullSigma","Width of pull",1,0.1,5) ;
1090/// pullMean.setPlotLabel("pull #mu"); // optional (to get nicer plot labels if you want)
1091/// pullSigma.setPlotLabel("pull #sigma"); // optional
1092/// RooGaussian pullGauss("pullGauss","Gaussian of pull", *frame->getPlotVar(), pullMean, pullSigma);
1093/// pullGauss.fitTo(const_cast<RooDataSet&>(mcstudy->fitParDataSet()),
1094/// RooFit::Minos(0), RooFit::PrintLevel(-1)) ;
1095/// pullGauss.plotOn(frame) ;
1096/// pullGauss.paramOn(frame, RooFit::Layout(0.65, 0.9, 0.9)); // optionally specify label position (xmin, xmax, ymax)
1097/// ~~~
1098
1099RooPlot* RooMCStudy::plotPull(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
1100 const RooCmdArg& arg3, const RooCmdArg& arg4,
1101 const RooCmdArg& arg5, const RooCmdArg& arg6,
1102 const RooCmdArg& arg7, const RooCmdArg& arg8)
1103{
1104 // Stuff all arguments in a list
1105 RooLinkedList cmdList;
1106 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
1107 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
1108 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
1109 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
1110
1111 TString name(param.GetName()), title(param.GetTitle()) ;
1112 name.Append("pull") ; title.Append(" Pull") ;
1113 RooRealVar pvar(name,title,-100,100) ;
1114 pvar.setBins(100) ;
1115
1116
1117 RooPlot* frame = makeFrameAndPlotCmd(pvar, cmdList, true) ;
1118 if (frame) {
1119
1120 // Pick up optonal FitGauss command from list
1121 RooCmdConfig pc(Form("RooMCStudy::plotPull(%s)",_genModel->GetName())) ;
1122 pc.defineInt("fitGauss","FitGauss",0,0) ;
1123 pc.allowUndefined() ;
1124 pc.process(cmdList) ;
1125 bool fitGauss=pc.getInt("fitGauss") ;
1126
1127 // Pass stripped command list to plotOn()
1128 RooCmdConfig::stripCmdList(cmdList,"FitGauss") ;
1129 const bool success = _fitParData->plotOn(frame,cmdList) ;
1130
1131 if (!success) {
1132 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1133 return frame;
1134 }
1135
1136 // Add Gaussian fit if requested
1137 if (fitGauss) {
1138 fitGaussToPulls(*frame, *_fitParData);
1139 }
1140
1141 // To make sure the frame has no dangling pointer to pvar.
1143 }
1144 return frame;
1145}
1146
1147
1148
1149////////////////////////////////////////////////////////////////////////////////
1150/// Internal function. Construct RooPlot from given parameter and modify the list of named
1151/// arguments 'cmdList' to only contain the plot arguments that should be forwarded to
1152/// RooAbsData::plotOn()
1153
1154RooPlot* RooMCStudy::makeFrameAndPlotCmd(const RooRealVar& param, RooLinkedList& cmdList, bool symRange) const
1155{
1156 // Select the frame-specific commands
1157 RooCmdConfig pc(Form("RooMCStudy::plotParam(%s)",_genModel->GetName())) ;
1158 pc.defineInt("nbins","Bins",0,0) ;
1159 pc.defineDouble("xlo","Range",0,0) ;
1160 pc.defineDouble("xhi","Range",1,0) ;
1161 pc.defineInt("dummy","FrameArgs",0,0) ;
1162 pc.defineMutex("Bins","FrameArgs") ;
1163 pc.defineMutex("Range","FrameArgs") ;
1164
1165 // Process and check varargs
1166 pc.allowUndefined() ;
1167 pc.process(cmdList) ;
1168 if (!pc.ok(true)) {
1169 return 0 ;
1170 }
1171
1172 // Make frame according to specs
1173 Int_t nbins = pc.getInt("nbins") ;
1174 double xlo = pc.getDouble("xlo") ;
1175 double xhi = pc.getDouble("xhi") ;
1176 RooPlot* frame ;
1177
1178 if (pc.hasProcessed("FrameArgs")) {
1179 // Explicit frame arguments are given, pass them on
1180 RooCmdArg* frameArg = static_cast<RooCmdArg*>(cmdList.FindObject("FrameArgs")) ;
1181 frame = param.frame(frameArg->subArgs()) ;
1182 } else {
1183 // FrameBins, FrameRange or none are given, build custom frame command list
1184 RooCmdArg bins = RooFit::Bins(nbins) ;
1185 RooCmdArg range = RooFit::Range(xlo,xhi) ;
1187 RooLinkedList frameCmdList ;
1188
1189 if (pc.hasProcessed("Bins")) frameCmdList.Add(&bins) ;
1190 if (pc.hasProcessed("Range")) {
1191 frameCmdList.Add(&range) ;
1192 } else {
1193 frameCmdList.Add(&autor) ;
1194 }
1195 frame = param.frame(frameCmdList) ;
1196 }
1197
1198 // Filter frame command from list and pass on to plotOn()
1199 RooCmdConfig::stripCmdList(cmdList,"FrameArgs,Bins,Range") ;
1200
1201 return frame ;
1202}
1203
1204
1205
1206////////////////////////////////////////////////////////////////////////////////
1207/// Create a RooPlot of the -log(L) distribution in the range lo-hi
1208/// with 'nBins' bins
1209
1210RooPlot* RooMCStudy::plotNLL(double lo, double hi, Int_t nBins)
1211{
1212 RooPlot* frame = _nllVar->frame(lo,hi,nBins) ;
1213
1214 _fitParData->plotOn(frame) ;
1215 return frame ;
1216}
1217
1218
1219
1220////////////////////////////////////////////////////////////////////////////////
1221/// Create a RooPlot of the distribution of the fitted errors of the given parameter.
1222/// The frame is created with a range [lo,hi] and plotted data will be binned in 'nbins' bins
1223
1224RooPlot* RooMCStudy::plotError(const RooRealVar& param, double lo, double hi, Int_t nbins)
1225{
1226 if (_canAddFitResults) {
1227 calcPulls() ;
1228 _canAddFitResults=false ;
1229 }
1230
1231 std::unique_ptr<RooErrorVar> evar{param.errorVar()};
1232 RooPlot* frame = evar->frame(lo,hi,nbins) ;
1233 _fitParData->plotOn(frame) ;
1234
1235 return frame ;
1236}
1237
1238
1239
1240////////////////////////////////////////////////////////////////////////////////
1241/// Create a RooPlot of the pull distribution for the given
1242/// parameter. The range lo-hi is plotted in nbins. If fitGauss is
1243/// set, an unbinned ML fit of the distribution to a Gaussian p.d.f
1244/// is performed. The fit result is overlaid on the returned RooPlot
1245/// and a box with the fitted mean and sigma is added.
1246///
1247/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1248/// corresponding parameters:
1249/// - Parameters have the same name: They will be used to compute pulls.
1250/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1251/// computed. The parameter at the same position in the set of generator parameters will be used.
1252
1253RooPlot* RooMCStudy::plotPull(const RooRealVar& param, double lo, double hi, Int_t nbins, bool fitGauss)
1254{
1255 if (_canAddFitResults) {
1256 calcPulls() ;
1257 _canAddFitResults=false ;
1258 }
1259
1260
1261 TString name(param.GetName()), title(param.GetTitle()) ;
1262 name.Append("pull") ; title.Append(" Pull") ;
1263 RooRealVar pvar(name,title,lo,hi) ;
1264 pvar.setBins(nbins) ;
1265
1266 RooPlot* frame = pvar.frame() ;
1267 const bool success = _fitParData->plotOn(frame);
1268
1269 if (!success) {
1270 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1271 return frame;
1272 }
1273
1274 if (fitGauss) {
1275 fitGaussToPulls(*frame, *_fitParData);
1276 }
1277
1278 return frame ;
1279}
1280
1281
1282////////////////////////////////////////////////////////////////////////////////
1283/// If one of the TObject we have a referenced to is deleted, remove the
1284/// reference.
1285
1287{
1291 if (_ngenVar.get() == obj) _ngenVar.reset();
1292
1293 if (_fitParData) _fitParData->RecursiveRemove(obj);
1294 if (_fitParData.get() == obj) _fitParData.reset();
1295
1296 if (_genParData) _genParData->RecursiveRemove(obj);
1297 if (_genParData.get() == obj) _genParData.reset();
1298}
1299
#define coutI(a)
Definition: RooMsgService.h:34
#define coutP(a)
Definition: RooMsgService.h:35
#define oocoutW(o, a)
Definition: RooMsgService.h:51
#define coutW(a)
Definition: RooMsgService.h:36
#define coutF(a)
Definition: RooMsgService.h:38
#define oocoutE(o, a)
Definition: RooMsgService.h:52
#define oocoutI(o, a)
Definition: RooMsgService.h:49
#define coutE(a)
Definition: RooMsgService.h:37
#define ooccoutI(o, a)
Definition: RooMsgService.h:57
#define ooccoutP(o, a)
Definition: RooMsgService.h:58
#define oocoutP(o, a)
Definition: RooMsgService.h:50
int Int_t
Definition: RtypesCore.h:45
#define ClassImp(name)
Definition: Rtypes.h:375
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
Definition: THbookFile.cxx:128
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition: TString.cxx:2468
#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:72
RooArgSet * getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
Definition: RooAbsArg.h:296
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...
Definition: RooAbsArg.cxx:563
bool empty() const
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:61
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:105
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Definition: RooAbsData.cxx:374
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.
Definition: RooAbsPdf.cxx:3255
Int_t * randomizeProtoOrder(Int_t nProto, Int_t nGen, bool resample=false) const
Return lookup table with randomized order for nProto prototype events.
Definition: RooAbsPdf.cxx:2300
virtual RooFitResult * fitTo(RooAbsData &data, const RooLinkedList &cmdList={})
Fit PDF to given dataset.
Definition: RooAbsPdf.cxx:1611
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.
Definition: RooAbsPdf.cxx:3104
virtual 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....
Definition: RooAbsPdf.cxx:3434
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.
Definition: RooAbsPdf.cxx:1940
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:60
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:56
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:179
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.
Definition: RooCmdConfig.h:31
static void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
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.
Definition: RooFitResult.h:40
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Definition: RooFitResult.h:111
Int_t status() const
Return MINUIT status code.
Definition: RooFitResult.h:78
double minNll() const
Return minimized -log(L) value.
Definition: RooFitResult.h:99
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:38
Int_t GetSize() const
Definition: RooLinkedList.h:63
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)
Definition: RooLinkedList.h:67
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...
Definition: RooMCStudy.cxx:706
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.
Definition: RooMCStudy.cxx:974
const RooArgSet * fitParams(Int_t sampleNum) const
Return an argset with the fit parameters for the given sample number.
Definition: RooMCStudy.cxx:825
void calcPulls()
Calculate the pulls for all fit parameters in the fit results data set, and add them to that dataset.
Definition: RooMCStudy.cxx:740
~RooMCStudy() override
Definition: RooMCStudy.cxx:294
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.
Definition: RooMCStudy.cxx:109
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.
Definition: RooMCStudy.cxx:661
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.
Definition: RooMCStudy.cxx:536
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.
Definition: RooMCStudy.cxx:843
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.
Definition: RooMCStudy.cxx:998
RooArgSet _fitParams
List of actual fit parameters.
Definition: RooMCStudy.h:122
std::unique_ptr< RooAbsGenContext > _genContext
Generator context.
Definition: RooMCStudy.h:109
RooFitResult * refit(RooAbsData *genSample=nullptr)
Redo fit on 'current' toy sample, or if genSample is not nullptr do fit on given sample instead.
Definition: RooMCStudy.cxx:634
RooAbsData * genData(Int_t sampleNum) const
Return the given generated dataset.
Definition: RooMCStudy.cxx:868
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.
Definition: RooMCStudy.cxx:805
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.
Definition: RooMCStudy.cxx:896
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.
Definition: RooMCStudy.cxx:327
void resetFitParams()
Reset all fit parameters to the initial model parameters at the time of the RooMCStudy constructor.
Definition: RooMCStudy.cxx:589
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.
Definition: RooMCStudy.cxx:553
bool generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, bool keepGenData=false, const char *asciiFilePat=nullptr)
Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
Definition: RooMCStudy.cxx:514
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.
Definition: RooMCStudy.cxx:940
void addModule(RooAbsMCStudyModule &module)
Insert given RooMCStudy add-on module to the processing chain of this MCStudy object.
Definition: RooMCStudy.cxx:306
RooArgSet _fitInitParams
List of initial values of fit parameters.
Definition: RooMCStudy.h:121
RooFitResult * doFit(RooAbsData *genSample)
Internal function. Performs actual fit according to specifications.
Definition: RooMCStudy.cxx:599
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:1451
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.
Definition: RooRealVar.cxx:290
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
Definition: RooRealVar.cxx:854
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
Definition: RooRealVar.cxx:407
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
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.
Definition: TCollection.h:184
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:136
const char * Data() const
Definition: TString.h:369
TString & Append(const char *cs)
Definition: TString.h:565
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)
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Definition: RooGlobalFunc.h:60
@ Generation
Definition: RooGlobalFunc.h:62
@ InputArguments
Definition: RooGlobalFunc.h:63
static constexpr double pc