#ifndef ROO_MC_STUDY
#define ROO_MC_STUDY
#include "TList.h"
#include "TNamed.h"
#include "RooArgSet.h"
#include <list>
class RooAbsPdf;
class RooDataSet ;
class RooAbsData ;
class RooAbsGenContext ;
class RooFitResult ;
class RooPlot ;
class RooRealVar ;
class RooAbsMCStudyModule ;
class RooMCStudy : public TNamed {
public:
RooMCStudy(const RooAbsPdf& model, const RooArgSet& observables,
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()) ;
RooMCStudy(const RooAbsPdf& genModel, const RooAbsPdf& fitModel,
const RooArgSet& dependents, const char* genOptions="",
const char* fitOptions="", const RooDataSet* genProtoData=0,
const RooArgSet& projDeps=RooArgSet()) ;
virtual ~RooMCStudy() ;
void addModule(RooAbsMCStudyModule& module) ;
Bool_t generateAndFit(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char* asciiFilePat=0) ;
Bool_t generate(Int_t nSamples, Int_t nEvtPerSample=0, Bool_t keepGenData=kFALSE, const char* asciiFilePat=0) ;
Bool_t fit(Int_t nSamples, const char* asciiFilePat) ;
Bool_t fit(Int_t nSamples, TList& dataSetList) ;
Bool_t addFitResult(const RooFitResult& fr) ;
const RooArgSet* fitParams(Int_t sampleNum) const ;
const RooFitResult* fitResult(Int_t sampleNum) const ;
const RooAbsData* genData(Int_t sampleNum) const ;
const RooDataSet& fitParDataSet() ;
const RooDataSet* genParDataSet() const {
return _genParData ;
}
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()) ;
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()) ;
RooPlot* plotParam(const char* paramName, 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()) ;
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()) ;
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()) ;
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()) ;
RooPlot* plotNLL(Double_t lo, Double_t hi, Int_t nBins=100) ;
RooPlot* plotError(const RooRealVar& param, Double_t lo, Double_t hi, Int_t nbins=100) ;
RooPlot* plotPull(const RooRealVar& param, Double_t lo=-3.0, Double_t hi=3.0, Int_t nbins=25, Bool_t fitGauss=kFALSE) ;
protected:
friend class RooAbsMCStudyModule ;
RooPlot* makeFrameAndPlotCmd(const RooRealVar& param, RooLinkedList& cmdList, Bool_t symRange=kFALSE) const ;
Bool_t run(Bool_t generate, Bool_t fit, Int_t nSamples, Int_t nEvtPerSample, Bool_t keepGenData, const char* asciiFilePat) ;
Bool_t fitSample(RooAbsData* genSample) ;
RooFitResult* doFit(RooAbsData* genSample) ;
void calcPulls() ;
RooAbsData* _genSample ;
RooAbsPdf* _genModel ;
RooAbsGenContext* _genContext ;
RooArgSet* _genInitParams ;
RooArgSet* _genParams ;
const RooDataSet* _genProtoData ;
RooArgSet _projDeps ;
RooAbsPdf* _constrPdf ;
RooAbsGenContext* _constrGenContext ;
RooArgSet _dependents ;
RooArgSet _allDependents ;
RooAbsPdf* _fitModel ;
RooArgSet* _fitInitParams ;
RooArgSet* _fitParams ;
RooRealVar* _nllVar ;
RooRealVar* _ngenVar ;
TList _genDataList ;
TList _fitResList ;
RooDataSet* _genParData ;
RooDataSet* _fitParData ;
TString _fitOptions ;
RooLinkedList _fitOptList ;
Bool_t _extendedGen ;
Bool_t _binGenData ;
Double_t _nExpGen ;
Bool_t _randProto ;
Bool_t _canAddFitResults ;
Bool_t _verboseGen ;
Bool_t _perExptGenParams ;
Bool_t _silence ;
std::list<RooAbsMCStudyModule*> _modList ;
RooFitResult* refit(RooAbsData* genSample=0) ;
void resetFitParams() ;
private:
RooMCStudy(const RooMCStudy&) ;
ClassDef(RooMCStudy,0)
} ;
#endif