Problem while comparing two histograms

Dear @couet, @Wile_E_Coyote,

I have this following macro. I want to plot both with Y values per bin. One has bin width = 4.55, another one has 5. How do I make bin width 1 in both the cases? Thanks

FILE *f1,*f2;
double col1[40],col2[40],col3[40];
double col4[30],col5[30];

f1=fopen("data1.txt","r"); 
f2=fopen("data2.txt","r");

for (int i = 0; i < 40; ++i )
{
fscanf(f1,"%lf %lf %lf",&col1[i],&col2[i],&col3[i]);
}

for (int j = 0; j < 30; ++j )
{
fscanf(f2,"%lf %lf",&col4[j],&col5[j]);
}

auto hist0=new TH1D("hist0","",150,50,200);
for (int k=0; k<=40; k++) {
hist0->Fill(col1[k],col2[k]);
int bin = hist0->GetXaxis()->FindBin(col1[k]);
hist0->SetBinError(bin,col3[k]);
}
hist0->SetMarkerColor(1);
hist0->SetMarkerSize(1.0);
hist0->SetMarkerStyle(21);

hist0->Draw("E1");

hist0->GetXaxis()->SetRangeUser(50,200);

auto hist1=new TH1D("hist1","",150,50,200);
for (int j=0; j<=30; j++) {
hist1->Fill(col4[j],col5[j]);
}
hist1->SetMarkerColor(2);
hist1->SetMarkerSize(1.0);
hist1->SetMarkerStyle(21);
hist1->Draw("same");
fclose(f1);
fclose(f2);

__
ROOT Version: 5
__
data1.txt (664 Bytes) data2.txt (415 Bytes)

You need to ask the author(s) of your “data*.txt” files to provide you with appropriate data.

{
  TGraphErrors *g1 = new TGraphErrors("data1.txt", "%lg %lg %lg");
  g1->SetMarkerStyle(7); g1->SetMarkerColor(3); g1->SetLineColor(3);
  TGraphErrors *g2 = new TGraphErrors("data2.txt", "%lg %lg");
  g2->SetMarkerStyle(7); g2->SetMarkerColor(4); g2->SetLineColor(4);
  TMultiGraph *mg = new TMultiGraph();
  mg->Add(g1); mg->Add(g2);
  mg->Draw("APL");
}

Rebinning is not possible?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.