Home | News | Documentation | Download

Error in <TTreeFormula::Compile>: Bad numerical expression : "bifTime"

I have 4 existing branch variables: bif_nTrigger, bif_source, bif_BXID and bif_Time. The first three are integers, the last one is a float. The last three variables all depend on the first, bif_nTrigger. These have all been initialized properly.

I am trying to implement a for loop that will trim two of the variables, bif_Time and bif_BXID, according to whether the value of bif_source is equal to 3. This code is successfully done in python the following way:

# loop for bif_nTrigger times,  if bif_source[i] equals 3, read bifTime and bunchcrossingID from this source.

        for i in range(0, bif_nTrigger):
            if bif_source[i] == 3:
                bifTime = bif_Time[i]
                bxID = bif_BXID[i] % 2

I am trying to adapt it to C, but I keep getting the following errors:
Error in TTreeFormula::Compile: Bad numerical expression : “bifTime”
Error in TTreeFormula::Compile: Bad numerical expression : “bxID”

My code is as follows:

 int bxID;
 float bifTime;

  for (int i = 0; i = bif_nTrigger; ++i) {
      if (bif_source[i] == 3) {
               bifTime = bif_Time[i];
               bxID = bif_BXID[i] %2;
        }
  }

I am very new to C and so I can’t seem to figure out what the error is caused by. Any help would be much appreciated!

ROOT Version: 5.28
Platform: C
Compiler: gcc ?


Hi Aveen,

first off, you have a mistake in the for loop:

for (int i = 0; i = bif_nTrigger; ++i) {

should be replaced with

for (int i = 0; i < bif_nTrigger; ++i) {

Thanks for pointing that out, just changed it.
It still does not fix the error I am getting however, any other ideas?

I guess I need to see more of your code to figure out what’s happening.

Hi,
I might be wrong (@pcanal can confirm/deny) but I don’t think TTreeFormula supports variable definitions like that? I think that’s what the error complains about.

I suggest you don’t pass your code as a TTreeFormula but actually read and process data with full C++ so you have no limitations in terms of the syntax/types/language features you can use (see e.g. this post for a list of interfaces ROOT offers to read and process TTree data.

Cheers,
Enrico