Difference: HiggsAnalysisAtATLASUsingRooStats (42 vs. 43)

Revision 432013-08-07 - WilliamBreadenMadden

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
-- WilliamBreadenMadden - 2013-08-05
Line: 20 to 20
  Execute the following commands in order to set up ROOT version 5.32.00 on PPELX:
Changed:
<
<
>
>
%CODE{"bash"}%
 export ROOTSYS=/data/ppe01/sl5x/x86_64/root/5.32.00 export PATH=$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib/root:$LD_LIBRARY_PATH
Changed:
<
<
>
>
%ENDCODE%
 

using ROOT on the CERN LXPLUS network

Execute the following commands in order to set up ROOT version 5.32.00 on LXPLUS:

Changed:
<
<
>
>
%CODE{"bash"}%
 . /afs/cern.ch/sw/lcg/external/gcc/4.3.2/x86_64-slc5/setup.sh cd /afs/cern.ch/sw/lcg/app/releases/ROOT/5.32.00/x86_64-slc5-gcc43-opt/root/ . bin/thisroot.sh
Changed:
<
<
>
>
%ENDCODE%
 

setting up RooStats

Line: 49 to 49
 Follow the appropriate instructions here to build the ROOT trunk.

shell script: building ROOT with RooFit and RooStats

Changed:
<
<

>
>
%CODE{"bash"}%
 #!/bin/bash

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

Line: 105 to 106
  export ROOTSYS=/usr/local/root export PATH=$ROOTSYS/bin:$PATH export LD_LIBRARY_PATH=$ROOTSYS/lib/root:$LD_LIBRARY_PATH
Changed:
<
<

>
>
%ENDCODE%
 

option 3: Build the RooStats branch.

Line: 136 to 137
 Composite functions correspond to composite objects. The ArgSet class is dependent on argument order while the ArgList class is not.

example code: defining a RooFit variable

Changed:
<
<

general form for defining a RooFit variable:

>
>
%CODE{"c++"}% // general form for defining a RooFit variable:
  RooRealVar x(<object name>, <object title>, <value>, <minimum value>, <maximum value>)
Changed:
<
<
specific example for defining a RooFit variable x with the value 5:
>
>
// specific example for defining a RooFit variable x with the value 5:
  RooRealVar x("x", "x observable", 5, -10, 10)
Changed:
<
<

>
>
%ENDCODE%
 

RooPlot

Line: 158 to 160
 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.

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

Changed:
<
<

>
>
%CODE{"c++"}%
  { // Build a Gaussian PDF. RooRealVar x("x", "x", -10, 10);
Line: 171 to 174
  gauss.plotOn(xframe); xframe->Draw(); }
Changed:
<
<

>
>
%ENDCODE%
 

example code: telling a RooFit PDF what to normalise over

Changed:
<
<

not normalised (i.e., this is not a PDF):

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

>
>
// What is the value if sigma is considered the observable? (i.e., guarantees Int[smin, smax] Gauss(x, m, s)ds == 1): %ENDCODE%
 

datasets

Line: 193 to 197
 

RooDataSet (unbinned data)

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

>
>
%CODE{"c++"}%
  } // Create a RooDataSet and fill it with generated toy Monte Carlo data: RooDataSet* myData = gauss.generate(x, 100);
Line: 202 to 207
  myData.plotOn()(myFrame); myFrame.Draw(); }
Changed:
<
<

>
>
%ENDCODE%
  Plotting unbinned data is similar to plotting binned data with the exception that one can display it in some preferred binning.

example code: plotting unbinned data (a RooDataSet) using a specified binning
Changed:
<
<

>
>
%CODE{"c++"}%
  RooPlot* myFrame = x.frame() ; myData.plotOn(myFrame, Binning(25)) ; myFrame->Draw()
Changed:
<
<

>
>
%ENDCODE%
 
importing data from ROOT trees (how to populate RooDataSets from TTrees)
Line: 226 to 232
 In displaying the data, RooFit, by default, shows the 68% confidence interval for Poisson statistics.

example code: import a ROOT histogram into a RooDataHist (a RooFit binned dataset)
Changed:
<
<

>
>
%CODE{"c++"}%
  { // Access the file. TFile* myFile = new TFile("myFile.root");
Line: 246 to 253
  myData.plotOn(myFrame) myFrame.Draw() }
Changed:
<
<

>
>
%ENDCODE%
 

fitting

Line: 257 to 264
 

fitting a PDF to unbinned data

example code: fit a Gaussian PDF to data
Changed:
<
<

>
>
%CODE{"c++"}%
  // Fit gauss to unbinned data gauss.fitTo(*myData);
Changed:
<
<

>
>
%ENDCODE%
 

The RooFit workspace

Line: 271 to 279
 Consider a Gaussian PDF. One might create this Gaussian PDF and then import it into a workspace. All of the dependencies of the Gaussian would 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".

example code: using the Workspace Factory to create a Gaussian PDF

Changed:
<
<

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

>
>
%ENDCODE%
 

What's in the RooFit workspace?

example code: What's in the workspace?

Changed:
<
<

>
>
%CODE{"c++"}%
  // Open the appropriate ROOT file. root -l myFile.root // Import the workspace.
Line: 309 to 319
  RooAbsData* myData = myWorkspace.data("d"); // Import the ModelConfig saved as m. ModelConfig* myModelConfig = (ModelConfig*) myWorkspace.obj("m");
Changed:
<
<

>
>
%ENDCODE%
 

visual representations of the model/PDF contents

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

example code: examining PDFs and creating graphical representations of them
Changed:
<
<

>
>
%CODE{"c++"}%
  // Create variables and a PDF using those variables. RooRealVar mu("mu", "mu", 150); RooRealVar sigma("sigma", "sigma", 5, 0, 20);
Line: 352 to 363
  // 0x15f7fe0/V- RooRealVar::x = 150 // 0x1487090/V- RooRealVar::mu = 150 // 0x1487bc0/V- RooRealVar::sigma = 5
Changed:
<
<

>
>
%ENDCODE%
 
Model Inspector

The Model Inspector is a GUI for examining the model contained in the RooFit workspace. The function and it's parameters are as follows:

Changed:
<
<


>
>
%CODE{"c++"}%
 void ModelInspector(const char* infile = "", const char* workspaceName = "combined", const char* modelConfigName = "ModelConfig", const char* dataName = "obsData")
Changed:
<
<

>
>
%ENDCODE%
  If the workspace(s) were made using hist2workspace, the names have a standard form (as shown above).

using the Model Inspector
Changed:
<
<
>
>
%CODE{"c++"}%
  // Load the macro. root -L ModelInspector.C++ // Run the macro on the appropriate ROOT workspace file. ModelInspector("results/my_combined_example_model.root")
Changed:
<
<
>
>
%ENDCODE%
  The Model Inspector GUI should appear. The GUI consists of a number of plots, corresponding to the various channels in the model, and a few sliders, corresponding to the parameters of interest and the nuisance parameters in the model. The initial plots are based on the values of the parameters in the workspace. There is a little "Fit" button which fits the model to the data points (while also printing the standard terminal output detailing the fitting). After fitting, a yellow band is shown around the best fit model indicating the uncertainty from propagating the uncertainty of the fit through the model. On the plots, there is a red line shown (corresponding to the fit for each of the parameters at their nominal value pushed up by 1 sigma).
Line: 385 to 397
 

accessing the RooFit workspace

example code: accessing the workspace
Changed:
<
<

>
>
%CODE{"c++"}%
  // 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:
Line: 405 to 418
  myPDF.plotOn(myFrame); // Draw the RooPlot. myFrame->Draw();
Changed:
<
<

>
>
%ENDCODE%
 
example code: accessing both data and PDF from a workspace stored in a file
Changed:
<
<

>
>
%CODE{"c++"}%
  // 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.

Line: 424 to 438
  RooPlot* myFrame = w->var("m")->frame(-1,1) ; pll.plotOn(myFrame) ; myFrame->Draw()
Changed:
<
<

>
>
%ENDCODE%
 

links for RooFit

Line: 441 to 455
 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.

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:
<
<

>
>
%CODE{"c++"}%
  { // 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.
Line: 501 to 516
  cout << "No" << endl; } }
Changed:
<
<

>
>
%ENDCODE%
 

links for RooStats

Line: 540 to 554
  The hist2workspace executable is run using the top-level XML configuration file as an argument in the following manner:
Changed:
<
<
>
>
%CODE{"bash"}%
  hist2workspace top_level.xml
Changed:
<
<
>
>
%ENDCODE%
  hist2workspace builds the model and saves input histograms in the output ROOT file. The measurement's configuration class is made to persist as well. This measurement class has a member function that can write XML configuration files which point to the histograms saved in the (output) ROOT file (e.g.: GaussExample->WriteToXML).
Line: 612 to 626
 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.

example file: $ROOTSYS/tutorials/histfactory/example.xml
Changed:
<
<
<!DOCTYPE Combination  SYSTEM 'HistFactorySchema.dtd'>
>
>
%CODE{"html"}%
  OutputFilePrefix="./results/example" Mode="comb" >
Line: 643 to 658
 

Changed:
<
<
>
>
%ENDCODE%
 
channel XML files
Line: 835 to 849
  example file: createXMLFiles.sh
Changed:
<
<

>
>
%CODE{"bash"}%
 #!/bin/bash

# This script is designed for use with the naming conventions described in the following page:

Line: 874 to 887
  createXMLFiles $originalMass 125 #userSet createXMLFiles $originalMass 130 #userSet createXMLFiles $originalMass 140 #userSet
Changed:
<
<
>
>
%ENDCODE%
 

C++ approach to HistFactory

Line: 906 to 919
 
example (early in project development): creation of the Measurement and a Channel and, thence, creation of the channel samples, including signal and backgrounds
Changed:
<
<

>
>
%CODE{"c++"}%
 // Create the Measurement and a channel std::string myInputFile = "./data/myData.root"; std::string myChannel1Path = "";
Line: 946 to 958
  myChannel.samples.push_back(myBackground2); // Add the samples to the measurement. myMeasurement.channels.push_back(myChannel);
Changed:
<
<
>
>
%ENDCODE%
 

example HistFactory model construction using C++

A HistFactory model is to be created. It shall consist of a single channel that shall have only signal and background. Uncertainties on the luminosity, statistical uncertainties from Monte Carlo and separate systematics on signal and background shall be included.

Changed:
<
<

>
>
%CODE{"c++"}%
 #include "RooStats/HistFactory/Measurement.h" void MakeSimpleModel() { // This function creates a simple model with one channel.
Line: 1029 to 1040
  // Run the measurement (this is equivalent to an execution of // the program hist2workspace). MakeModelAndMeasurementFast(measurement_1);
Changed:
<
<
>
>
%ENDCODE%
 

details on HistFactory usage in C++

Line: 1053 to 1064
 
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]")
Changed:
<
<

>
>
%CODE{"c++"}%
 void AddPreprocessFunction(std::string name, std::string expression, std::string dependencies);
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
Line: 1062 to 1072
 
PreprocessFunction::PreprocessFunction(std::string Name, std::string Expression, std::string Dependents);
void AddPreprocessFunction(const std::string& function);
Changed:
<
<
>
>
%ENDCODE%
 
details on object channel
Line: 1091 to 1101
  A sample object can have many different types of systematic uncertainties defined.
Changed:
<
<

>
>
%CODE{"c++"}%
 void AddOverallSys(std::string Name, Double_t Low, Double_t High); void AddNormFactor(std::string Name, Double_t Val, Double_t Low, Double_t High, bool Const=false); void AddHistoSys(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh); void AddHistoFactor(std::string Name, std::string HistoNameLow, std::string HistoFileLow, std::string HistoPathLow, std::string HistoNameHigh, std::string HistoFileHigh, std::string HistoPathHigh); void AddShapeFactor(std::string Name); void AddShapeSys(std::string Name, Constraint::Type ConstraintType, std::string HistoName, std::string HistoFile, std::string HistoPath="");
Changed:
<
<
>
>
%ENDCODE%
  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:
Changed:
<
<

>
>
%CODE{"c++"}%
 void ActivateStatError(); void ActivateStatError(std::string HistoName, std::string InputFile, std::string HistoPath="");
Changed:
<
<
>
>
%ENDCODE%
 
combining

Once each channel has been created, filled with data and samples and added to the overall measurement, the analysis can begin. The first step is to generate the RooFit model from the measurement object. This model is stored in a RooFit workspace object. There are two ways to do this. The first way is used by the program hist2workspace. It builds the workspace, fits it, creates output plots and saves the workspace and plots to files.

Changed:
<
<

>
>
%CODE{"c++"}%
 RooWorkspace* MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement& measurement);
Changed:
<
<
>
>
%ENDCODE%
  The second way is to build the workspace in memory and return a pointer to the workspace object.
Changed:
<
<

>
>
%CODE{"c++"}%
 static RooWorkspace* MakeCombinedModel(Measurement& measurement);
Changed:
<
<
>
>
%ENDCODE%
 A workspace can be created for only a single channel of a model:
Changed:
<
<

>
>
%CODE{"c++"}%
 RooWorkspace* MakeSingleChannelModel(Measurement& measurement, Channel& channel);
Changed:
<
<
>
>
%ENDCODE%
  A function can be used to fit a model.
Changed:
<
<

>
>
%CODE{"c++"}%
 void FitModel(RooWorkspace *, std::string data_name="obsData");
Changed:
<
<
>
>
%ENDCODE%
  All of these methods return a pointer to the newly created workspace object. The workspace can be analysed directly, for example using RooStats scripts, or it can be saved to an output file for later analysis or publication.
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback