00001 /***************************************************************************** 00002 * Project: RooFit * 00003 * Package: RooFitCore * 00004 * File: $Id: RooAbsMCStudyModule.h,v 1.2 2007/05/11 09:11:30 verkerke Exp $ 00005 * Authors: * 00006 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu * 00007 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu * 00008 * * 00009 * Copyright (c) 2000-2005, Regents of the University of California * 00010 * and Stanford University. All rights reserved. * 00011 * * 00012 * Redistribution and use in source and binary forms, * 00013 * with or without modification, are permitted according to the terms * 00014 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) * 00015 *****************************************************************************/ 00016 00017 #ifndef ROO_ABS_MC_STUDY_MODULE 00018 #define ROO_ABS_MC_STUDY_MODULE 00019 00020 #include "TList.h" 00021 #include "RooArgSet.h" 00022 #include "RooMCStudy.h" 00023 class RooAbsPdf; 00024 class RooDataSet ; 00025 class RooAbsData ; 00026 class RooAbsGenContext ; 00027 class RooFitResult ; 00028 class RooPlot ; 00029 class RooRealVar ; 00030 00031 class RooAbsMCStudyModule : public TNamed { 00032 public: 00033 00034 RooAbsMCStudyModule(const char* name, const char* title) ; 00035 RooAbsMCStudyModule(const RooAbsMCStudyModule& other) ; 00036 virtual ~RooAbsMCStudyModule() {} ; 00037 00038 // Initializer method called upon attachement to given RooMCStudy object 00039 Bool_t doInitializeInstance(RooMCStudy& /*study*/) ; 00040 00041 virtual Bool_t initializeInstance() { 00042 // Initializer called immediately after attachment to RooMCStudy object and initialization of module base class 00043 return kTRUE ; 00044 } 00045 00046 virtual Bool_t initializeRun(Int_t /*numSamples*/) { 00047 // Method called at the beginning of each RooMCStudy run 00048 return kTRUE ; 00049 } 00050 00051 virtual RooDataSet* finalizeRun() { 00052 // Method called at the end of each RooMCStudy run. If a RooDataSet is returned, it must have a length equal to 00053 // the number of toy experiments performed and will merged with the fitpar dataset of RooMCStudy. 00054 return 0 ; 00055 } 00056 00057 virtual Bool_t processBeforeGen(Int_t /*sampleNum*/) { 00058 // Method called after resetting of generator parameters to initial values and before call to generator context 00059 // Any modifications to generator parameters will affect next generation operation (only) 00060 return kTRUE ; 00061 } 00062 00063 00064 virtual Bool_t processBetweenGenAndFit(Int_t /*sampleNum*/) { 00065 // Method called after generation of toy data sample and resetting of fit parameters to initial values and before 00066 // actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant 00067 // flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist 00068 return kTRUE ; 00069 } 00070 00071 virtual Bool_t processAfterFit(Int_t /*sampleNum*/) { 00072 // Method called after fit has been performed. 00073 return kTRUE ; 00074 } 00075 00076 protected: 00077 00078 // Interface methods to RooMCStudy objects, 00079 // which are only functional after module has been attached to a RooMCStudy object 00080 00081 RooFitResult* refit(RooAbsData* inGenSample=0) { 00082 // Refit model using orignal or specified data sample 00083 if (_mcs) return _mcs->refit(inGenSample) ; else return 0 ; 00084 } 00085 00086 RooAbsData* genSample() { 00087 // Return generate sample 00088 return _mcs ? _mcs->_genSample : 0 ; 00089 } 00090 RooAbsPdf* genModel() { 00091 // Return generator pdf 00092 return _mcs ? _mcs->_genModel : 0 ; 00093 } 00094 00095 // Accessor for generator context, generator parameters, prototype data and projected dependents 00096 RooAbsGenContext* genContext() { 00097 // Return generator context 00098 return _mcs ? _mcs->_genContext : 0 ; 00099 } 00100 RooArgSet* genInitParams() { 00101 // Return initial value of generator model parameters 00102 return _mcs ? _mcs->_genInitParams : 0 ; 00103 } 00104 RooArgSet* genParams() { 00105 // Return current value of generator model parameters 00106 return _mcs ? _mcs->_genParams : 0 ; 00107 } 00108 const RooDataSet* genProtoData() { 00109 // Return generator prototype data provided by user 00110 return _mcs ? _mcs->_genProtoData : 0 ; 00111 } 00112 RooArgSet* projDeps() { 00113 // Return projected observables 00114 return _mcs ? &_mcs->_projDeps : 0 ; 00115 } 00116 00117 // Accessors for fit observables, fit model, current and initial fit parameters and NLL value 00118 RooArgSet* dependents() { 00119 // Return fit model observables 00120 return _mcs ? &_mcs->_dependents : 0 ; 00121 } 00122 RooArgSet* allDependents() { 00123 // Returna all observables 00124 return _mcs ? &_mcs->_allDependents : 0 ; 00125 } 00126 RooAbsPdf* fitModel() { 00127 // Return fit model 00128 return _mcs ? _mcs->_fitModel : 0 ; 00129 } 00130 RooArgSet* fitInitParams() { 00131 // Return initial value of parameters of fit model 00132 return _mcs ? _mcs->_fitInitParams : 0 ; 00133 } 00134 RooArgSet* fitParams() { 00135 // Return current value of parameters of fit model 00136 return _mcs ? _mcs-> _fitParams : 0 ; 00137 } 00138 RooRealVar* nllVar() { 00139 // Return pointer to RooRealVar holding minimized -log(L) value 00140 return _mcs ? _mcs->_nllVar : 0 ; 00141 } 00142 00143 // Accessors for fit options, generator annd MCstudy configuration flags 00144 const char* fitOptions() { 00145 // Return fit option string provided user 00146 return _mcs ? _mcs->_fitOptions.Data() : 0 ; 00147 } 00148 RooLinkedList* fitOptList() { 00149 // Return list of fit options provided by user 00150 return _mcs ? &_mcs->_fitOptList : 0 ; 00151 } 00152 Bool_t extendedGen() { 00153 // If true extended mode generation is requested 00154 return _mcs ? _mcs->_extendedGen : 0 ; 00155 } 00156 Bool_t binGenData() { 00157 // If true binning of data between generating and fitting is requested 00158 return _mcs ? _mcs->_binGenData : 0 ; 00159 } 00160 Double_t numExpGen() { 00161 // Return expected number of events from generator model 00162 return _mcs ? _mcs->_nExpGen : 0 ; 00163 } 00164 Bool_t randProto() { 00165 // If true randomization of prototype data order is requested 00166 return _mcs ? _mcs->_randProto : 0 ; 00167 } 00168 Bool_t verboseGen() { 00169 // If true verbose message in the generation step is requested 00170 return _mcs ? _mcs->_verboseGen : 0 ; 00171 } 00172 00173 private: 00174 00175 RooMCStudy* _mcs ; // Pointer to RooMCStudy object module is attached to 00176 00177 ClassDef(RooAbsMCStudyModule,0) // Monte Carlo study manager add-on module 00178 } ; 00179 00180 00181 #endif 00182