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()
{
gROOT->Reset();
// 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
hAll->Sumw2();
hGood->Sumw2();
hEff->Sumw2();
// 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
hEff->Divide(hGood,hAll,1.,1.,"b");
// Draw
hEff->Draw();
//hEff->SetStats(kFALSE);
//TCanvas *c1 = new TCanvas;
//hEff->Draw();
}[/code]
Thanks in advance.