Problem with TChain?

I am tearing my hair out because I can’t get this small script to work. If I comment the GetEntries line the code runs as expected–I get 130 prints of “in”. But using any method of ccbar (TChain) I only get one print of “in” and that’s it. It is as if it’s not moving through the iterator. I’ve tried:

  • One root file (this works), any 2 files do not (although I have ~560 files)
  • recasting some of these variables
void compareAllSigAndBack(){

  TChain *ccbar = new TChain("ntp11");

  TIter iter((TObjArray*) ccbar->GetListOfBranches());
  while(iter.Next()) {
    cout << "in" <<endl>GetEntries();
        //      cout << nbackground << endl;


Thank you!

As posted, your code is non-sense.
Please post it as attachment or by clicking in the item “Disable HTML in this post” before posting.

From the few lines that you post, it looks like you use the list of branches
in the chain. In case you get a pointer to one of the branches, you must know that this pointer will become invalid when moving to a new file in the chain.