TTreeFormula: EvalInstance crashing with few branches: Solved!

Hello everyone

I’m currently using TTreeFormulas to compute results of simple operations on branches. So far, it has been working very well when considering two to three branches, but recently one of our user reported us that with 8 variables or more, it was quickly crashing.

I’ve investigated a bit, starting on our platform to know if we were doing something stupid on our side, but it appears that I can reproduce the behavior in ROOT in an interactive way without calling anything from our platform.

To illustrate this, i’m joining a tiny piece of code an the corresponding input data (meaningless data that I used only for illustration purpose). There is a boolean switch to define either a 2-variable TTreeFormula that runs, or a 10-one that crashes…
StandAloneAttForm.C (523 Bytes)
Here is the input file read to start the macro
inputs.txt (7.7 KB)

For completeness I’m currently running a 5.34/36 (I know at some point we’ll be moving to 6, it’s ongoing). So the question is: Is this a known issue ? Are we mis-using the TTreeFormula class ? If so, what should we do instead ?

Thanks a lot
jb

No news from my side on this subject… Any ideas …?

cheers
jb

I hope that @pcanal will have a look…

Hi,

The crash is triggered by the use of “pouet->Compile()”, this is already executed as part of the TTreeFormula and re-doing it has (obviously) very negative consequence.

Cheers,
Philippe.

Note that if the purpose of calling Compile is to test for the validity of the formula, use 'pouet->GetNdim() which will return zero in vase of invalid formula (this relates to ( How to detect bad TTreeFormula? )

Cheers,
Philippe.

Salut jbb,

must be your birthday today (happy birthday!): here is how you’d do it with Go-HEP:

package main

import (
	"log"

	"go-hep.org/x/hep/hbook/ntup/ntcsv"
)

func main() {
	log.SetPrefix("hbook/ntup: ")
	log.SetFlags(0)

	nt, err := ntcsv.Open("./inputs.txt", ntcsv.Comma(' '))
	if err != nil {
		log.Fatal(err)
	}
	defer nt.DB().Close()

	sum := 0.0
	cuts := ""
	err = nt.Scan(
		"var1, var2, var3, var4, var5, var6, var7, var8, var9, var10",
		cuts,
		func(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10 float64) error {
			v := x10 + x9 - x5 + x4 + x3 - x8 - x7 + x2 + x1 + x6
			sum += v
			log.Printf("%v", v)
			return nil
		},
	)
	if err != nil {
		log.Fatal(err)
	}
}

see:

$> go run ./main.go
hbook/ntup: 147088.91601934668
hbook/ntup: 100043.3761472886
hbook/ntup: 84593.80291448893
[...]
hbook/ntup: sum=4.999419847077312e+06

Great ! Thanks everyone, Philippe’s suggestion has solved my issue.

Thanks also Seb, I’ll let you know once we’ve re-written our entire framework in Go-HEP (should be done near your 20th anniversary :P)

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