# Difference: HiggsAnalysisAtATLASUsingRooStats (25 vs. 26)

Line: 1 to 1

 META TOPICPARENT name="WebHome"
Changed:
<
<
>
>

Line: 26 to 26
To check what version of ROOT is running, use the following command:
Changed:
<
<
root -v -b
>
>
root -v -b

## Setting up RooStats

Line: 42 to 40
Follow the appropriate instructions here to build the ROOT trunk.
Deleted:
<
<

#### Shell script: building ROOT with RooFit and RooStats

Changed:
<
<
```

```
>
>
```

```
#!/bin/bash

# This script builds the latest version of ROOT with RooFit and RooStats in Ubuntu.

Line: 100 to 97
# The following line could be added to the ~/.bashrc file: # export PATH=\$PATH:/home/wbm/root/bin
Changed:
<
<

>
>

### Option 3: Build the RooStats branch.

Line: 130 to 127
Composite functions correspond to composite objects. The ArgSet class is dependent on argument order while the ArgList class is not.
Deleted:
<
<

### Example code: defining a RooFit variable

Changed:
<
<
```

```
>
>
```

```
General form for defining a RooFit variable: RooRealVar x(<object name>, <object title>, <value>, <minimum value>, <maximum value>) Specific example for defining a RooFit variable x with the value 5: RooRealVar x("x", "x observable", 5, -10, 10)
Changed:
<
<

>
>

### RooPlot

Line: 154 to 150
Bayes' theorem holds that the probability of b given a is related to the probability of a given b. Normally, one might say that the mean of a Gaussian is 1 and that then gives a distribution for x. However, if one had a dataset for x, 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 x in the Gaussian could actually be a function of, say, x^2. A Jacobian factor is picked up in going from x to x^2, 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.
Deleted:
<
<

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

Changed:
<
<
```

```
>
>
```

```
{ // Build a Gaussian PDF. RooRealVar x("x", "x", -10, 10);
Line: 168 to 163
// Plot the PDF. RooPlot* xframe = x.frame(); gauss.plotOn(xframe);
Changed:
<
<
xframe->Draw();
>
>
xframe->Draw();
}
Changed:
<
<

>
>

Deleted:
<
<

#### Example code: telling a RooFit PDF what to normalise over

Changed:
<
<
```

```
>
>
```

```
Not normalised (i.e., this is not a PDF): gauss.getVal(); Hey, RooFit! This is the thing to normalise over (i.e., guarantees Int[xmin, xmax] Gauss(x, m, s)dx == 1): gauss.getVal(x); What is the value if sigma is considered the observable? (i.e., guarantees Int[smin, smax] Gauss(x, m, s)ds == 1):
Changed:
<
<

>
>

### Datasets

Line: 194 to 188

#### RooDataSet (unbinned data)

Deleted:
<
<

##### Example code: generating toy Monte Carlo, storing it as unbinned data and then plotting it
Changed:
<
<
```

```
>
>
```

```
} // Create a RooDataSet and fill it with generated toy Monte Carlo data: RooDataSet* myData = gauss.generate(x, 100);
Line: 206 to 199
myFrame.Draw(); }
Changed:
<
<

>
>

Plotting unbinned data is similar to plotting binned data with the exception that one can show it in some preferred binning.
Deleted:
<
<

##### Example code: plotting unbinned data (a RooDataSet) using a specified binning
Changed:
<
<
```

```
>
>
```

```
RooPlot* myFrame = x.frame() ; myData.plotOn(myFrame, Binning(25)) ;
Changed:
<
<
myFrame->Draw()
>
>
myFrame->Draw()

Changed:
<
<

>
>

##### Importing data from ROOT trees (how to populate RooDataSets from TTrees)
Line: 231 to 223
In displaying the data, RooFit, by default, shows the 68% confidence interval for Poisson statistics.
Deleted:
<
<

##### Example code: import a ROOT histogram into a RooDataHist (a RooFit binned dataset)
Changed:
<
<
```

```
>
>
```

```
{ // 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: 254 to 245
myFrame.Draw() }
Changed:
<
<

>
>

### Fitting

#### Fitting a model to data

Changed:
<
<
Fitting a model to data can be done in many ways. The most common methods are the χ2 fit and the -log(L) fit. The default fitting method in ROOT is the χ2 method, while the default method in RooFit is the -log(L) method. The -log(L) method is often preferred because it is more robust for low statistics fits and because it can also be performed on unbinned data.
>
>
Fitting a model to data can be done in many ways. The most common methods are the χ2 fit and the -log(L) fit. The default fitting method in ROOT is the χ2 method, while the default method in RooFit is the -log(L) method. The -log(L) method is often preferred because it is more robust for low statistics fits and because it can also be performed on unbinned data.

#### Fitting a PDF to unbinned data

Deleted:
<
<

##### Example code: fit a Gaussian PDF to data
Changed:
<
<
```

```
>
>
```

```
// Fit gauss to unbinned data gauss.fitTo(*myData);
Changed:
<
<

>
>

### The RooFit workspace

Line: 280 to 270
One might create a Gaussian PDF and then import it into a workspace. All of the dependencies of the Gaussian shall be drawn in and owned by the workspace. There are no nightmarish ownership problems. Alternatively, one might create simply the Gaussian inside the workspace using the "Workspace Factory".
Deleted:
<
<

#### Example code: using the Workspace Factory to create a Gaussian PDF

Changed:
<
<
```

```
>
>
```

```
// Create a Gaussian PDF using the Workspace Factory (this is essentially the shorthand for creating a Gaussian). RooWorkspace* myWorkspace = new RooWorkspace("myWorkspace");
Changed:
<
<
myWorkspace->factory("Gaussian::g(x[-5, 5], mu, sigma");
>
>
myWorkspace->factory("Gaussian::g(x[-5, 5], mu, sigma");

Changed:
<
<

>
>

### What's in the RooFit workspace?

Deleted:
<
<

#### Example code: What's in the workspace?

Changed:
<
<
```

```
>
>
```

```
// 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: 323 to 311
// Import the ModelConfig saved as m. ModelConfig* myModelConfig = (ModelConfig*) myWorkspace.obj("m");
Changed:
<
<

>
>

#### Visual representations of the model/PDF contents

Line: 331 to 319
Graphviz consists of a graph description language called the DOT language and a set of tools that can generate and/or process DOT files.
Deleted:
<
<

##### Example code: examining PDFs and creating graphical representations of them
Changed:
<
<
```

```
>
>
```

```
// Create variables and a PDF using those variables. RooRealVar mu("mu", "mu", 150); RooRealVar sigma("sigma", "sigma", 5, 0, 20);
Line: 368 to 355
// 0x1487090/V- RooRealVar::mu = 150 // 0x1487bc0/V- RooRealVar::sigma = 5
Changed:
<
<

>
>

#### Accessing the RooFit workspace

Deleted:
<
<

##### Example code: accessing the workspace
Changed:
<
<
```

```
>
>
```

```
// Open the appropriate ROOT file. root -l BR5_MSSM_signal90_combined_datastat_model.root // Alternatively, you could open the file in a manner such as the following: 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();

Changed:
<
<

>
>

Deleted:
<
<

##### Example code: accessing both data and PDF from a workspace stored in a file
Changed:
<
<
```

```
>
>
```

```
// Note that the following code is independent of actual PDF in the file. So, for example, a full Higgs combination could work with identical code.

// Open a file and import the workspace. 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()

Changed:
<
<

>
>

## RooStats

Line: 426 to 411
The main goal is to standardise the interface for major statistical procedures so that they can work on an arbitrary RooFit model and dataset and handle any parameters of interest and nuisance parameters. Another goal is to implement most accepted techniques from frequentist, Bayesian and likelihood based approaches. A further goal is to provide utilities to perform combined measurements.
Deleted:
<
<

#### Example code: create a simple model using the RooFit Workspace Factory. Specify parts of the model using ModelConfig. Create a simple dataset. Complete a confidence interval test using the ProfileLikelihoodCalculator of RooStats

Changed:
<
<
```

```
>
>
```

```
{ // In this script, a simple model is created using the Workspace Factory in RooFit. // ModelConfig is used to specify the parts of the model necessary for the statistical tools of RooStats. // 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)");
>
>
myWorkspace->factory("Gaussian::normal(x[-10,10], mu[-1,1], sigma)");
// 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. // Specify the confidence level required. double confidenceLevel = 0.95;
Line: 473 to 457
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;
} }
Changed:
<
<

>
>

## ModelConfig

Changed:
<
<
The ModelConfig RooStats class encapsulates the configuration of a model to define a particular hypothesis. It is now used extensively by the calculator tools. ModelConfig always contains a reference to an external workspace that manages all of the objects that are a part of the model (PDFs and parameter sets). So, in order to use ModelConfig, the user must specify a workspace pointer before creating the various objects of the model.
>
>
The ModelConfig RooStats class encapsulates the configuration of a model to define a particular hypothesis. It is now used extensively by the calculator tools. ModelConfig always contains a reference to an external workspace that manages all of the objects that are a part of the model (PDFs and parameter sets). So, in order to use ModelConfig, the user must specify a workspace pointer before creating the various objects of the model.

## HistFactory

Line: 512 to 495

### hist2workspace

Changed:
<
<
The hist2workspace executable is used in the following manner: hist2workspace input.xml
>
>
The hist2workspace executable is used in the following manner: hist2workspace input.xml

### XML files

Line: 543 to 525
There are several parts in the top-level XML file. Initially, the XML schema is specified. The output is specified next. Specifically, the prefix for any output files (ROOT files containing workspaces) is given. Now, the channel XML files are given for each measurement (e.g., signal, background, systematics information) using the Input tag. Next, the details for each channel are defined using the Measurement tag. Which bins to use are specified inclusively using the Measurement tag attributes BinLow and BinHigh. Within the Measurement tag, the POI tag is used to specify the point of interest for the channel, i.e. the test statistic.
Deleted:
<
<

##### Example file: \$ROOTSYS/tutorials/histfactory/example.xml
Changed:
<
<
```

```
>
>
```
```

```<!DOCTYPE Combination  SYSTEM 'HistFactorySchema.dtd'>

<Combination OutputFilePrefix="./results/example" Mode="comb" >```
Line: 578 to 559

Changed:
<
<
>
>

#### Channel XML files

Line: 610 to 591
HistoNameHigh="myShapeSystematic_1_high" HistoNameLow="myShapeSystematic_1_low" />
Deleted:
<
<

##### Example file: \$ROOTSYS/tutorials/histfactory/example_channel.xml
Changed:
<
<
```

```
>
>
```
```

```<!DOCTYPE Channel  SYSTEM 'HistFactorySchema.dtd'>

<Channel Name="channel1" InputFile="./data/example.root" HistoName="" >```
Line: 630 to 610

Changed:
<
<
>
>

## Analysis!

Line: 658 to 638
HistFactory manual Changed:
<
<
E-group for support with ATLAS-sensitive information: atlas-phys-stat-root@cern.ch
>
>
E-group for support with ATLAS-sensitive information: atlas-phys-stat-root@cern.ch

Changed:
<
<
E-mail support for software issues, bugs etc.: roostats-development@cern.ch
>
>
E-mail support for software issues, bugs etc.: roostats-development@cern.ch