Hi,
i have the following code for plotting a histogram by reading a text file. To this histogram I want to add my experimental resolution of 3.5. The follwing is the macro :
void Analysis()
{
gStyle->SetOptStat(2211);
gStyle->SetOptFit(1111);
auto h1 = new TH1D("h1_gaus","Mass (amu);Counts",121.0,27.5,148.5);
TH1D*h2 = new TH1D("h2","h2_Derivative", 121.0,27.5,148.5);
ifstream inp;
double x;
inp.open("gaus_theo.txt");
for (int i=0;i<120;i++)
{
inp>>x;
h1->SetBinContent(i,x);
h2->SetBinContent(i,x+ gRandom->Gaus(0,3.5));
}
TCanvas *c1 = new TCanvas("c1","Without constraint",800,600);
c1->Divide(1,2);
c1->cd(1);
h1->Draw("HIST");
c1->cd(2);
gStyle->SetOptStat(1002211);
gStyle->SetOptFit(1111);
h2->Draw("HIST");
}
and the text file is :
gaus_theo.txt (1.6 KB)
and I get the output as :
Res.pdf (16.3 KB)
What is my mistake here, which I dont understand that gives me bizzard result for the second histogram with resolution ?
thank you