Problems with histograms scaling

Hello everybody,
I have created 2 histos (on and off) with TChain and I want to draw them according some criteria I have defined and called kCut. When I try to normalize them one to another I don’t know how to do …In this case BGOff=0 and I have to normalize off before drawning it (!!)

Here is the code: (read and readoff are TChain pointers):

read->Draw(“abs(MSource.fHeight)>>on”,kCut);
readoff->Draw(“abs(MSource.fHeight)>>off”,kCut);

Float_t BGOn = on->Integral(bin1, bin2);
Float_t BGOff = off->Integral(bin1, bin2);
cout<<"BGOn="<< BGOn << "BGOff=" << BGOff <<endl;
Float_t ScaleN = BGOn/BGOff;
off->Scale(ScaleN);
off->Draw("");

[color=red]I tried to create a new histo hist_temp [/color]:

ead->Draw(“abs( MSource.fHeight>)>on”,kCut);
readoff->Draw(“abs( MSource.fHeight )>>[color=red]hist_temp[/color]”,kCut);

Float_t BGOn = on->Integral(bin1, bin2);
Float_t BGOff = [color=red]hist_temp[/color]->Integral(bin1, bin2);
cout<<"BGOn="<< BGOn << "BGOff=" << BGOff <<endl;
Float_t ScaleN = BGOn/BGOff;

[color=red]and then I have to fill off with hist_temp…but I am not able to do it![/color]
Could you helpme ??

Thank U very much

Hi,

In the sub-set of your example that you showed, I can not see any reason why “off” would behave differently from “hist_temp”. So I suspect that there is some additional code that is affecting the result. Could you provide us with a complete running example?

Thanks,
Philippe.

yes, you are right. But I dont’ understand why off histo is not being scaled…
Here is the code again:

new TCanvas;
read->Draw(“abs(MSource.fHeight)>>on”,kCut);
readoff->Draw(“abs(MSource.fHeight)>>off”,kCut);
Float_t BGOn = on->Integral(30,80);
Float_t BGOff = off->Integral(30,80);
cout<<“BGOn=”<< BGOn << “BGOff=” << BGOff <<endl;
Float_t ScaleN = BGOn/BGOff;
off->Sumw2();
//histon->Sumw2();
off->Scale(ScaleN);
on->Draw(“ep”);
off->Draw(“same”);

Did I miss anything?
Thank you again!

Hi,

Can you also provide you ROOT file so that we can try to reproduce your exact problem?

Thanks,
Philippe.