Filling 2D histo gives an empty canva

Dear all
I tried to use MakeClass for some data analysis but I had some problem with the vectors lorentz which can’t be generated automatically so I m trying to do it in pyroot that I used only when I was summer student, so I am not very comfortable with.
For instance here is my little pyroot script:

import ROOT
from math import *
from ROOT import*
from glob import glob
from ROOT import gROOT, TCanvas, TF2
f1 = ROOT.TFile("myclass.root", "recreate")
#c1 = TCanvas( 'c1', 'Example with Formula', 200, 10, 700, 500 )
h = TProfile("eOpinHisto","eOpin vs eta 1RG",60,-0.441,0.,0.,1.2)
#h = TH1D("eOpinHisto","eOpin vs eta 1RG",60,0,1.2)
for e in f.redTree:
    # h.Fill(e.electron0_p4.eta())
    A =e.electron0_p4.e()/sqrt(pow(e.electron0_p4In.px(),2)+pow(,2)+pow(e.electron0_p4In.pz(),2))
    B =e.electron0_p4.eta()
   # print e.electron0_p4.eta()

With this script I get the plot pyroot.pdf I attached where I expected the root.pdf attached obtained by doing:


So I would really appreciate if someone could tell me why I get this numbers of entries reduced please, it seems that the negatif part of the plot obtained with the pyroot script is empty and I don’t know why.
Thanks in advance.
pyroot.pdf (13.9 KB)
root.pdf (16.3 KB)

why don’t you you do the same command in ROOT and PyROOT ?

Thanks for replying. In fact I started with this method at first for instance I get this plot attached from this code:

 TFile* f = new TFile("DataTreeMergerd.root");
  TFile* f1 = new TFile("essai1.root","recreate");
  TTree *redTree;
 redTree->Draw("electron0_p4.e()/sqrt(pow(electron0_p4In.px(),2)+pow(,2)+pow(electron0_p4In.pz(),2)):-electron0_p4.eta()>>h(60,-0.441,0.441)"," electron0_p4.eta() > -0.441 && electron0_p4.eta() < 0.441  && electron0_class == 0 && dielectron_mass > 60. && dielectron_mass < 120. && electron0_r9 > 0.94","prof");
 TH1F *h = (TH1F*)gPad->GetPrimitive("h");
     h->SetTitle("eoP vs eta first region;etafirstRG");

for both MC and data but in the plot we can realize that the errors bars are wrong because I get more entries in data so I must have less errors bars, but instead I have the contrary, the errors bars in data are bigger than the MC. So with this method I guess the errors bars are not well handled that’s why I choose to do a loop, fill the histogram and after to deal with the errors bars to have a good concordance.
I tried with makeClass at frist by changing the lorentz vector manually since it can’t be generated automatically, normally it must be work but unfortunately all the variables linked to the lorentz vector (for instance energy via electron0_p4.e() , pt via…) take 0 as value, that’s why I choose pyroot.
DataMCComparison_EoPin_1stModule.pdf (22.1 KB)

My point is:

If you are happy with what you get with the C++, you should get exactly the same thing with PyRoot assuming you are using the same ROOT version on the same machine.

for the two first plots (in my first message), they are generated from the same root version and from the same machine, but I don’t have the same plot and that’s the problem.

Yes, but in your first post you are using two different techniques to generate the plots in PyROOT and ROOT.

What about if you use the same technique in PyROOT and ROOT, on the same machine, with the same ROOT version … ?

Yes I do get the same I checked it, so may be the way I fill the histo was wrong I gonna look for how to fill 2D histo in pyroot, or try the resolve the problem in makeclass.
Thanks a so much for yours answers