/***************************************************************************** * Project: BaBar detector at the SLAC PEP-II B-factory * Package: RooRarFit * File: $Id: combine.cc,v 1.10 2006/02/22 22:00:16 zhanglei Exp $ * Authors: Lei Zhang * History: * * Copyright (C) 2005 University of California, Riverside *****************************************************************************/ // This macro provides functions for NLL scan plots/curves // using RooRarFit facilities // Sample macro to call these functions is combine.C #if !defined(__CINT__) || defined(__MAKECINT__) #include "TFile.h" #include "RooFitCore/RooPlot.hh" #include "RooRarFit/rarMLFitter.hh" #include "RooRarFit/rarNLL.hh" #endif // Wrappers of RooRarFit functions // `Add' Error onto NLL curve // maxNLL is the pointer to store max NLL value for plotting void addErrToCurve(RooCurve *curve, Double_t errLo, Double_t errHi, Double_t *maxNLL=0) { rarMLFitter::addErrToCurve(curve, errLo, errHi, maxNLL); } void addErrToCurve(RooCurve *curve, Double_t err, Double_t *maxNLL=0) { addErrToCurve(curve, err, err, maxNLL); } // Shift NLL curve with dx and dy RooCurve *shiftNLLCurve(RooCurve *curve, Double_t dx, Double_t dy) { return rarMLFitter::shiftNLLCurve(curve, dx, dy); } // Combine NLL curves and shift the new min to zero (if shiftToZero) RooCurve *combineNLLCurves(TList &curves, Bool_t shiftToZero=kTRUE, Double_t *maxNLL=0) { return rarMLFitter::combineNLLCurves(curves, shiftToZero, maxNLL); } // Combine NLL curves and their CORRELATED errors // maxNLL is pointer to store maxNLL value for plotting RooCurve *combineNLLCurves(TList &curves,Double_t errs[], Double_t *maxNLL=0) { return rarMLFitter::combineNLLCurves(curves, errs, maxNLL); } // Get significance wrt refVal on NLL curve Double_t getSignf(RooCurve *curve, Double_t refVal=0.) { return rarMLFitter::getSignf(curve, refVal); } // Get upper limit (default CL set to 90%) Double_t getUL(RooCurve *curve, Double_t CL=0.90) { return rarMLFitter::getUL(curve, CL); } // Get mean and errors from NLL curve Double_t getMeanErrs(RooCurve *curve, Double_t *errLo=0, Double_t *errHi=0) { return rarMLFitter::getMeanErrs(curve, errLo, errHi); } // combine NLL curves (w sys errs), draw the plots, // calculate signf. and UL based on the final curve RooPlot *combine(Int_t nModes, Char_t* fileNames[], Char_t* plotNames[], Double_t fitBias[], Double_t addSystErrLo[], Double_t addSystErrHi[], Double_t uncorrSystErrLo[], Double_t uncorrSystErrHi[], Double_t corrSystErr[], Char_t *xAxisTitle=0, Bool_t doSignf=kTRUE, Bool_t doUL=kFALSE, Double_t CL=.90) { RooPlot *thePlot(0); // List of RooCurves TList curves; // original individual NLL curves TList curvesWadds; // individual NLL curves with additive errors TList curvesWerrs; // individual NLL curves with uncorrelated errors // RooPlot properties TString yAxisTitle="-2 ln (L/L_{0})"; Double_t xMin(0), xMax(0), yMax(0); // read in all the NLL Curves for (Int_t i=0; iGet(plotNames[i]); if (!scanPlot) { cout<<" Can not read in RooPlot "<GetMaximum(); if (yMaxGetXaxis(); Double_t theXmin=a->GetXmin(); if (xMin>theXmin) xMin=theXmin; Double_t theXmax=a->GetXmax(); if (xMaxGetTitle(); // Get curve RooCurve *nllCurve=scanPlot->getCurve("NLL_curve"); if (!nllCurve) { cout<<" Can not read NLL curve NLL_curve from RooPlot "<SetNameTitle(Form("NLL_curve_Mode%d", i), Form("curve for sub-mode %d", i)); { // now shift the curve to min=0 Double_t mean(0), yMin(0); rarNLL nll(nllCurve); nll.getMin(mean, yMin); shiftNLLCurve(nllCurve, -fitBias[i], -yMin); } // Clone it RooCurve *nllCurveWadd=(RooCurve*)nllCurve->Clone(); RooCurve *nllCurveWerr=(RooCurve*)nllCurve->Clone(); // `add' errors onto the curve addErrToCurve(nllCurveWadd, addSystErrLo[i], addSystErrHi[i]); addErrToCurve(nllCurveWerr, uncorrSystErrLo[i], uncorrSystErrHi[i]); // add the curve into lists curves.Add(nllCurve); curvesWadds.Add(nllCurveWadd); curvesWerrs.Add(nllCurveWerr); } //curves.Print(); //curvesWadds.Print(); //curvesWerrs.Print(); // combine the curve together RooCurve *tCurve=combineNLLCurves(curves, kTRUE, &yMax); tCurve->SetNameTitle("NLL_curve_total", "total curve w/o syst errors"); // combine the curve (w additive errors) together RooCurve *aCurve=combineNLLCurves(curvesWadds, kTRUE, &yMax); aCurve->SetNameTitle("NLL_curve_additive", "total curve w/ additve errors"); // combine the curve (w uncorrelated errors) together RooCurve *uCurve=combineNLLCurves(curvesWerrs, kTRUE, &yMax); uCurve->SetNameTitle("NLL_curve_unCorr", "total curve w/ unCorr. errors"); // combine the curves and add correlated errors RooCurve *cCurve=combineNLLCurves(curvesWerrs, corrSystErr, &yMax); cCurve->SetNameTitle("NLL_curve_Corr", "total curve w/ ALL syst errors"); // Draw the RooPlot thePlot=new RooPlot(xMin, xMax, 0, yMax); thePlot->SetNameTitle(plotNames[0], plotNames[0]); thePlot->SetYTitle(yAxisTitle); thePlot->SetXTitle(xAxisTitle); // total curve without syst. error thePlot->addPlotable(tCurve); tCurve->SetLineWidth(2); tCurve->SetLineStyle(2); thePlot->setInvisible(tCurve->GetName()); // invisible // total curve w/ additive errors thePlot->addPlotable(aCurve); aCurve->SetLineWidth(2); aCurve->SetLineStyle(4); aCurve->SetLineColor(kYellow); thePlot->setInvisible(aCurve->GetName()); // invisible // total curve w/ uncorrelated errors thePlot->addPlotable(uCurve); uCurve->SetLineWidth(2); uCurve->SetLineStyle(4); uCurve->SetLineColor(kGreen); thePlot->setInvisible(uCurve->GetName()); // invisible // total curve w/ all errors thePlot->addPlotable(cCurve); cCurve->SetLineWidth(2); // add individual NLL curves for (Int_t i=0; iClone(); thePlot->addPlotable(theCCurve); theCCurve->SetLineWidth(1); theCCurve->SetLineColor(rarBasePdf::getColor(i)); theCCurve->SetLineStyle(0==(i%2)?2:4); } // draw it thePlot->Draw(); thePlot->Print("v"); cout<