Logo ROOT   6.18/05
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 generated from either same PDF
25or another PDF.
26
27Given a fit PDF and a generator PDF, RooMCStudy can produce
28large numbers of toyMC samples and/or fit these samples
29and accumulate the final parameters of each fit in a dataset.
30Additional plotting routines simplify the task of plotting
31the distribution of the minimized likelihood, the fitted parameter values,
32fitted error and pull distribution.
33RooMCStudy provides the option to insert add-in modules
34that modify the generate-and-fit cycle and allow to perform
35extra steps in the cycle. Output of these modules can be stored
36alongside the fit results in the aggregate results dataset.
37These study modules should derive from the class RooAbsMCStudyModule.
38
39**/
40
41
42
43#include "RooFit.h"
44#include "Riostream.h"
45
46#include "RooMCStudy.h"
47#include "RooAbsMCStudyModule.h"
48
49#include "RooGenContext.h"
50#include "RooAbsPdf.h"
51#include "RooDataSet.h"
52#include "RooDataHist.h"
53#include "RooRealVar.h"
54#include "RooFitResult.h"
55#include "RooErrorVar.h"
56#include "RooFormulaVar.h"
57#include "RooArgList.h"
58#include "RooPlot.h"
59#include "RooGenericPdf.h"
60#include "RooRandom.h"
61#include "RooCmdConfig.h"
62#include "RooGlobalFunc.h"
63#include "RooPullVar.h"
64#include "RooMsgService.h"
65#include "RooProdPdf.h"
66
67using namespace std ;
68
70 ;
71
72
73/**
74Construct Monte Carlo Study Manager. This class automates generating data from a given PDF,
75fitting the PDF to data and accumulating the fit statistics.
76
77\param[in] model The PDF to be studied
78\param[in] observables The variables of the PDF to be considered observables
79\param[in] argX Arguments from the table below
80
81<table>
82<tr><th> Optional arguments <th>
83<tr><td> Silence() <td> Suppress all RooFit messages during running below PROGRESS level
84<tr><td> FitModel(const RooAbsPdf&) <td> The PDF for fitting if it is different from the PDF for generating.
85<tr><td> ConditionalObservables(const RooArgSet& set) <td> The set of observables that the PDF should _not_ be normalized over
86<tr><td> Binned(Bool_t flag) <td> Bin the dataset before fitting it. Speeds up fitting of large data samples
87<tr><td> FitOptions(const char*) <td> Classic fit options, provided for backward compatibility
88<tr><td> FitOptions(....) <td> Options to be used for fitting. All named arguments inside FitOptions() are passed to RooAbsPdf::fitTo()
89<tr><td> Verbose(Bool_t flag) <td> Activate informational messages in event generation phase
90<tr><td> Extended(Bool_t flag) <td> Determine number of events for each sample anew from a Poisson distribution
91<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.
92<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.
93<tr><td> ProtoData(const RooDataSet&, Bool_t randOrder)
94 <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
95 cycle to protect against systematic biases if the number of generated events does not exactly match the number of events in the prototype dataset
96 at the cost of reduced precision with mu equal to the specified number of events
97</table>
98*/
99RooMCStudy::RooMCStudy(const RooAbsPdf& model, const RooArgSet& observables,
100 const RooCmdArg& arg1, const RooCmdArg& arg2,
101 const RooCmdArg& arg3,const RooCmdArg& arg4,const RooCmdArg& arg5,
102 const RooCmdArg& arg6,const RooCmdArg& arg7,const RooCmdArg& arg8) : TNamed("mcstudy","mcstudy")
103
104{
105 // Stuff all arguments in a list
106 RooLinkedList cmdList;
107 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
108 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
109 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
110 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
111
112 // Select the pdf-specific commands
113 RooCmdConfig pc(Form("RooMCStudy::RooMCStudy(%s)",model.GetName())) ;
114
115 pc.defineObject("fitModel","FitModel",0,0) ;
116 pc.defineObject("condObs","ProjectedDependents",0,0) ;
117 pc.defineObject("protoData","PrototypeData",0,0) ;
118 pc.defineSet("cPars","Constrain",0,0) ;
119 pc.defineSet("extCons","ExternalConstraints",0,0) ;
120 pc.defineInt("silence","Silence",0,0) ;
121 pc.defineInt("randProtoData","PrototypeData",0,0) ;
122 pc.defineInt("verboseGen","Verbose",0,0) ;
123 pc.defineInt("extendedGen","Extended",0,0) ;
124 pc.defineInt("binGenData","Binned",0,0) ;
125 pc.defineString("fitOpts","FitOptions",0,"") ;
126 pc.defineInt("dummy","FitOptArgs",0,0) ;
127 pc.defineMutex("FitOptions","FitOptArgs") ; // can have either classic or new-style fit options
128 pc.defineMutex("Constrain","FitOptions") ; // constraints only work with new-style fit options
129 pc.defineMutex("ExternalConstraints","FitOptions") ; // constraints only work with new-style fit options
130
131 // Process and check varargs
132 pc.process(cmdList) ;
133 if (!pc.ok(kTRUE)) {
134 // WVE do something here
135 throw std::string("RooMCStudy::RooMCStudy() Error in parsing arguments passed to contructor") ;
136 return ;
137 }
138
139 // Save fit command options
140 if (pc.hasProcessed("FitOptArgs")) {
141 RooCmdArg* fitOptArg = static_cast<RooCmdArg*>(cmdList.FindObject("FitOptArgs")) ;
142 for (Int_t i=0 ; i<fitOptArg->subArgs().GetSize() ;i++) {
143 _fitOptList.Add(new RooCmdArg(static_cast<RooCmdArg&>(*fitOptArg->subArgs().At(i)))) ;
144 }
145 }
146
147 // Decode command line arguments
148 _silence = pc.getInt("silence") ;
149 _verboseGen = pc.getInt("verboseGen") ;
150 _extendedGen = pc.getInt("extendedGen") ;
151 _binGenData = pc.getInt("binGenData") ;
152 _randProto = pc.getInt("randProtoData") ;
153
154 // Process constraints specifications
155 const RooArgSet* cParsTmp = pc.getSet("cPars") ;
156 const RooArgSet* extCons = pc.getSet("extCons") ;
157
158 RooArgSet* cPars = new RooArgSet ;
159 if (cParsTmp) {
160 cPars->add(*cParsTmp) ;
161 }
162
163 // If constraints are specified, add to fit options
164 if (cPars) {
166 }
167 if (extCons) {
169 }
170
171 // Make list of all constraints
172 RooArgSet allConstraints ;
173 RooArgSet consPars ;
174 if (cPars) {
175 RooArgSet* constraints = model.getAllConstraints(observables,*cPars,kTRUE) ;
176 if (constraints) {
177 allConstraints.add(*constraints) ;
178 delete constraints ;
179 }
180 }
181
182 // Construct constraint p.d.f
183 if (allConstraints.getSize()>0) {
184 _constrPdf = new RooProdPdf("mcs_constr_prod","RooMCStudy constraints product",allConstraints) ;
185
186 if (cPars) {
187 consPars.add(*cPars) ;
188 } else {
189 RooArgSet* params = model.getParameters(observables) ;
190 RooArgSet* cparams = _constrPdf->getObservables(*params) ;
191 consPars.add(*cparams) ;
192 delete params ;
193 delete cparams ;
194 }
196
198
199 coutI(Generation) << "RooMCStudy::RooMCStudy: INFO have pdf with constraints, will generate parameters from constraint pdf for each experiment" << endl ;
200
201
202 } else {
203 _constrPdf = 0 ;
205
207 }
208
209
210 // Extract generator and fit models
211 _genModel = const_cast<RooAbsPdf*>(&model) ;
212 _genSample = 0 ;
213 RooAbsPdf* fitModel = static_cast<RooAbsPdf*>(pc.getObject("fitModel",0)) ;
214 _fitModel = fitModel ? fitModel : _genModel ;
215
216 // Extract conditional observables and prototype data
217 _genProtoData = static_cast<RooDataSet*>(pc.getObject("protoData",0)) ;
218 if (pc.getObject("condObs",0)) {
219 _projDeps.add(static_cast<RooArgSet&>(*pc.getObject("condObs",0))) ;
220 }
221
222 _dependents.add(observables) ;
223
225 _fitOptions = pc.getString("fitOpts") ;
227
229 oocoutW(_fitModel,Generation) << "RooMCStudy::RooMCStudy: WARNING Using generator option 'e' (Poisson distribution of #events) together " << endl
230 << " with a prototype dataset implies incomplete sampling or oversampling of proto data." << endl
231 << " Use option \"r\" to randomize prototype dataset order and thus to randomize" << endl
232 << " the set of over/undersampled prototype events for each generation cycle." << endl ;
233 }
234
236 if (!_binGenData) {
239 } else {
240 _genContext = 0 ;
241 }
242
244
245 // Store list of parameters and save initial values separately
248
250
251 // Place holder for NLL
252 _nllVar = new RooRealVar("NLL","-log(Likelihood)",0) ;
253
254 // Place holder for number of generated events
255 _ngenVar = new RooRealVar("ngen","number of generated events",0) ;
256
257 // Create data set containing parameter values, errors and pulls
258 RooArgSet tmp2(*_fitParams) ;
259 tmp2.add(*_nllVar) ;
260 tmp2.add(*_ngenVar) ;
261
262 // Mark all variable to store their errors in the dataset
263 tmp2.setAttribAll("StoreError",kTRUE) ;
264 tmp2.setAttribAll("StoreAsymError",kTRUE) ;
265 TString fpdName ;
266 if (_fitModel==_genModel) {
267 fpdName = Form("fitParData_%s",_fitModel->GetName()) ;
268 } else {
269 fpdName= Form("fitParData_%s_%s",_fitModel->GetName(),_genModel->GetName()) ;
270 }
271
272 _fitParData = new RooDataSet(fpdName.Data(),"Fit Parameters DataSet",tmp2) ;
273 tmp2.setAttribAll("StoreError",kFALSE) ;
274 tmp2.setAttribAll("StoreAsymError",kFALSE) ;
275
276 if (_perExptGenParams) {
277 _genParData = new RooDataSet("genParData","Generated Parameters dataset",*_genParams) ;
278 } else {
279 _genParData = 0 ;
280 }
281
282 // Append proto variables to allDependents
283 if (_genProtoData) {
285 }
286
287 // Call module initializers
288 list<RooAbsMCStudyModule*>::iterator iter ;
289 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
290 Bool_t ok = (*iter)->doInitializeInstance(*this) ;
291 if (!ok) {
292 oocoutE(_fitModel,Generation) << "RooMCStudy::ctor: removing study module " << (*iter)->GetName() << " from analysis chain because initialization failed" << endl ;
293 iter = _modList.erase(iter) ;
294 }
295 }
296
297}
298
299
300////////////////////////////////////////////////////////////////////////////////
301/// \deprecated PLEASE USE CONSTRUCTOR WITH NAMED ARGUMENTS. RETAINED FOR BACKWARD COMPATIBILY.
302///
303/// Constructor with a generator and fit model. Both models may point
304/// to the same object. The 'dependents' set of variables is generated
305/// in the generator phase. The optional prototype dataset is passed to
306/// the generator
307///
308/// Available generator options
309/// v - Verbose
310/// e - Extended: use Poisson distribution for Nevts generated
311///
312/// Available fit options
313/// See RooAbsPdf::fitTo()
314///
315
316RooMCStudy::RooMCStudy(const RooAbsPdf& genModel, const RooAbsPdf& fitModel,
317 const RooArgSet& dependents, const char* genOptions,
318 const char* fitOptions, const RooDataSet* genProtoData,
319 const RooArgSet& projDeps) :
320 TNamed("mcstudy","mcstudy"),
321 _genModel((RooAbsPdf*)&genModel),
322 _genProtoData(genProtoData),
323 _projDeps(projDeps),
324 _constrPdf(0),
325 _constrGenContext(0),
326 _dependents(dependents),
327 _allDependents(dependents),
328 _fitModel((RooAbsPdf*)&fitModel),
329 _nllVar(0),
330 _ngenVar(0),
331 _genParData(0),
332 _fitOptions(fitOptions),
333 _canAddFitResults(kTRUE),
334 _perExptGenParams(0),
335 _silence(kFALSE)
336{
337 // Decode generator options
338 TString genOpt(genOptions) ;
339 genOpt.ToLower() ;
340 _verboseGen = genOpt.Contains("v") ;
341 _extendedGen = genOpt.Contains("e") ;
342 _binGenData = genOpt.Contains("b") ;
343 _randProto = genOpt.Contains("r") ;
344
345 if (_extendedGen && genProtoData && !_randProto) {
346 oocoutE(_fitModel,Generation) << "RooMCStudy::RooMCStudy: WARNING Using generator option 'e' (Poisson distribution of #events) together " << endl
347 << " with a prototype dataset implies incomplete sampling or oversampling of proto data." << endl
348 << " Use option \"r\" to randomize prototype dataset order and thus to randomize" << endl
349 << " the set of over/undersampled prototype events for each generation cycle." << endl ;
350 }
351
352 if (!_binGenData) {
353 _genContext = genModel.genContext(dependents,genProtoData,0,_verboseGen) ;
354 } else {
355 _genContext = 0 ;
356 }
358 _genSample = 0 ;
359 RooArgSet* tmp = genModel.getParameters(&dependents) ;
361 delete tmp ;
362
363 // Store list of parameters and save initial values separately
364 _fitParams = fitModel.getParameters(&dependents) ;
366
367 _nExpGen = _extendedGen ? genModel.expectedEvents(&dependents) : 0 ;
368
369 // Place holder for NLL
370 _nllVar = new RooRealVar("NLL","-log(Likelihood)",0) ;
371
372 // Place holder for number of generated events
373 _ngenVar = new RooRealVar("ngen","number of generated events",0) ;
374
375 // Create data set containing parameter values, errors and pulls
376 RooArgSet tmp2(*_fitParams) ;
377 tmp2.add(*_nllVar) ;
378 tmp2.add(*_ngenVar) ;
379
380 // Mark all variable to store their errors in the dataset
381 tmp2.setAttribAll("StoreError",kTRUE) ;
382 tmp2.setAttribAll("StoreAsymError",kTRUE) ;
383 _fitParData = new RooDataSet("fitParData","Fit Parameters DataSet",tmp2) ;
384 tmp2.setAttribAll("StoreError",kFALSE) ;
385 tmp2.setAttribAll("StoreAsymError",kFALSE) ;
386
387 // Append proto variables to allDependents
388 if (genProtoData) {
389 _allDependents.add(*genProtoData->get(),kTRUE) ;
390 }
391
392 // Call module initializers
393 list<RooAbsMCStudyModule*>::iterator iter ;
394 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
395 Bool_t ok = (*iter)->doInitializeInstance(*this) ;
396 if (!ok) {
397 oocoutE(_fitModel,Generation) << "RooMCStudy::ctor: removing study module " << (*iter)->GetName() << " from analysis chain because initialization failed" << endl ;
398 iter = _modList.erase(iter) ;
399 }
400 }
401
402}
403
404
405
406////////////////////////////////////////////////////////////////////////////////
407
409{
412 delete _ngenVar ;
413 delete _fitParData ;
414 delete _genParData ;
415 delete _fitInitParams ;
416 delete _fitParams ;
417 delete _genInitParams ;
418 delete _genParams ;
419 delete _genContext ;
420 delete _nllVar ;
421 delete _constrPdf ;
422 delete _constrGenContext ;
423}
424
425
426
427////////////////////////////////////////////////////////////////////////////////
428/// Insert given RooMCStudy add-on module to the processing chain
429/// of this MCStudy object
430
432{
433 module.doInitializeInstance(*this) ;
434 _modList.push_back(&module) ;
435}
436
437
438
439////////////////////////////////////////////////////////////////////////////////
440/// Run engine method. Generate and/or fit, according to flags, 'nSamples' samples of 'nEvtPerSample' events.
441/// If keepGenData is set, all generated data sets will be kept in memory and can be accessed
442/// later via genData().
443///
444/// When generating, data sets will be written out in ascii form if the pattern string is supplied
445/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
446/// and should contain one integer field that encodes the sample serial number.
447///
448/// When fitting only, data sets may optionally be read from ascii files, using the same file
449/// pattern.
450///
451
452Bool_t RooMCStudy::run(Bool_t doGenerate, Bool_t DoFit, Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char* asciiFilePat)
453{
455 if (_silence) {
458 }
459
460 list<RooAbsMCStudyModule*>::iterator iter ;
461 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
462 (*iter)->initializeRun(nSamples) ;
463 }
464
465 Int_t prescale = nSamples>100 ? Int_t(nSamples/100) : 1 ;
466
467 while(nSamples--) {
468
469 if (nSamples%prescale==0) {
470 oocoutP(_fitModel,Generation) << "RooMCStudy::run: " ;
471 if (doGenerate) ooccoutI(_fitModel,Generation) << "Generating " ;
472 if (doGenerate && DoFit) ooccoutI(_fitModel,Generation) << "and " ;
473 if (DoFit) ooccoutI(_fitModel,Generation) << "fitting " ;
474 ooccoutP(_fitModel,Generation) << "sample " << nSamples << endl ;
475 }
476
477 _genSample = 0;
478 Bool_t existingData = kFALSE ;
479 if (doGenerate) {
480 // Generate sample
481 Int_t nEvt(nEvtPerSample) ;
482
483 // Reset generator parameters to initial values
485
486 // If constraints are present, sample generator values from constraints
487 if (_constrPdf) {
489 *_genParams = *tmp->get() ;
490 delete tmp ;
491 }
492
493 // Save generated parameters if required
494 if (_genParData) {
496 }
497
498 // Call module before-generation hook
499 list<RooAbsMCStudyModule*>::iterator iter2 ;
500 for (iter2=_modList.begin() ; iter2!= _modList.end() ; ++iter2) {
501 (*iter2)->processBeforeGen(nSamples) ;
502 }
503
504 if (_binGenData) {
505
506 // Calculate the number of (extended) events for this run
507 if (_extendedGen) {
509 nEvt = RooRandom::randomGenerator()->Poisson(nEvtPerSample==0?_nExpGen:nEvtPerSample) ;
510 }
511
512 // Binned generation
514
515 } else {
516
517 // Calculate the number of (extended) events for this run
518 if (_extendedGen) {
520 nEvt = RooRandom::randomGenerator()->Poisson(nEvtPerSample==0?_nExpGen:nEvtPerSample) ;
521 }
522
523 // Optional randomization of protodata for this run
525 oocoutI(_fitModel,Generation) << "RooMCStudy: (Re)randomizing event order in prototype dataset (Nevt=" << nEvt << ")" << endl ;
527 _genContext->setProtoDataOrder(newOrder) ;
528 delete[] newOrder ;
529 }
530
531 coutP(Generation) << "RooMCStudy: now generating " << nEvt << " events" << endl ;
532
533 // Actual generation of events
534 if (nEvt>0) {
536 } else {
537 // Make empty dataset
538 _genSample = new RooDataSet("emptySample","emptySample",_dependents) ;
539 }
540 }
541
542
543 //} else if (asciiFilePat && &asciiFilePat) { //warning: the address of 'asciiFilePat' will always evaluate as 'true'
544 } else if (asciiFilePat) {
545
546 // Load sample from ASCII file
547 char asciiFile[1024] ;
548 snprintf(asciiFile,1024,asciiFilePat,nSamples) ;
549 RooArgList depList(_allDependents) ;
550 _genSample = RooDataSet::read(asciiFile,depList,"q") ;
551
552 } else {
553
554 // Load sample from internal list
555 _genSample = (RooDataSet*) _genDataList.At(nSamples) ;
556 existingData = kTRUE ;
557 if (!_genSample) {
558 oocoutW(_fitModel,Generation) << "RooMCStudy::run: WARNING: Sample #" << nSamples << " not loaded, skipping" << endl ;
559 continue ;
560 }
561 }
562
563 // Save number of generated events
565
566 // Call module between generation and fitting hook
567 list<RooAbsMCStudyModule*>::iterator iter3 ;
568 for (iter3=_modList.begin() ; iter3!= _modList.end() ; ++iter3) {
569 (*iter3)->processBetweenGenAndFit(nSamples) ;
570 }
571
572 if (DoFit) fitSample(_genSample) ;
573
574 // Call module between generation and fitting hook
575 for (iter3=_modList.begin() ; iter3!= _modList.end() ; ++iter3) {
576 (*iter3)->processAfterFit(nSamples) ;
577 }
578
579 // Optionally write to ascii file
580 if (doGenerate && asciiFilePat && *asciiFilePat) {
581 char asciiFile[1024] ;
582 snprintf(asciiFile,1024,asciiFilePat,nSamples) ;
583 RooDataSet* unbinnedData = dynamic_cast<RooDataSet*>(_genSample) ;
584 if (unbinnedData) {
585 unbinnedData->write(asciiFile) ;
586 } else {
587 coutE(InputArguments) << "RooMCStudy::run(" << GetName() << ") ERROR: ASCII writing of binned datasets is not supported" << endl ;
588 }
589 }
590
591 // Add to list or delete
592 if (!existingData) {
593 if (keepGenData) {
595 } else {
596 delete _genSample ;
597 }
598 }
599 }
600
601 for (iter=_modList.begin() ; iter!= _modList.end() ; ++iter) {
602 RooDataSet* auxData = (*iter)->finalizeRun() ;
603 if (auxData) {
604 _fitParData->merge(auxData) ;
605 }
606 }
607
609
610 if (_genParData) {
611 const RooArgSet* genPars = _genParData->get() ;
612 TIterator* iter2 = genPars->createIterator() ;
613 RooAbsArg* arg ;
614 while((arg=(RooAbsArg*)iter2->Next())) {
615 _genParData->changeObservableName(arg->GetName(),Form("%s_gen",arg->GetName())) ;
616 }
617 delete iter2 ;
618
620 }
621
622 if (DoFit) calcPulls() ;
623
624 if (_silence) {
626 }
627
628 return kFALSE ;
629}
630
631
632
633
634
635
636////////////////////////////////////////////////////////////////////////////////
637/// Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
638/// If keepGenData is set, all generated data sets will be kept in memory and can be accessed
639/// later via genData().
640///
641/// Data sets will be written out in ascii form if the pattern string is supplied.
642/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
643/// and should contain one integer field that encodes the sample serial number.
644///
645
646Bool_t RooMCStudy::generateAndFit(Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char* asciiFilePat)
647{
648 // Clear any previous data in memory
649 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
651 _fitParData->reset() ;
652
653 return run(kTRUE,kTRUE,nSamples,nEvtPerSample,keepGenData,asciiFilePat) ;
654}
655
656
657
658////////////////////////////////////////////////////////////////////////////////
659/// Generate 'nSamples' samples of 'nEvtPerSample' events.
660/// If keepGenData is set, all generated data sets will be kept in memory
661/// and can be accessed later via genData().
662///
663/// Data sets will be written out in ascii form if the pattern string is supplied.
664/// The pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
665/// and should contain one integer field that encodes the sample serial number.
666///
667
668Bool_t RooMCStudy::generate(Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char* asciiFilePat)
669{
670 // Clear any previous data in memory
672
673 return run(kTRUE,kFALSE,nSamples,nEvtPerSample,keepGenData,asciiFilePat) ;
674}
675
676
677
678////////////////////////////////////////////////////////////////////////////////
679/// Fit 'nSamples' datasets, which are read from ASCII files.
680///
681/// The ascii file pattern, which is a template for snprintf, should look something like "data/toymc_%04d.dat"
682/// and should contain one integer field that encodes the sample serial number.
683///
684
685Bool_t RooMCStudy::fit(Int_t nSamples, const char* asciiFilePat)
686{
687 // Clear any previous data in memory
688 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
689 _fitParData->reset() ;
690
691 return run(kFALSE,kTRUE,nSamples,0,kFALSE,asciiFilePat) ;
692}
693
694
695
696////////////////////////////////////////////////////////////////////////////////
697/// Fit 'nSamples' datasets, as supplied in 'dataSetList'
698///
699
700Bool_t RooMCStudy::fit(Int_t nSamples, TList& dataSetList)
701{
702 // Clear any previous data in memory
703 _fitResList.Delete() ; // even though the fit results are owned by gROOT, we still want to scratch them here.
705 _fitParData->reset() ;
706
707 // Load list of data sets
708 TIterator* iter = dataSetList.MakeIterator() ;
709 RooAbsData* gset ;
710 while((gset=(RooAbsData*)iter->Next())) {
711 _genDataList.Add(gset) ;
712 }
713 delete iter ;
714
715 return run(kFALSE,kTRUE,nSamples,0,kTRUE,0) ;
716}
717
718
719
720////////////////////////////////////////////////////////////////////////////////
721/// Reset all fit parameters to the initial model
722/// parameters at the time of the RooMCStudy constructor
723
725{
727}
728
729
730
731////////////////////////////////////////////////////////////////////////////////
732/// Internal function. Performs actual fit according to specifications
733
735{
736 // Fit model to data set
737 TString fitOpt2(_fitOptions) ; fitOpt2.Append("r") ;
738 if (_silence) {
739 fitOpt2.Append("b") ;
740 }
741
742 // Optionally bin dataset before fitting
743 RooAbsData* data ;
744 if (_binGenData) {
745 RooArgSet* depList = _fitModel->getObservables(genSample) ;
746 data = new RooDataHist(genSample->GetName(),genSample->GetTitle(),*depList,*genSample) ;
747 delete depList ;
748 } else {
749 data = genSample ;
750 }
751
752 RooFitResult* fr ;
753 if (_fitOptList.GetSize()==0) {
754 if (_projDeps.getSize()>0) {
756 } else {
757 fr = (RooFitResult*) _fitModel->fitTo(*data,RooFit::FitOptions(fitOpt2)) ;
758 }
759 } else {
760 RooCmdArg save = RooFit::Save() ;
762 RooCmdArg plevel = RooFit::PrintLevel(-1) ;
763 RooLinkedList fitOptList(_fitOptList) ;
764 fitOptList.Add(&save) ;
765 if (_projDeps.getSize()>0) {
766 fitOptList.Add(&condo) ;
767 }
768 if (_silence) {
769 fitOptList.Add(&plevel) ;
770 }
771 fr = (RooFitResult*) _fitModel->fitTo(*data,fitOptList) ;
772 }
773
774 if (_binGenData) delete data ;
775
776 return fr ;
777}
778
779
780
781////////////////////////////////////////////////////////////////////////////////
782/// Redo fit on 'current' toy sample, or if genSample is not NULL
783/// do fit on given sample instead
784
786{
787 if (!genSample) {
788 genSample = _genSample ;
789 }
790
791 RooFitResult* fr(0) ;
792 if (genSample->sumEntries()>0) {
793 fr = doFit(genSample) ;
794 }
795
796 return fr ;
797}
798
799
800
801////////////////////////////////////////////////////////////////////////////////
802/// Internal method. Fit given dataset with fit model. If fit
803/// converges (TMinuit status code zero) The fit results are appended
804/// to the fit results dataset
805///
806/// If the fit option "r" is supplied, the RooFitResult
807/// objects will always be saved, regardless of the
808/// fit status. RooFitResults objects can be retrieved
809/// later via fitResult().
810///
811
813{
814 // Reset all fit parameters to their initial values
816
817 // Perform actual fit
818 Bool_t ok ;
819 RooFitResult* fr(0) ;
820 if (genSample->sumEntries()>0) {
821 fr = doFit(genSample) ;
822 ok = (fr->status()==0) ;
823 } else {
824 ok = kFALSE ;
825 }
826
827 // If fit converged, store parameters and NLL
828 if (ok) {
829 _nllVar->setVal(fr->minNll()) ;
830 RooArgSet tmp(*_fitParams) ;
831 tmp.add(*_nllVar) ;
832 tmp.add(*_ngenVar) ;
833
834 _fitParData->add(tmp) ;
835 }
836
837 // Store fit result if requested by user
838 Bool_t userSaveRequest = kFALSE ;
839 if (_fitOptList.GetSize()>0) {
840 if (_fitOptList.FindObject("Save")) userSaveRequest = kTRUE ;
841 } else {
842 if (_fitOptions.Contains("r")) userSaveRequest = kTRUE ;
843 }
844
845 if (userSaveRequest) {
846 _fitResList.Add(fr) ;
847 } else {
848 delete fr ;
849 }
850
851 return !ok ;
852}
853
854
855
856////////////////////////////////////////////////////////////////////////////////
857/// Utility function to add fit result from external fit to this RooMCStudy
858/// and process its results through the standard RooMCStudy statistics gathering tools.
859/// This function allows users to run the toy MC generation and/or fitting
860/// in a distributed way and to collect and analyze the results in a RooMCStudy
861/// as if they were run locally.
862///
863/// This method is only functional if this RooMCStudy object is cleanm, i.e. it was not used
864/// to generate and/or fit any samples.
865
867{
868 if (!_canAddFitResults) {
869 oocoutE(_fitModel,InputArguments) << "RooMCStudy::addFitResult: ERROR cannot add fit results in current state" << endl ;
870 return kTRUE ;
871 }
872
873 // Transfer contents of fit result to fitParams ;
875
876 // If fit converged, store parameters and NLL
877 Bool_t ok = (fr.status()==0) ;
878 if (ok) {
879 _nllVar->setVal(fr.minNll()) ;
880 RooArgSet tmp(*_fitParams) ;
881 tmp.add(*_nllVar) ;
882 tmp.add(*_ngenVar) ;
883 _fitParData->add(tmp) ;
884 }
885
886 // Store fit result if requested by user
887 if (_fitOptions.Contains("r")) {
888 _fitResList.Add((TObject*)&fr) ;
889 }
890
891 return kFALSE ;
892}
893
894
895
896////////////////////////////////////////////////////////////////////////////////
897/// Calculate the pulls for all fit parameters in
898/// the fit results data set, and add them to that dataset.
899
901{
902 for (auto it = _fitParams->begin(); it != _fitParams->end(); ++it) {
903 const auto par = static_cast<RooRealVar*>(*it);
904 RooErrorVar* err = par->errorVar();
905 _fitParData->addColumn(*err);
906 delete err;
907
908 TString name(par->GetName()), title(par->GetTitle()) ;
909 name.Append("pull") ;
910 title.Append(" Pull") ;
911
912 if (!par->hasError(false)) {
913 coutW(Generation) << "Fit parameter '" << par->GetName() << "' does not have an error."
914 " A pull distribution cannot be generated. This might be caused by the parameter being constant or"
915 " because the fits were not run." << std::endl;
916 continue;
917 }
918
919 // First look in fitParDataset to see if per-experiment generated value has been stored
920 auto genParOrig = static_cast<RooAbsReal*>(_fitParData->get()->find(Form("%s_gen",par->GetName())));
921 if (genParOrig && _perExptGenParams) {
922
923 RooPullVar pull(name,title,*par,*genParOrig) ;
925
926 } else {
927 // If not use fixed generator value
928 genParOrig = static_cast<RooAbsReal*>(_genInitParams->find(par->GetName()));
929
930 if (!genParOrig) {
931 std::size_t index = it - _fitParams->begin();
932 genParOrig = index < _genInitParams->size() ?
933 static_cast<RooAbsReal*>((*_genInitParams)[index]) :
934 nullptr;
935
936 if (genParOrig) {
937 coutW(Generation) << "The fit parameter '" << par->GetName() << "' is not in the model that was used to generate toy data. "
938 "The parameter '" << genParOrig->GetName() << "'=" << genParOrig->getVal() << " was found at the same position in the generator model."
939 " It will be used to compute pulls."
940 "\nIf this is not desired, the parameters of the generator model need to be renamed or reordered." << std::endl;
941 }
942 }
943
944 if (genParOrig) {
945 std::unique_ptr<RooAbsReal> genPar(static_cast<RooAbsReal*>(genParOrig->Clone("truth")));
946 RooPullVar pull(name,title,*par,*genPar);
947
949 } else {
950 coutE(Generation) << "Cannot generate pull distribution for the fit parameter '" << par->GetName() << "'."
951 "\nNo similar parameter was found in the set of parameters that were used to generate toy data." << std::endl;
952 }
953 }
954 }
955
956}
957
958
959
960
961////////////////////////////////////////////////////////////////////////////////
962/// Return a RooDataSet the resulting fit parameters of each toy cycle.
963/// This dataset also contains any additional output that was generated
964/// by study modules that were added to this RooMCStudy
965
967{
968 if (_canAddFitResults) {
969 calcPulls() ;
971 }
972
973 return *_fitParData ;
974}
975
976
977
978////////////////////////////////////////////////////////////////////////////////
979/// Return an argset with the fit parameters for the given sample number
980///
981/// NB: The fit parameters are only stored for successfull fits,
982/// thus the maximum sampleNum can be less that the number
983/// of generated samples and if so, the indeces will
984/// be out of synch with genData() and fitResult()
985
986const RooArgSet* RooMCStudy::fitParams(Int_t sampleNum) const
987{
988 // Check if sampleNum is in range
989 if (sampleNum<0 || sampleNum>=_fitParData->numEntries()) {
990 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitParams: ERROR, invalid sample number: " << sampleNum << endl ;
991 return 0 ;
992 }
993
994 return _fitParData->get(sampleNum) ;
995}
996
997
998
999////////////////////////////////////////////////////////////////////////////////
1000/// Return the RooFitResult object of the fit to given sample
1001
1003{
1004 // Check if sampleNum is in range
1005 if (sampleNum<0 || sampleNum>=_fitResList.GetSize()) {
1006 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, invalid sample number: " << sampleNum << endl ;
1007 return 0 ;
1008 }
1009
1010 // Retrieve fit result object
1011 const RooFitResult* fr = (RooFitResult*) _fitResList.At(sampleNum) ;
1012 if (fr) {
1013 return fr ;
1014 } else {
1015 oocoutE(_fitModel,InputArguments) << "RooMCStudy::fitResult: ERROR, no fit result saved for sample "
1016 << sampleNum << ", did you use the 'r; fit option?" << endl ;
1017 }
1018 return 0 ;
1019}
1020
1021
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Return the given generated dataset. This method will only return datasets
1025/// if during the run cycle it was indicated that generator data should be saved.
1026
1028{
1029 // Check that generated data was saved
1030 if (_genDataList.GetSize()==0) {
1031 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, generated data was not saved" << endl ;
1032 return 0 ;
1033 }
1034
1035 // Check if sampleNum is in range
1036 if (sampleNum<0 || sampleNum>=_genDataList.GetSize()) {
1037 oocoutE(_fitModel,InputArguments) << "RooMCStudy::genData() ERROR, invalid sample number: " << sampleNum << endl ;
1038 return 0 ;
1039 }
1040
1041 return (RooAbsData*) _genDataList.At(sampleNum) ;
1042}
1043
1044
1045
1046////////////////////////////////////////////////////////////////////////////////
1047/// Plot the distribution of fitted values of a parameter. The parameter shown is the one from which the RooPlot
1048/// was created, e.g.
1049///
1050/// RooPlot* frame = param.frame(100,-10,10) ;
1051/// mcstudy.paramOn(frame,LineStyle(kDashed)) ;
1052///
1053/// Any named arguments passed to plotParamOn() are forwarded to the underlying plotOn() call
1054
1055RooPlot* RooMCStudy::plotParamOn(RooPlot* frame, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1056 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
1057{
1058 _fitParData->plotOn(frame,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1059 return frame ;
1060}
1061
1062
1063
1064////////////////////////////////////////////////////////////////////////////////
1065/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
1066///
1067/// <table>
1068/// <tr><th> Optional arguments <th>
1069/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1070/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1071/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1072/// for list of allowed arguments
1073/// </table>
1074/// If no frame specifications are given, the AutoRange() feature will be used to set the range
1075/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
1076
1077RooPlot* RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1078 const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
1079{
1080
1081 // Find parameter in fitParDataSet
1082 RooRealVar* param = static_cast<RooRealVar*>(_fitParData->get()->find(paramName)) ;
1083 if (!param) {
1084 oocoutE(_fitModel,InputArguments) << "RooMCStudy::plotParam: ERROR: no parameter defined with name " << paramName << endl ;
1085 return 0 ;
1086 }
1087
1088 // Forward to implementation below
1089 return plotParam(*param,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1090}
1091
1092
1093
1094////////////////////////////////////////////////////////////////////////////////
1095/// Plot the distribution of the fitted value of the given parameter on a newly created frame.
1096/// \copydetails RooMCStudy::plotParam(const char* paramName, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1097/// const RooCmdArg& arg5, const RooCmdArg& arg6, const RooCmdArg& arg7, const RooCmdArg& arg8)
1098
1099RooPlot* RooMCStudy::plotParam(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2, const RooCmdArg& arg3, const RooCmdArg& arg4,
1100 const RooCmdArg& arg5, const RooCmdArg& arg6, 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 RooPlot* frame = makeFrameAndPlotCmd(param, cmdList) ;
1110 if (frame) {
1111 _fitParData->plotOn(frame, cmdList) ;
1112 }
1113
1114 return frame ;
1115}
1116
1117
1118
1119////////////////////////////////////////////////////////////////////////////////
1120/// Plot the distribution of the -log(L) values on a newly created frame.
1121///
1122/// <table>
1123/// <tr><th> Optional arguments <th>
1124/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1125/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1126/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1127/// for list of allowed arguments
1128/// </table>
1129///
1130/// If no frame specifications are given, the AutoRange() feature will be used to set the range.
1131/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
1132
1134 const RooCmdArg& arg3, const RooCmdArg& arg4,
1135 const RooCmdArg& arg5, const RooCmdArg& arg6,
1136 const RooCmdArg& arg7, const RooCmdArg& arg8)
1137{
1138 return plotParam(*_nllVar,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1139}
1140
1141
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// Plot the distribution of the fit errors for the specified parameter on a newly created frame.
1145///
1146/// <table>
1147/// <tr><th> Optional arguments <th>
1148/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1149/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1150/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1151/// for list of allowed arguments
1152/// </table>
1153///
1154/// If no frame specifications are given, the AutoRange() feature will be used to set the range
1155/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
1156
1157RooPlot* RooMCStudy::plotError(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
1158 const RooCmdArg& arg3, const RooCmdArg& arg4,
1159 const RooCmdArg& arg5, const RooCmdArg& arg6,
1160 const RooCmdArg& arg7, const RooCmdArg& arg8)
1161{
1162 if (_canAddFitResults) {
1163 calcPulls() ;
1165 }
1166
1167 RooErrorVar* evar = param.errorVar() ;
1168 RooRealVar* evar_rrv = static_cast<RooRealVar*>(evar->createFundamental()) ;
1169 RooPlot* frame = plotParam(*evar_rrv,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1170 delete evar_rrv ;
1171 delete evar ;
1172 return frame ;
1173}
1174
1175
1176
1177////////////////////////////////////////////////////////////////////////////////
1178/// Plot the distribution of pull values for the specified parameter on a newly created frame. If asymmetric
1179/// errors are calculated in the fit (by MINOS) those will be used in the pull calculation
1180///
1181/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1182/// corresponding parameters:
1183/// - Parameters have the same name: They will be used to compute pulls.
1184/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1185/// computed. The parameter at the same position in the set of generator parameters will be used.
1186///
1187/// Further options:
1188/// <table>
1189/// <tr><th> Optional arguments <th>
1190/// <tr><td> FrameRange(double lo, double hi) <td> Set range of frame to given specification
1191/// <tr><td> FrameBins(int bins) <td> Set default number of bins of frame to given number
1192/// <tr><td> Frame() <td> Pass supplied named arguments to RooAbsRealLValue::frame() function. See there
1193/// for list of allowed arguments
1194/// <tr><td> FitGauss(Bool_t flag) <td> Add a gaussian fit to the frame
1195/// </table>
1196///
1197/// If no frame specifications are given, the AutoSymRange() feature will be used to set the range
1198/// Any other named argument is passed to the RooAbsData::plotOn() call. See that function for allowed options
1199
1200RooPlot* RooMCStudy::plotPull(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2,
1201 const RooCmdArg& arg3, const RooCmdArg& arg4,
1202 const RooCmdArg& arg5, const RooCmdArg& arg6,
1203 const RooCmdArg& arg7, const RooCmdArg& arg8)
1204{
1205 // Stuff all arguments in a list
1206 RooLinkedList cmdList;
1207 cmdList.Add(const_cast<RooCmdArg*>(&arg1)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg2)) ;
1208 cmdList.Add(const_cast<RooCmdArg*>(&arg3)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg4)) ;
1209 cmdList.Add(const_cast<RooCmdArg*>(&arg5)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg6)) ;
1210 cmdList.Add(const_cast<RooCmdArg*>(&arg7)) ; cmdList.Add(const_cast<RooCmdArg*>(&arg8)) ;
1211
1212 TString name(param.GetName()), title(param.GetTitle()) ;
1213 name.Append("pull") ; title.Append(" Pull") ;
1214 RooRealVar pvar(name,title,-100,100) ;
1215 pvar.setBins(100) ;
1216
1217
1218 RooPlot* frame = makeFrameAndPlotCmd(pvar, cmdList, kTRUE) ;
1219 if (frame) {
1220
1221 // Pick up optonal FitGauss command from list
1222 RooCmdConfig pc(Form("RooMCStudy::plotPull(%s)",_genModel->GetName())) ;
1223 pc.defineInt("fitGauss","FitGauss",0,0) ;
1224 pc.allowUndefined() ;
1225 pc.process(cmdList) ;
1226 Bool_t fitGauss=pc.getInt("fitGauss") ;
1227
1228 // Pass stripped command list to plotOn()
1229 pc.stripCmdList(cmdList,"FitGauss") ;
1230 const bool success = _fitParData->plotOn(frame,cmdList) ;
1231
1232 if (!success) {
1233 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1234 return frame;
1235 }
1236
1237 // Add Gaussian fit if requested
1238 if (fitGauss) {
1239 RooRealVar pullMean("pullMean","Mean of pull",0,-10,10) ;
1240 RooRealVar pullSigma("pullSigma","Width of pull",1,0.1,5) ;
1241 RooGenericPdf pullGauss("pullGauss","Gaussian of pull",
1242 "exp(-0.5*(@0-@1)*(@0-@1)/(@2*@2))",
1243 RooArgSet(pvar,pullMean,pullSigma)) ;
1245 pullGauss.plotOn(frame) ;
1246 pullGauss.paramOn(frame,_fitParData) ;
1247 }
1248 }
1249 return frame;
1250}
1251
1252
1253
1254////////////////////////////////////////////////////////////////////////////////
1255/// Internal function. Construct RooPlot from given parameter and modify the list of named
1256/// arguments 'cmdList' to only contain the plot arguments that should be forwarded to
1257/// RooAbsData::plotOn()
1258
1260{
1261 // Select the frame-specific commands
1262 RooCmdConfig pc(Form("RooMCStudy::plotParam(%s)",_genModel->GetName())) ;
1263 pc.defineInt("nbins","Bins",0,0) ;
1264 pc.defineDouble("xlo","Range",0,0) ;
1265 pc.defineDouble("xhi","Range",1,0) ;
1266 pc.defineInt("dummy","FrameArgs",0,0) ;
1267 pc.defineMutex("Bins","FrameArgs") ;
1268 pc.defineMutex("Range","FrameArgs") ;
1269
1270 // Process and check varargs
1271 pc.allowUndefined() ;
1272 pc.process(cmdList) ;
1273 if (!pc.ok(kTRUE)) {
1274 return 0 ;
1275 }
1276
1277 // Make frame according to specs
1278 Int_t nbins = pc.getInt("nbins") ;
1279 Double_t xlo = pc.getDouble("xlo") ;
1280 Double_t xhi = pc.getDouble("xhi") ;
1281 RooPlot* frame ;
1282
1283 if (pc.hasProcessed("FrameArgs")) {
1284 // Explicit frame arguments are given, pass them on
1285 RooCmdArg* frameArg = static_cast<RooCmdArg*>(cmdList.FindObject("FrameArgs")) ;
1286 frame = param.frame(frameArg->subArgs()) ;
1287 } else {
1288 // FrameBins, FrameRange or none are given, build custom frame command list
1289 RooCmdArg bins = RooFit::Bins(nbins) ;
1290 RooCmdArg range = RooFit::Range(xlo,xhi) ;
1292 RooLinkedList frameCmdList ;
1293
1294 if (pc.hasProcessed("Bins")) frameCmdList.Add(&bins) ;
1295 if (pc.hasProcessed("Range")) {
1296 frameCmdList.Add(&range) ;
1297 } else {
1298 frameCmdList.Add(&autor) ;
1299 }
1300 frame = param.frame(frameCmdList) ;
1301 }
1302
1303 // Filter frame command from list and pass on to plotOn()
1304 pc.stripCmdList(cmdList,"FrameArgs,Bins,Range") ;
1305
1306 return frame ;
1307}
1308
1309
1310
1311////////////////////////////////////////////////////////////////////////////////
1312/// Create a RooPlot of the -log(L) distribution in the range lo-hi
1313/// with 'nBins' bins
1314
1316{
1317 RooPlot* frame = _nllVar->frame(lo,hi,nBins) ;
1318
1319 _fitParData->plotOn(frame) ;
1320 return frame ;
1321}
1322
1323
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Create a RooPlot of the distribution of the fitted errors of the given parameter.
1327/// The frame is created with a range [lo,hi] and plotted data will be binned in 'nbins' bins
1328
1330{
1331 if (_canAddFitResults) {
1332 calcPulls() ;
1334 }
1335
1336 RooErrorVar* evar = param.errorVar() ;
1337 RooPlot* frame = evar->frame(lo,hi,nbins) ;
1338 _fitParData->plotOn(frame) ;
1339
1340 delete evar ;
1341 return frame ;
1342}
1343
1344
1345
1346////////////////////////////////////////////////////////////////////////////////
1347/// Create a RooPlot of the pull distribution for the given
1348/// parameter. The range lo-hi is plotted in nbins. If fitGauss is
1349/// set, an unbinned ML fit of the distribution to a Gaussian p.d.f
1350/// is performed. The fit result is overlaid on the returned RooPlot
1351/// and a box with the fitted mean and sigma is added.
1352///
1353/// If the parameters of the models for generation and fit differ, simple heuristics are used to find the
1354/// corresponding parameters:
1355/// - Parameters have the same name: They will be used to compute pulls.
1356/// - Parameters have different names: The position of the fit parameter in the set of fit parameters will be
1357/// computed. The parameter at the same position in the set of generator parameters will be used.
1358
1360{
1361 if (_canAddFitResults) {
1362 calcPulls() ;
1364 }
1365
1366
1367 TString name(param.GetName()), title(param.GetTitle()) ;
1368 name.Append("pull") ; title.Append(" Pull") ;
1369 RooRealVar pvar(name,title,lo,hi) ;
1370 pvar.setBins(nbins) ;
1371
1372 RooPlot* frame = pvar.frame() ;
1373 const bool success = _fitParData->plotOn(frame);
1374
1375 if (!success) {
1376 coutF(Plotting) << "No pull distribution for the parameter '" << param.GetName() << "'. Check logs for errors." << std::endl;
1377 return frame;
1378 }
1379
1380 if (fitGauss) {
1381 RooRealVar pullMean("pullMean","Mean of pull",0,lo,hi) ;
1382 RooRealVar pullSigma("pullSigma","Width of pull",1,0,5) ;
1383 RooGenericPdf pullGauss("pullGauss","Gaussian of pull",
1384 "exp(-0.5*(@0-@1)*(@0-@1)/(@2*@2))",
1385 RooArgSet(pvar,pullMean,pullSigma)) ;
1387 pullGauss.plotOn(frame) ;
1388 pullGauss.paramOn(frame,_fitParData) ;
1389 }
1390
1391 return frame ;
1392}
1393
1394
1395////////////////////////////////////////////////////////////////////////////////
1396/// If one of the TObject we have a referenced to is deleted, remove the
1397/// reference.
1398
1400{
1404 if (_ngenVar == obj) _ngenVar = nullptr;
1405
1407 if (_fitParData == obj) _fitParData = nullptr;
1408
1410 if (_genParData == obj) _genParData = nullptr;
1411}
1412
#define coutI(a)
Definition: RooMsgService.h:31
#define coutP(a)
Definition: RooMsgService.h:32
#define oocoutW(o, a)
Definition: RooMsgService.h:46
#define coutW(a)
Definition: RooMsgService.h:33
#define coutF(a)
Definition: RooMsgService.h:35
#define oocoutE(o, a)
Definition: RooMsgService.h:47
#define oocoutI(o, a)
Definition: RooMsgService.h:44
#define coutE(a)
Definition: RooMsgService.h:34
#define ooccoutI(o, a)
Definition: RooMsgService.h:51
#define ooccoutP(o, a)
Definition: RooMsgService.h:52
#define oocoutP(o, a)
Definition: RooMsgService.h:45
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
float type_of_call hi(const int &, const int &)
char * Form(const char *fmt,...)
#define snprintf
Definition: civetweb.c:1540
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:70
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Return the observables of this pdf given a set of observables.
Definition: RooAbsArg.h:240
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
Definition: RooAbsArg.cxx:543
Int_t getSize() const
Storage_t::size_type size() const
const_iterator begin() const
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
TIterator end() and range-based for loops.")
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:37
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual Bool_t changeObservableName(const char *from, const char *to)
Definition: RooAbsData.cxx:286
virtual void reset()
Definition: RooAbsData.cxx:313
virtual Double_t sumEntries() const =0
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:306
virtual 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
Calls RooPlot* plotOn(RooPlot* frame, const RooLinkedList& cmdList) const ;.
Definition: RooAbsData.cxx:552
virtual void attach(const RooArgSet &params)
Interface to attach given parameters to object in this context.
virtual RooDataSet * generate(Double_t nEvents=0, Bool_t skipInit=kFALSE, Bool_t extendedMode=kFALSE)
Generate the specified number of events with nEvents>0 and and return a dataset containing the genera...
virtual void setProtoDataOrder(Int_t *lut)
Set the traversal order of prototype data to that in the lookup tables passed as argument.
RooAbsMCStudyModule is a base class for add-on modules to RooMCStudy that can perform additional calc...
Bool_t doInitializeInstance(RooMCStudy &)
Store reference to RooMCStudy object that this module relates to and call internal module initializat...
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Interface function to create a generator context from a p.d.f.
Definition: RooAbsPdf.cxx:1709
virtual RooArgSet * getAllConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, Bool_t stripDisconnected=kTRUE) const
This helper function finds and collects all constraints terms of all coponent p.d....
Definition: RooAbsPdf.cxx:3112
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
Definition: RooAbsPdf.cxx:1119
virtual RooDataHist * generateBinned(const RooArgSet &whatVars, Double_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
As RooAbsPdf::generateBinned(const RooArgSet&, const RooCmdArg&,const RooCmdArg&, const RooCmdArg&,...
Definition: RooAbsPdf.h:105
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:2769
Int_t * randomizeProtoOrder(Int_t nProto, Int_t nGen, Bool_t resample=kFALSE) const
Return lookup table with randomized access order for prototype events, given nProto prototype data ev...
Definition: RooAbsPdf.cxx:2063
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
Definition: RooAbsPdf.cxx:2920
virtual 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
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
Definition: RooAbsPdf.h:119
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:53
RooAbsArg * createFundamental(const char *newname=0) const
Create a RooRealVar fundamental object with our properties.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
RooLinkedList & subArgs()
Definition: RooCmdArg.h:46
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
Definition: RooCmdArg.h:51
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Definition: RooCmdConfig.h:27
The RooDataHist is a container class to hold N-dimensional binned data.
Definition: RooDataHist.h:40
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
Bool_t write(const char *filename) const
Write the contents of this dataset to an ASCII file with the specified name.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
static RooDataSet * read(const char *filename, const RooArgList &variables, const char *opts="", const char *commonPath="", const char *indexCatName=0)
Read given list of ascii files, and construct a data set, using the given ArgList as structure defini...
Bool_t merge(RooDataSet *data1, RooDataSet *data2=0, RooDataSet *data3=0, RooDataSet *data4=0, RooDataSet *data5=0, RooDataSet *data6=0)
RooErrorVar is an auxilary class that represents the error of a RooRealVar as a seperate object.
Definition: RooErrorVar.h:28
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
Double_t minNll() const
Definition: RooFitResult.h:98
const RooArgList & floatParsFinal() const
Definition: RooFitResult.h:110
Int_t status() const
Definition: RooFitResult.h:77
RooGenericPdf is a concrete implementation of a probability density function, which takes a RooArgLis...
Definition: RooGenericPdf.h:25
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:36
Int_t GetSize() const
Definition: RooLinkedList.h:61
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
TObject * At(Int_t index) const
Return object stored in sequential position given by index.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:63
RooMCStudy is a helper class to facilitate Monte Carlo studies such as 'goodness-of-fit' studies,...
Definition: RooMCStudy.h:32
RooAbsData * _genSample
Definition: RooMCStudy.h:111
RooArgSet _projDeps
Definition: RooMCStudy.h:117
const RooArgSet * fitParams(Int_t sampleNum) const
Return an argset with the fit parameters for the given sample number.
Definition: RooMCStudy.cxx:986
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.
void calcPulls()
Calculate the pulls for all fit parameters in the fit results data set, and add them to that dataset.
Definition: RooMCStudy.cxx:900
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.
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.
Bool_t addFitResult(const RooFitResult &fr)
Utility function to add fit result from external fit to this RooMCStudy and process its results throu...
Definition: RooMCStudy.cxx:866
Bool_t run(Bool_t generate, Bool_t fit, Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char *asciiFilePat)
Run engine method.
Definition: RooMCStudy.cxx:452
Bool_t _extendedGen
Definition: RooMCStudy.h:136
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.
Bool_t _silence
Definition: RooMCStudy.h:144
RooArgSet _dependents
Definition: RooMCStudy.h:122
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:99
std::list< RooAbsMCStudyModule * > _modList
Definition: RooMCStudy.h:146
RooAbsGenContext * _constrGenContext
Definition: RooMCStudy.h:120
RooFitResult * refit(RooAbsData *genSample=0)
Redo fit on 'current' toy sample, or if genSample is not NULL do fit on given sample instead.
Definition: RooMCStudy.cxx:785
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.
TList _fitResList
Definition: RooMCStudy.h:131
RooDataSet * _genParData
Definition: RooMCStudy.h:132
Bool_t fitSample(RooAbsData *genSample)
Internal method.
Definition: RooMCStudy.cxx:812
const RooDataSet * _genProtoData
Definition: RooMCStudy.h:116
const RooFitResult * fitResult(Int_t sampleNum) const
Return the RooFitResult object of the fit to given sample.
Bool_t _perExptGenParams
Definition: RooMCStudy.h:143
RooAbsGenContext * _genContext
Definition: RooMCStudy.h:113
Bool_t _randProto
Definition: RooMCStudy.h:139
RooAbsPdf * _constrPdf
Definition: RooMCStudy.h:119
RooArgSet * _fitInitParams
Definition: RooMCStudy.h:125
Bool_t _canAddFitResults
Definition: RooMCStudy.h:141
RooPlot * makeFrameAndPlotCmd(const RooRealVar &param, RooLinkedList &cmdList, Bool_t symRange=kFALSE) const
Internal function.
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
RooAbsData * genData(Int_t sampleNum) const
Return the given generated dataset.
RooArgSet * _genInitParams
Definition: RooMCStudy.h:114
Bool_t _binGenData
Definition: RooMCStudy.h:137
RooAbsPdf * _genModel
Definition: RooMCStudy.h:112
Double_t _nExpGen
Definition: RooMCStudy.h:138
const RooDataSet & fitParDataSet()
Return a RooDataSet the resulting fit parameters of each toy cycle.
Definition: RooMCStudy.cxx:966
RooLinkedList _fitOptList
Definition: RooMCStudy.h:135
Bool_t generate(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char *asciiFilePat=0)
Generate 'nSamples' samples of 'nEvtPerSample' events.
Definition: RooMCStudy.cxx:668
RooArgSet _allDependents
Definition: RooMCStudy.h:123
virtual ~RooMCStudy()
Definition: RooMCStudy.cxx:408
RooArgSet * _fitParams
Definition: RooMCStudy.h:126
void resetFitParams()
Reset all fit parameters to the initial model parameters at the time of the RooMCStudy constructor.
Definition: RooMCStudy.cxx:724
RooArgSet * _genParams
Definition: RooMCStudy.h:115
Bool_t _verboseGen
Definition: RooMCStudy.h:142
RooAbsPdf * _fitModel
Definition: RooMCStudy.h:124
Bool_t generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char *asciiFilePat=0)
Generate and fit 'nSamples' samples of 'nEvtPerSample' events.
Definition: RooMCStudy.cxx:646
Bool_t fit(Int_t nSamples, const char *asciiFilePat)
Fit 'nSamples' datasets, which are read from ASCII files.
Definition: RooMCStudy.cxx:685
RooRealVar * _ngenVar
Definition: RooMCStudy.h:128
TList _genDataList
Definition: RooMCStudy.h:130
void addModule(RooAbsMCStudyModule &module)
Insert given RooMCStudy add-on module to the processing chain of this MCStudy object.
Definition: RooMCStudy.cxx:431
RooFitResult * doFit(RooAbsData *genSample)
Internal function. Performs actual fit according to specifications.
Definition: RooMCStudy.cxx:734
RooRealVar * _nllVar
Definition: RooMCStudy.h:127
TString _fitOptions
Definition: RooMCStudy.h:134
RooDataSet * _fitParData
Definition: RooMCStudy.h:133
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:41
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
Class RooPullVar represents the pull of measurement w.r.t to true value using the measurement value a...
Definition: RooPullVar.h:25
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition: RooRandom.cxx:54
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
void setBins(Int_t nBins, const char *name=0)
Definition: RooRealVar.h:78
RooErrorVar * errorVar() const
Return a RooAbsRealLValue representing the error associated with this variable.
Definition: RooRealVar.cxx:268
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:233
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
Iterator abstract base class.
Definition: TIterator.h:30
virtual TObject * Next()=0
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:354
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TList.cxx:761
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:719
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Definition: TRandom.cxx:391
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
const char * Data() const
Definition: TString.h:364
TString & Append(const char *cs)
Definition: TString.h:559
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
RooCmdArg Constrain(const RooArgSet &params)
@ Generation
Definition: RooGlobalFunc.h:57
@ InputArguments
Definition: RooGlobalFunc.h:58
RooCmdArg ExternalConstraints(const RooArgSet &constraintPdfs)
RooCmdArg Save(Bool_t flag=kTRUE)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg FitOptions(const char *opts)
RooCmdArg Range(const char *rangeName, Bool_t adjustNorm=kTRUE)
RooCmdArg ConditionalObservables(const RooArgSet &set)
RooCmdArg AutoSymRange(const RooAbsData &data, Double_t marginFactor=0.1)
RooCmdArg AutoRange(const RooAbsData &data, Double_t marginFactor=0.1)
RooCmdArg Bins(Int_t nbin)
RooCmdArg Minos(Bool_t flag=kTRUE)
static constexpr double pc