KaliVeda
Toolkit for HIC analysis
Base & utility classes

Before plunging into the many specific classes provided by KaliVeda for handling heany-ion collision data, it is worth mentioning quite a few utility classes which can be useful for a wide range of general programming needs. Some of them are simple extensions to existing ROOT classes, others are more original. See KaliVeda Core Classes for the full list.

KVBase

KVBase is the base class for the toolkit, derived from the ROOT TNamed (nearly-) base class. TNamed objects have a name and a title, KVBase extends this to include a type (actually just an alias for the TNamed title), a label (a string attribute distinct from the name and title/type) and a number. The class also provides quite a few static methods which have general usefulness. See the class reference for details.

Strings

KVString is a (small) extension to ROOT's TString class (some methods which were originally added to KVString have long since been adopted by the official ROOT TString and are therefore no longer defined by KVString).

One thing that it is very useful for is iterating over items in a string separated by 'tokens' in a memory-safe way (unlike TString::Tokenize()):

KVString stuff = "first | second,third | last";
stuff.Begin("|"); // separate according to '|' token
while(!stuff.End())
{
auto tok = stuff.Next(kTRUE); // get next item
tok.Begin(","); // separate according to ',' token
while(!tok.End())
{
std::cout << tok.Next(kTRUE) << std::endl;
}
}
second
third
last
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
void Begin(TString delim) const
Definition: KVString.cpp:565
Bool_t End() const
Definition: KVString.cpp:634
KVString Next(Bool_t strip_whitespace=kFALSE) const
Definition: KVString.cpp:695

Number lists & ranges

KVNumberList handles lists of integers. Doesn't sound much, but it's amazing how useful such a class can be!

KVNumberList l("1,5-6,2,7,10")// or KVNumberList l{1,5,6,2,7,10};;
for(auto i : l) std::cout << i << ",";
1,2,5,6,7,10,
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
TLine l

KVValueRange can be used to define a range of values \([min,max]\) and then do useful things such as generate a random value in the range, or generate a sequence of integer values between the limits, test if a value is contained in the range, etc.

Units

Physical quantities like pressure, mass, energy, etc. obviously have associated units. The default units used by (nearly) all classes and methods in the KaliVeda toolkit are:

  • grammes for mass;
  • centimetres for distance;
  • torr for pressures;

etc. etc. The full list can be found in the detailed description of the KVUnits namespace, which provides conversion factors between the standard units. For example, if x is a density expressed in kilogrammes per cubic metre, the corresponding density in standard units of \([g/cm^3]\) is given by

RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
Double_t x[n]
const long double kg
Definition: KVUnits.h:73
const long double m
Definition: KVUnits.h:70

See the detailed description for more info.

Lists of objects

As you may (or may not) know, much of ROOT's infrastructure is based on the use of containers which store base pointers (pointer to TObject) to the objects referenced by the container:

TList obj_list;
obj_list.Add(new TNamed("obj1","An object"));
obj_list.Add(new TNamed("obj2","Another object"));
obj_list.ls()
OBJ: TList TList Doubly linked list : 0
OBJ: TNamed obj1 An object : 0 at: 0x606674a5ae50
OBJ: TNamed obj2 Another object : 0 at: 0x606674a7e4d0
obj_list.FindObject("obj2")
(TObject *) 0x606674a7e4d0
void ls(Option_t *option="") const override
TObject * FindObject(const char *name) const override
void Add(TObject *obj) override

KaliVeda extends the functionality of the existing ROOT list classes (those derived from TSeqCollection) with the KVSeqCollection base class which adds methods to search for objects in the list not only by name (as with TSeqCollection::FindObject()), but also by title, class, type, label, or number (the last 3 attributes only for objects derived from KVBase). It is also possible to select more than one object in a list using the KVSeqCollection::GetSubListWith...() methods.

Derived from KVSeqCollection are 4 more list classes which all inherit the new functionalities and add their own specific flavour:

  • KVList - a list which by default 'owns' its objects (i.e. will delete all objects it contains when the list goes out of scope/is deleted);
  • KVUnownedList - a list which by default does not own its objects (historically, KVList has existed for a lot longer than this recent addition);
  • KVHashList - list permitting fast look-up of objects by name (based on THashList) with automatic re-hashing enabled;
  • KVUniqueNameList - list in which each object must have a unique name: if you try to add an object with the same name as an object already in the list it is either simply not added, or used to replace the previously-added object (which may in turn be automatically deleted).

Class source code generator

KVClassFactory, as its name implies, can be used to generate new classes (source code) with very little effort. Many classes in the KaliVeda framework were in fact generated (at least their basic structure) using KVClassFactory. The classes are ROOT-compliant, i.e. they have the necessary macros in order to be used on the ROOT command line. Simple example:

KVClassFactory::MakeClass("MyClass", "My new class", "TObject")
<KVClassFactory::WriteClassHeader> : File MyClass.h generated.
<KVClassFactory::WriteClassImp> : File MyClass.cpp generated.
void WriteClassHeader()
Write the class header file.
static void MakeClass(const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="", Bool_t withTemplate=kFALSE, const Char_t *templateFile="")

This will produce the following files:

//========MyClass.h========//
#ifndef __MYCLASS_H
#define __MYCLASS_H
#include "TObject.h"
//**
\class MyClass
\brief My new class
Write a detailed documentation for your class here, see doxygen manual for help.
\author John Frankland
\date Tue Mar 26 16:08:32 2024
*/
class MyClass : public TObject
{
public:
MyClass()
: TObject()
{
}
virtual ~MyClass()
{
}
ClassDef(MyClass,1)//My new class
};
#endif
#define ClassDef(name, id)
for(Int_t i=0;i< n;i++)
TArc a

and

//========MyClass.cpp========//
#include "MyClass.h"
ClassImp(MyClass)
ClassImp(TPyArg)