Difference: HiggsAnalysisAtATLASUsingRooStats (48 vs. 49)

Revision 492015-07-15 - WilliamBreadenMadden

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
Changed:
<
<
-- Will Breaden Madden - 2015-06-18
>
>
-- Will Breaden Madden - 2015-07-15
 
Line: 1281 to 1281
  Run some code such as the following. For fun, we will create a simulated data signal at about 126 GeV at about three times the number of events of that which was expected.
Changed:
<
<
example file: make_test_histograms.c
>
>
example file: make_test_histograms.cxx
  %CODE{"c++"}%
Changed:
<
<
{
>
>
#include #include #include #include <stdio.h> #include <string.h> #include #include "TStyle.h" #include "TROOT.h" #include "TPluginManager.h" #include "TSystem.h" #include "TFile.h" #include "TGaxis.h" #include "TCanvas.h" #include "TH1.h" #include "TF1.h" #include "TLine.h" #include "TSpline.h" #include "RooAbsData.h" #include "RooDataHist.h" #include "RooCategory.h" #include "RooDataSet.h" #include "RooRealVar.h" #include "RooAbsPdf.h" #include "RooSimultaneous.h" #include "RooProdPdf.h" #include "RooNLLVar.h" #include "RooProfileLL.h" #include "RooFitResult.h" #include "RooPlot.h" #include "RooRandom.h" #include "RooMinuit.h" #include "TRandom3.h" #include "RooWorkspace.h" #include "RooStats/RooStatsUtils.h" #include "RooStats/ModelConfig.h" #include "RooStats/ProfileLikelihoodCalculator.h" #include "RooStats/LikelihoodInterval.h" #include "RooStats/LikelihoodIntervalPlot.h" #include "TStopwatch.h" using namespace std; using namespace RooFit; using namespace RooStats;

int main() {

  // Create the expected signal histogram.
Added:
>
>
  // Create the function used to describe the signal shape (a simple Gaussian shape). TF1 mySignalFunction("mySignalFunction", "(1/sqrt(2*pi*0.5^2))*2.718^(-(x-126)^2/(2*0.5^2))", 120, 130); // Create the histogram with 100 bins between 120 and 130 GeV.
Line: 1303 to 1352
  // Create the histogram using by combining the signal histogram multiplied by 3 with the background histogram. TH1F myData=3*mySignal+myBackground; // Set the name of the histogram.
Changed:
<
<
myData->SetName("myData");
>
>
myData.SetName("myData");
  // Save the histograms created to a ROOT file. TFile myFile("test_histograms.root", "RECREATE");
Changed:
<
<
mySignal->Write(); myBackground->Write(); myData->Write();
>
>
mySignal.Write(); myBackground.Write(); myData.Write();
  myFile.Close();
Added:
>
>
return 0;
 } %ENDCODE%
Line: 1339 to 1390
 

<-- workspace output file prefix -->
Changed:
<
<
OutputFilePrefix="./workspaces/test_workspace" Mode="comb" >
>
>
OutputFilePrefix="./workspaces/test_workspace">
 
<-- channel XML file(s) -->
./config/test_channel.xml
Line: 1400 to 1451
  Create a C++ program such as the following:
Changed:
<
<
example file: ProfileLikeliHoodCalculator_confidence_level.cpp
>
>
example file: ProfileLikeliHoodCalculator_confidence_level.cxx
  %CODE{"c++"}% #include
Line: 1447 to 1498
 using namespace RooStats;

int main(){

Changed:
<
<
// Access the inputs.
>
>
  // Open the ROOT workspace file. TString myInputFileName = "workspaces/test_workspace_combined_datastat_model.root";
Changed:
<
<
cout << "Opening file " << myInputFileName << "..." << endl;
>
>
cout << "open file " << myInputFileName << endl;
  TFile *_file0 = TFile::Open(myInputFileName); // Access the workspace.
Changed:
<
<
cout << "Accessing workspace..." << endl;
>
>
cout << "access workspace" << endl;
  RooWorkspace* myWorkspace = (RooWorkspace*) _file0->Get("combined");
Changed:
<
<
// Access the ModelConfig cout << "Accessing ModelConfig..." << endl;
>
>
// Access the ModelConfig. cout << "access ModelConfig..." << endl;
  ModelConfig* myModelConfig = (ModelConfig*) myWorkspace->obj("ModelConfig"); // Access the data.
Changed:
<
<
cout << "Accessing data..." << endl;
>
>
cout << "accessing data" << endl;
  RooAbsData* myData = myWorkspace->data("obsData");
Changed:
<
<
// Use the ProfileLikelihoodCalculator to calculate the 95% confidence interval on the parameter of interest as specified in the ModelConfig. cout << "Calculating profile likelihood...\n" << endl;
>
>
// Use the ProfileLikelihoodCalculator to calculate the 95% confidence // interval on the parameter of interest as specified in the ModelConfig. cout << "calculate profile likelihood" << endl;
  ProfileLikelihoodCalculator myProfileLikelihood(*myData, *myModelConfig); myProfileLikelihood.SetConfidenceLevel(0.95); LikelihoodInterval* myConfidenceInterval = myProfileLikelihood.GetInterval(); // Access the confidence interval on the parameter of interest (POI). RooRealVar* myPOI = (RooRealVar*) myModelConfig->GetParametersOfInterest()->first();
Changed:
<
<
// Print the results. cout << "Printing results..." << endl;
>
>
// Print results. cout << "print results" << endl;
  // Print the confidence interval on the POI.
Changed:
<
<
cout << "\n95% confidence interval on the point of interest " << myPOI->GetName()<<": ["<<
>
>
cout << "\n95% confidence interval on the point of interest " << myPOI->GetName()<<": ["<<
  myConfidenceInterval->LowerLimit(*myPOI) << ", "<< myConfidenceInterval->UpperLimit(*myPOI) <<"]\n"<<endl; return 0;
Line: 1485 to 1539
 
example file: Makefile

%CODE{"bash"}%

Changed:
<
<
ProfileLikeliHoodCalculator_confidence_level.cpp : ProfileLikeliHoodCalculator_confidence_level.cpp g++ -g -O2 -fPIC -Wno-deprecated -o ProfileLikeliHoodCalculator_confidence_level.cpp ProfileLikeliHoodCalculator_confidence_level.cpp `root-config --cflags --libs --ldflags` -lHistFactory -lXMLParser -lRooStats -lRooFit -lRooFitCore -lThread -lMinuit -lFoam -lHtml -lMathMore -I$ROOTSYS/include -L$ROOTSYS/lib
>
>
ProfileLikeliHoodCalculator_confidence_level : ProfileLikeliHoodCalculator_confidence_level.cxx g++ -g -O2 -fPIC -Wno-deprecated -o ProfileLikeliHoodCalculator_confidence_level ProfileLikeliHoodCalculator_confidence_level.cxx `root-config --cflags --libs --ldflags` -lHistFactory -lXMLParser -lRooStats -lRooFit -lRooFitCore -lThread -lMinuit -lFoam -lHtml -lMathMore
 %ENDCODE%

Compile the code.

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 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