Updating 'tree->Project()' within a for loop issue

_ROOT Version: 6.04.02
Platform: Not Provided
Compiler: Not Provided

Hi all,

I am trying to change the arguments within tree->Project() inside a for loop. I am projecting a 2D histogram for specific chanID values e.g

tree->Project(“hist+hello”,“chPeaktime:theta”,“chanID == hello”,“colz”);

where ‘hello’ is an Int_t type which changes with every iteration.

The error that is returned is the following:

Error in TTreeFormula::Compile: Bad numerical expression : “hello”
Info in TSelectorDraw::AbortProcess: Variable compilation failed: {chPeaktime:theta,chanID == hello}

If I replace ‘hello’ with 600 for example, it works.

Does anyone know how I can achieve this?

Many thanks,



tree->Project(TString::Format("hist%d", hello), "chPeaktime:theta",
              TString::Format("chanID == %d", hello), "colz");

Ah, that seems to have done the trick! So now if hello = 600, the projected histogram would be called ‘hist600’ ?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.