// merge the HTI results #include "TFile.h" #include "TMath.h" #include "TError.h" #include "TCanvas.h" #include "RooStats/HypoTestInverterResult.h" #include "RooStats/HypoTestInverterPlot.h" #include "RoOStats/SamplingDistPlot.h" #include //gSystem->Load("libRooStats"); using namespace RooStats; bool PlotDetailedOutput(HypoTestResult * r, const char * poiName, double poiValue) { RooAbsData * nullData = r->GetNullDetailedOutput(); RooAbsData * altData = r->GetAltDetailedOutput(); if (!nullData || !altData) { Error("PlotDetailedOutput","Detailed output is not present in result file"); return; } TCanvas * c2 = new TCanvas(); c2->SetTitle(TString::Format("Output for poi = %f",poiValue) ); //RooArgList pars(*nullData->get(0)); TString muName1 = TString("ModelConfig_TS0_fitUncond_")+TString(poiName); TString muName0 = TString("ModelConfig_with_poi_0_TS0_fitUncond_")+TString(poiName); TString tsName1 = TString("ModelConfig_TS0"); TString tsName0 = TString("ModelConfig_with_poi_0_TS0"); TH1 * h1 = new TH1D("h1","POI S+B",100,1,0); TH1 * h0 = new TH1D("h0","POI B",100,1,0); TH1 * ts1 = new TH1D("ts1","TS S+B",100,1,0); TH1 * ts0 = new TH1D("ts1","TS B",100,1,0); // fill the histograms for (int i = 0; i < nullData->numEntries() ; ++i) { RooArgSet * args = nullData->get(i); h1->Fill(args->getRealValue(muName1, -999 ) ); ts1->Fill(args->getRealValue(tsName1, -999 ) ); } for (int i = 0; i < altData->numEntries() ; ++i) { RooArgSet * args = altData->get(i); h0->Fill(args->getRealValue(muName0, -999 ) ); ts0->Fill(args->getRealValue(tsName0, -999 ) ); } // TH1 * h1 = nullData->createHistogram(muName1, (RooRealVar&)pars[1],Binning(100,0.5,1.5)); // TH1 * h0 = altData->createHistogram(muName0, (RooRealVar&)pars[1],Binning(100,-.1,.1)); // // TH1 * hy = nullData->createHistogram("muy", (RooRealVar&)pars[],Binning(100,-5,5)); // TH1 * ts1 = nullData->createHistogram(tsName1, (RooRealVar&)pars[0],Binning(100,0,10) ); // TH1 * ts0 = altData->createHistogram(tsName0, (RooRealVar&)pars[0],Binning(100,0,10) ); c2->Divide(2,2); c2->cd(1); h1->Draw(); //h1->Fit("gaus","L"); c2->cd(2); h0->Draw(); //h0->Fit("gaus","L"); c2->cd(3); ts1->Draw(); TF1 * f1 = new TF1("f1","[0]*ROOT::Math::chisquared_pdf(2*x,[1])"); f1->SetParameters(1,2); //ts1->Fit(f1,"L"); c2->cd(4); ts0->Draw(); return true; } void readHypoTestInvDetailedOutput(const char * file1, const char *poiName = "s") { TFile * f1 = new TFile(file1); TString resultName = "result_"; resultName += poiName; HypoTestInverterResult * r1 = (HypoTestInverterResult*) f1->Get(resultName); if (!r1) { Error("read_CLs","result with name %s is not found in file ",resultName.Data() ); f1->ls(); return; } // loop on the points for (int i = 0; i < r1->ArraySize(); ++i) { HypoTestResult * r = r1->GetResult(i); bool ok = PlotDetailedOutput(r, poiName, r1->GetXValue(i)); if (!ok) return; } }