//------------------------------------------------------------------------------------------ void FillFolder(TFolder *folder) { TObjArray oarray, *poarray = 0; TString str(""); TObjString *ostr; folder->SetOwner(); // create 5 times an object array (10 entries) of object strings for (UInt_t i=0; i<5; i++) { oarray.Delete(); oarray.Expand(0); for (UInt_t j=0; j<10; j++) { str = ">> i="; str += i; str += ", j="; str += j; str += " this is a string."; ostr = new TObjString(str); oarray.Add(ostr); } poarray = new TObjArray(oarray); poarray->SetOwner(); str.Form("name%d", i); poarray->SetName(str.Data()); // debug info if (i==2) { cout << endl << "debug> ----"; for (UInt_t j=0; jGetEntries(); j++) { cout << endl << "debug> " << j << ": " << ((TObjString*)poarray->At(j))->GetString(); } } cout << endl << "debug> " << i << ": poarray=" << poarray; // add TObjArray to folder folder->Add(poarray); } } //------------------------------------------------------------------------------------------ int test(const char *filename) { // create a folder TFolder *header = new TFolder("Header", "Header Info"); if (header == 0) { cerr << endl << "**ERROR** allocating header ..." << endl; return -1; } // fill the folder with objects FillFolder(header); TObjArray* poarray = (TObjArray*)header->FindObjectAny("name2"); if (poarray == 0) { cerr << endl << "**ERROR** getting poarray ..." << endl; return -1; } // debug info cout << endl << "debug> ++++" << endl; cout << endl << "debug> poarray=" << poarray; cout << endl << "debug> " << header->FindObjectAny("name0")->ClassName(); cout << endl << "----"; cout << endl << "debug> poarray->GetName()=" << poarray->GetName(); for (UInt_t i=0; iGetEntries(); i++) { cout << endl << "debug> " << i << ": " << ((TObjString*)poarray->At(i))->GetString(); } cout << endl << "debug++++" << endl; /* TFile *f = new TFile(filename, "RECREATE", "test"); if (f->IsZombie()) { cerr << endl << "**ERROR** file is Zombie ..." << endl; delete f; delete header; return -1; } // header->Write(); f->Close(); delete f; */ delete header; return 0; }