Hi everybody, i’m just starting with Root and i’m trying to fill a 1D histogram with x and y values. I’m using Fill(x,y) to set the values, but when i draw the histogram i get values on the y that seem doubled. What am i doing wrong?
I think that the lines that i see are related to the fit. I would like to have the data and also the fit curve, nothing else.
This is the code (it’s a very simple program ):
void decade(Int_t n0, Double_t alfa, Double_t time_bin, Double_t T) {
Int_t size=1+(T/time_bin);
Int_t ndec;
TCanvas *c = new TCanvas("c", "Canvas", 500, 500);
TH1D *h = new TH1D("h","Istogramma",size,0.,T);
for (Int_t t=0; t<=T; t=t+time_bin) {
ndec=0;
for(Int_t n=0; n<n0; n++) {
if((gRandom->Rndm())<(alfa*time_bin)) {
ndec++;
}
}
n0=n0-ndec;
h->Fill((t+time_bin/2),n0);
}
h->Fit("expo");
gStyle->SetOptFit(1112);
h->Draw();
}
And thanks to everybody for your help