rarMLFitter.hh

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Project: BaBar detector at the SLAC PEP-II B-factory
00003 * Package: RooRarFit
00004  *    File: $Id: rarMLFitter.rdl,v 1.54 2011/12/15 13:32:28 fwilson Exp $
00005  * Authors: Lei Zhang
00006  * History:
00007  *
00008  * Copyright (C) 2005-2012, University of California, Riverside
00009  *****************************************************************************/
00010 #ifndef RAR_MLFITTER
00011 #define RAR_MLFITTER
00012 
00013 #include "TList.h"
00014 #include "TString.h"
00015 #include "TObject.h"
00016 #include "TMatrixD.h"
00017 #include "TArrayD.h"
00018 
00019 #include "RooRarFit/rarCompBase.hh"
00020 
00021 class RooFormulaVar;
00022 class RooMCStudy;
00023 class RooSimPdfBuilder;
00024 
00049 class rarMLFitter : public rarCompBase {
00050   
00051 public:
00052   rarMLFitter();
00053   rarMLFitter(const char *configFile, const char *configSec,
00054               const char *configStr, rarDatasets *theDatasets,
00055               RooDataSet *theData, const char *name, const char *title);
00056   virtual ~rarMLFitter();
00057   
00062   void setParamDir(TString paramDir) {_paramDir=paramDir;}
00063 
00068   void setResultDir(TString resultDir) {_resultDir=resultDir;}
00069   
00075   void setToyID(Int_t toyID=0) {_toyID=toyID;}
00076   
00081   void setToyNexp(Int_t toyNexp=0) {_toyNexp=toyNexp;}
00082   
00087   void setToyDir(TString toyDir) {_toyDir=toyDir;}
00088 
00090   virtual RooArgSet getProtDataEVars() {return _protDataEVars;}
00091   virtual RooAbsPdf *getProtGen();
00092   virtual RooAbsPdf *getGenerator();
00093   virtual RooSimultaneous *compGen(RooAbsPdf *gen, RooArgList subGens,
00094                                    RooCategory &compCat);
00097   virtual RooSimPdfBuilder* getSimBuilder(){return _simBuilder;}
00098   TString getPhysCat();
00099   TString getSplitCats();
00100   RooArgSet getSplitCatSet();
00101   RooAbsCategory *getSplitCat(RooArgSet &splitCatSet, TString catName);
00102   
00103   void run();
00104 
00105   static void addErrToCurve(RooCurve *curve, Double_t errLo, Double_t errHi,
00106                             Double_t *maxNLL=0);
00107   static void addErrToCurve(RooCurve *curve, Double_t err, Double_t *maxNLL=0);
00108   static RooCurve *shiftNLLCurve(RooCurve *curve, Double_t dx, Double_t dy);
00109   static RooCurve *combineNLLCurves(TList &curves, Bool_t shiftToZero=kTRUE,
00110                                     Double_t *maxNLL=0);
00111   static RooCurve *combineNLLCurves(TList &curves, Double_t errs[],
00112                                     Double_t *maxNLL=0);
00113   static Double_t getMeanErrs(RooCurve *curve,
00114                               Double_t *errLo=0, Double_t *errHi=0);
00115   static Double_t getSignf(RooCurve *curve, Double_t refVal=0.);
00116   static Double_t getUL(RooCurve *curve, Double_t CL=0.90);
00117   static RooCurve *combCurves(RooCurve* crv1, RooCurve* crv2,
00118                               const char* formula, const char* valid="1",
00119                               const char* crvName=0, Int_t lineWidth=2,
00120                               Int_t lineStyle=2, Int_t lineColor=kBlue);
00121   
00122 protected:
00123   void init();
00124   virtual Bool_t initParams(TString act, RooArgSet fullParams,
00125                             RooArgSet fullParamsWOI,
00126                             TString readParams="yes",
00127                             TString paramFileID="pdfFit",
00128                             TString readSecParams="yes",
00129                             Bool_t useFloatFix=kFALSE,
00130                             RooArgSet postPdfFloatSet=RooArgSet(),
00131                             RooArgSet preMLFixSet=RooArgSet(),
00132                             RooArgSet preMLFloatSet=RooArgSet());
00133   virtual RooArgSet getSpecialSet(TString setName="specialSet");
00134   virtual void setSpecialStr(RooArgSet *simConfigSet);
00135   virtual void getSplitCoeffValues(RooArgList coeffList, TString valType,
00136                                    ostream &o);
00137   virtual void chkBlind(TString dsName);
00138   virtual RooFitResult *doMLFit(RooDataSet *mlFitData,TString opt,ostream &o, Int_t ncpus=1);
00139   virtual RooFitResult *doTheFit(RooAbsPdf *pdf, RooDataSet *mlFitData, TString opt, Int_t ncpus=1);
00140   virtual void doSignf(RooDataSet *mlFitData,TString signfStr,
00141                        RooFitResult *fitResult, RooArgSet fullParams,
00142                        ostream &o);
00143   virtual void doSysStudy(RooDataSet *mlFitData, TString paramsStr,
00144                           TString varsStr,RooArgSet fullParams, ostream &o);
00145   virtual void setVariation(RooArgSet theParams, Double_t myV,
00146                             Bool_t useErr, Bool_t isPlus);
00147   virtual void calSysErrors(Int_t iParam, RooArgSet &cstudyVars,
00148                             RooArgSet &studyVars, TArrayD &eArray);
00149   virtual void avgSysErrors(ostream &o, TString vParams, Int_t pnLen,
00150                             TArrayD &pV, TArrayD &pArray, TArrayD &mV,
00151                             TArrayD &mArray, TArrayD &aArray, TMatrixD corrM);
00152   virtual void outSysErrors(ostream &o, TString rowName, Int_t pnLen,
00153                             TMatrixD corrM, TArrayD &aArray);
00154   virtual TMatrixD getCorrMatrix(Int_t nSysParams, TString vParams,
00155                                  Bool_t diagOnly=kFALSE);
00156   virtual Double_t doGOFChisq(RooDataSet *mlFitData, ostream &o,
00157                               TList *plotList=0);
00158   
00159   virtual RooDataSet *doToyStudy(RooArgSet fullParams);
00160   virtual void getCompCatDS(TList*ds,RooDataSet *iData,RooCategory *compCat=0);
00161   virtual RooAbsArg *findSimed(RooArgSet &simSet,
00162                                TString argName, TString catName,
00163                                RooAbsPdf *srcPdf=0);
00164   virtual Int_t randInt(Double_t iNumber);
00165   virtual void generate(RooMCStudy *theToy, RooAbsPdf *theGen,
00166                         const TString genOpt, const Int_t toyNexp);
00167   virtual void generate(RooMCStudy *theToy,
00168                         const RooArgList& etoyDeps,
00169                         const TString genStr, const TString genOpt,
00170                         const Int_t toyNexp);
00171   virtual RooDataSet *generate(const RooArgList& dependents,
00172                                const TString genSrcName,
00173                                Double_t nEvtGen, const TString genOpt);
00174   virtual RooAbsPdf *getExtCompPdf(RooAbsPdf *thePdf, RooAbsReal *theCoef);
00175   virtual void getSnB();
00176   virtual RooDataSet *getLLRDataset(RooDataSet *theData, RooFormulaVar *LLR);
00177   virtual void doLLRPlot(RooDataSet *projData, TList &plotList);
00178   virtual void getLLRPlot(TList &plotList, TString plotName,
00179                           RooAbsPdf *thePdf, Int_t nEvt,
00180                           RooArgSet theDeps, RooDataSet *protData,
00181                           Int_t nBins, RooAbsReal *LLRFunc);
00182   virtual RooPlot *doProjPlot(RooDataSet *projData, RooRealVar *theVar,
00183                               TList &plotList);
00184   virtual RooPlot *getProjPlot(RooRealVar *theVar, Double_t plotMin,
00185                                Double_t plotMax, Int_t nBins,
00186                                RooDataSet *sliceData, TString frameName,
00187                                TString frameTitle, TList &plotList,
00188                                const RooCmdArg &asymCat=RooCmdArg(),
00189                                const RooCmdArg &nuBins=RooCmdArg(),
00190                                const RooCmdArg &xerrorscale=RooCmdArg(),
00191                                RooPlot *frameM=0, RooPlot *frameP=0);
00192   virtual void scanVarShiftToNorm(RooArgList scanVars, TArrayD &scanVarDiff);
00193   virtual RooPlot *doScanPlot(TList &plotList);
00194   virtual RooPlot *doContourPlot(TList &plotList);
00195   virtual RooPlot *doSPlot(RooRealVar *theVar, TList &plotList);
00196   
00197   virtual TString getRootFileName(TString aType, TString configToken="yes");
00198   virtual TString getParamFileName(TString aType, TString configToken="yes",
00199                                    TString dirName="");
00200   virtual void paramFileIO(RooArgSet params, TString paramFile,
00201                            Bool_t In=kTRUE);
00202   virtual void paramFileI(RooArgSet params, TString paramFile);
00203   virtual void paramFileO(RooArgSet params, TString paramFile);
00204   virtual RooPlot *doCombinePlot(TList &plotList);
00205   virtual RooPlot *combine(Int_t nModes, 
00206                            const vector<TString> fileNames,
00207                            const vector<TString> plotNames,
00208                            const vector<Double_t> fitBias,
00209                            const vector<Double_t> addSystErrLo,
00210                            const vector<Double_t> addSystErrHi,
00211                            const vector<Double_t> uncorrSystErrLo,
00212                            const vector<Double_t> uncorrSystErrHi,
00213                            const vector<Double_t> corrSystErr,
00214                            const TString xAxisTitle,
00215                            Bool_t doSignf=kTRUE, Bool_t doUL=kFALSE, Double_t CL=0.90);
00216   
00217   virtual void saveAsRootFile(const RooDataSet *ds, 
00218                               const TString rootfilename, 
00219                               Bool_t withErrors);
00220   virtual TTree *createTreeFromDataset(const RooDataSet *ds, Bool_t withErrors);
00221 
00222   static TString _physCatStr; 
00223   static TString _splitCatStr; 
00224   static RooArgSet _splitCatSet; 
00225   static RooArgSet _splitCatSet2; 
00226   RooSimPdfBuilder *_simBuilder; 
00227   RooArgSet *_simConfig; 
00228   RooAbsCategoryLValue *_category; 
00229   RooAbsPdf *_theGen; 
00230   Int_t _protGenLevel; 
00231   RooDataSet *_protDataset; 
00232   TList _protDatasetsM; 
00233   TList _protDatasets; 
00234   RooArgSet _protDataEVars; 
00235   RooArgList _preToyRandGenerators; 
00236   RooAbsPdf *_theToyParamGen; 
00237   RooArgSet _embdObsRandSet; 
00238   RooArgSet _embdObsGens; 
00239   RooArgSet _extCompPdfs; 
00240   RooAbsPdf *_theSPdf; 
00241   RooAbsPdf *_theBPdf; 
00242   TList _fCompList; 
00243   RooArgList _fCoefList; 
00244   TList _sCompList; 
00245   RooArgList _sCoefList; 
00246   
00247   TString _paramDir; 
00248   TString _resultDir; 
00249   Int_t _toyID; 
00250   Int_t _toyNexp; 
00251   TString _toyDir; 
00252   
00253 private:
00254   rarMLFitter(const rarMLFitter&);
00255   ClassDef(rarMLFitter, 0) // Final RooRarFit ML fitter class
00256     ;
00257 };
00258 
00259 #endif

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7