Difference python vs ROOT interactive

I am running two similar scripts, but I get completely different result:

import ROOT

dir_sys = "PSUp"
dir_nom = "all_mc"

fnom = ROOT.TFile(dir_nom + "/data-NTUP_output/mc12_8TeV.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.merge.NTUP_PHOTON.e1189_s1771_s1741_r4829_r4540_p1344.root")
fsys = ROOT.TFile(dir_sys + "/data-NTUP_output/mc12_8TeV.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.merge.NTUP_PHOTON.e1189_s1771_s1741_r4829_r4540_p1344.root")

tree_nom = fnom.Get("photon")
profile_nom = ROOT.TProfile("profile_nom", "profile_nom", 100, -2.5, 2.5)
tree_nom.Draw("energies/ph_truth_E:ph_cl_eta>>profile_nom", "(ph_Rconv >0 && ph_Rconv < 800) && (Iteration$==index_leading || Iteration$==index_subleading)", "prof")
histo_nom = profile_nom.ProjectionX()
histo_nom.SetDirectory(0)

tree_sys = fsys.Get("photon")
profile_sys = ROOT.TProfile("profile_sys", "profile_sys", 100, -2.5, 2.5)
tree_sys.Draw("energies/ph_truth_E:ph_cl_eta>>profile_sys", "(ph_Rconv >0 && ph_Rconv < 800) && (Iteration$==index_leading || Iteration$==index_subleading)", "prof")
histo_sys = profile_sys.ProjectionX()
histo_sys.SetDirectory(0)

ratio = histo_sys.Clone()
ratio.Divide(histo_nom)

canvas = ROOT.TCanvas()
ratio.Draw()
canvas.SaveAs("bo.png")
root [4] TFile fnom("all_mc/data-NTUP_output/mc12_8TeV.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.merge.NTUP_PHOTON.e1189_s1771_s1741_r4829_r4540_p1344.root")
root [5] photon->Draw("energies/ph_truth_E:ph_cl_eta>>hnom(100,-2.5,2.5)", "abs(ph_cl_eta)<2.5 && (Iteration$==index_leading || Iteration$==index_subleading) && (ph_R$
(Long64_t)1054554
root [6] hnom->SetDirectory(0)
root [9] TH1D* hhnom = hnom->ProjectionX()
root [10] hhnom->SetDirectory(0)
root [11] TFile fPSUp("PSUp/data-NTUP_output/mc12_8TeV.160009.PowhegPythia8_AU2CT10_ggH125_gamgam.merge.NTUP_PHOTON.e1189_s1771_s1741_r4829_r4540_p1344.root")
root [12] photon->Draw("energies/ph_truth_E:ph_cl_eta>>hdist(100,-2.5,2.5)", "(ph_Rconv >0 && ph_Rconv < 800) && (Iteration$==index_leading || Iteration$==index_subleading)", "prof")
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
(Long64_t)1054610

root [13] TH1D* hhdist = hdist->ProjectionX()                                                                                                                 
hhdist->Sroot [14] hhdist->SetDirectory(0)
root [15] ratio = (*hhdist) / (*hhnom)
(class TH1D)256361552
root [16] ratio->Draw()

I am getting completely different result:




yeah, but “similar” != “exactly the same”. In fact, the scripts are rarther different. In the python script, you first open both files, then get the TTrees (which apparently are named the same for both files). In the CINT script, you open file get tree, open file get tree.

Cheers,
Wim

yeah, but “similar” != “exactly the same”. In fact, the scripts are rarther different. In the python script, you first open both files, then get the TTrees (which apparently are named the same for both files). In the CINT script, you open file get tree, open file get tree.

Cheers,
Wim[/quote]

I think I found that I get different result if I declare

TProfile p("profile", "profile", 100, -2.5, 2.5)

wrt

TProfile p("profile", "profile", 100, -2.5, 2.5, -10, 10)

Hi,

sorry, not following … both scripts use the same constructor (i.e. w/o ylow, yup)?

Cheers,
Wim

[quote=“wlav”]Hi,

sorry, not following … both scripts use the same constructor (i.e. w/o ylow, yup)?

Cheers,
Wim[/quote]

actually in the cint script I am not declaring any TProfile

Hi,

right … only quickly saw the “(100, -2.5, 2.5)” arguments.

Still, confirms the same point: two rather different scripts, with two different results. Seems not so surprising.

Cheers,
Wim

[quote=“wlav”]Hi,

right … only quickly saw the “(100, -2.5, 2.5)” arguments.

Still, confirms the same point: two rather different scripts, with two different results. Seems not so surprising.

Cheers,
Wim[/quote]

Ok, but they shoud do the same simple thing: do two profiles and then the ratio

Is it possible to write really equivalent scripts and compare them? So if you use TProfile in one script, use it in another? Or at least provide some sample root file with data to try these scripts.