Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|

| ||||||||

Deleted: | ||||||||

< < | -- Will Breaden Madden - 2016-01-25 | |||||||

## Higgs analysis at ATLAS using RooStats | ||||||||

Changed: | ||||||||

< < | This page contains basic information on getting started with Higgs analysis at ATLAS using RooStats. | |||||||

> > | This page contains basic information on getting started with Higgs analysis at ATLAS using RooStats. Only the most meager of attempts is made to keep this documentation current. | |||||||

- Higgs analysis at ATLAS using RooStats
- What is RooStats?
- setting up RooStats
- RooFit
- general description
- example code: defining a RooFit variable
- RooPlot
- PDFs
- datasets
- fitting
- The RooFit workspace
- What's in the RooFit workspace?
- links for RooFit
- RooStats
- ModelConfig
- HistFactory
- general description
- XML approach to HistFactory
- C++ approach to HistFactory
- HistFactory class tree structure
- HistFactory configuration in C++
- example HistFactory model construction using C++
- details on HistFactory usage in C++
- details on the object measurement
- add a preprocessed function by giving the function a name, a functional expression and a string with a bracketed list of dependencies (e.g. "SigXsecOverSM[0,3]")
- create a class representing a preprocess function and add it to a measurement directly using the constructor PreprocessFunction and a method of a measurement object
- details on object channel
- details on object sample
- combining
- details on the object measurement
- links for HistFactory
- analysis!
- full significance calculation example, from histogram creation to model production (using hist2workspace), to RooStats calculations
- further information
| ||||||||

Line: 14 to 12 | ||||||||

RooStats is a project to create statistical tools built on top of the RooFit library, which is a data-modelling toolkit. It is distributed in ROOT. Specifically, it has been distributed in the ROOT release since version 5.22 (December 2008). The latest version of ROOT is recommended as the RooStats project develops quickly. | ||||||||

Deleted: | ||||||||

< < | ## using ROOT on the Glasgow PPELX networkThere are instructions on how to use the different versions of ROOT at Glasgow here. Execute commands something like the following in order to set up ROOT version 5.32.00 on PPELX:
## using ROOT on the CERN LXPLUS networkExecute commands something like the following in order to set up ROOT version 5.32.00 on LXPLUS:
| |||||||

## setting up RooStatsThere are three main options available for acquiring ROOT with RooStats included. | ||||||||

Line: 208 to 184 | ||||||||

| ||||||||

Changed: | ||||||||

< < | RooRealVar x(<object name>, <object title>, <value>, <minimum value>, <maximum value>) | |||||||

> > | RooRealVar x( | |||||||

// specific example for defining a RooFit variable x with the value 5: RooRealVar x("x", "x observable", 5, -10, 10) %ENDCODE% | ||||||||

Line: 225 to 201 | ||||||||

What is the value of this? In a nutshell, it allows one to do Bayesian stuff very easily. | ||||||||

Changed: | ||||||||

< < | Bayes' theorem holds that the probability of given is related to the probability of given . Normally, one might say that the mean of a Gaussian is 1 and that then gives a distribution for . However, if one had a dataset for , one might want to know the posterior for the mean. The RooFit ability to switch what the probability density function is of is very useful for Bayesian stuff. Because RooFit allows this composition, the thing that acts as in the Gaussian could actually be a function of, say, to , so the normalisation no longer makes sense. Sometimes RooFit can figure out what the Jacobian factor should be and sometimes it resorts to numerical integration. | |||||||

> > | Bayes' theorem holds that the probability of given is related to the probability of given . Normally, one might say that the mean of a Gaussian is 1 and that then gives a distribution for . However, if one had a dataset for , one might want to know the posterior for the mean. The RooFit ability to switch what the probability density function is of is very useful for Bayesian stuff. Because RooFit allows this composition, the thing that acts as in the Gaussian could actually be a function of, say, . A Jacobian factor is picked up in going from to , so the normalisation no longer makes sense. Sometimes RooFit can figure out what the Jacobian factor should be and sometimes it resorts to numerical integration. | |||||||

## example code: create a Gaussian PDF using RooStats and plot it using the RooPlot class | ||||||||

Line: 240 to 216 | ||||||||

// Plot the PDF. RooPlot* xframe = x.frame(); gauss.plotOn(xframe); | ||||||||

Changed: | ||||||||

< < | xframe->Draw(); | |||||||

> > | xframe->Draw(); | |||||||

} %ENDCODE% | ||||||||

Line: 284 to 260 | ||||||||

Changed: | ||||||||

< < | myFrame->Draw() | |||||||

> > | myFrame->Draw() | |||||||

%ENDCODE%
## importing data from ROOT trees (how to populate RooDataSets from TTrees) | ||||||||

Line: 306 to 282 | ||||||||

// Access the file. TFile* myFile = new TFile("myFile.root"); // Load the histogram. | ||||||||

Changed: | ||||||||

< < | TH1* myHistogram = (TH1*) myFile->Get("myHistogram"); | |||||||

> > | TH1* myHistogram = (TH1*) myFile->Get("myHistogram"); | |||||||

// Draw the loaded histogram. myHistogram.Draw(); | ||||||||

Line: 351 to 327 | ||||||||

Changed: | ||||||||

< < | myWorkspace->factory("Gaussian::g(x[-5, 5], mu[0], sigma[1]"); | |||||||

> > | myWorkspace->factory("Gaussian::g(x[-5, 5], mu[0], sigma[1]"); | |||||||

%ENDCODE%
## What's in the RooFit workspace? | ||||||||

Line: 362 to 338 | ||||||||

// Open the appropriate ROOT file. root -l myFile.root // Import the workspace. | ||||||||

Changed: | ||||||||

< < | myWorkspace = (RooWorkspace*) _file0->Get("myWorkspace"); | |||||||

> > | myWorkspace = (RooWorkspace*) _file0->Get("myWorkspace"); | |||||||

// Print the workspace contents. myWorkspace.Print(); // Example printout: | ||||||||

Line: 478 to 454 | ||||||||

// myFileName = "BR5_MSSM_signal90_combined_datastat_model.root" // TFile *myFile = TFile::Open(myFileName); // Import the workspace. | ||||||||

Changed: | ||||||||

< < | RooWorkspace* myWorkspace = (RooWorkspace*) _file0->Get("combined"); | |||||||

> > | RooWorkspace* myWorkspace = (RooWorkspace*) _file0->Get("combined"); | |||||||

// Print the workspace contents. | ||||||||

Changed: | ||||||||

< < | myWorkspace->Print(); | |||||||

> > | myWorkspace->Print(); | |||||||

// Import the PDF. | ||||||||

Changed: | ||||||||

< < | RooAbsPdf* myPDF = myWorkspace->pdf("model_BR5_MSSM_signal90"); | |||||||

> > | RooAbsPdf* myPDF = myWorkspace->pdf("model_BR5_MSSM_signal90"); | |||||||

// Import the variable representing the observable. | ||||||||

Changed: | ||||||||

< < | RooRealVar* myObservable = myWorkspace->var("obs"); | |||||||

> > | RooRealVar* myObservable = myWorkspace->var("obs"); | |||||||

// Create a RooPlot frame using the imported variable.. RooPlot* myFrame = myObservable.frame(); // Plot the PDF on the created RooPlot frame. myPDF.plotOn(myFrame); // Draw the RooPlot. | ||||||||

Changed: | ||||||||

< < | myFrame->Draw(); | |||||||

> > | myFrame->Draw(); | |||||||

%ENDCODE%
## example code: accessing both data and PDF from a workspace stored in a file | ||||||||

Line: 502 to 478 | ||||||||

TFile myFile("myResults.root") ; RooWorkspace* myWorkspace = f.Get("myWorkspace") ; // Plot the data and PDF | ||||||||

Changed: | ||||||||

< < | RooPlot* xframe = w->var("x")->frame() ; w->data("d")->plotOn(xframe) ; w->pdf("g")->plotOn(xframe) ; | |||||||

> > | RooPlot* xframe = w->var("x")->frame() ; w->data("d")->plotOn(xframe) ; w->pdf("g")->plotOn(xframe) ; | |||||||

// Construct a likelihood and profile likelihood | ||||||||

Changed: | ||||||||

< < | RooNLLVar nll("nll","nll",*myWorkspace->pdf("g"),*w->data("d")) ; RooProfileLL pll("pll","pll", nll,*myWorkspace->var("m")) ; RooPlot* myFrame = w->var("m")->frame(-1,1) ; | |||||||

> > | RooNLLVar nll("nll","nll",*myWorkspace->pdf("g"),*w->data("d")) ; RooProfileLL pll("pll","pll", nll,*myWorkspace->var("m")) ; RooPlot* myFrame = w->var("m")->frame(-1,1) ; | |||||||

pll.plotOn(myFrame) ; | ||||||||

Changed: | ||||||||

< < | myFrame->Draw() | |||||||

> > | myFrame->Draw() | |||||||

%ENDCODE%
## links for RooFit | ||||||||

Line: 535 to 511 | ||||||||

// A 95% confidence interval test is run using the ProfileLikelihoodCalculator of RooStats.
// Define a RooFit random seed in order to produce reproducible results. | ||||||||

Changed: | ||||||||

< < | RooRandom::randomGenerator()->SetSeed(271); | |||||||

> > | RooRandom::randomGenerator()->SetSeed(271); | |||||||

// Make a simple model using the Workspace Factory.
// Create a new workspace. RooWorkspace* myWorkspace = new RooWorkspace(); // Create the PDF G(x|mu,1) and the variables x, mu and sigma in one command using the factory syntax. | ||||||||

Changed: | ||||||||

< < | myWorkspace->factory("Gaussian::normal(x[-10,10], mu[-1,1], sigma[1])"); | |||||||

> > | myWorkspace->factory("Gaussian::normal(x[-10,10], mu[-1,1], sigma[1])"); | |||||||

// Define parameter sets for observables and parameters of interest. | ||||||||

Changed: | ||||||||

< < | myWorkspace->defineSet("poi","mu"); myWorkspace->defineSet("obs","x"); | |||||||

> > | myWorkspace->defineSet("poi","mu"); myWorkspace->defineSet("obs","x"); | |||||||

// Print the workspace contents. | ||||||||

Changed: | ||||||||

< < | myWorkspace->Print() ; | |||||||

> > | myWorkspace->Print() ; | |||||||

// Specify for the statistical tools the components of the defined model. // Create a new ModelConfig. ModelConfig* myModelConfig = new ModelConfig("my G(x|mu,1)"); // Specify the workspace. | ||||||||

Changed: | ||||||||

< < | myModelConfig->SetWorkspace(*myWorkspace); | |||||||

> > | myModelConfig->SetWorkspace(*myWorkspace); | |||||||

// Specify the PDF. | ||||||||

Changed: | ||||||||

< < | myModelConfig->SetPdf(*myWorkspace->pdf("normal")); | |||||||

> > | myModelConfig->SetPdf(*myWorkspace->pdf("normal")); | |||||||

// Specify the parameters of interest. | ||||||||

Changed: | ||||||||

< < | myModelConfig->SetParametersOfInterest(*myWorkspace->set("poi")); | |||||||

> > | myModelConfig->SetParametersOfInterest(*myWorkspace->set("poi")); | |||||||

// Specify the observables. | ||||||||

Changed: | ||||||||

< < | myModelConfig->SetObservables(*myWorkspace->set("obs")); | |||||||

> > | myModelConfig->SetObservables(*myWorkspace->set("obs")); | |||||||

// Create a toy dataset.
// Create a toy dataset of 100 measurements of the observables (x). | ||||||||

Changed: | ||||||||

< < | RooDataSet* myData = myWorkspace->pdf("normal")->generate(*myWorkspace->set("obs"), 100); //myData->print(); | |||||||

> > | RooDataSet* myData = myWorkspace->pdf("normal")->generate(*myWorkspace->set("obs"), 100); //myData->print(); | |||||||

// Use the ProfileLikelihoodCalculator to obtain a 95% confidence interval. | ||||||||

Line: 580 to 556 | ||||||||

LikelihoodInterval* myProfileLikelihoodInterval = myProfileLikelihoodCalculator.GetInterval(); // Use this interval result. In this case, it makes sense to say what the lower and upper limits are. // Define the object variables for the purposes of the confidence interval. | ||||||||

Changed: | ||||||||

< < | RooRealVar* x = myWorkspace->var("x"); RooRealVar* mu = myWorkspace->var("mu"); cout << "The profile likelihood calculator interval is [ "<< myProfileLikelihoodInterval->LowerLimit(*mu) << ", " << myProfileLikelihoodInterval->UpperLimit(*mu) << "] " << endl; | |||||||

> > | RooRealVar* x = myWorkspace->var("x"); RooRealVar* mu = myWorkspace->var("mu"); cout << "The profile likelihood calculator interval is [ "<< myProfileLikelihoodInterval->LowerLimit(*mu) << ", " << myProfileLikelihoodInterval->UpperLimit(*mu) << "] " << endl; | |||||||

// Set mu equal to zero. | ||||||||

Changed: | ||||||||

< < | mu->setVal(0); | |||||||

> > | mu->setVal(0); | |||||||

// Is mu in the interval? | ||||||||

Changed: | ||||||||

< < | cout << "Is mu = 0 in the interval?" << endl; if (myProfileLikelihoodInterval->IsInInterval(*mu) == 1){ cout << "Yes" << endl; | |||||||

> > | cout << "Is mu = 0 in the interval?" << endl; if (myProfileLikelihoodInterval->IsInInterval(*mu) == 1){ cout << "Yes" << endl; | |||||||

} else{ | ||||||||

Changed: | ||||||||

< < | cout << "No" << endl; | |||||||

> > | cout << "No" << endl; | |||||||

} } %ENDCODE% | ||||||||

Line: 996 to 972 | ||||||||

##
example (early in project development): creation of the Measurement and a Channel and, thence, creation of the channel samples, including signal and backgrounds
| ||||||||

Changed: | ||||||||

< < | // Create the Measurement and a channel | |||||||

> > | // Create the Measurement and a channel. | |||||||

std::string myInputFile = "./data/myData.root"; std::string myChannel1Path = ""; | ||||||||

Line: 1127 to 1103 | ||||||||

## details on the object measurement | ||||||||

Changed: | ||||||||

< < | A measurement has several methods to configure its options, each of which are equivalent to their XML equivalents. | |||||||

> > | A measurement has several methods to configure its options, each of which is equivalent to their XML equivalents. | |||||||

| ||||||||

Line: 1192 to 1168 | ||||||||

void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath=""); %ENDCODE% | ||||||||

Changed: | ||||||||

< < | A sample can be included in a channel's bin-by-bin statistical uncertainty fluctuations by "activating" the sample. There are two ways to do this. The first way is to use the default errors that are stored in the histogram's uncertainty array. The second way is to supply the errors using an external histogram (in the case where the desired errors differ from those stored by the HT1 histogram). These can be achieved using thw following methods: | |||||||

> > | A sample can be included in a channel's bin-by-bin statistical uncertainty fluctuations by "activating" the sample. There are two ways to do this. The first way is to use the default errors that are stored in the histogram's uncertainty array. The second way is to supply the errors using an external histogram (in the case where the desired errors differ from those stored by the HT1 histogram). These can be achieved using the following methods: | |||||||

| ||||||||

Line: 1228 to 1204 | ||||||||

## links for HistFactory | ||||||||

Changed: | ||||||||

< < | ||||||||

> > | ||||||||

View topic | History: r51 < r50 < r49 < r48 | More topic actions...

Copyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback