nTuple analysis cannot read branch variables
Preface: Variables are read from nTuples with the TQTreeFormulaObservable. This observable builds a TTreeFormula with an expression and links it to a tree. When the formula is evaluated (EvalInstance), a variable is read from the tree branches. In order to read the correct entry, an event index needs to be set on the tree with the method GetEntry. This is done by the MCASV here.
The issue that I'm observing only appears in the ATLAS environment. All variables read from nTuple branches evaluate to 0. The same code returns reasonable variables in a standalone setup.
The problem is that the MCASV calls the GetEntry method on a different tree than the tree in the TQTreeFormulaObservable. The method TQSample::setTree
is called via TQSample::getTree
, TQSample::getEventToken
, which is called in the MCASV here. This piece of code is only executed if HAS_XAOD
is set, which I assume refers to the ATLAS environment setup.
I do not understand the logic behind the chain of calls in the previous paragraph. But somehow it looks like these methods should not be called when analyzing nTuples.