My program and a data file in which systematic and statistical errors are added in quadrature.
#include “TCanvas.h”
#include “TROOT.h”
#include “TMath.h”
#include “TGraphErrors.h”
#include “TF1.h”
#include “TLegend.h”
#include “TArrow.h”
#include “TLatex.h”
using namespace std;
void Validate_NBD_epH1()
{
gStyle->SetOptFit(1);
// data files
const char *file1[4] = {“t1-epH1”, “t2-epH1”,“t3-epH1”,“t4-epH1”};
const double file2[4] = {0,0,0,0}; // min. value of x
const double file3[4] = {13,17,18,18}; // max. value of x
// Initialising the parameter values: normalisation, K and
const double file4[4] = {90.0,90.0,90.0,90.0};
const double file5[4] = {3.0,2.0, 3.0, 4.0};
const double file6[4] = {2.0, 2.0,2.0,2.0};
const char *file7[16] = {“t1-epH1”,“t2-epH1”,“t3-epH1”,“t4-epH1”}; // output fnames
char name1[200]; char name2[200]; char name3[200];
for(int i=0;i<4;i++){
sprintf(name1, "%s.txt", file1[i]);
TGraphErrors graph(name1);
graph.SetTitle("Charged multiplicity Distribution for ep-H1 NBD)");
graph.SetMarkerStyle(kOpenCircle);
graph.SetMarkerColor(kBlue);
graph.SetLineColor(kBlue);
//graph.GetYaxis()->SetMaximum(0.15);
// Function NBD
TF1
f(“f”,"[0]*((TMath::Gamma(x+[1])*TMath::Power(([2]/[1]),x))/(TMath::Gamma(x+1)*TMath::Gamma([1])*TMath::Power((1+([2]/[1])),x+[1])))",file2[i], file3[i]);
f.SetParNames("c","k","<n>");
// f.SetParameter(0, file4[i]); // c (normalization constant)
// f.SetParameter(1, file5[i]); // k
// f.SetParameter(2, file6[i]); //
f.SetParameter(0, 90.0); // c (normalization constant)
f.SetParameter(1, 2.0); // k
f.SetParameter(2, 2.0); // <n>
graph.Fit(&f, "ME");
TCanvas* c1 = new TCanvas();
// sprintf(name2, “PNG/%s.png”, file7[i]);
sprintf(name3, “PDF/%s.pdf”, file7[i]);
graph.DrawClone(“APE”);
f.DrawClone(“Same”);
c1->SaveAs(name2);
c1->SaveAs(name3);
cout<<""<<endl;
cout<<""<<endl;
}
}
Data File
// N PROB ERX ERY
0.00 15.7900 0.00 2.2412
1.00 22.5500 0.00 1.9840
2.00 20.6200 0.00 1.3226
3.00 15.9600 0.00 2.3300
4.00 10.2100 0.00 1.1227
5.00 6.0700 0.00 1.5689
6.00 3.8500 0.00 0.5459
7.00 2.2400 0.00 0.6403
8.00 1.1500 0.00 0.4368
9.00 0.6800 0.00 0.3257
10.00 0.4900 0.00 0.2683
11.00 0.1900 0.00 0.2668
12.00 0.0700 0.00 0.1360
13.00 0.0500 0.00 0.0671