# Converting TH1 histogram into RooHist

Hi, I am trying to convert a TH1 Histogram that I get from another file to a RooHist one in order to use plotOn:

hist=ROOT.TH1F('y_l_weight_0','y(\ell)',5,-2.1,2.1)
hist=file.Get('y_l_weight_0')
y_l=RooRealVar('y_l','y_l',-2.1,2.1)
y_l_RooHist=ROOT.RooDataHist(hist.GetName(), hist.GetTitle(), RooArgSet(y_l), ROOT.RooFit.Import(hist, kFALSE),1)


This, however produces type errors, basically complaining about not being able to convert the fourth argument ROOT.RooFit.Import(hist, kFALSE). Can anyone help?

That’s the only reason ? that’s only for plotting reason ? standard histograms have many options to be drawn. Is there something you want do do with plotOn and you cannot with the normal TH1::Draw() ?

I have code that already used the plotOn option extensively and I just want to overlay a further TH1 Histogram

Ah ok … it makes sense .

So any ideas why this is not working?

I presume the is a PyROOT issue. Have you tried in C++ ?
Otherwise try maybe to use this constructor of RooDataHist:

RooDataHist(const char *name, const char title, const RooArgList& vars, const TH1 hist, Double_t initWgt=1.0) ;

Lorenzo

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