Hello, (I've sent this message a couple times now, and so far it hasn't shown up in the roottalk archives. I assume it's getting cut by some spam filter, so I've removed the attached code. I apologize if it you are getting several copies) I often find myself with a TTree that I would like to use MakeClass (or similar) to start an analysis, but there is a problem when the TTree definition changes and I need to regenerate the "loop" file. Any new MakeClass will stomp on my Loop code, unless I've been careful and copied/renamed my file. However, it occurs to me that the problem can be solved very simply with an iterator. root [0] TTree *t = GetATree(); root [1] t->MakeClass("TTreeClass"); root [2] .L TTreeClass.C root [3] TTreeClass dst; root [4] TTreeClass::iterator it; root [5] for(it=dst.Begin();it!=dst.End();++it) cout << it->nev << endl; which is rather simpler and more intuitive (to me) than the only other solution I've run across (compare lines [4] and [5] below). root [0] TTree *t = GetATree(); root [1] t->MakeClass("TTreeClass"); root [2] .L TTreeClass.C root [3] TTreeClass dst; root [4] int i; root [5] for(i=0;;++i) { if (dst.LoadTree(i)<0) break; dst.GetEntry(i); cout << dst.nev << endl; } I've put modified code at: <http:://ale.physics.sunysb.edu/~mcgrew/TTreePlayer.cxx.gz> I made the patch against Version 1.126 from CVS. I've been using the code generated by this patch for a while, and it seems to be working pretty well. Sincerely, Clark -- Clark McGrew Univ. at Stony Brook, Physics and Astronomy <clark.mcgrew@sunysb.edu> 631-632-8299
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET