This module defines a class for \( (x,y)\) graphs with an arbitrary set of systematic uncertainties. It provides storage and visualisation of such data, as well as import/export to the HepData format.
We define a function in a script. It takes one argument - whether to fit the data or not.
The first thing we do, is to check if we have the class
GraphSysErr, and if not, we compile the script.
if (!gROOT->GetClass("GraphSysErr"))
gROOT->LoadMacro("GraphSysErr.C+g");
Then, we adjust some sizes - the default error along X, how large the end bars should be.
gStyle->SetErrorX(.2);
gStyle->SetEndErrorSize(10);
Now we're ready to declare our object.
The first we do, is set some parameters on the object: That we shouldn't put tick marks ('ends') on the error, and the name of the X and Y axis.
Next, we set some key values. These are mainly for exporting to a Durham database input file. In principle one can define any key, but only a sub-set is written when exporting.
gse->
SetKey(
"laboratory",
"The Center");
gse->
SetKey(
"accelerator",
"Mega Collider");
gse->
SetKey(
"detector",
"Huge Experiment");
gse->
SetKey(
"author",
"Christensen");
gse->
SetKey(
"reference",
"Jour.All.Things A1,999");
gse->
SetKey(
"doi",
"9999-9999-9999-9999");
gse->
SetKey(
"abstract",
"The data");
gse->
SetKey(
"location",
"In the paper");
gse->
SetKey(
"reackey",
"graviton -> tachyons");
Next, we can add as many qualifiers to the data set we want. If one is to export multiple graphs to a table, one should set a
RE qualifier to distinguish the columns, or give each graph a distinct title.
gse->
AddQualifier(
"question",
"Life, universe, and everything");
Now we can define common errors. That is, errors that are correlated over all points. Common errors only have one negative and one positive value (which may be identical). Common errors can be relative. The member function
GraphSysErr:DefineCommon returns a unique identifier. This identifier should be stored for later manipulation of the error.
Next is the point-to-point (uncorrelated) systematic errors. Here, we simple give a name and whether the error is relative. The member function
GraphSysErr:DeclarePoint2Point returns a unique identifier. This identifier should be stored for later manipulation of the error.
Now we customize the graphical output of each error
In this example, we take the data points to from a Gaussian deviate. Technically, we make a histogram of the probability of a given number.
TH1* h =
new TH1F(
"h",
"h", 30, -3, 3);
h->Sumw2();
h->SetDirectory(0);
h->FillRandom("gaus",1000);
h->Scale(1./1000, "width");
Now we can set all our points. We remove our temporary histogram after we're done with it.
for (
Int_t i = 0; i < h->GetNbinsX(); i++) {
Double_t x = h->GetXaxis()->GetBinCenter(bin);
Double_t w = h->GetXaxis()->GetBinWidth(bin);
}
delete h;
Finally, we can build a canvas
TCanvas* c = new TCanvas("c","c", 1400, 1000);
c->SetFillColor(0);
c->SetFillStyle(0);
c->SetTopMargin(0.01);
c->SetRightMargin(0.01);
Depending on the single parameter, we either draw or fit a Gaussian distribtion to the data.
const char* option = "STACK stat axis quad split max west";
if (!fit)
else
gse->
Fit(
"gaus",
"SQ", option, -3, 3);
And then we draw and finish
TLegend* l = c->BuildLegend(0.7,0.7,0.97,0.97);
l->SetFillColor(0);
l->SetFillStyle(0);
l->SetBorderSize(0);
c->Modified();
c->Update();
c->cd();
c->Print("Example.png");
}