Skip Error in <TTree::SetBranchAddress>: unknown branch & Duplicate branches

Dear experts,

I hava a root file with many trees. I used MakeClass to get the header file using one of Trees where I have n number of branches. In other trees, I have less than n branches.

When I read the other branches, with the same header file, it gives me messages for the branch which is not present in the current tree like:

Error in <TTree::SetBranchAddress>: unknown branch -> ElectronRecoWeightUp01sigma

How I can skip this warning messages?

Also, I can see for each Trees there are two entries. I am unable to get rid of duplicates.

For now I am using hadd to get rid of duplicates on the output of current root file. But, for large root file it does not removes all duplicate trees. I need to do hadd two times to get rid of all duplicates.


I am doing the following

#include "interface/flashgg_MC.h" // got from Make class
#include "interface/output.h" // variables need to append in output root file.
.
.
.
// grab all trees from input root files.
// loop over all trees:
for (std::vector<TString>::iterator OldTreeName = Vec_ListOfAllTrees.begin(); OldTreeName != Vec_ListOfAllTrees.end(); ++OldTreeName)
{
   TTree *OldTree = (TTree*)OldRootFile->Get(TString(*OldTreeName));
   flashgg_MC flashggReader(OldTree);

   auto newtree = OldTree->CloneTree(0);
   output outputVars = output(newtree);
   .
   .
   for (Long64_t jentry=0; jentry<OldTree->GetEntries();;jentry++)
   {
   .
   .
   // Filling some additional variables.
   newtree->Fill();
   }
}
newtree->Write("",TObject::kOverwrite);
newfile->Write();
delete OldTree;

You can see my full code here: ReRunFHJetSelection.C, flashgg_MC.h


ROOT Version: 6.14/09
Platform: Lxplus
Compiler: Not Provided


Hi @ramkrishna ,
you cannot use a header obtained by running MakeClass on a given TTree to process another TTree with a different schema (e.g. less branches). You should at least modify the code so that it does not call SetBranchAddress for the missing branches.

I am not sure what you mean, two entries where? In the ROOT file? You might just be seeing namecycles: you can safely ignore the repeated entries if they are of the form treename;1 and treename;2 – the short version is that data is saved to file only once, those are two versions of the metadata, and ROOT automatically only considers the latest. It’s a data-loss-prevention mechanism.

Cheers,
Enrico

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