Suggestion: int TObject::tag

Sometimes I’m missing a possibility to carry some additional information in Objects.

In Delphi every Object had a freely usable variable int tag. You could for example distinguish between dynamically created objects or as I would need it: distinguishing between TLorentzVectors that are created from some Tracks in our analysis software and I would like to keep the information which track I used to create the particular LorentzVector afterwards.

I would find a variable free to use very useful. Or is there a way to store some additional Information to a TObject object in root?

Best regards from a ROOT loving fan

Hi,

not directly. You could derive from TObject add throw a member in in your derived class, e.g. a TList which can hold whatever you want it to hold.

Alternatively you can use the UniqueID of the TObject to store properties, as long as you don’t use TRefs pointing to the object. Certain bits of TObject::fBits are also available, see the documentation.

Cheers, Axel.

Deriving is of course an option but to complicated for me if i want to store the objects in trees or similar afterwards.

The bits seem to be an other option and I was already thinking about. But who tells me that in the future the bits will stay untouched from ROOT site.

I just wanted to throw my idea to the pool of suggestions. Maybe worth it to think about the next time you change somthing in the TObject it self.

Cheers Promme

Hi,

[quote]The bits seem to be an other option and I was already thinking about. But who tells me that in the future the bits will stay untouched from ROOT site.
[/quote]As stated in the documentation: //----- Global bits (can be set for any object and should not be reused). //----- Bits 0 - 13 are reserved as global bits. Bits 14 - 23 can be used //----- in different class hierarchies (make sure there is no overlap in //----- any given hierarchy).and thus we have no plan to ever use Bits 14-23 for anything in TObject itself. (Other classes that derived from TObject do use other bits but you would have to worry about that only if you derive from those classes).

Cheers,
Philippe.

Ok, I’ll try to use them for tagging.

Thank you pointing this part of the documentation out.

Cheers Promme

Hi,

FWIW, If you make a new “base” class that derives from TObject and your objects derive from this class, there should be no problem making dictionaries for these objects and storing them.

Cheers,
Charles