Hi wxie,
That's a known (and indeed surprising) limitation of CINT. You can even
simply say "h1" and CINT will pick it up from the ROOT file so you can
use it in the following lines.
Cheers, Axel.
On 1/6/12 12:18 AM, wxie wrote:
>
> One more input is that this issue happens only when the histograms are
> read from a file. The following macro have no problem to run:
>
> {
> TH1F* h = new TH1F("h", "", 1, 0, 1);
> h->Fill(0.5);
> h->Sumw2();
>
> TH1F* h0 = new TH1F("h0", "", 1, 0, 1);
> h0->Sumw2();
> h0->Fill(0.5);
>
> TH1F* h1 = new TH1F("h1", "", 1, 0, 1);
> h1->Sumw2();
> h1->Fill(0.5);
>
> h->Divide(h0);
> h->Divide(h1);
> }
>
>
>
> On 1/5/2012 5:40 PM, wxie wrote:
>> I run the following macro producing a file "oo.root".
>>
>> {
>> TFile f("oo.root", "recreate");
>> TH1F* h = new TH1F("h", "", 1, 0, 1);
>> h->Fill(0.5);
>> h->Sumw2();
>>
>> TH1F* h0 = new TH1F("h0", "", 1, 0, 1);
>> h0->Sumw2();
>> h0->Fill(0.5);
>>
>> TH1F* h1 = new TH1F("h1", "", 1, 0, 1);
>> h1->Sumw2();
>> h1->Fill(0.5);
>>
>> h->Write();
>> h0->Write();
>> h1->Write();
>> f.Close();
>> }
>>
>> then I run the following macro:
>> {
>> TFile f("oo.root");
>> h->Divide(h0);
>> h->Divide(h1);
>> }
>>
>> and got an error message:
>>
>> root.exe [1] h->Divide(h0);
>> root.exe [2] h->Divide(h1);
>> Error: Symbol h1 is not defined in current scope (tmpfile):1:
>> *** Interpreter error recovered ***
>>
>> People usually bypass it by defining another pointer, e.g. the
>> following macro:
>> {
>> TFile f("oo.root");
>> h->Divide(h0);
>> TH1F* h2 = h1;
>> h->Divide(h2);
>> }
>>
>> Is there a way not to redefine this new pointer?
>>
>> Thanks
>> --Wei
>>
>>
>>
>>
>>
>>
>>
>
>
Received on Tue Jan 10 2012 - 15:15:19 CET