I want to calculate the relative error between two histogram for each bin( 9 bins ).
I need to get the content of each bin(i) from several histograms.
For that I want to use the “TH1F(Form(“h%s”,pdf[1]))->GetContentBin(i);” instead "hstw->GetContentBin(i); " in order to access to all the histogram.
But I get these error.
Thank you for your help!!
Amine
Error: No matching constructor for explicit conversion TH1F(Form("h%s",pdf[1])) comp_jetphjox_plot.C:90:
Error: non class,struct,union object TH1F(Form("h%s",pdf[1])) used with . or -> comp_jetphjox_plot.C:90:
*** Break *** segmentation violation
I’m new here and face the same problem as Amelkhalii. I want to calculate the relative error between two histogram for each bin( 100 bins ). Here is the code I used for plotting the two histogram:
[code]int macro2(){
auto c=new TCanvas();c->SetGrid();
TGraphErrors graph_expected("./test_TError03.txt",
"%lg %lg %lg");
graph_expected.SetTitle(
"Measurement XYZ and Expectation;"
"lenght [cm];"
"Arb.Units");
graph_expected.SetFillColor(kRed);
graph_expected.DrawClone("E3AL"); // E3 draws the band
TGraphErrors graph("./test_TError04.txt","%lg %lg %lg");
graph.SetMarkerStyle(2);
graph.SetFillColor(kBlue);
graph.DrawClone("PESame");
// Draw the Legend
TLegend leg(.1,.7,.3,.9,"Lab. Lesson 2");
leg.SetFillColor(0);
leg.AddEntry(&graph_expected,"Expected Points");
leg.AddEntry(&graph,"Measured Points");
leg.DrawClone("Same");
graph.Print();
return 0;
}[/code]
I understand about the loop for bin but I don’t understand the loop of array histogram. How should I start doing this?
Yes. I forgot to mention that. Instead of histogram, I plot two graph because in HAWK, it also gave the y-error so I read the data files and plot two graph on top of each other. But what I’m interested is to plot the relative difference between these two graph as a function of mass ZH. So the idea is to get the array of number given as points to TGrapherror from each bin and then loop over the number of bin to calculate the relative difference. Lastly plot the graph of relative difference vs mass of ZH. That’s the only idea I can think about.
But the problem is, I don’t know how to do it… Do you know any reference I can refer to? About how to get the array of number given as points to TGrapherror from each bin? Is there any special commands or something?