How to not store TEntryLists in UPDATE mode

Hi rooters,

I am having some problem with TEntryList :

I have several artificial neural network outputs that I would like to add as a leaf on several files. At the same time, I want to use only a subset of the entries to fill histograms.

So I have

[code]TCut PreCut = “”; // This cut needs to change from run to run

TFile *input = new TFile(“myFile.root”);
TTree theTree = (TTree) input->Get(“tree”);

TEntryList *allentries, *entries;

gDirectory->cd(0);

theTree->Draw(">>myEListAll",PreCut,“entrylist”);
allentries = (TEntryList*) gDirectory->Get(“myEListAll”);

theTree->Draw(">>myEList",PreCut&&Tagged,“entrylist”);
entries = (TEntryList*) gDirectory->Get(“myEList”);
[/code]
Then I proceed with

[code]theTree->Branch(“branch_name”, &value, “branch_name/F”);

Int_t entry = allentries->GetEntry(0);

do{

if(entries->Contains(entry)) …

} while((entry = allentries->Next()) != -1);
[/code]
At the end:

input->ReOpen("UPDATE"); input->cd(); input->Write("branch_name",TObject::kOverwrite); input->Close();

My problem is the following:

When I rerun my script (to add a branch or update the one previously set) and want to create histograms based on another PreCut, I realise this is not possible: I keep processing the same entries as my initial run. Using TTree::Draw() in my macro with my new cut and plotting works well.

So I open myFile.root and notice that the entry lists have been saved in its root. Now I suspect that the entrylists I am fetching are the ones stored in the file, not those I just generated.

Now I have tried many things : either open the file immediately in UPDATE mode, pur input->cd(); or gDirectory->cd(0); at several positions but I cannot avoid the entry lists to be saved in the file.

Can someone help me with this ?

Thanks

Karolos

By default TEntryLists are added to the current dir (otherwise you have no way to retrieve them). You can exclude them from the cd before writing with the following changes

theTree->Draw(">>myEListAll",PreCut,"entrylist"); allentries = (TEntryList*) gDirectory->Get("myEListAll"); allentries->SetDirectory(0); //<========= theTree->Draw(">>myEList",PreCut&&Tagged,"entrylist"); entries = (TEntryList*) gDirectory->Get("myEList"); entries->SetDirectory(0); //<=========

Rene

Thanks Rene.