Using Bit Mask

see for example TH1 class …

why fgStatOverflows (for exapmle) is declared as static Bool_t
and not declared as TH1 status bit kStatOverflows = BIT(xx) ?
(except globalize this members)
or revrse: why kLogX is TH1 status bit, why not static Bool_t fgLogX ?

Thanks, Jan

Bool_t fgStatOverflows is a class static variable.
This means that it applies to all histograms.
When using a TH1 status bit, you set the bit only for one histogram.


OK, otherwise:
why kLogX is TH1 status bit, why not “simple” Bool_t fLogX
if (TestBit(kLogX)) … is more efficiency than if (fLogX) … ?

Thanks Rene.

You can store up to 32 Bool_t equivalent in the TObject::fBits.
This is more efficient for I/O and space (1 bit instead of one byte,
or even worst 4 bytes on the MAC!
fBits has also the advantage that you can test multiple bits in
one single test.



I have noticed that when streamed, the fBits gets truncated for the last bit. This can be tested very easy with the following lines

TObject *o = new TObject();
TObject *o1 = o->Clone();

Is there a special feature here or an error ?

Thank you



See the TObject documentation, in particular: //----- 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). enum EStatusBits { kCanDelete = BIT(0), // if object in a list can be deleted kMustCleanup = BIT(3), // if object destructor must call RecursiveRemove() kObjInCanvas = BIT(3), // for backward compatibility only, use kMustCleanup kIsReferenced = BIT(4), // if object is referenced by a TRef or TRefArray kHasUUID = BIT(5), // if object has a TUUID (its fUniqueID=UUIDNumber) kCannotPick = BIT(6), // if object in a pad cannot be picked kNoContextMenu = BIT(8), // if object does not want context menu kInvalidObject = BIT(13) // if object ctor succeeded but object should not be used };

All bits up to 13 are reserved (and used) by ROOT itself. The “last bit” is use to indicate whether a canvas can delete the object or not.


Dear Philippe,

Thank you very much for pointing this feature. to me