TTreeReaderArray update not performed with a new TTree?

Dear rooters,

I am following up the discussion from Update TTreeReader addresses failed, for a TTree in a TMemFile, read from TSocket:

I think I solved most of the problems, which was due to the way the TTree has to be updated from the client. This is how the core of the client code looks now :

 TMemFile *fin = NULL;
 TTree *tree = NULL;
 TSelector *selector = TSelector::GetSelector("macros/ttree_analysis.C+O");
 selector->SetOption(cmd[0]);


  while(1){
      TMessage *mess = new TMessage(kMESS_OBJECT); 

      if(sock->Recv(mess)){
	    if(!mess) break;
	    if(!mess->GetClass()) break;

     	if (mess->GetClass()->InheritsFrom(TTree::Class())) {
	      if(fin) {
	        fin->Clear();
	        fin->Close();
	        fin->Delete("slow");
	  }
	  fin = new TMemFile(filename,"new");
	  fin->cd();

	  tree = (TTree*) mess->ReadObject(mess->GetClass());
	  tree->SetDirectory(fin);

	  tree = (TTree*)fin->Get(argv[optind]);
      tree->SetNotify(selector);

	  if(kToInit) {
	    selector->Begin(tree);
	    kToInit = kFALSE;
	  }

      selector->Init(tree);          
	  selector->Notify();
          
	  for (int entry=0;entry<tree->GetEntries();entry++) {	              
            tree->LoadTree(entry);
     	    selector->Process(entry);
	  }
    }
	mess->Delete("slow");      
   }
}
selector->Terminate();         

basically it reads few events sent by the server and process them using a TSelector, then repeat with few other events, etc…

It almost works : most of the leaf/branches I tested are properly read. But some TTreeReaderArray variables are not read anymore after a new TTree is used. Note that the first events with the first TTree are properly read.

I did add fReader.SetTree(tree); in the Init() method of my TSelector.

Note that if I use Scan() on the tree, looking for my variable of interest, both in the client and in the TSelector, what is printed is consistent with the tree properly updated/read and is what I expect.

What really puzzle me is that some other TTreeReaderArray arrays are properly updated for the proper entry in the proper updated TTree.

Right now I do not see what kind of additional test I can do.

Thank you very much in advance for your help

Julien

Let’s try to ask @pcanal again