%%cpp -d #include "TFile.h" #include "TROOT.h" #include "TCanvas.h" #include "TList.h" #include "TMath.h" #include "TSystem.h" #include "RooWorkspace.h" #include "RooAbsData.h" #include "RooStats/ModelConfig.h" #include "RooStats/ProfileInspector.h" using namespace RooFit; using namespace RooStats; const char *infile = ""; const char *workspaceName = "combined"; const char *modelConfigName = "ModelConfig"; const char *dataName = "obsData"; const char *filename = ""; if (!strcmp(infile, "")) { filename = "results/example_combined_GaussExample_model.root"; bool fileExist = !gSystem->AccessPathName(filename); // note opposite return code // if file does not exists generate with histfactory if (!fileExist) { // Normally this would be run on the command line cout << "will run standard hist2workspace example" << endl; gROOT->ProcessLine(".! prepareHistFactory ."); gROOT->ProcessLine(".! hist2workspace config/example.xml"); cout << "\n\n---------------------" << endl; cout << "Done creating example input" << endl; cout << "---------------------\n\n" << endl; } } else filename = infile; TFile *file = TFile::Open(filename); RooWorkspace *w = (RooWorkspace *)file->Get(workspaceName); ModelConfig *mc = (ModelConfig *)w->obj(modelConfigName); RooAbsData *data = w->data(dataName); ProfileInspector p; TList *list = p.GetListOfProfilePlots(*data, mc); TCanvas *c1 = new TCanvas("c1", "ProfileInspectorDemo", 800, 200); if (list->GetSize() > 4) { double n = list->GetSize(); int nx = (int)sqrt(n); int ny = TMath::CeilNint(n / nx); nx = TMath::CeilNint(sqrt(n)); c1->Divide(ny, nx); } else c1->Divide(list->GetSize()); for (int i = 0; i < list->GetSize(); ++i) { c1->cd(i + 1); list->At(i)->Draw("al"); } cout << endl; %jsroot on gROOT->GetListOfCanvases()->Draw()