Troubles reading vector of pairs


ROOT Version: 6.28/08
Platform: LCG_104b
Compiler: x86_64-el9-gcc13-opt


I have troubles reading a branch of type std::vector<std::pair<uint8_t, uint8_t>>. ROOT properly detects it as vector<pair<unsigned char, unsigned char>>. I can also read the content with TBrowser and JSROOT.

The issue happens when I try to read the branch in C++. I have dictionaries generated and SetBranchAddress returns 0 which means all is OK on paper. The symptoms are that all pair values are 0.

This used to work in the past, then for a while I did not need this branch and now that I do, it is not correct. Note that the input file is produced with ROOT 6.20/06 built with GCC8.

Hi Tadej,

Thanks for the post. I am sorry to read you are experiencing this issue.
Would you be so kind to share the file so that we can reproduce the issue?

Cheers,
Danilo

Hi Danilo, I shared the following file with you (not public as it is in principle ATLAS-internal data): /eos/user/t/tadej/shared/ROOT/user.jedebevc.601352.PhPy8EG_tW_dyn_DR_incl_antitop.e8547_e8455_s3889_r9364_r9315_p5313.39485021._000002.tree.root. Let me know if you have troubles accessing it.

You can check the branch trigMatchedPairs_HLT_2e17_lhvloose_nod0.

I managed to reproduce this issue in a minimal example. These branches are read as something like the following:

gInterpreter->GenerateDictionary("pair<uint8_t,uint8_t>;vector<pair<uint8_t,uint8_t> >", "utility;vector");

TChain* chain { new TChain("physics") };
chain->Add("user.jedebevc.601352.PhPy8EG_tW_dyn_DR_incl_antitop.e8547_e8455_s3889_r9364_r9315_p5313.39485021._000002.tree.root");

chain->SetBranchStatus("*", false);
// Selectively turn on only the branches that we need
chain->SetBranchStatus("trigMatchedPairs_HLT_2e17_lhvloose_nod0", true);

The problem stems from the fact that the branch trigMatchedPairs_HLT_2e17_lhvloose_nod0 appears to be ‘split’, and the sub-branches to the first and second elements do not get reactivated when doing chain->SetBranchStatus("trigMatchedPairs_HLT_2e17_lhvloose_nod0", true) (noted in the documentation for function TTree::SetBranchStatus). Adding * to the end of branchName enables the sub-branches, and reading the elements of std::pair works correctly.

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