Dear experts,
I am using ROOT 6.20/02 (6.24/06 behaves similarly) to test a simple code that creates a snapshot of a nanoAODv9 file, once keeping all branches, and once only a subset of them.
The input file is:
root://cms-xrd-global.cern.ch///store/mc/RunIISummer20UL16NanoAODv9/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/NANOAODSIM/106X_mcRun2_asymptotic_v17-v1/70000/9F50F913-6EC7-8242-A2BD-4FC37A03EAC9.root
The snippet using the dataframe object df is:
branches = ROOT.std.vector("string")()
branches.push_back(str('Jet_pt')) # original branch name, as stored in NanoAOD
branches.push_back(str('JetPt')) # renamed branch, as defined below
df=df.Define('JetPt','Jet_pt')
df.Snapshot('Events', 'snapshot_test.root', branches)
This fails with the error:
Error in TBranch::TBranch: Illegal leaf: Jet_pt/Jet_pt[nJet]/F. If this is a variable size C array it’s possible that the branch holding the size is not available.
*** Break *** segmentation violation
However, removing the original branch ‘Jet_pt’ in ‘branches’ solves the problem.
Similarly, not specifying any branches in snapshot also works (but this defies the goal at hand).
I guess the issue is that the native nanoAOD branches are not vectors, and somehow snapshot is not handling them properly, while creating an alias in RDF somehow solves this issue (which is an ugly workaround).
Is there any other way other than this workaround to slim a nanoAOD TTree?
Thanks!