[ROOT] uncertain file order after TChain::Add("<regular expression>")

From: Maksim A. Nikulin (nikulin@gorodok.net)
Date: Wed Aug 20 2003 - 07:32:12 MEST


Hi,

Firstly, mandatory info: root-3.05.07 gcc2.95.2 RedHat-7.3 binary 
installation.

I noticed that file order in a chain after
Int_t TChain::Add(const char *name, Int_t nentries)
is depends on file creation sequence, if I use a regular expression.
I think the file file1.root should be before file2.root when
chain->Add("file[1-2].root") is used.

If chain1 have a friend chain2 then inappropriate file order in any 
chain leads to wrong entry accordance.

See the script wrong_order in the attachment. Four files
tree1.root, tree2.root, friend2.root, friend1.root are created and 
merged. I get
<session>
$ root wrong_order.C
<skip />
************************************
*    Row   *       var * friend_va *
************************************
*        0 *         1 *         2 *
*        1 *         2 *         1 *
************************************
</session>

I expect
<expected>
************************************
*    Row   *       var * friend_va *
************************************
*        0 *         1 *         1 *
*        1 *         2 *         2 *
************************************
</expected>

I think this effect takes place because of simple loop other directory 
without sorting in the
Int_t TChain::Add(const char *name, Int_t nentries)
implementation.

Best regards,
Maksim Nikulin


//
// TChain::Add("<regexp>") and friends:
// wrong file order in a friend chain
// tree1 <-> friend2
// tree2 <-> friend1
void tree(const char *name, Int_t var)
{
   f = new TFile(name, "create");
   t = new TTree("tree", "tree");
   t->Branch("var", &var, "var/I");
   t->Fill();
   t->Write();
   f->Write();
   delete f;
}
void friend_tree(const char *name, Int_t friend_var)
{
   f = new TFile(name, "create");
   t = new TTree("friend_tree", "friend_tree");
   t->Branch("friend_var", &friend_var, "friend_var/I");
   t->Fill();
   t->Write();
   f->Write();
   delete f;
}
   
void wrong_order (void)
{
   tree("tree1.root", 1);
   tree("tree2.root", 2);

   friend_tree("friend2.root", 2);
   friend_tree("friend1.root", 1);

   chain = new TChain("tree");
   chain->Add("tree[1-2].root");

   friend_chain = new TChain("friend_tree");
   friend_chain->Add("friend[1-2].root");
   chain->AddFriend(friend_chain);
   chain->Scan("var:friend_var");
}
   



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET