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