gROOT->ProcessLine() in ROOT6

Hi,

I would like to produce plots with various sorts of cuts on them. I save the cut definitions (C++ code) in a vector:

std::vector<const char*> cuts; cuts.push_back("handler->setCut(\"NBJETSCSVM\", 0, 0);"); cuts.push_back("handler->setCut(\"NBJETSCSVM\", 1);");

Later on, I loop over the vector, and call gROOT->ProcessLineFast(cuts[i]); which worked fine in ROOT5.

In ROOT6, I get:

How can I solve this? I already tried ProcessLine() instead of ProcessLineFast(), but the problem remains.

Thanks!
Peter

Hi,

Which objects handler ? You need to define it otherwise it cannot work.

Lorenzo

Hi,

Sure. At the code location where I call gROOT->ProcessLine(), handler is already defined. In fact, if I replace the ProcessLine() code by its argument, it works. It just doesn’t when using ProcessLine().

(But I can’t avoid ProcessLine() in general because I would like to do this multiple times, based on what’s in the “cuts” vector.)

Thanks,
Peter

Hi,

Can you then please provide a full script (working in ROOT 5) showing the problem ?

Thanks

Lorenzo

Sure:

void test() { TH1F* h = new TH1F("test", "test", 10, 0, 10); h->Fill(2); cout << h->GetEntries() << endl; gROOT->ProcessLineFast("cout << h->GetEntries() << endl;"); }

Best,
Peter

Hi,

That’s a bug in CINT: “h” should not be visible, CINT confuses the scopes.

Now - I don’t understand yet why you need to go through code that you pass to the interpreter, instead of simply creating TCut-s. But if it’s really needed, then just use a global variable, or use the name of a variable: ROOT 6, just like ROOT 5, checks for names of objects registered in the current directory (gDirectory), for instance histograms.

Cheers, Axel.