Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMCStudy.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooMCStudy.h,v 1.18 2007/05/11 10:14:56 verkerke Exp $
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#ifndef ROO_MC_STUDY
17#define ROO_MC_STUDY
18
19#include "TList.h"
20#include "TNamed.h"
21#include "RooArgSet.h"
22#include <list>
23class RooAbsPdf;
24class RooDataSet ;
25class RooAbsData ;
26class RooAbsGenContext ;
27class RooFitResult ;
28class RooPlot ;
29class RooRealVar ;
31
32class RooMCStudy : public TNamed {
33public:
34
35 RooMCStudy(const RooAbsPdf& model, const RooArgSet& observables,
36 const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
37 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(), const RooCmdArg& arg5=RooCmdArg::none(),
38 const RooCmdArg& arg6=RooCmdArg::none(), const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
39
40 RooMCStudy(const RooAbsPdf& genModel, const RooAbsPdf& fitModel,
41 const RooArgSet& dependents, const char* genOptions="",
42 const char* fitOptions="", const RooDataSet* genProtoData=0,
43 const RooArgSet& projDeps=RooArgSet()) R__DEPRECATED(6,28,
44 "please migrate to the other RooMCStudy constructor that doesn't use the deprecated string-based fit options.");
45
46 virtual ~RooMCStudy() ;
47
48 // Method to add study modules
49 void addModule(RooAbsMCStudyModule& module) ;
50
51
52 // Run methods
53 Bool_t generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char* asciiFilePat=0) ;
54 Bool_t generate(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char* asciiFilePat=0) ;
55 Bool_t fit(Int_t nSamples, const char* asciiFilePat) ;
56 Bool_t fit(Int_t nSamples, TList& dataSetList) ;
58
59 // Result accessors
60 const RooArgSet* fitParams(Int_t sampleNum) const ;
61 const RooFitResult* fitResult(Int_t sampleNum) const ;
62 RooAbsData* genData(Int_t sampleNum) const ;
63 const RooDataSet& fitParDataSet() ;
64 /// Return dataset with generator parameters for each toy. When constraints are used these
65 /// may generally not be the same as the fitted parameters.
66 const RooDataSet* genParDataSet() const {
67 return _genParData ;
68 }
69
70 // Plot methods
71 RooPlot* plotParamOn(RooPlot* frame, const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
72 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
73 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
74 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
75 RooPlot* plotParam(const RooRealVar& param, const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
76 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
77 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
78 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
79 RooPlot* plotParam(const char* paramName, const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
80 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
81 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
82 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
84 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
85 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
86 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
87 RooPlot* plotError(const RooRealVar& param, const RooCmdArg& arg1=RooCmdArg::none(), const RooCmdArg& arg2=RooCmdArg::none(),
88 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
89 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
90 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
91 RooPlot* plotPull(const RooRealVar& param, const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg::none(),
92 const RooCmdArg& arg3=RooCmdArg::none(), const RooCmdArg& arg4=RooCmdArg::none(),
93 const RooCmdArg& arg5=RooCmdArg::none(), const RooCmdArg& arg6=RooCmdArg::none(),
94 const RooCmdArg& arg7=RooCmdArg::none(), const RooCmdArg& arg8=RooCmdArg::none()) ;
95
96
97 RooPlot* plotNLL(Double_t lo, Double_t hi, Int_t nBins=100) ;
98 RooPlot* plotError(const RooRealVar& param, Double_t lo, Double_t hi, Int_t nbins=100) ;
99 RooPlot* plotPull(const RooRealVar& param, Double_t lo=-3.0, Double_t hi=3.0, Int_t nbins=25, Bool_t fitGauss=kFALSE) ;
100
101protected:
102
103 friend class RooAbsMCStudyModule ;
104
105 RooPlot* makeFrameAndPlotCmd(const RooRealVar& param, RooLinkedList& cmdList, Bool_t symRange=kFALSE) const ;
106
107 Bool_t run(Bool_t generate, Bool_t fit, Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char* asciiFilePat) ;
108 Bool_t fitSample(RooAbsData* genSample) ;
109 RooFitResult* doFit(RooAbsData* genSample) ;
110
111 void calcPulls() ;
112
113 RooAbsData* _genSample ; // Currently generated sample
114 RooAbsPdf* _genModel ; // Generator model
115 RooAbsGenContext* _genContext ; // Generator context
116 RooArgSet* _genInitParams ; // List of original generator parameters
117 RooArgSet* _genParams ; // List of actual generator parameters
118 const RooDataSet* _genProtoData ; // Generator prototype data set
119 RooArgSet _projDeps ; // List of projected dependents in fit
120
121 RooAbsPdf* _constrPdf ; // Constraints p.d.f
122 RooAbsGenContext* _constrGenContext ; // Generator context for constraints p.d.f
123
124 RooArgSet _dependents ; // List of dependents
125 RooArgSet _allDependents ; // List of generate + prototype dependents
126 RooAbsPdf* _fitModel ; // Fit model
127 RooArgSet* _fitInitParams ; // List of initial values of fit parameters
128 RooArgSet* _fitParams ; // List of actual fit parameters
131
132 TList _genDataList ; // List of generated data sample
133 TList _fitResList ; // List of RooFitResult fit output objects
134 RooDataSet* _genParData ; // List of of generated parameters of each sample
135 RooDataSet* _fitParData ; // Data set of fit parameters of each sample
136 TString _fitOptions ; // Fit options string
137 RooLinkedList _fitOptList ; // Fit option command list
138 Bool_t _extendedGen ; // Add poisson term to number of events to generate?
139 Bool_t _binGenData ; // Bin data between generating and fitting
140 Double_t _nExpGen ; // Number of expected events to generate in extended mode
141 Bool_t _randProto ; // Randomize order of prototype data access
142
143 Bool_t _canAddFitResults ; // Allow adding of external fit results?
144 Bool_t _verboseGen ; // Verbose generation?
145 Bool_t _perExptGenParams ; // Do generation parameter change per event?
146 Bool_t _silence ; // Silent running mode?
147
148 std::list<RooAbsMCStudyModule*> _modList ; // List of additional study modules ;
149
150 // Utilities for modules ;
151 RooFitResult* refit(RooAbsData* genSample=0) ;
152 void resetFitParams() ;
153 virtual void RecursiveRemove(TObject *obj);
154
155private:
156
158
159 ClassDef(RooMCStudy,0) // A general purpose toy Monte Carlo study manager
160} ;
161
162
163#endif
164
#define R__DEPRECATED(MAJOR, MINOR, REASON)
Definition RConfig.hxx:516
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
#define ClassDef(name, id)
Definition Rtypes.h:325
#define hi
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:82
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
RooAbsMCStudyModule is a base class for add-on modules to RooMCStudy that can perform additional calc...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:27
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:52
RooDataSet is a container class to hold unbinned data.
Definition RooDataSet.h:36
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
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:113
RooArgSet _projDeps
Definition RooMCStudy.h:119
RooPlot * plotNLL(const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Plot the distribution of the -log(L) values on a newly created frame.
const RooArgSet * fitParams(Int_t sampleNum) const
Return an argset with the fit parameters for the given sample number.
void calcPulls()
Calculate the pulls for all fit parameters in the fit results data set, and add them to that dataset.
Bool_t addFitResult(const RooFitResult &fr)
Utility function to add fit result from external fit to this RooMCStudy and process its results throu...
Bool_t run(Bool_t generate, Bool_t fit, Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char *asciiFilePat)
Run engine method.
Bool_t _extendedGen
Definition RooMCStudy.h:138
Bool_t _silence
Definition RooMCStudy.h:146
RooArgSet _dependents
Definition RooMCStudy.h:124
std::list< RooAbsMCStudyModule * > _modList
Definition RooMCStudy.h:148
RooAbsGenContext * _constrGenContext
Definition RooMCStudy.h:122
RooFitResult * refit(RooAbsData *genSample=0)
Redo fit on 'current' toy sample, or if genSample is not NULL do fit on given sample instead.
TList _fitResList
Definition RooMCStudy.h:133
RooDataSet * _genParData
Definition RooMCStudy.h:134
Bool_t fitSample(RooAbsData *genSample)
Internal method.
const RooDataSet * _genProtoData
Definition RooMCStudy.h:118
const RooFitResult * fitResult(Int_t sampleNum) const
Return the RooFitResult of the fit with the given run number.
Bool_t _perExptGenParams
Definition RooMCStudy.h:145
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.
RooAbsGenContext * _genContext
Definition RooMCStudy.h:115
Bool_t _randProto
Definition RooMCStudy.h:141
RooAbsPdf * _constrPdf
Definition RooMCStudy.h:121
RooArgSet * _fitInitParams
Definition RooMCStudy.h:127
Bool_t _canAddFitResults
Definition RooMCStudy.h:143
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:116
const RooDataSet * genParDataSet() const
Return dataset with generator parameters for each toy.
Definition RooMCStudy.h:66
Bool_t _binGenData
Definition RooMCStudy.h:139
RooAbsPdf * _genModel
Definition RooMCStudy.h:114
Double_t _nExpGen
Definition RooMCStudy.h:140
const RooDataSet & fitParDataSet()
Return a RooDataSet containing the post-fit parameters of each toy cycle.
RooPlot * plotParamOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Plot the distribution of fitted values of a parameter.
RooLinkedList _fitOptList
Definition RooMCStudy.h:137
Bool_t generate(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char *asciiFilePat=0)
Generate 'nSamples' samples of 'nEvtPerSample' events.
RooArgSet _allDependents
Definition RooMCStudy.h:125
virtual ~RooMCStudy()
RooArgSet * _fitParams
Definition RooMCStudy.h:128
void resetFitParams()
Reset all fit parameters to the initial model parameters at the time of the RooMCStudy constructor.
RooArgSet * _genParams
Definition RooMCStudy.h:117
Bool_t _verboseGen
Definition RooMCStudy.h:144
RooAbsPdf * _fitModel
Definition RooMCStudy.h:126
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.
Bool_t fit(Int_t nSamples, const char *asciiFilePat)
Fit 'nSamples' datasets, which are read from ASCII files.
RooRealVar * _ngenVar
Definition RooMCStudy.h:130
TList _genDataList
Definition RooMCStudy.h:132
RooPlot * plotParam(const RooRealVar &param, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Plot the distribution of the fitted value of the given parameter on a newly created frame.
void addModule(RooAbsMCStudyModule &module)
Insert given RooMCStudy add-on module to the processing chain of this MCStudy object.
RooFitResult * doFit(RooAbsData *genSample)
Internal function. Performs actual fit according to specifications.
RooMCStudy(const RooMCStudy &)
RooRealVar * _nllVar
Definition RooMCStudy.h:129
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.
TString _fitOptions
Definition RooMCStudy.h:136
RooDataSet * _fitParData
Definition RooMCStudy.h:135
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:44
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:136