(18:39, mercoledì 30 luglio 2003) > What are you trying to accomplish? I'm trying to skip the more steps it's possible in my program, as redundant clearings. I'm filling a tree with an object, err... Event, which has a pointer to a TClonesArray (CA) of, say, Particle-s. I use an instance of Event, call it pEvent, as branch address and like a buffer. So if on first loop I put 5 Particle-s in pEvent, the CA will have 5 newly created entries. Streamer will write them. On second loop I am trying to clear nothing (this Particle object are simple enough to allow this without risk). Say that second event has only 3 particles; if it's possible to set fLast to -1, I'm going to do that and then to add (via TClonesArray::operator[]) the 3 particles. If it's not possible, I'll leave fLast untouched, assign particles (always with the same operator[]) and then I shall set fLast to 2; in both cases Streamer() should write 3 particles, right? If an odd event had no particle, anyway, I couldn't save a CA with zero elements (unless I Clear() it, which is what I'm trying to avoid). As you see it's not an essential request, anyway. -- Hamlet > -----Original Message----- > From: owner-roottalk@pcroot.cern.ch > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Hamlet > Sent: Wednesday, July 30, 2003 5:41 AM > To: roottalk@pcroot.cern.ch > Subject: [ROOT] Truncating a TClonesArray > > > Greetings! > > I need to roughly (and temporary) truncate a TClonesArray (CA). > I see that SetLast() method can do this except that it can't set CA > to be empty (it would be SetLast(-1), but -1 is refused as an invalid > index - well, it actually is invalid). Clear() method is slower, and > I would simply need something that sets that fLast internal variable > to -1. > How can I achieve this? Wouldn't be safe to allow SetLast() to handle > "-1" value?
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET