KaliVeda
1.13/01
Heavy-Ion Analysis Toolkit
|
Manage a list of global variables.
The KVGVList class handles a list of global variables. A list can be used in the following schematic way to calculate several global variables at once:
One or more branches can be added to a TTree and filled with the values of all or some of the global variables in the list using method MakeBranches(TTree*). For each single-valued variable a branch with name
will be added. For multi-valued variables (those for which KVVarGlob::GetNumberOfValues() returns >1) we add
branches for each named value defined for the variable (see KVFlowTensor for an example of a multi-valued variable). The total number of branches added is determined by KVVarGlob::SetMaxNumBranches(): calling this method with argument 0
will prevent any branch being added for the variable in question.
Once variables have been calculated, calling FillBranches() will prepare the TTree for filling. Note that you have to call TTree::Fill() after calling this method.
Conditions ('cuts') can be set on each variable which decide whether or not to retain an event for analysis. If any variable in the list fails the test, processing of the list is abandoned.
Selection criteria are set using lambda expressions. In this example, the variable "mtot" must have a value of at least 4 for the event to be retained:
Any event selection criterion is tested as soon as each variable has been calculated. If the test fails, no further variables are calculated and the KVGVList goes into 'abort event' mode:
One or more variables in the list can be used to define new kinematical frames which can in turn be used by any variables which occur after them in the list. In order to do so, call method SetNewFrameDefinition() for the variable(s) in question with a lambda function having the following signature:
When called (e.g. by KVGVList), the KVVarGlob pointer gives access to the global variable.
As an example of use, imagine that KVZmax is used to find the heaviest (largest Z) fragment in the forward CM hemisphere, then the velocity of this fragment is used to define a "QP_FRAME" in order to calculate the KVFlowTensor in this frame:
Event classifier (KVEventClassifier) objects can be defined for any global variable in the list using method AddEventClassifier():
which returns a pointer to the event classifier, in order to set up either cuts or bins.
mtot_EC
is the default name for an event classification based on mtot
and will be used for the branch added to the user's analysis TTree by method MakeBranches().
Definition at line 122 of file KVGVList.h.
Public Member Functions | |
KVGVList (const KVGVList &a) | |
KVGVList (const KVString &name="default", const KVParticleCondition &selection=KVParticleCondition()) | |
bool | AbortEventAnalysis () const |
virtual void | Add (TObject *obj) |
KVEventClassifier * | AddEventClassifier (const TString &varname, const TString &value="") |
virtual void | AddFirst (TObject *obj) |
KVVarGlob * | AddGV (const Char_t *class_name, const Char_t *name) |
KVVarGlob * | AddGVFirst (const Char_t *class_name, const Char_t *name) |
void | CalculateGlobalVariables (KVEvent *e) |
void | FillBranches () |
KVVarGlob * | GetGV (const Char_t *nom) const |
Return pointer to global variable in list with name 'nom'. More... | |
KVVarGlob * | GetGVType (const Char_t *class_name) |
Returns first global variable in list with given class. More... | |
Bool_t | Has1BodyVariables () |
returns kTRUE if list contains 1-body variables More... | |
Bool_t | Has2BodyVariables () |
returns kTRUE if list contains 2-body variables More... | |
Bool_t | HasNBodyVariables () |
returns kTRUE if list contains N-body variables More... | |
void | Init (void) |
void | MakeBranches (TTree *) |
void | Reset (void) |
Reset all variables before treating an event. More... | |
![]() | |
KVUniqueNameList (Bool_t R=kFALSE) | |
Default constructor. More... | |
virtual | ~KVUniqueNameList () |
Destructor. More... | |
virtual void | AddAfter (const TObject *after, TObject *obj) |
virtual void | AddAt (TObject *obj, Int_t idx) |
virtual void | AddBefore (const TObject *before, TObject *obj) |
virtual void | AddLast (TObject *obj) |
Bool_t | ObjectAdded () const |
void | ReplaceObjects (Bool_t yes=kTRUE) |
![]() | |
KVHashList (Int_t capacity=TCollection::kInitHashTableCapacity, Int_t rehash=2) | |
virtual | ~KVHashList () |
Destructor. More... | |
Float_t | AverageCollisions () const |
template<typename T > | |
Bool_t | ContainsObjectWithName (const T &o) |
const TList * | GetListForObject (const char *name) const |
const TList * | GetListForObject (const TObject *obj) const |
void | Rehash (Int_t newCapacity=0) |
void | Sort (Bool_t order=kSortAscending) |
![]() | |
KVSeqCollection () | |
Default constructor. More... | |
KVSeqCollection (const Char_t *collection_classname) | |
KVSeqCollection (const KVSeqCollection &) | |
virtual | ~KVSeqCollection () |
virtual TObject * | After (const TObject *obj) const |
virtual TObject * | At (Int_t idx) const |
virtual TObject * | Before (const TObject *obj) const |
virtual void | Clear (Option_t *option="") |
const Char_t * | CollectionClassName () const |
virtual void | Copy (TObject &obj) const |
virtual void | Delete (Option_t *option="") |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
virtual TObject * | FindObject (const char *name) const |
virtual TObject * | FindObject (const TObject *obj) const |
virtual TObject * | FindObjectAny (const Char_t *att, const Char_t *keys, Bool_t contains_all=kFALSE, Bool_t case_sensitive=kTRUE) const |
TObject * | FindObjectByClass (const Char_t *) const |
Return (first) object in embedded list with given class. More... | |
TObject * | FindObjectByClass (const TClass *) const |
Return (first) object in embedded list with given class. More... | |
virtual TObject * | FindObjectByLabel (const Char_t *) const |
virtual TObject * | FindObjectByName (const Char_t *name) const |
virtual TObject * | FindObjectByNumber (UInt_t num) const |
virtual TObject * | FindObjectByTitle (const Char_t *) const |
Will return object with given title (value of TObject::GetTitle() method). More... | |
virtual TObject * | FindObjectByType (const Char_t *) const |
virtual TObject * | FindObjectWithMethod (const Char_t *retvalue, const Char_t *method) const |
virtual TObject * | FindObjectWithNameAndType (const Char_t *name, const Char_t *type) const |
virtual TObject * | First () const |
template<typename T > | |
T * | get_object (const TString &name) const |
TSeqCollection * | GetCollection () const |
virtual TObject ** | GetObjectRef (const TObject *obj) const |
Return reference to object. More... | |
virtual Int_t | GetSize () const |
KVSeqCollection * | GetSubListWithClass (const Char_t *class_name) const |
KVSeqCollection * | GetSubListWithClass (const TClass *_class) const |
KVSeqCollection * | GetSubListWithLabel (const Char_t *retvalue) const |
KVSeqCollection * | GetSubListWithMethod (const Char_t *retvalue, const Char_t *method) const |
KVSeqCollection * | GetSubListWithName (const Char_t *retvalue) const |
KVSeqCollection * | GetSubListWithType (const Char_t *retvalue) const |
virtual Bool_t | IsCleanup () const |
virtual Bool_t | IsSendingModifiedSignals () const |
virtual Bool_t | IsSortable () const |
virtual Bool_t | IsSorted () const |
virtual TObject * | Last () const |
virtual TIterator * | MakeIterator (Bool_t dir=kIterForward) const |
Make and return iterator for the list. More... | |
virtual void | Modified () |
KVSeqCollection & | operator= (const KVSeqCollection &) |
virtual void | RecursiveRemove (TObject *obj) |
virtual TObject * | Remove (TObject *obj) |
Remove object from list. More... | |
virtual void | SendModifiedSignals (Bool_t yes=kTRUE) |
virtual void | SetCleanup (Bool_t enable=kTRUE) |
virtual void | SetOwner (Bool_t enable=kTRUE) |
![]() | |
virtual | ~TSeqCollection () |
virtual Int_t | GetLast () const |
virtual Int_t | IndexOf (const TObject *obj) const |
Int_t | LastIndex () const |
Long64_t | Merge (TCollection *list) |
virtual void | RemoveAfter (TObject *after) |
virtual TObject * | RemoveAt (Int_t idx) |
virtual void | RemoveBefore (TObject *before) |
virtual void | RemoveFirst () |
virtual void | RemoveLast () |
void | UnSort () |
![]() | |
virtual | ~TCollection () |
virtual void | AddAll (const TCollection *col) |
void | AddVector (TObject *obj1,...) |
Bool_t | AssertClass (TClass *cl) const |
TIter | begin () const |
void | Browse (TBrowser *b) |
Int_t | Capacity () const |
virtual TObject * | Clone (const char *newname="") const |
Int_t | Compare (const TObject *obj) const |
Bool_t | Contains (const char *name) const |
Bool_t | Contains (const TObject *obj) const |
virtual void | Draw (Option_t *option="") |
virtual void | Dump () const |
TIter | end () const |
virtual Int_t | GetEntries () const |
virtual const char * | GetName () const |
virtual Int_t | GrowBy (Int_t delta) const |
ULong_t | Hash () const |
Bool_t | IsArgNull (const char *where, const TObject *obj) const |
virtual Bool_t | IsEmpty () const |
virtual Bool_t | IsFolder () const |
Bool_t | IsOwner () const |
R__ALWAYS_INLINE Bool_t | IsUsingRWLock () const |
virtual void | ls (Option_t *option="") const |
virtual TIterator * | MakeReverseIterator () const |
virtual Bool_t | Notify () |
TObject * | operator() (const char *name) const |
virtual void | Paint (Option_t *option="") |
virtual void | Print (Option_t *option, const char *wildcard, Int_t recurse=1) const |
virtual void | Print (Option_t *option, Int_t recurse) const |
virtual void | Print (Option_t *option, TPRegexp ®exp, Int_t recurse=1) const |
virtual void | Print (Option_t *option="") const |
void | RemoveAll () |
virtual void | RemoveAll (TCollection *col) |
void | SetCurrentCollection () |
void | SetName (const char *name) |
virtual bool | UseRWLock () |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
![]() | |
TObject () | |
TObject (const TObject &object) | |
virtual | ~TObject () |
void | AbstractMethod (const char *method) const |
virtual void | AppendPad (Option_t *option="") |
ULong_t | CheckedHash () |
virtual const char * | ClassName () const |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
virtual void | DrawClass () const |
virtual TObject * | DrawClone (Option_t *option="") const |
virtual void | Error (const char *method, const char *msgfmt,...) const |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
virtual Option_t * | GetDrawOption () const |
virtual const char * | GetIconName () const |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
virtual Option_t * | GetOption () const |
virtual const char * | GetTitle () const |
virtual UInt_t | GetUniqueID () const |
virtual Bool_t | HandleTimer (TTimer *timer) |
Bool_t | HasInconsistentHash () const |
virtual void | Info (const char *method, const char *msgfmt,...) const |
virtual Bool_t | InheritsFrom (const char *classname) const |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
virtual void | Inspect () const |
void | InvertBit (UInt_t f) |
virtual Bool_t | IsEqual (const TObject *obj) const |
R__ALWAYS_INLINE Bool_t | IsOnHeap () const |
R__ALWAYS_INLINE Bool_t | IsZombie () const |
void | MayNotUse (const char *method) const |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
void | operator delete (void *ptr) |
void | operator delete[] (void *ptr) |
void * | operator new (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, void *vp) |
TObject & | operator= (const TObject &rhs) |
virtual void | Pop () |
virtual Int_t | Read (const char *name) |
void | ResetBit (UInt_t f) |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
void | SetBit (UInt_t f) |
void | SetBit (UInt_t f, Bool_t set) |
virtual void | SetDrawOption (Option_t *option="") |
virtual void | SetUniqueID (UInt_t uid) |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
R__ALWAYS_INLINE Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
virtual void | UseCurrentStyle () |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Protected Member Functions | |
void | Calculate () |
Calculate all 1-body observables after filling. More... | |
void | Calculate2 () |
Calculate all 2-body observables after filling. More... | |
void | CalculateN () |
Calculate all N-body observables after filling. More... | |
void | Fill (const KVNucleus *c) |
void | Fill2 (const KVNucleus *c1, const KVNucleus *c2) |
void | FillN (const KVEvent *e) |
Calls KVVarGlob::FillN(KVEvent*) method of all N-body variables in the list. More... | |
void | init_KVGVList (void) |
![]() | |
void | _GetSubListWithClass (KVSeqCollection *, TCollection *, const TClass *) const |
virtual void | _GetSubListWithMethod (KVSeqCollection *, TCollection *, const Char_t *, const Char_t *) const |
virtual void | Changed () |
virtual KVSeqCollection * | NewCollectionLikeThisOne () const |
virtual void | PrintCollectionHeader (Option_t *option) const |
Overrides TCollection::PrintCollectionHeader to show the class name of the embedded list. More... | |
virtual void | SetCollection (const Char_t *) |
![]() | |
TSeqCollection () | |
![]() | |
TCollection () | |
virtual const char * | GetCollectionEntryName (TObject *entry) const |
virtual void | PrintCollectionEntry (TObject *entry, Option_t *option, Int_t recurse) const |
![]() | |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
void | MakeZombie () |
Protected Attributes | |
TList | fVG1 |
one-body variables More... | |
TList | fVG2 |
two-body variables More... | |
TList | fVGN |
N-body variables. More... | |
![]() | |
TSeqCollection * | fCollection |
Pointer to embedded ROOT collection. More... | |
![]() | |
Bool_t | fSorted |
![]() | |
TString | fName |
Int_t | fSize |
kIsOwner | |
kUseRWLock | |
![]() | |
kOnlyPrepStep | |
Private Member Functions | |
TString | NameSanitizer (const Char_t *s) const |
KVVarGlob * | prepareGVforAdding (const Char_t *class_name, const Char_t *name) |
Private Attributes | |
bool | fAbortEventAnalysis |
set to false if a global variable fails its own event selection criterion More... | |
std::vector< Double_t > | fBranchVar |
used for automatic creation & filling of TTree branches More... | |
std::vector< Int_t > | fIBranchVar |
used for automatic creation & filling of TTree branches More... | |
Int_t | fNbBranch |
Int_t | fNbIBranch |
KVParticleCondition | fSelection |
used to select particles to iterate over in event More... | |
#include <KVGVList.h>
KVGVList::KVGVList | ( | const KVString & | name = "default" , |
const KVParticleCondition & | selection = KVParticleCondition() |
||
) |
Create a list of global variables.
If given, the KVParticleCondition will be used to select the particles to iterate over in each event in order to calculate the global variables.
By default, if no selection is defined, only particles which are "OK" (i.e. for which KVParticle::IsOK() returns true) will be iterated over - this will change in the future!
Definition at line 32 of file KVGVList.cpp.
KVGVList::KVGVList | ( | const KVGVList & | a | ) |
Definition at line 52 of file KVGVList.cpp.
|
inline |
Definition at line 199 of file KVGVList.h.
Overrides KVUniqueNameList::Add(TObject*) so that global variable pointers are sorted between the 3 lists used for 1-body, 2-body & N-body variables.
We also print a warning in case the user tries to add a global variable with the same name as one already in the list. In the case we retain only the first global variable, any others with the same name are ignored
Reimplemented from KVUniqueNameList.
Definition at line 279 of file KVGVList.cpp.
KVEventClassifier * KVGVList::AddEventClassifier | ( | const TString & | varname, |
const TString & | value = "" |
||
) |
Add an event classification object to the list, based on the named global variable (which must already be in the list).
[in] | varname | name of global variable previously added to list |
[in] | value | [optional] for multi-valued variables, you can specify which value to use by name, or a mathematical expression involving one or more of the available values |
Returns a pointer to the object, in order to add either cuts or bins like so:
This will class events according to:
mtot | mtot_EC |
---|---|
<5 | 0 |
[5, 9] | 1 |
[10, 14] | 2 |
[15, 19] | 3 |
[20, 24] | 4 |
[25, 29] | 5 |
>=30 | 6 |
mtot_EC
is the default name for an event classification based on mtot
and will be used for the branch added to the user's analysis TTree by method MakeBranches().
This will class events according to the 2 bins with the following numbers:
mtot | mtot_EC |
---|---|
[5, 9] | 0 |
[15, 19] | 1 |
[25, 29] | 2 |
other | -1 |
Note that in this case, any value outside of a defined bin is unclassified.
Definition at line 555 of file KVGVList.cpp.
Overrides KVUniqueNameList::AddFirst(TObject*) so that global variable pointers are sorted between the 3 lists used for 1-body, 2-body & N-body variables.
We also print a warning in case the user tries to add a global variable with the same name as one already in the list. In the case we retain only the first global variable, any others with the same name are ignored
Reimplemented from KVUniqueNameList.
Definition at line 316 of file KVGVList.cpp.
Add a global variable to the list.
"class_name"
must be the name of a valid class inheriting from KVVarGlob, e.g. any of the default global variable classes defined as part of the standard KaliVeda package (see the Global Variables module), or the name of a user-defined class (see below).
"name"
is a unique name for the new global variable object which will be created and added to the list of global variables. This name can later be used to retrieve the object (see GetGV()).
Returns pointer to new global variable object in case more than the usual default initialisation is necessary.
The user may use her own global variables, without having to add them to the main libraries. If the given class name is not known, it is assumed to be a user-defined class and we attempt to compile and load the class from the user's source code. For this to work, the user must:
$HOME/.rootrc
add the following line:It is assumed that MyNewVarGlob.h
and MyNewVarGlob.cpp
will be found in $HOME/myVarGlobs
(in this example). The constructor taking a single character string argument (name of the variable) must be defined in the class.
Definition at line 648 of file KVGVList.cpp.
Add a global variable at the beginning of the list.
See AddGV() for details.
Definition at line 734 of file KVGVList.cpp.
Calculate all 1-body observables after filling.
Definition at line 144 of file KVGVList.cpp.
|
protected |
Calculate all 2-body observables after filling.
Definition at line 163 of file KVGVList.cpp.
This method will calculate all global variables defined in the list for the event 'e'.
This will iterate over all particles in the event which correspond to the KVParticleCondition fSelection; if none has been defined, only particles for which KVParticle::IsOK() returns true will be used.
Note that for 2-body variables, the Fill2 method will be called for each distinct pair of particles in the event, plus each pair made up of a particle and itself.
For each variable for which an event selection condition was set (see KVVarGlob::SetEventSelection()) the condition is tested as soon as the variable is calculated. If the condition is not satisfied, calculation of the other variables is abandonded and method AbortEventAnalysis() returns kTRUE.
Definition at line 211 of file KVGVList.cpp.
|
protected |
Calculate all N-body observables after filling.
Definition at line 182 of file KVGVList.cpp.
Calls KVVarGlob::Fill(KVNucleus*) method of all one-body variables in the list for all KVNucleus satisfying the KVParticleCondition given to KVVarGlob::SetSelection() (if no selection given, all nuclei are used).
Definition at line 102 of file KVGVList.cpp.
Calls KVVarGlob::Fill(KVNucleus*,KVNucleus*) method of all two-body variables in the list for all pairs of KVNucleus (c1,c2) satisfying the KVParticleCondition given to KVVarGlob::SetSelection() (if no selection given, all nuclei are used).
Definition at line 119 of file KVGVList.cpp.
void KVGVList::FillBranches | ( | ) |
Use this method ONLY if you first use MakeBranches(TTree*) in order to automatically create branches for your global variables. Call this method for each event in order to put the values of the variables in the branches ready for TTree::Fill to be called (note that TTree::Fill is not called in this method: you should do it after this).
Definition at line 459 of file KVGVList.cpp.
Calls KVVarGlob::FillN(KVEvent*) method of all N-body variables in the list.
Definition at line 133 of file KVGVList.cpp.
Return pointer to global variable in list with name 'nom'.
Definition at line 262 of file KVGVList.cpp.
Returns first global variable in list with given class.
Definition at line 171 of file KVGVList.h.
|
inline |
returns kTRUE if list contains 1-body variables
Definition at line 179 of file KVGVList.h.
|
inline |
returns kTRUE if list contains 2-body variables
Definition at line 185 of file KVGVList.h.
|
inline |
returns kTRUE if list contains N-body variables
Definition at line 191 of file KVGVList.h.
Initialisation of all global variables in list
As this method may be called several times we ensure that variables are only initialised once
If no selection for particles in the event has been defined, a default selection of "OK" particles is set here.
Definition at line 67 of file KVGVList.cpp.
Definition at line 15 of file KVGVList.cpp.
Create a branch in the TTree for each global variable in the list. A leaf with the name of each global variable will be created to hold the value of the variable (result of KVVarGlob::GetValue() method). For multi-valued global variables we add a branch for each value with name
GVname.ValueName
To avoid problems with TTree::Draw, 'GVName' will be sanitized i.e. any mathematical symbols will be replaced by '_'.
Any variable for which KVVarGlob::SetMaxNumBranches() was called with argument 0
will not be added to the TTree.
Definition at line 361 of file KVGVList.cpp.
Definition at line 132 of file KVGVList.h.
Definition at line 690 of file KVGVList.cpp.
Reset all variables before treating an event.
Definition at line 88 of file KVGVList.cpp.
|
private |
set to false if a global variable fails its own event selection criterion
Definition at line 129 of file KVGVList.h.
|
private |
used for automatic creation & filling of TTree branches
Definition at line 125 of file KVGVList.h.
|
private |
used for automatic creation & filling of TTree branches
Definition at line 126 of file KVGVList.h.
|
private |
Definition at line 127 of file KVGVList.h.
|
private |
Definition at line 128 of file KVGVList.h.
|
private |
used to select particles to iterate over in event
Definition at line 124 of file KVGVList.h.
|
protected |
one-body variables
Definition at line 146 of file KVGVList.h.
|
protected |
two-body variables
Definition at line 147 of file KVGVList.h.
|
protected |
N-body variables.
Definition at line 148 of file KVGVList.h.