But filling and histogram with these points will give you a complete different view… try:
{
auto g1 = new TGraphErrors("data.txt","%lg %lg %lg");
int n = g1->GetN();
double *x = g1->GetX();
double *y = g1->GetY();
double *ey = g1->GetEY();
double xmin=0, xmax=0;
for (int j = 0; j<n; j++) {
if(xmin > x[j]) xmin = x[j];
if(xmax < x[j]) xmax = x[j];
}
auto h = new TH1D("h","h",1000,xmin,xmax);
printf("%g %g\n",xmin,xmax);
for(int i=0; i < n; ++i) {
h->Fill(x[i],y[i]);
}
h->Draw("HIST");
}
You have several time the same value on X, they are cumulated in the same bin … you get a flat distribution … I am not sure that’s what you are looking for.
{
auto g1 = new TGraphErrors("dt.txt","%lg %lg %lg");
int n = g1->GetN();
double *x = g1->GetX();
double *y = g1->GetY();
double *ey = g1->GetEY();
auto h = new TH1D("h","h",1000,60,190);
for(int i=0; i < n; ++i) {
h->Fill(x[i],y[i]);
}
h->Fit(“gaus”,“Lr+”,“E1”,60.0,190.0);
}
{
auto g1 = new TGraphErrors("dt.txt","%lg %lg %lg");
int n = g1->GetN();
double *x = g1->GetX();
double *y = g1->GetY();
double *ey = g1->GetEY();
auto h = new TH1D("h","h",1000,60,190);
for(int i=0; i < n; ++i) {
h->Fill(x[i],y[i]);
}
h->Fit("gaus","Lr+","E1",60.0,190.0);
}