Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 "TList.h"
21 #include "RooArgSet.h"
22 #include "RooMCStudy.h"
23 class RooAbsPdf;
24 class RooDataSet ;
25 class RooAbsData ;
26 class RooAbsGenContext ;
27 class RooFitResult ;
28 class RooPlot ;
29 class RooRealVar ;
30 
31 class RooAbsMCStudyModule : public TNamed {
32 public:
33 
34  RooAbsMCStudyModule(const char* name, const char* title) ;
35  RooAbsMCStudyModule(const RooAbsMCStudyModule& other) ;
36  virtual ~RooAbsMCStudyModule() {} ;
37 
38  // Initializer method called upon attachement to given RooMCStudy object
39  Bool_t doInitializeInstance(RooMCStudy& /*study*/) ;
40 
41  virtual Bool_t initializeInstance() {
42  // Initializer called immediately after attachment to RooMCStudy object and initialization of module base class
43  return kTRUE ;
44  }
45 
46  virtual Bool_t initializeRun(Int_t /*numSamples*/) {
47  // Method called at the beginning of each RooMCStudy run
48  return kTRUE ;
49  }
50 
51  virtual RooDataSet* finalizeRun() {
52  // Method called at the end of each RooMCStudy run. If a RooDataSet is returned, it must have a length equal to
53  // the number of toy experiments performed and will merged with the fitpar dataset of RooMCStudy.
54  return 0 ;
55  }
56 
57  virtual Bool_t processBeforeGen(Int_t /*sampleNum*/) {
58  // Method called after resetting of generator parameters to initial values and before call to generator context
59  // Any modifications to generator parameters will affect next generation operation (only)
60  return kTRUE ;
61  }
62 
63 
64  virtual Bool_t processBetweenGenAndFit(Int_t /*sampleNum*/) {
65  // Method called after generation of toy data sample and resetting of fit parameters to initial values and before
66  // actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant
67  // flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist
68  return kTRUE ;
69  }
70 
71  virtual Bool_t processAfterFit(Int_t /*sampleNum*/) {
72  // Method called after fit has been performed.
73  return kTRUE ;
74  }
75 
76 protected:
77 
78  // Interface methods to RooMCStudy objects,
79  // which are only functional after module has been attached to a RooMCStudy object
80 
81  RooFitResult* refit(RooAbsData* inGenSample=0) {
82  // Refit model using orignal or specified data sample
83  if (_mcs) return _mcs->refit(inGenSample) ; else return 0 ;
84  }
85 
86  RooAbsData* genSample() {
87  // Return generate sample
88  return _mcs ? _mcs->_genSample : 0 ;
89  }
90  RooAbsPdf* genModel() {
91  // Return generator pdf
92  return _mcs ? _mcs->_genModel : 0 ;
93  }
94 
95  // Accessor for generator context, generator parameters, prototype data and projected dependents
96  RooAbsGenContext* genContext() {
97  // Return generator context
98  return _mcs ? _mcs->_genContext : 0 ;
99  }
100  RooArgSet* genInitParams() {
101  // Return initial value of generator model parameters
102  return _mcs ? _mcs->_genInitParams : 0 ;
103  }
104  RooArgSet* genParams() {
105  // Return current value of generator model parameters
106  return _mcs ? _mcs->_genParams : 0 ;
107  }
108  const RooDataSet* genProtoData() {
109  // Return generator prototype data provided by user
110  return _mcs ? _mcs->_genProtoData : 0 ;
111  }
112  RooArgSet* projDeps() {
113  // Return projected observables
114  return _mcs ? &_mcs->_projDeps : 0 ;
115  }
116 
117  // Accessors for fit observables, fit model, current and initial fit parameters and NLL value
118  RooArgSet* dependents() {
119  // Return fit model observables
120  return _mcs ? &_mcs->_dependents : 0 ;
121  }
122  RooArgSet* allDependents() {
123  // Returna all observables
124  return _mcs ? &_mcs->_allDependents : 0 ;
125  }
126  RooAbsPdf* fitModel() {
127  // Return fit model
128  return _mcs ? _mcs->_fitModel : 0 ;
129  }
130  RooArgSet* fitInitParams() {
131  // Return initial value of parameters of fit model
132  return _mcs ? _mcs->_fitInitParams : 0 ;
133  }
134  RooArgSet* fitParams() {
135  // Return current value of parameters of fit model
136  return _mcs ? _mcs-> _fitParams : 0 ;
137  }
138  RooRealVar* nllVar() {
139  // Return pointer to RooRealVar holding minimized -log(L) value
140  return _mcs ? _mcs->_nllVar : 0 ;
141  }
142 
143  // Accessors for fit options, generator annd MCstudy configuration flags
144  const char* fitOptions() {
145  // Return fit option string provided user
146  return _mcs ? _mcs->_fitOptions.Data() : 0 ;
147  }
148  RooLinkedList* fitOptList() {
149  // Return list of fit options provided by user
150  return _mcs ? &_mcs->_fitOptList : 0 ;
151  }
152  Bool_t extendedGen() {
153  // If true extended mode generation is requested
154  return _mcs ? _mcs->_extendedGen : 0 ;
155  }
156  Bool_t binGenData() {
157  // If true binning of data between generating and fitting is requested
158  return _mcs ? _mcs->_binGenData : 0 ;
159  }
160  Double_t numExpGen() {
161  // Return expected number of events from generator model
162  return _mcs ? _mcs->_nExpGen : 0 ;
163  }
164  Bool_t randProto() {
165  // If true randomization of prototype data order is requested
166  return _mcs ? _mcs->_randProto : 0 ;
167  }
168  Bool_t verboseGen() {
169  // If true verbose message in the generation step is requested
170  return _mcs ? _mcs->_verboseGen : 0 ;
171  }
172 
173 private:
174 
175  RooMCStudy* _mcs ; // Pointer to RooMCStudy object module is attached to
176 
177  ClassDef(RooAbsMCStudyModule,0) // Monte Carlo study manager add-on module
178 } ;
179 
180 
181 #endif
182