Discrepancy between entered code and script

Hi there all,

I have a small script that projects two histograms from a TTree in a TFile, divides them and draws the output. This works fine when I enter the code manually, however, running it with the .x command just displays a blank canvas. Am I missing somethis obvious? The code is shown below:

[code]void effs()

// Histogram settings
Int_t bins = 100;
Int_t lower = 0;
Int_t upper = 30;

TFile f("befftree.root");

// Histograms
TH1F *hAll = new TH1F("hall","all tags",bins,lower,upper);
TH1F *hGood = new TH1F("hgood","good tags",bins,lower,upper);
TH1F *hEff = new TH1F("heff","ZVTOP Tagging Efficiency - CMS 200GeV, 0 <= jetenergy < 30;Transverse B Decay Length / mm;Efficiency",bins,lower,upper);

// Stats

// Load histograms
TTree *t = f.Get("befftree");
t->Project("hall","btransdecaylength","(bdecaylength > -1) && (jetenergy >= 0) && (jetenergy < 30)"); // 
t->Project("hgood","btransdecaylength","(bdecaylength > -1) && (vtxdistance > -1) && (jetenergy >= 0) && (jetenergy < 30)");

// Do Calc

// Draw
//TCanvas *c1 = new TCanvas;


Thanks in advance.

typical mistakes
-never use gROOT->Reset in a named script (remove this line)
-replace the line
TFile f(“befftree.root”);
TFile *f = new TFile(“befftree.root”);

Otherwise when you return from the function effs, all
objects created in the stack (like TFile f) are
deleted. This also deletes the histograms assiciated with f.
Creating the object in the heap (via new), the file is not
closed (it is up to you to close the file later).