GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
void RandObj::Add ( TObject *  obj,
Float_t  weight 
)
virtual

it adds an object with a weight to this collection.

What happens if:

  • the object already exists in the collection:
    1. only its weight is modified (sum with the old one)

if the new weight is positive, the weight of the object is changed. if it becomes negative, the corresponding object is removed from the collection.

  • the object doesn't exist in the collection:

It is added to the collection even if the weight is negative. In this case, it is assumed as a mistake and the stored weight is the absolute value.

Because this class used std::vector, you should avoid adding/removing objects too often like in a loop.

Definition at line 49 of file RandObj.cpp.