Logo ROOT  
Reference Guide
RooAbsMCStudyModule.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAbsMCStudyModule.h,v 1.2 2007/05/11 09:11:30 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
17#ifndef ROO_ABS_MC_STUDY_MODULE
18#define ROO_ABS_MC_STUDY_MODULE
19
20#include "RooArgSet.h"
21#include "RooMCStudy.h"
22class RooAbsPdf;
23class RooDataSet ;
24class RooAbsData ;
25class RooAbsGenContext ;
26class RooFitResult ;
27class RooPlot ;
28class RooRealVar ;
29
31public:
32
33 RooAbsMCStudyModule(const char* name, const char* title) ;
35 ~RooAbsMCStudyModule() override {} ;
36
37 /// Initializer method called upon attachement to given RooMCStudy object
38 bool doInitializeInstance(RooMCStudy& /*study*/) ;
39
40 /// Initializer called immediately after attachment to RooMCStudy object and initialization of module base class
41 virtual bool initializeInstance() {
42 return true ;
43 }
44
45 /// Method called at the beginning of each RooMCStudy run
46 virtual bool initializeRun(Int_t /*numSamples*/) {
47 return true ;
48 }
49
50 /// Method called at the end of each RooMCStudy run. If a RooDataSet is returned, it must have a length equal to
51 /// the number of toy experiments performed and will merged with the fitpar dataset of RooMCStudy.
53 return nullptr ;
54 }
55
56 /// Method called after resetting of generator parameters to initial values and before call to generator context
57 /// Any modifications to generator parameters will affect next generation operation (only)
58 virtual bool processBeforeGen(Int_t /*sampleNum*/) {
59 return true ;
60 }
61
62 /// Method called after generation of toy data sample and resetting of fit parameters to initial values and before
63 /// actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant
64 /// flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist
65 virtual bool processBetweenGenAndFit(Int_t /*sampleNum*/) {
66 return true ;
67 }
68
69 /// Method called after fit has been performed.
70 virtual bool processAfterFit(Int_t /*sampleNum*/) {
71 return true ;
72 }
73
74protected:
75
76 // Interface methods to RooMCStudy objects,
77 // which are only functional after module has been attached to a RooMCStudy object
78
79 /// Refit model using original or specified data sample
80 RooFitResult* refit(RooAbsData* inGenSample=nullptr) {
81 if (_mcs) return _mcs->refit(inGenSample) ; else return nullptr ;
82 }
83
84 /// Return generate sample
86 return _mcs ? _mcs->_genSample : nullptr ;
87 }
88
89 /// Return generator pdf
91 return _mcs ? _mcs->_genModel : nullptr ;
92 }
93
94 // Accessor for generator context, generator parameters, prototype data and projected dependents.
96 return _mcs ? _mcs->_genContext.get() : nullptr ;
97 }
98
99 /// Return initial value of generator model parameters
101 return _mcs ? &_mcs->_genInitParams : nullptr ;
102 }
103
104 /// Return current value of generator model parameters
106 return _mcs ? &_mcs->_genParams : nullptr ;
107 }
108
109 /// Return generator prototype data provided by user
111 return _mcs ? _mcs->_genProtoData : nullptr ;
112 }
113
114 /// Return projected observables
116 return _mcs ? &_mcs->_projDeps : nullptr ;
117 }
118
119 // Accessors for fit observables, fit model, current and initial fit parameters and NLL value
120
121 /// Return fit model observables
123 return _mcs ? &_mcs->_dependents : nullptr ;
124 }
125
126 /// Return all observables
128 return _mcs ? &_mcs->_allDependents : nullptr ;
129 }
130
131 /// Return fit model
133 return _mcs ? _mcs->_fitModel : nullptr ;
134 }
135
136 /// Return initial value of parameters of fit model
138 return _mcs ? &_mcs->_fitInitParams : nullptr ;
139 }
140
141 /// Return current value of parameters of fit model
143 return _mcs ? &_mcs-> _fitParams : nullptr ;
144 }
145
146 /// Return pointer to RooRealVar holding minimized -log(L) value
148 return _mcs ? _mcs->_nllVar.get() : nullptr ;
149 }
150
151 // Accessors for fit options, generator and MCstudy configuration flags
152
153 /// Return list of fit options provided by user
155 return _mcs ? &_mcs->_fitOptList : nullptr ;
156 }
157
158 /// If true extended mode generation is requested
159 bool extendedGen() {
160 return _mcs ? _mcs->_extendedGen : false ;
161 }
162
163 /// If true binning of data between generating and fitting is requested
164 bool binGenData() {
165 return _mcs ? _mcs->_binGenData : false ;
166 }
167
168 /// Return expected number of events from generator model
169 double numExpGen() {
170 return _mcs ? _mcs->_nExpGen : 0 ;
171 }
172
173 /// If true randomization of prototype data order is requested
174 bool randProto() {
175 return _mcs ? _mcs->_randProto : false ;
176 }
177
178 /// If true verbose message in the generation step is requested
179 bool verboseGen() {
180 return _mcs ? _mcs->_verboseGen : false ;
181 }
182
183private:
184
185 RooMCStudy* _mcs ; ///< Pointer to RooMCStudy object module is attached to
186
187 ClassDefOverride(RooAbsMCStudyModule,0) // Monte Carlo study manager add-on module
188} ;
189
190
191#endif
192
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
char name[80]
Definition: TGX11.cxx:110
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
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 * allDependents()
Return all observables.
RooRealVar * nllVar()
Return pointer to RooRealVar holding minimized -log(L) value.
RooMCStudy * _mcs
Pointer to RooMCStudy object module is attached to.
virtual RooDataSet * finalizeRun()
Method called at the end of each RooMCStudy run.
bool extendedGen()
If true extended mode generation is requested.
virtual bool initializeInstance()
Initializer called immediately after attachment to RooMCStudy object and initialization of module bas...
RooAbsData * genSample()
Return generate sample.
virtual bool initializeRun(Int_t)
Method called at the beginning of each RooMCStudy run.
RooAbsGenContext * genContext()
RooFitResult * refit(RooAbsData *inGenSample=nullptr)
Refit model using original or specified data sample.
bool randProto()
If true randomization of prototype data order is requested.
RooLinkedList * fitOptList()
Return list of fit options provided by user.
virtual bool processBetweenGenAndFit(Int_t)
Method called after generation of toy data sample and resetting of fit parameters to initial values a...
double numExpGen()
Return expected number of events from generator model.
const RooDataSet * genProtoData()
Return generator prototype data provided by user.
RooArgSet * genInitParams()
Return initial value of generator model parameters.
virtual bool processAfterFit(Int_t)
Method called after fit has been performed.
RooAbsMCStudyModule(const char *name, const char *title)
Constructor.
RooAbsPdf * fitModel()
Return fit model.
RooArgSet * fitParams()
Return current value of parameters of fit model.
bool binGenData()
If true binning of data between generating and fitting is requested.
RooArgSet * genParams()
Return current value of generator model parameters.
RooArgSet * projDeps()
Return projected observables.
RooAbsPdf * genModel()
Return generator pdf.
bool verboseGen()
If true verbose message in the generation step is requested.
virtual bool processBeforeGen(Int_t)
Method called after resetting of generator parameters to initial values and before call to generator ...
RooArgSet * fitInitParams()
Return initial value of parameters of fit model.
RooArgSet * dependents()
Return fit model observables.
bool doInitializeInstance(RooMCStudy &)
Initializer method called upon attachement to given RooMCStudy object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:38
RooMCStudy is a helper class to facilitate Monte Carlo studies such as 'goodness-of-fit' studies,...
Definition: RooMCStudy.h:32
RooAbsData * _genSample
Currently generated sample.
Definition: RooMCStudy.h:107
RooArgSet _projDeps
List of projected dependents in fit.
Definition: RooMCStudy.h:113
RooArgSet _genParams
List of actual generator parameters.
Definition: RooMCStudy.h:111
RooArgSet _dependents
List of dependents.
Definition: RooMCStudy.h:118
bool _verboseGen
Verbose generation?
Definition: RooMCStudy.h:137
RooArgSet _genInitParams
List of original generator parameters.
Definition: RooMCStudy.h:110
double _nExpGen
Definition: RooMCStudy.h:133
bool _extendedGen
Definition: RooMCStudy.h:131
const RooDataSet * _genProtoData
Generator prototype data set.
Definition: RooMCStudy.h:112
bool _binGenData
Definition: RooMCStudy.h:132
std::unique_ptr< RooAbsGenContext > _genContext
Generator context.
Definition: RooMCStudy.h:109
RooFitResult * refit(RooAbsData *genSample=nullptr)
Redo fit on 'current' toy sample, or if genSample is not nullptr do fit on given sample instead.
Definition: RooMCStudy.cxx:634
RooAbsPdf * _genModel
Generator model.
Definition: RooMCStudy.h:108
std::unique_ptr< RooRealVar > _nllVar
Definition: RooMCStudy.h:123
RooLinkedList _fitOptList
Definition: RooMCStudy.h:130
RooArgSet _allDependents
List of generate + prototype dependents.
Definition: RooMCStudy.h:119
RooAbsPdf * _fitModel
Fit model.
Definition: RooMCStudy.h:120
bool _randProto
Definition: RooMCStudy.h:134
RooArgSet _fitInitParams
List of initial values of fit parameters.
Definition: RooMCStudy.h:121
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:43
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29