susy2015 / SusyAnaTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array branch not accessed correctly from first event in file

jsw-fnal opened this issue · comments

I discovered that, if I registered the Jet_puId branch with NTupleReader, then, on reading the first event in a file, I would get the following error from CleanedJets:

ERROR in cleanVector(): vector sizes do not match for Jet_puId: keepJet.size() = 1 and vec.size() = 0

On further investigation, I found that the Jet_puId branch is an array branch, and as such it has an associated array-length branch, nJet. The first time that any array branch whose length branch is nJet is accessed, the nJet branch has not yet been properly set up, and so NTupleReader thinks that the array length is 0 for that event. Subsequent accesses to other array branches with the same length branch are successful.

One solution is to register the length branch whenever an array branch is registered.

@pastika I remember that some arrary issues have been addressed already during the update to using NanoAOD ntuples. Have we seen this issue already, or is this new?

Ah, the cleanVector() error is a safety check that requires all collection variables (say Jet_var) to have the same length.

@pastika 's pull request #382 resolves this issue.

PR #382 merged, issue resolved