Dear ROOT experts,
I have a problem that I don’t understand well. Let’s say I have a piece of code in PyROOT:
[code]pos_hist = TH1F(‘c_pos_hist’,‘c_pos_hist’,nbins4fit,binlo,binhi)
pos_hist.Reset()
pos_hist.SetDirectory(0)
pos_hist.Sumw2(kTRUE)
neg_hist = TH1F(‘c_neg_hist’,‘c_neg_hist’,nbins4fit,binlo,binhi)
pos_hist.Reset()
neg_hist.SetDirectory(0)
neg_hist.Sumw2(kTRUE)
fill hists etc.
pos_datahist = RooDataHist(‘pos_datahist_%s’%para,‘pos_datahist_%s’%para,RooArgList(rrv_mass_lvj),pos_hist)
neg_datahist = RooDataHist(‘neg_datahist_%s’%para,‘neg_datahist_%s’%para,RooArgList(rrv_mass_lvj),neg_hist)
[/code]
it works works and everything is fine, then I want to get histograms from the file.And the problem is that it’s not working neither when I change to getting to histograms from the file nor just adding the line defining the TFile object, so the code:
[code]fileWithHists = TFile(’/afs/cern.ch/work/i/ishvetso/aTGCRun2/CMSSW_7_6_4/src/aTGCsAnalysis/Common/test/Plotting/hists_signal_%s.root’%ch)
pos_hist = TH1F(‘c_pos_hist’,‘c_pos_hist’,nbins4fit,binlo,binhi)
pos_hist.Reset()
pos_hist.SetDirectory(0)
pos_hist.Sumw2(kTRUE)
neg_hist = TH1F(‘c_neg_hist’,‘c_neg_hist’,nbins4fit,binlo,binhi)
pos_hist.Reset()
neg_hist.SetDirectory(0)
neg_hist.Sumw2(kTRUE)
fill hists etc.
pos_datahist = RooDataHist(‘pos_datahist_%s’%para,‘pos_datahist_%s’%para,RooArgList(rrv_mass_lvj),pos_hist)
neg_datahist = RooDataHist(‘neg_datahist_%s’%para,‘neg_datahist_%s’%para,RooArgList(rrv_mass_lvj),neg_hist)
[/code]
gives the error:
File "make_signal_PDF.py", line 305, in make_input
hist4fit.SetBinContent(1,neg_datahist.sumEntries()/N_SM.getVal())
AttributeError: 'PyROOT_NoneType' object has no attribute 'SetBinContent'
I would expect that SetDirectory(0) solves the problem, but it doesn’t.
Sorry if I missed something simple.
Regards,
Ivan.