Using Sumw2() and E3 for multiple histograms

Hi,

Apologies if the title is unclear, or if this is in the wrong forum section.

I’m trying to use Sumw2 on three different histograms, and plot all of them on the same canvas, with a line drawn between each set of the points. However, I’ve only been able to either have a line through only one set of data, and error bars on all of them, or lines through all data sets and no error bars.

I’ve tried different variations of “hist”, “same”, “sames” etc, but I can’t seem to get a winning combination.

The code segment in question:

[code]TH1F *histogram_default ;
TH1F *histogram_jet;
TH1F *histogram_jetmuon;

histogram_default->Sumw2();
histogram_jet->Sumw2();
histogram_jetmuon->Sumw2();

   (fill histograms in particular way...)

gStyle->SetOptStat(1);
    TCanvas a1(" ","unnormalized weight",700,700);

histogram_default->SetLineColor(gROOT->GetColor(2)->GetNumber());
histogram_jet->SetLineColor(gROOT->GetColor(8)->GetNumber());
histogram_jetmuon->SetLineStyle(3);
histogram_jet->SetLineWidth(3);
histogram_jetmuon->SetLineWidth(3);
histogram_default->SetLineWidth(3);
histogram_jet->SetLineWidth(2);	
histogram_jetmuon->SetLineWidth(2);
histogram_default->Draw("E3 hist"); //the hist is needed to combine sumw2 and an error bar specification like E3	

histogram_default->Draw("same");
histogram_jet->Draw("same");	
histogram_jetmuon->Draw("same");

a1.Print("ttH_TFcomparison_weights_280415.eps");

[/code]

Any help would be greatly appreciated.
Cheers.

Can you post a example we can run ?
the picture produced ?

The above code will produce something similar to the attached image. (Colours / Line style may be slightly different, that’s the only version I can find at the moment, sorry). I can attach the full code too if you like, although it currently reads in a number of files before it plots the data - might be a bit much to attach all of it.
ttH_TFcomparison_weights.eps (29.1 KB)

The “code above” gives:

root [0] 
Processing codeabove.C...
Error: illegal pointer to class object histogram_default 0x0 201  codeabove.C:6:
*** Interpreter error recovered ***

I’ve attached the full code, the plotting part (and in particular, the comparative plot) is what I need help with. But like I said before, this code reads in 9 different files to run, so it won’t run properly unless I attach them all (which I can do if you’d like, but I’m not sure if I’d be breaking a forum upload rule or something).
create_2500ev_weightratio_050415_pls.C (18.1 KB)

Ok so that’s useless…

let me guess what you should see. You do:

   histogram_default->Draw("E3 hist");
   histogram_default->Draw("same");
   histogram_jet->Draw("same");   
   histogram_jetmuon->Draw("same");

First of all you draw twice the same histogram (histogram_default) with different options. That does not work… You how use DrawClone for the 2nd drawing. Let’s imagine that’s the case. Then you should see histogram_default drawn with option E3 and then 3 histograms on top of it drawn with the default drawing option. Which is a bar chart if the histogram has no built in errors, or errors bars if its has built-in errors. I am afraid I cannot help you further without a small example reproducing the issue.

Thanks for the reply. I’ve attempted to attach the relevant files for the code, but when I try to upload, I’m told the extensions .lhco and .out are not allowed.

I’ve tried changing the code to

	histogram_default->DrawClone("E3 hist"); 
	histogram_jet->DrawClone("same hist");	
	histogram_jetmuon->DrawClone("same hist");

which gives result1 attached below, also

	histogram_default->DrawClone("E3 hist"); 
	histogram_jet->DrawClone("");	
	histogram_jetmuon->DrawClone("");

which gives result2 and

	histogram_default->Draw("E3 hist"); 
	histogram_jet->DrawClone("");	
	histogram_jetmuon->DrawClone("");

which gives the same as result2. I’m basically looking for result1 with error bars, is that at all possible?
result2.eps (10.5 KB)
result1.eps (9.38 KB)

   histogram_default->Draw("E"); 
   histogram_jet->Draw("same E");   
   histogram_jetmuon->Draw("same E");

Unfortunately that code fails to draw a contour through any of the points (the result’s attached below). Appreciate the help though.
result3.eps (15.1 KB)

You told me you want error bars … so you have error bars… try :

   histogram_default->Draw("E3"); 
   histogram_default->SetFillColor(kBlue);
   histogram_jet->Draw("same E");   
   histogram_jetmuon->Draw("same E");

Oh, sorry if I wasn’t clear, I’d like to have both error bars and a line going through the points. Your previous post didn’t work either, sorry.

What does it produce ?

Sure, it’s attached below.
result3.eps (14.6 KB)

Can you save your plot into a ROOT file and post it here (File/SaveAs…)

Sorry for the delay.
histograms.root (5.93 KB)

{
   TFile *f = new TFile("histograms.root");

   TH1F *histogram_default = (TH1F*)f->Get("Default MadWeight Transfer Function");
   TH1F *histogram_jet     = (TH1F*)f->Get("Jet Transfer Function");
   TH1F *histogram_jetmuon = (TH1F*)f->Get("Jet Muon Transfer Function");

   histogram_default->Draw("E3");
   histogram_default->SetFillColor(kAzure-4);
   histogram_default->SetLineColor(kAzure-4);

   histogram_jet->Draw("same E");
   histogram_jet->SetLineColor(kRed);

   histogram_jetmuon->Draw("same E");
   histogram_jetmuon->SetLineColor(kYellow-3);
}

Gives me this plot: