Problem in adding histograms to root

Hi,

I am trying to add histograms to a list but getting some error, the code is like below:

import ROOT as r
filesig=['RSGraviton_controlPlot.root','BulkGraviton_controlPlot.root','Radion_controlPlot.root','nonreso_controlPlot.root','officialHH_gluglu_10_controlPlot.root']
histsig = []
variable ='InvariantMass_of_4_particle_with_totCharge==0'
sigtitle = ['RSGraviton','BulkGraviton','Radion','nonreco','SM']
color = [2,4,6,8,12]
for ifile in range(0,4) :
    file_ = r.TFile(filesig[ifile])
    histsig.append(file_.Get(variable +'_in_tau1iso_tau2iso'))
    histsig[ifile].SetLineColor(color[ifile])
    histsig[ifile].SetMarkerColor(color[ifile])
    histsig[ifile].SetName(sigtitle[ifile])
    print ifile, '****************',histsig
print histsig

The error which I am getting is

python test.py 
0 **************** [<ROOT.TH1F object ("RSGraviton") at 0x33697b0>]

 *** Break *** segmentation violation
1 **************** [


===========================================================
There was a crash.
This is the entire stack trace of all threads:

But the histograms are present in all files, Please help me.

Thanks,
Saswati

Hard to tell, especially because you didn’t post the interesting part, following This is the entire stack trace of all threads:. Could you add that, please?

Hi Axel,

I have attached the error herewith.dump.txt (9.8 KB)

Thanks,
Saswati

file_.Get(variable +'_in_tau1iso_tau2iso')

returns a nullptr on the second iteration.

Yes it return null pointer on 3rd iteration, but histograms & files both are present i my working directory, Also the name of 1st histogram is changed in 2nd iteration.

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