Sharing histos between macros

Hi,
I would like to use an histo (heff) filled in a macro (eff_l1) inside a different one (ana) as follow:

eff.C:


TH1D *heff;

void eff_l1(…) {


TH1D heff = new TH1D(“eff”, "#epsilon_{L1} (T0NTRGbit0/T0N)", nbin, vmin, vmax);
heff->Fill(num/den);

}


ana.C:


void ana(…) {

eff_l1(…);

Double_t eff[100];
for(i=0; i<100; i++) {
eff[i] = heff.GetBinContent(i);
}

}


I declared heff outside void eff_l1(…) both with TH1D *heff; and TH1D heff; but in the first case I got

Error: illegal pointer to class object heff 0x0 654 ana.C:25:
*** Interpreter error recovered ***

while in the second heff is empty.

Can you help me?

At first, please read UserGuide (especially chapters Creating Histograms, Input/Output).
Create two files, first eff.C:void eff() { TH1D *heff = new TH1D("eff", "", 10, 0, 10); heff->Fill(5); } second ana.C:void ana() { TH1D *heff2 = (TH1D*)gDirectory->Get("eff"); Double_t eff[10]; for(Int_t i = 0; i < 10; i++) { eff[i] = heff2->GetBinContent(i); Printf("%5.3f ", eff[i]); } } and run root: [quote]root [0] .x eff.C
root [1] gDirectory->ls()
TROOT* Rint The ROOT of EVERYTHING
OBJ: TH1D eff : 0 at: 0x9b1c348
root [2] .x ana.C
0.000
0.000
0.000
0.000
0.000
0.000
1.000
0.000
0.000
0.000
root [3] TH1D heff99 = (TH1D)gDirectory->Get(“eff”)
root [4] heff99->GetName()
(const char* 0x9b1c5a8)"eff"
root [5] [/quote] I hope this help, Jan