ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooAbsMCStudyModule.h,v 1.2 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/

#ifndef ROO_ABS_MC_STUDY_MODULE
#define ROO_ABS_MC_STUDY_MODULE

#include "TList.h"
#include "RooArgSet.h"
#include "RooMCStudy.h"
class RooAbsPdf;
class RooDataSet ;
class RooAbsData ;
class RooAbsGenContext ;
class RooFitResult ;
class RooPlot ;
class RooRealVar ;

class RooAbsMCStudyModule : public TNamed {
public:

  RooAbsMCStudyModule(const char* name, const char* title) ;
  RooAbsMCStudyModule(const RooAbsMCStudyModule& other) ;
  virtual ~RooAbsMCStudyModule() {} ;

  // Initializer method called upon attachement to given RooMCStudy object
  Bool_t doInitializeInstance(RooMCStudy& /*study*/) ; 

  virtual Bool_t initializeInstance() { 
    // Initializer called immediately after attachment to RooMCStudy object and initialization of module base class
    return kTRUE ; 
  } 

  virtual Bool_t initializeRun(Int_t /*numSamples*/) { 
    // Method called at the beginning of each RooMCStudy run
    return kTRUE ; 
  } 

  virtual RooDataSet* finalizeRun() { 
    // Method called at the end of each RooMCStudy run. If a RooDataSet is returned, it must have a length equal to 
    // the number of toy experiments performed and will merged with the fitpar dataset of RooMCStudy.
    return 0 ; 
  }

  virtual Bool_t processBeforeGen(Int_t /*sampleNum*/) { 
    // Method called after resetting of generator parameters to initial values and before call to generator context
    // Any modifications to generator parameters will affect next generation operation (only)
    return kTRUE ; 
  }


  virtual Bool_t processBetweenGenAndFit(Int_t /*sampleNum*/) { 
    // Method called after generation of toy data sample and resetting of fit parameters to initial values and before
    // actual fit is performed. Any modifications to fit parameters will apply to next fit operation. Note that setConstant
    // flag of fit parameters are not explicitly reset by RooMCStudy, so any changes made to these flags here will persist
    return kTRUE ; 
  }

  virtual Bool_t processAfterFit(Int_t /*sampleNum*/) { 
    // Method called after fit has been performed.
    return kTRUE ; 
  }

protected:

   // Interface methods to RooMCStudy objects, 
   // which are only functional after module has been attached to a RooMCStudy object

   RooFitResult* refit(RooAbsData* inGenSample=0) { 
     // Refit model using orignal or specified data sample
     if (_mcs) return _mcs->refit(inGenSample) ; else return 0 ; 
   }

   RooDataSet* genSample() { 
     // Return generate sample
     return _mcs ? _mcs->_genSample : 0 ; 
   }
   RooAbsPdf* genModel() {
     // Return generator pdf
     return _mcs ? _mcs->_genModel : 0 ; 
   }

   // Accessor for generator context, generator parameters,	prototype data and projected dependents
   RooAbsGenContext* genContext() { 
     // Return generator context
     return _mcs ? _mcs->_genContext : 0 ; 
   }
   RooArgSet* genInitParams() { 
     // Return initial value of generator model parameters
     return _mcs ? _mcs->_genInitParams : 0 ; 
   } 
   RooArgSet* genParams() { 
     // Return current value of generator model parameters
     return _mcs ? _mcs->_genParams : 0 ; 
   } 
   const RooDataSet* genProtoData() { 
     // Return generator prototype data provided by user
     return _mcs ? _mcs->_genProtoData : 0 ; 
   }
   RooArgSet* projDeps() { 
     // Return projected observables
     return _mcs ? &_mcs->_projDeps : 0 ; 
   }

   // Accessors for fit observables, fit model, current and initial fit parameters and NLL value
   RooArgSet* dependents() { 
     // Return fit model observables
     return _mcs ? &_mcs->_dependents : 0 ; 
   } 
   RooArgSet* allDependents() { 
     // Returna all observables
     return _mcs ? &_mcs->_allDependents : 0 ; 
   }
   RooAbsPdf* fitModel() { 
     // Return fit model
     return _mcs ? _mcs->_fitModel : 0 ; 
   }
   RooArgSet* fitInitParams() { 
     // Return initial value of parameters of fit model
     return _mcs ? _mcs->_fitInitParams : 0 ; 
   }
   RooArgSet* fitParams() { 
     // Return current value of parameters of fit model
     return _mcs ? _mcs-> _fitParams : 0 ; 
   }
   RooRealVar* nllVar() { 
     // Return pointer to RooRealVar holding minimized -log(L) value
     return _mcs ? _mcs->_nllVar : 0 ; 
   }
  
   // Accessors for fit options, generator annd MCstudy configuration flags
   const char* fitOptions() { 
     // Return fit option string provided user
     return _mcs ? _mcs->_fitOptions.Data() : 0 ; 
   }
   RooLinkedList* fitOptList() { 
     // Return list of fit options provided by user
     return _mcs ? &_mcs->_fitOptList : 0 ; 
   }
   Bool_t extendedGen() { 
     // If true extended mode generation is requested
     return _mcs ? _mcs->_extendedGen : 0 ; 
   }
   Bool_t binGenData() { 
     // If true binning of data between generating and fitting is requested
     return _mcs ? _mcs->_binGenData : 0 ; 
   }
   Double_t numExpGen() { 
     // Return expected number of events from generator model
     return _mcs ? _mcs->_nExpGen : 0 ; 
   }
   Bool_t randProto() { 
     // If true randomization of prototype data order is requested
     return _mcs ? _mcs->_randProto : 0 ; 
   }
   Bool_t verboseGen() { 
     // If true verbose message in the generation step is requested
     return _mcs ? _mcs->_verboseGen : 0 ; 
   }

private:

  RooMCStudy* _mcs ; // Pointer to RooMCStudy object module is attached to
	
  ClassDef(RooAbsMCStudyModule,0) // Monte Carlo study manager add-on module
} ;


#endif

 RooAbsMCStudyModule.h:1
 RooAbsMCStudyModule.h:2
 RooAbsMCStudyModule.h:3
 RooAbsMCStudyModule.h:4
 RooAbsMCStudyModule.h:5
 RooAbsMCStudyModule.h:6
 RooAbsMCStudyModule.h:7
 RooAbsMCStudyModule.h:8
 RooAbsMCStudyModule.h:9
 RooAbsMCStudyModule.h:10
 RooAbsMCStudyModule.h:11
 RooAbsMCStudyModule.h:12
 RooAbsMCStudyModule.h:13
 RooAbsMCStudyModule.h:14
 RooAbsMCStudyModule.h:15
 RooAbsMCStudyModule.h:16
 RooAbsMCStudyModule.h:17
 RooAbsMCStudyModule.h:18
 RooAbsMCStudyModule.h:19
 RooAbsMCStudyModule.h:20
 RooAbsMCStudyModule.h:21
 RooAbsMCStudyModule.h:22
 RooAbsMCStudyModule.h:23
 RooAbsMCStudyModule.h:24
 RooAbsMCStudyModule.h:25
 RooAbsMCStudyModule.h:26
 RooAbsMCStudyModule.h:27
 RooAbsMCStudyModule.h:28
 RooAbsMCStudyModule.h:29
 RooAbsMCStudyModule.h:30
 RooAbsMCStudyModule.h:31
 RooAbsMCStudyModule.h:32
 RooAbsMCStudyModule.h:33
 RooAbsMCStudyModule.h:34
 RooAbsMCStudyModule.h:35
 RooAbsMCStudyModule.h:36
 RooAbsMCStudyModule.h:37
 RooAbsMCStudyModule.h:38
 RooAbsMCStudyModule.h:39
 RooAbsMCStudyModule.h:40
 RooAbsMCStudyModule.h:41
 RooAbsMCStudyModule.h:42
 RooAbsMCStudyModule.h:43
 RooAbsMCStudyModule.h:44
 RooAbsMCStudyModule.h:45
 RooAbsMCStudyModule.h:46
 RooAbsMCStudyModule.h:47
 RooAbsMCStudyModule.h:48
 RooAbsMCStudyModule.h:49
 RooAbsMCStudyModule.h:50
 RooAbsMCStudyModule.h:51
 RooAbsMCStudyModule.h:52
 RooAbsMCStudyModule.h:53
 RooAbsMCStudyModule.h:54
 RooAbsMCStudyModule.h:55
 RooAbsMCStudyModule.h:56
 RooAbsMCStudyModule.h:57
 RooAbsMCStudyModule.h:58
 RooAbsMCStudyModule.h:59
 RooAbsMCStudyModule.h:60
 RooAbsMCStudyModule.h:61
 RooAbsMCStudyModule.h:62
 RooAbsMCStudyModule.h:63
 RooAbsMCStudyModule.h:64
 RooAbsMCStudyModule.h:65
 RooAbsMCStudyModule.h:66
 RooAbsMCStudyModule.h:67
 RooAbsMCStudyModule.h:68
 RooAbsMCStudyModule.h:69
 RooAbsMCStudyModule.h:70
 RooAbsMCStudyModule.h:71
 RooAbsMCStudyModule.h:72
 RooAbsMCStudyModule.h:73
 RooAbsMCStudyModule.h:74
 RooAbsMCStudyModule.h:75
 RooAbsMCStudyModule.h:76
 RooAbsMCStudyModule.h:77
 RooAbsMCStudyModule.h:78
 RooAbsMCStudyModule.h:79
 RooAbsMCStudyModule.h:80
 RooAbsMCStudyModule.h:81
 RooAbsMCStudyModule.h:82
 RooAbsMCStudyModule.h:83
 RooAbsMCStudyModule.h:84
 RooAbsMCStudyModule.h:85
 RooAbsMCStudyModule.h:86
 RooAbsMCStudyModule.h:87
 RooAbsMCStudyModule.h:88
 RooAbsMCStudyModule.h:89
 RooAbsMCStudyModule.h:90
 RooAbsMCStudyModule.h:91
 RooAbsMCStudyModule.h:92
 RooAbsMCStudyModule.h:93
 RooAbsMCStudyModule.h:94
 RooAbsMCStudyModule.h:95
 RooAbsMCStudyModule.h:96
 RooAbsMCStudyModule.h:97
 RooAbsMCStudyModule.h:98
 RooAbsMCStudyModule.h:99
 RooAbsMCStudyModule.h:100
 RooAbsMCStudyModule.h:101
 RooAbsMCStudyModule.h:102
 RooAbsMCStudyModule.h:103
 RooAbsMCStudyModule.h:104
 RooAbsMCStudyModule.h:105
 RooAbsMCStudyModule.h:106
 RooAbsMCStudyModule.h:107
 RooAbsMCStudyModule.h:108
 RooAbsMCStudyModule.h:109
 RooAbsMCStudyModule.h:110
 RooAbsMCStudyModule.h:111
 RooAbsMCStudyModule.h:112
 RooAbsMCStudyModule.h:113
 RooAbsMCStudyModule.h:114
 RooAbsMCStudyModule.h:115
 RooAbsMCStudyModule.h:116
 RooAbsMCStudyModule.h:117
 RooAbsMCStudyModule.h:118
 RooAbsMCStudyModule.h:119
 RooAbsMCStudyModule.h:120
 RooAbsMCStudyModule.h:121
 RooAbsMCStudyModule.h:122
 RooAbsMCStudyModule.h:123
 RooAbsMCStudyModule.h:124
 RooAbsMCStudyModule.h:125
 RooAbsMCStudyModule.h:126
 RooAbsMCStudyModule.h:127
 RooAbsMCStudyModule.h:128
 RooAbsMCStudyModule.h:129
 RooAbsMCStudyModule.h:130
 RooAbsMCStudyModule.h:131
 RooAbsMCStudyModule.h:132
 RooAbsMCStudyModule.h:133
 RooAbsMCStudyModule.h:134
 RooAbsMCStudyModule.h:135
 RooAbsMCStudyModule.h:136
 RooAbsMCStudyModule.h:137
 RooAbsMCStudyModule.h:138
 RooAbsMCStudyModule.h:139
 RooAbsMCStudyModule.h:140
 RooAbsMCStudyModule.h:141
 RooAbsMCStudyModule.h:142
 RooAbsMCStudyModule.h:143
 RooAbsMCStudyModule.h:144
 RooAbsMCStudyModule.h:145
 RooAbsMCStudyModule.h:146
 RooAbsMCStudyModule.h:147
 RooAbsMCStudyModule.h:148
 RooAbsMCStudyModule.h:149
 RooAbsMCStudyModule.h:150
 RooAbsMCStudyModule.h:151
 RooAbsMCStudyModule.h:152
 RooAbsMCStudyModule.h:153
 RooAbsMCStudyModule.h:154
 RooAbsMCStudyModule.h:155
 RooAbsMCStudyModule.h:156
 RooAbsMCStudyModule.h:157
 RooAbsMCStudyModule.h:158
 RooAbsMCStudyModule.h:159
 RooAbsMCStudyModule.h:160
 RooAbsMCStudyModule.h:161
 RooAbsMCStudyModule.h:162
 RooAbsMCStudyModule.h:163
 RooAbsMCStudyModule.h:164
 RooAbsMCStudyModule.h:165
 RooAbsMCStudyModule.h:166
 RooAbsMCStudyModule.h:167
 RooAbsMCStudyModule.h:168
 RooAbsMCStudyModule.h:169
 RooAbsMCStudyModule.h:170
 RooAbsMCStudyModule.h:171
 RooAbsMCStudyModule.h:172
 RooAbsMCStudyModule.h:173
 RooAbsMCStudyModule.h:174
 RooAbsMCStudyModule.h:175
 RooAbsMCStudyModule.h:176
 RooAbsMCStudyModule.h:177
 RooAbsMCStudyModule.h:178
 RooAbsMCStudyModule.h:179
 RooAbsMCStudyModule.h:180
 RooAbsMCStudyModule.h:181
 RooAbsMCStudyModule.h:182