Dividing histograms

Hi,

I would like to divide two histograms and then plot the resultant. IHow do I do this? I currently have the following code but it does not work.

TH1D *fakeVsP = new TH1D(" fake vs p", “fake vs p”, 150, 0,100);
T->Draw(“pid:momentum >> fake vs p”, “abs(pid)!=13”);
TH1D *pidVsP = new TH1D(" pid vs p", “pid vs p”, 150, 0,100);
T->Draw(“pid:momentum >> pid vs p”);
fakeVsP->Divide(pidVsP);
T->Draw();

Cheers,

Lisa

Lisa,

You have several problems:
-you create and fill a 1-D histogram instead of a 2-D
-you misuse the spaces in the histogram names:
TH1D *fakeVsP = new TH1D(" fake vs p", “fake vs p”, 150, 0,100);
is not the same as
TH1D *fakeVsP = new TH1D(“fake vs p”, “fake vs p”, 150, 0,100);

You should do something like:

TH2D *fakeVsP = new TH2D("fake vs p", "fake vs p", 50,0,100,50,?,?); T->Draw("pid:momentum >> fake vs p", "abs(pid)!=13"); TH2D *pidVsP = new TH2D("pid vs p", "pid vs p", 50,0,100,50,?,?); T->Draw("pid:momentum >> pid vs p"); fakeVsP->Divide(pidVsP);
Rene