KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVVarGlob Class Referenceabstract

Detailed Description

Base class for all global variable implementations.

Abstract base class for the management of global variables.

A global variable is an analysis tool for condensing the information in a multibody event into one or a few characteristic values. A simple example is the event multiplicity (the number of particles in each event), which can be used to characterize heavy-ion collision events in terms of violence or centrality.

In KaliVeda, the base class for a multibody event is KVEvent, which is basically a collection of nuclei (base class KVNucleus). Therefore the global variable classes below can be used with any event described by a class derived from KVEvent, containing particles described by a class which inherits from KVNucleus.

Each global variable class implements the calculation of a given observable for any set of nuclei; this is done independently of the selection of the nuclei in the set, or in what reference frame kinematics should be calculated for either selection purposes or for the calculation of the observable. The way the observable is calculated is defined by the implementation of the fill(const KVNucleus*) (for 1-body observables: see below) and Calculate() methods.

Global variables can be of different types:

  • One-body global variable (type = KVVarGlob::kOneBody)
    • the variable is computed by performing a loop over all particles in an event and calling the overridden fill(const KVNucleus*) method for each particle in turn.
  • Two-body global variable (type = KVVarGlob::kTwoBody)
  • N-body global variable (type = KVVarGlob::kNBody)
    • the variable is computed from the full list of particles of the event, by defining the overridden fillN(KVEvent*) method.

Derived global variable classes of 2-body or N-body type must set the fType member variable to the appropriate type (kTwoBody or kNBody) and define the fill2(const KVNucleus*,const KVNucleus*) method (for 2-body variables) or the fillN(KVEvent*) method (for N-body variables).

This is handled semi-automatically when using method

MakeClass(const Char_t * classname, const Char_t * classdesc, int type)
char Char_t
static void MakeClass(const Char_t *classname, const Char_t *classdesc, int type=kOneBody)
Definition KVVarGlob.cpp:45

to generate a skeleton '.h' and '.cpp' file for the implementation of a new global variable class.

By default, global variables are 1-body and must define the fill(const KVNucleus*) method.

In addition, implementations in daughter classes must define the following methods:

  • getvalue_int(int) : return (possibly) several values calculated by the global variable, depending on the index.
  • Init() : initialisation of any internal variables to be performed once before beginning analysis loop.
  • Calculate() : perform any necessary calculations after filling for 1 event is finished.
  • Reset() : reset internal variables ready for another event.

Usage

Creation & initialisation

SomeVarGlob VG("var1"); // daughter class implementing 1-body global variable
VG.SetSelection( [particle selection criteria] );
VG.SetFrame( [reference frame for kinematics] );
VG.Init(); // perform any necessary initialisations

Analysis loop

while( [loop over events] )
{
while( [loop over particles in event] )
{
VG.Fill( [particle] );
}
VG.Calculate(); // perform any necessary calculations
auto vg = VG.GetValue(); // retrieve unique or principal value of variable
auto vh = VG.GetValue(2); // retrieve value with index 2 from multi-valued variable (implementation-dependent)
auto vi = VG.GetValue("Toto"); // retrieve value named "Toto" from multi-valued variable (implementation-dependent)
auto vv = VG.GetValueVector(); // retrieve vector containing all values of multi-valued variable
for(auto V : vv) // print all values
{
std::cout << V << std::endl;
}
VG.Reset(); // reinitialise prior to analysis of next event
}
winID h TVirtualViewer3D vv

Note that although the Fill() method is called for all particles, only those which satsify the conditions given to SetSelection() will be used to calculate the variable. Also, the internal fill(const KVNucleus*) etc. methods of each global variable class actually receive a pointer to each nucleus with as default kinematics those of the frame chosen with SetFrame().

Global variable lists

The KVGVList class handles a list of global variables. The recommended way to use global variables is through a list of this type (even if only one). The user analysis classes derived from KVEventSelector all have an internal KVGVList for definition and calculation of global variables. See KVGVList and KVEventSelector class documentation for more details.

Options, parameters, reference frames, particle selection, etc.

Particle selection

The selection of particles which are taken into account is handled by the variable itself by calling method SetSelection().

Kinematical reference frames

To change the reference frame used by the variable to calculate kinematical properties of particles (including those used for particle selection), call method SetFrame() (see KVEvent::SetFrame() and KVParticle::GetFrame() for how to define and access different frames).

Options and parameters

In order to give greater flexibility to global variable classes without the need to add member variables and the associated Get/Set methods, we provide methods to handle generic 'options' and 'parameters' for all variables.

An 'option' is a name-value pair, the value is a character string. Methods to use are:

void SetOption(const Char_t* option, const Char_t* value)
Bool_t IsOptionGiven(const Char_t* option)
KVString& GetOptionString(const Char_t* option) const
void UnsetOption(const Char_t* opt)
bool Bool_t
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
void SetOption(const Char_t *option, const Char_t *value)
Definition KVVarGlob.h:521
void UnsetOption(const Char_t *opt)
Definition KVVarGlob.h:542
TString GetOptionString(const Char_t *opt) const
Definition KVVarGlob.h:536
Bool_t IsOptionGiven(const Char_t *opt)
Definition KVVarGlob.h:529

A 'parameter' is a name-value pair, the value is a double-precision float value. Methods to use are:

void SetParameter(const Char_t* par, Double_t value)
void UnsetParameter(const Char_t* par)
double Double_t
void SetParameter(const Char_t *par, Double_t value)
Definition KVVarGlob.h:549
Double_t GetParameter(const Char_t *par) const
Definition KVVarGlob.h:580
Bool_t IsParameterSet(const Char_t *par)
Definition KVVarGlob.h:573
void UnsetParameter(const Char_t *par)
Definition KVVarGlob.h:592

Normalization

The value(s) returned by the variable will all be divided by the normalization factor set with one of the following methods:

SetParameter("Normalization", Double_t)
virtual void SetNormalization(Double_t norm)
Definition KVVarGlob.h:564

Definition of event selection criteria

When used in a KVGVList of global variables, 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:

KVGVList vglist;
auto mtot = vglist.AddGV("KVMult","mtot");
mtot->SetEventSelection([](const KVVarGlob* v){ return v->GetValue()>=4; });
#define KVGVLIST_OPTIMIZE_GVLIST
Definition KVGVList.h:227
KVVarGlob * AddGV(const Char_t *class_name, const Char_t *name)
Definition KVGVList.cpp:705
Base class for all global variable implementations.
Definition KVVarGlob.h:233
void SetEventSelection(const EventSelector &f)
Definition KVVarGlob.h:699
v

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:

KVEvent* event_to_analyse;
vglist.CalculateGlobalVariables( event_to_analyse );
if( !vglist.AbortEventAnalysis() )
{
... do further analysis, mtot is >=4
}
Abstract base class container for multi-particle events.
Definition KVEvent.h:67
void CalculateGlobalVariables(KVEvent *e)
Definition KVGVList.cpp:206
bool AbortEventAnalysis() const
Definition KVGVList.h:372

This mechanism is implemented in KVEventSelector, i.e. in all user analysis classes.

Definition of new kinematical frames

When used in a KVGVList of global variables, a variable can be used to define a new kinematical frame which can in turn be used by any variables which occur after them in the list. In order to do so, call method SetNewFrameDefinition() with a lambda function having the following signature:

[](KVEvent* e, const KVVarGlob* vg){ e->SetFrame("_frame_name_", ...); }
#define e(i)

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:

KVGVList vglist;
auto vg = vglist.AddGV("KVZmax", "zmax");
vg->SetFrame("CM");
vg->SetSelection( {"V>0", [](const KVNucleus* n){ return n->GetVpar()>0; }} );
vg->SetNewFrameDefinition(
[](KVEvent* e, const KVVarGlob* v){
e->SetFrame("QP_FRAME", static_cast<const KVZmax*>(v)->GetZmax(0)->GetVelocity());
});
vg = vglist.AddGV("KVFlowTensor", "qp_tensor");
vg->SetFrame("QP_FRAME"); // frame will have been defined before tensor is filled
Description of properties and kinematics of atomic nuclei.
Definition KVNucleus.h:126
void SetFrame(const Char_t *ref)
Definition KVVarGlob.h:505
Global variable used to sort particles in order of decreasing atomic number
Definition KVZmax.h:35
const Int_t n

Tagging groups of particles with global variables

Each global variable can be used to 'tag' the particles which are used for its calculation, i.e. those which satisfy the selection criteria set with SetSelection(). Each particle will be added to a group which can be subsequently used for iteration (see Iterating over nuclei). By default, the group name will be the same as the global variable, but can be changed by giving an argument to the SetDefineGroup() method:

KVMult alpha_mult("alpha");
alpha_mult.SetSelection({"4He", [](const KVNucleus* n){ return n->IsIsotope(2,4); });
alpha_mult.SetDefineGroup();
Multiplicity of all nuclei in event (including )
Definition KVMult.h:15
Authors
D. Cussol (LPC Caen), J.D. Frankland (GANIL)
Date
2004-2021
Examples
ExampleAnalysis_KVEventMixerN_3Body.cpp, ExampleFilteredSimDataAnalysis.cpp, and ExampleINDRAAnalysis.cpp.

Definition at line 233 of file KVVarGlob.h.

#include <KVVarGlob.h>

Inheritance diagram for KVVarGlob:

Public Types

enum  { kOneBody , kTwoBody , kNBody }
 
- Public Types inherited from KVBase
enum  EKaliVedaBits { kIsKaliVedaObject = BIT(23) }
 
- Public Types inherited from TObject
enum  EDeprecatedStatusBits
 
enum  EStatusBits
 

Public Member Functions

 KVVarGlob ()
 
 KVVarGlob (const Char_t *nom)
 
virtual ~KVVarGlob (void)
 
void AddSelection (const KVParticleCondition &sel)
 
Double_t AsDouble () const
 
virtual void Calculate ()=0
 
void Copy (TObject &obj) const
 
void DefineNewFrame (KVEvent *e) const
 
void Fill (const KVNucleus *c)
 
void Fill2 (const KVNucleus *n1, const KVNucleus *n2)
 
virtual void FillN (const KVEvent *)
 
const TStringGetFrame () const
 
Int_t GetNameIndex (const Char_t *name) const
 
Double_t GetNormalization () const
 
Int_t GetNumberOfBranches () const
 
virtual Int_t GetNumberOfValues () const
 
TString GetOptionString (const Char_t *opt) const
 
Double_t GetParameter (const Char_t *par) const
 
Double_t GetValue (const Char_t *name) const
 
Double_t GetValue (Int_t i) const
 
Double_t GetValue (void) const
 
virtual TString GetValueName (Int_t i) const
 
const KVNameValueListGetValueNameList () const
 
virtual Char_t GetValueType (Int_t) const
 
virtual std::vector< Double_tGetValueVector (void) const
 
Bool_t HasValue (const Char_t *name) const
 
virtual void Init ()=0
 
bool IsDefiningNewFrame () const
 
virtual Bool_t IsGlobalVariable () const
 
Bool_t IsNBody () const
 
Bool_t IsOneBody () const
 
Bool_t IsOptionGiven (const Char_t *opt)
 
Bool_t IsParameterSet (const Char_t *par)
 
bool IsSelectingEvents () const
 
Bool_t IsTwoBody () const
 
void ListInit ()
 
 operator double () const
 
Double_t operator() (const Char_t *name) const
 
Double_t operator() (Int_t i) const
 
Double_t operator() (void) const
 
void Print (Option_t *="") const
 
virtual void Reset ()=0
 
void SetDefineGroup (const KVString &groupname="")
 
void SetEventSelection (const EventSelector &f)
 
void SetFrame (const Char_t *ref)
 
void SetMaxNumBranches (Int_t n)
 
void SetNewFrameDefinition (const FrameSetter &f)
 
virtual void SetNormalization (Double_t norm)
 
void SetOption (const Char_t *option, const Char_t *value)
 
void SetParameter (const Char_t *par, Double_t value)
 
void SetSelection (const KVParticleCondition &sel)
 
bool TestEventSelection () const
 
void UnsetOption (const Char_t *opt)
 
void UnsetParameter (const Char_t *par)
 
- Public Member Functions inherited from KVBase
 KVBase ()
 Default constructor.
 
 KVBase (const Char_t *name, const Char_t *title="")
 Ctor for object with given name and type.
 
 KVBase (const KVBase &)
 copy ctor
 
virtual ~KVBase ()
 
virtual void Clear (Option_t *opt="")
 Clear object properties : name, type/title, number, label.
 
const Char_tGetLabel () const
 
UInt_t GetNumber () const
 
UInt_t GetNumberOfObjects () const
 
virtual TObjectGetObject () const
 
virtual const Char_tGetType () const
 
Bool_t HasLabel () const
 
virtual Bool_t IsCalled (const Char_t *name) const
 
Bool_t IsLabelled (const Char_t *l) const
 
virtual Bool_t IsType (const Char_t *typ) const
 
virtual void List ()
 
KVBaseoperator= (const KVBase &)
 copy assignment operator
 
Double_t ProtectedGetX (const TF1 *func, Double_t val, int &status, Double_t xmin=0.0, Double_t xmax=0.0) const
 
void SetLabel (const Char_t *lab)
 
virtual void SetNumber (UInt_t num)
 
virtual void SetType (const Char_t *str)
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TNamed &named)
 
 TNamed (const TString &name, const TString &title)
 
virtual ~TNamed ()
 
void Clear (Option_t *option="") override
 
TObjectClone (const char *newname="") const override
 
Int_t Compare (const TObject *obj) const override
 
void Copy (TObject &named) const override
 
virtual void FillBuffer (char *&buffer)
 
const char * GetName () const override
 
const char * GetTitle () const override
 
ULong_t Hash () const override
 
TClassIsA () const override
 
Bool_t IsSortable () const override
 
void ls (Option_t *option="") const override
 
TNamedoperator= (const TNamed &rhs)
 
void Print (Option_t *option="") const override
 
virtual void SetName (const char *name)
 
virtual void SetNameTitle (const char *name, const char *title)
 
virtual void SetTitle (const char *title="")
 
virtual Int_t Sizeof () const
 
void Streamer (TBuffer &) override
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TObject
 TObject ()
 
 TObject (const TObject &object)
 
virtual ~TObject ()
 
void AbstractMethod (const char *method) const
 
virtual void AppendPad (Option_t *option="")
 
virtual void Browse (TBrowser *b)
 
ULong_t CheckedHash ()
 
virtual const char * ClassName () const
 
virtual void Delete (Option_t *option="")
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 
virtual void Draw (Option_t *option="")
 
virtual void DrawClass () const
 
virtual TObjectDrawClone (Option_t *option="") const
 
virtual void Dump () const
 
virtual void Error (const char *method, const char *msgfmt,...) const
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 
virtual TObjectFindObject (const char *name) const
 
virtual TObjectFindObject (const TObject *obj) const
 
virtual Option_tGetDrawOption () const
 
virtual const char * GetIconName () const
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 
virtual Option_tGetOption () 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)
 
Bool_t IsDestructed () const
 
virtual Bool_t IsEqual (const TObject *obj) const
 
virtual Bool_t IsFolder () const
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 
virtual Bool_t Notify ()
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *vp)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, void *vp)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 
virtual void Paint (Option_t *option="")
 
virtual void Pop ()
 
virtual Int_t Read (const char *name)
 
virtual void RecursiveRemove (TObject *obj)
 
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)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
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
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 

Static Public Member Functions

static void MakeClass (const Char_t *classname, const Char_t *classdesc, int type=kOneBody)
 
- Static Public Member Functions inherited from KVBase
static Bool_t AreEqual (Double_t x, Double_t y, Long64_t maxdif=1)
 Comparison between two 64-bit floating-point values.
 
static void BackupFileWithDate (const Char_t *path)
 
static void CombineFiles (const Char_t *file1, const Char_t *file2, const Char_t *newfilename, Bool_t keep=kTRUE)
 
static void Deprecated (const char *method, const char *advice)
 
static Bool_t FindClassSourceFiles (const Char_t *class_name, KVString &imp_file, KVString &dec_file, const Char_t *dir_name=".")
 
static Bool_t FindExecutable (TString &exec, const Char_t *path="$(PATH)")
 
static const Char_tFindFile (const Char_t *search, TString &wfil)
 
static const Char_tGetBINDIRFilePath (const Char_t *namefile="")
 
static const Char_tGetDATABASEFilePath ()
 
static const Char_tGetDATADIRFilePath (const Char_t *namefile="")
 
static Bool_t GetDataSetEnv (const Char_t *dataset, const Char_t *type, Bool_t defval)
 
static const Char_tGetDataSetEnv (const Char_t *dataset, const Char_t *type, const Char_t *defval)
 
static Double_t GetDataSetEnv (const Char_t *dataset, const Char_t *type, Double_t defval)
 
static const Char_tGetETCDIRFilePath (const Char_t *namefile="")
 
static const Char_tGetExampleFilePath (const Char_t *library, const Char_t *namefile)
 Return full path to example file for given library (="KVMultiDet", "BackTrack", etc.)
 
static const Char_tGetINCDIRFilePath (const Char_t *namefile="")
 
static const Char_tGetKVBuildDate ()
 Returns KaliVeda build date.
 
static const Char_tGetKVBuildDir ()
 Returns top-level directory used for build.
 
static const Char_tGetKVBuildTime ()
 Returns KaliVeda build time.
 
static const Char_tGetKVBuildType ()
 Returns KaliVeda build type (cmake build: Release, Debug, RelWithDebInfo, ...)
 
static const Char_tGetKVBuildUser ()
 Returns username of person who performed build.
 
static const Char_tGetKVSourceDir ()
 Returns top-level directory of source tree used for build.
 
static const Char_tGetKVVersion ()
 Returns KaliVeda version string.
 
static const Char_tGetLIBDIRFilePath (const Char_t *namefile="")
 
static const Char_tGetListOfPlugins (const Char_t *base)
 
static const Char_tGetListOfPluginURIs (const Char_t *base)
 
static const Char_tGetPluginURI (const Char_t *base, const Char_t *plugin)
 
static void GetTempFileName (TString &base)
 
static const Char_tGetTEMPLATEDIRFilePath (const Char_t *namefile="")
 
static const Char_tGetWORKDIRFilePath (const Char_t *namefile="")
 
static const Char_tgitBranch ()
 Returns git branch of sources.
 
static const Char_tgitCommit ()
 Returns last git commit of sources.
 
static void InitEnvironment ()
 
static bool is_gnuinstall ()
 
static Bool_t IsThisAPlugin (const TString &uri, TString &base)
 
static TPluginHandlerLoadPlugin (const Char_t *base, const Char_t *uri="0")
 
static Bool_t OpenContextMenu (const char *method, TObject *obj, const char *alt_method_name="")
 
static void OpenTempFile (TString &base, std::ofstream &fp)
 
static void PrintSplashScreen ()
 Prints welcome message and infos on version etc.
 
static Bool_t SearchAndOpenKVFile (const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
 
static Bool_t SearchAndOpenKVFile (const Char_t *name, std::ifstream &file, const Char_t *kvsubdir="", KVLockfile *locks=0)
 
static Bool_t SearchAndOpenKVFile (const Char_t *name, std::ofstream &file, const Char_t *kvsubdir="", KVLockfile *locks=0)
 
static Bool_t SearchKVFile (const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
 
static const Char_tWorkingDirectory ()
 
- Static Public Member Functions inherited from TNamed
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 
static Bool_t GetObjectStat ()
 
static void SetDtorOnly (void *obj)
 
static void SetObjectStat (Bool_t stat)
 

Private Types

using EventSelector = std::function< bool(const KVVarGlob *)>
 
using FrameSetter = std::function< void(KVEvent *, const KVVarGlob *)>
 

Private Member Functions

void ClearNameIndex ()
 
virtual void fill (const KVNucleus *)
 
virtual void fill2 (const KVNucleus *, const KVNucleus *)
 
int GetIndexAtListPosition (int pos) const
 
TString GetNameAtListPosition (int pos) const
 
KVNameValueListGetParameters ()
 
const KVNameValueListGetParameters () const
 
virtual Double_t getvalue_char (const Char_t *name) const
 
virtual Double_t getvalue_int (Int_t) const =0
 
virtual Double_t getvalue_void () const
 
void init ()
 
void SetNameIndex (const Char_t *name, Int_t index)
 

Static Private Member Functions

static void AddExtraInitMethodComment (KVClassFactory &cf, KVString &body)
 
static void AddFillMethod (KVClassFactory &cf, int type)
 
static void AddFillMethodBody (KVClassFactory &cf, KVString &body, int type)
 
static void AddInitMethod (KVClassFactory &cf, KVString &body)
 
static void FillMethodBody (KVString &body, int type)
 
static void ImplementInitMethod (KVClassFactory &cf, KVString &body, int type)
 

Private Attributes

Bool_t fDefineGroupFromSelection {kFALSE}
 
EventSelector fEventSelector
 used to select events in analysis based on value of variable
 
KVString fFrame
 (optional) name of reference frame used for kinematics
 
FrameSetter fFrameSetter
 used to define a new kinematical frame for event based on variable
 
Bool_t fIsInitialized
 flag set after initialisation
 
Int_t fMaxNumBranches
 max number of branches to create for multi-valued variable
 
Double_t fNormalization
 optional normalization parameter
 
KVNameValueList fOptions
 list of options
 
KVNameValueList fParameters
 list of parameters
 
KVParticleCondition fSelection
 (optional) condition used to select particles
 
Int_t fType
 type of variable global; = kOneBody, kTwoBody or kNBody
 
Char_t fValueType
 type (='I' integer or 'D' double) of global variable value
 
KVNameValueList nameList
 correspondence between variable name and index
 

Additional Inherited Members

- Public Attributes inherited from TObject
 kBitMask
 
 kCanDelete
 
 kCannotPick
 
 kHasUUID
 
 kInconsistent
 
 kInvalidObject
 
 kIsOnHeap
 
 kIsReferenced
 
 kMustCleanup
 
 kNoContextMenu
 
 kNotDeleted
 
 kObjInCanvas
 
 kOverwrite
 
 kSingleKey
 
 kWriteDelete
 
 kZombie
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 
void MakeZombie ()
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 
- Protected Attributes inherited from TObject
 kOnlyPrepStep
 

Member Typedef Documentation

◆ EventSelector

using KVVarGlob::EventSelector = std::function<bool(const KVVarGlob*)>
private

Definition at line 256 of file KVVarGlob.h.

◆ FrameSetter

using KVVarGlob::FrameSetter = std::function<void(KVEvent*, const KVVarGlob*)>
private

Definition at line 258 of file KVVarGlob.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kOneBody 
kTwoBody 
kNBody 

Definition at line 236 of file KVVarGlob.h.

Constructor & Destructor Documentation

◆ KVVarGlob() [1/2]

KVVarGlob::KVVarGlob ( )
inline

Definition at line 334 of file KVVarGlob.h.

◆ KVVarGlob() [2/2]

KVVarGlob::KVVarGlob ( const Char_t nom)
inline

Definition at line 339 of file KVVarGlob.h.

◆ ~KVVarGlob()

virtual KVVarGlob::~KVVarGlob ( void  )
inlinevirtual

Definition at line 366 of file KVVarGlob.h.

Member Function Documentation

◆ AddExtraInitMethodComment()

void KVVarGlob::AddExtraInitMethodComment ( KVClassFactory cf,
KVString body 
)
staticprivate

Definition at line 130 of file KVVarGlob.cpp.

◆ AddFillMethod()

void KVVarGlob::AddFillMethod ( KVClassFactory cf,
int  type 
)
staticprivate

PRIVATE method used by MakeClass. add 'Fill', 'Fill2', or 'FillN' method

Definition at line 164 of file KVVarGlob.cpp.

◆ AddFillMethodBody()

void KVVarGlob::AddFillMethodBody ( KVClassFactory cf,
KVString body,
int  type 
)
staticprivate

PRIVATE method used by MakeClass. add body of fill method

Definition at line 191 of file KVVarGlob.cpp.

◆ AddInitMethod()

void KVVarGlob::AddInitMethod ( KVClassFactory cf,
KVString body 
)
staticprivate

PRIVATE method used by MakeClass. add 'init' method

Definition at line 148 of file KVVarGlob.cpp.

◆ AddSelection()

void KVVarGlob::AddSelection ( const KVParticleCondition sel)
inline

Use this method to add a condition which will be applied to select particles to contribute to the global variable.

The final selection will be a logical 'AND' between any previously set conditions and this one

See also
SetSelection()

Definition at line 616 of file KVVarGlob.h.

◆ AsDouble()

Double_t KVVarGlob::AsDouble ( ) const
inline

Definition at line 629 of file KVVarGlob.h.

◆ Calculate()

◆ ClearNameIndex()

void KVVarGlob::ClearNameIndex ( )
inlineprivate

Delete previously defined associations between variable name and index

Definition at line 269 of file KVVarGlob.h.

◆ Copy()

void KVVarGlob::Copy ( TObject obj) const
inlinevirtual

Copy this to obj

Reimplemented from KVBase.

Reimplemented in KVVarGlob1, KVVarGlobMean, KVVGObjectSum< SumObject >, KVVGObjectSum< KVNucleus >, KVVGObjectSum< TVector3 >, and KVZmax.

Definition at line 346 of file KVVarGlob.h.

◆ DefineNewFrame()

void KVVarGlob::DefineNewFrame ( KVEvent e) const
inline

If method SetFrameDefinition() was called with a valid function to define a new kinematical frame for events, it will be used here to define the frame for all particles in the event.

Definition at line 745 of file KVVarGlob.h.

◆ fill()

virtual void KVVarGlob::fill ( const KVNucleus )
inlineprivatevirtual

abstract method which must be overriden in child classes describing one-body global variables.

Reimplemented in KVCaloBase, KVCalorimetry, KVRiso, KVSubEventMaker, KVQuadMoment, KVVGSum, KVZmax, KVDirectivity, KVFlowTensor, KVPtot, KVReactionPlaneEstimator, KVSource, and KVZVtot.

Definition at line 304 of file KVVarGlob.h.

◆ Fill()

void KVVarGlob::Fill ( const KVNucleus c)
inline

Evaluate contribution of particle to variable only if it satisfies the particle selection criteria given with SetSelection()/AddSelection(), call fill() with particle in desired frame

If SetDefineFrame() has been called, each selected particle will be added to a group with the name given to the method (default = name of variable)

Examples
globvars_kvzmax.C.

Definition at line 406 of file KVVarGlob.h.

◆ fill2()

virtual void KVVarGlob::fill2 ( const KVNucleus ,
const KVNucleus  
)
inlineprivatevirtual

abstract method which must be overriden in child classes describing two-body global variables.

NOTE: this method will be called for EVERY pair of nuclei in the event (i.e. n1-n2 and n2-n1), including pairs of identical nuclei (n1 = n2). If you want to calculate a global variable using only each non-identical pair once, then make sure in your implementation that you check n1!=n2 and divide the result of summing over the pairs by 2 to avoid double-counting.

Reimplemented in KVFoxH2, and KVRelativeVelocity.

Definition at line 311 of file KVVarGlob.h.

◆ Fill2()

void KVVarGlob::Fill2 ( const KVNucleus n1,
const KVNucleus n2 
)
inline

Evaluate contribution of particles to variable only if both satisfy the particle selection criteria given with SetSelection(KVParticleCondition&), call fill() with particle in desired frame

Definition at line 420 of file KVVarGlob.h.

◆ FillMethodBody()

void KVVarGlob::FillMethodBody ( KVString body,
int  type 
)
staticprivate

PRIVATE method used by MakeClass. body of 'fill', 'fill2', or 'FillN' method

Definition at line 87 of file KVVarGlob.cpp.

◆ FillN()

virtual void KVVarGlob::FillN ( const KVEvent )
inlinevirtual

abstract method which must be overriden in child classes describing N-body global variables.

Reimplemented in KVEventParameter.

Definition at line 430 of file KVVarGlob.h.

◆ GetFrame()

const TString & KVVarGlob::GetFrame ( ) const
inline

Definition at line 516 of file KVVarGlob.h.

◆ GetIndexAtListPosition()

int KVVarGlob::GetIndexAtListPosition ( int  pos) const
inlineprivate

return index value stored for 'pos'-th parameter stored in NameIndex list

Definition at line 274 of file KVVarGlob.h.

◆ GetNameAtListPosition()

TString KVVarGlob::GetNameAtListPosition ( int  pos) const
inlineprivate

return name value stored for 'pos'-th parameter stored in NameIndex list

Definition at line 279 of file KVVarGlob.h.

◆ GetNameIndex()

Int_t KVVarGlob::GetNameIndex ( const Char_t name) const
Returns
the index corresponding to name
See also
SetNameIndex()

Definition at line 254 of file KVVarGlob.cpp.

◆ GetNormalization()

Double_t KVVarGlob::GetNormalization ( ) const
inline

Definition at line 587 of file KVVarGlob.h.

◆ GetNumberOfBranches()

Int_t KVVarGlob::GetNumberOfBranches ( ) const
inline

Returns number of branches to create for this global variable (see KVGVList::MakeBranches).

This is the same as GetNumberOfValues() unless SetMaxNumBranches() has been called with a different (smaller) value.

Note that if SetMaxNumBranches(0) is called, no branch will be created for this variable.

Definition at line 644 of file KVVarGlob.h.

◆ GetNumberOfValues()

virtual Int_t KVVarGlob::GetNumberOfValues ( ) const
inlinevirtual
Returns
number of values associated with this global variable. This is the number of indices defined using SetNameIndex() method.

Reimplemented in KVVarGlob1.

Definition at line 638 of file KVVarGlob.h.

◆ GetOptionString()

TString KVVarGlob::GetOptionString ( const Char_t opt) const
inline

Returns the value of the option

Definition at line 536 of file KVVarGlob.h.

◆ GetParameter()

Double_t KVVarGlob::GetParameter ( const Char_t par) const
inline

Returns the value of the parameter 'par'

Definition at line 580 of file KVVarGlob.h.

◆ GetParameters() [1/2]

KVNameValueList & KVVarGlob::GetParameters ( )
inlineprivate

Definition at line 324 of file KVVarGlob.h.

◆ GetParameters() [2/2]

const KVNameValueList & KVVarGlob::GetParameters ( ) const
inlineprivate

Definition at line 328 of file KVVarGlob.h.

◆ GetValue() [1/3]

Double_t KVVarGlob::GetValue ( const Char_t name) const
inline
Returns
value of "name" To override behaviour of this method in child classes, redefine the protected method getvalue_char(const Char_t*)

If a "Normalization" parameter has been set, it is applied here

Definition at line 453 of file KVVarGlob.h.

◆ GetValue() [2/3]

Double_t KVVarGlob::GetValue ( Int_t  i) const
inline
Returns
value with index i To override behaviour of this method in child classes, redefine the protected method getvalue_int(Int_t)

If a "Normalization" parameter has been set, it is applied here

Definition at line 463 of file KVVarGlob.h.

◆ GetValue() [3/3]

Double_t KVVarGlob::GetValue ( void  ) const
inline
Returns
principal gobal variable value To override behaviour of this method in child classes, redefine the protected method getvalue_void()

If a "Normalization" parameter has been set, it is applied here

Examples
ExampleAnalysis_KVEventMixerN_3Body.cpp, ExampleFilteredSimDataAnalysis.cpp, and ExampleINDRAAnalysis.cpp.

Definition at line 443 of file KVVarGlob.h.

◆ getvalue_char()

virtual Double_t KVVarGlob::getvalue_char ( const Char_t name) const
inlineprivatevirtual

By default, this method returns the value of the variable "name" using the name-index table set up with SetNameIndex(const Char_t*,Int_t).

Reimplemented in KVVGSum.

Definition at line 296 of file KVVarGlob.h.

◆ getvalue_int()

virtual Double_t KVVarGlob::getvalue_int ( Int_t  ) const
privatepure virtual

◆ getvalue_void()

virtual Double_t KVVarGlob::getvalue_void ( ) const
inlineprivatevirtual

By default, returns value with index 0

Definition at line 291 of file KVVarGlob.h.

◆ GetValueName()

virtual TString KVVarGlob::GetValueName ( Int_t  i) const
inlinevirtual
Returns
name of value associated with index 'i', as defined by using SetNameIndex method.

Reimplemented in KVVGSum.

Definition at line 654 of file KVVarGlob.h.

◆ GetValueNameList()

const KVNameValueList & KVVarGlob::GetValueNameList ( ) const
inline
Returns
list of names of all values defined for variable

Definition at line 663 of file KVVarGlob.h.

◆ GetValueType()

virtual Char_t KVVarGlob::GetValueType ( Int_t  ) const
inlinevirtual

Returns type of value associated with index i.

This can be either 'I' (integer values) or 'D' (floating-point/double). By default, this method returns the same type (value of member variable fValueType) for all values of i.

For all global variables for which a normalization is defined (see SetNormalization()) the type becomes 'D' even if initially it was 'I'.

This can be overridden in child classes.

Reimplemented in KVFlowTensor, KVRiso, KVCaloBase, and KVSource.

Definition at line 668 of file KVVarGlob.h.

◆ GetValueVector()

virtual std::vector< Double_t > KVVarGlob::GetValueVector ( void  ) const
inlinevirtual
Returns
vector of all values calculated by variable. The order of the values in the vector is the same as the indices defined by calls to SetNameIndex(), these indices correspond to those used with GetValue(Int_t)

If a "Normalization" parameter has been set, it is applied here

Reimplemented in KVCaloBase, and KVZmax.

Definition at line 473 of file KVVarGlob.h.

◆ HasValue()

Bool_t KVVarGlob::HasValue ( const Char_t name) const
inline
Parameters
[in]namename of a value calculated by this variable
Returns
kTRUE if value with name is defined for variable

Definition at line 436 of file KVVarGlob.h.

◆ ImplementInitMethod()

void KVVarGlob::ImplementInitMethod ( KVClassFactory cf,
KVString body,
int  type 
)
staticprivate

Definition at line 111 of file KVVarGlob.cpp.

◆ init()

void KVVarGlob::init ( void  )
private

Definition at line 16 of file KVVarGlob.cpp.

◆ Init()

◆ IsDefiningNewFrame()

bool KVVarGlob::IsDefiningNewFrame ( ) const
inline
Returns
true if this global variable defines a new kinematic frame

Definition at line 752 of file KVVarGlob.h.

◆ IsGlobalVariable()

virtual Bool_t KVVarGlob::IsGlobalVariable ( ) const
inlinevirtual

Reimplemented in KVDummyGV, and KVEventClassifier.

Definition at line 387 of file KVVarGlob.h.

◆ IsNBody()

Bool_t KVVarGlob::IsNBody ( ) const
inline
Returns
kTRUE for variables of N-body type for which FillN(KVEvent*) method must be defined

Definition at line 381 of file KVVarGlob.h.

◆ IsOneBody()

Bool_t KVVarGlob::IsOneBody ( ) const
inline
Returns
kTRUE for variables of one-body type for which Fill(KVNucleus*) method must be defined

Definition at line 369 of file KVVarGlob.h.

◆ IsOptionGiven()

Bool_t KVVarGlob::IsOptionGiven ( const Char_t opt)
inline

Returns kTRUE if the option 'opt' has been set

Definition at line 529 of file KVVarGlob.h.

◆ IsParameterSet()

Bool_t KVVarGlob::IsParameterSet ( const Char_t par)
inline

Returns kTRUE if the parameter 'par' has been set

Definition at line 573 of file KVVarGlob.h.

◆ IsSelectingEvents()

bool KVVarGlob::IsSelectingEvents ( ) const
inline
Returns
true if this global variable is used to select events

Definition at line 729 of file KVVarGlob.h.

◆ IsTwoBody()

Bool_t KVVarGlob::IsTwoBody ( ) const
inline
Returns
kTRUE for variables of two-body type for which Fill2(KVNucleus*,KVNucleus*) method must be defined

Definition at line 375 of file KVVarGlob.h.

◆ ListInit()

void KVVarGlob::ListInit ( )
inline

Method called by KVGVList::Init Ensures that initialisation of variable is performed only once

Definition at line 392 of file KVVarGlob.h.

◆ MakeClass()

void KVVarGlob::MakeClass ( const Char_t classname,
const Char_t classdesc,
int  type = kOneBody 
)
static

Creates skeleton '.h' and '.cpp' files for a new global variable class which inherits from this class. Give a name for the new class and a short description which will be used to document the class.

By default the new class will be of type 1-body. A fill(const KVNucleus*) method will be generated which the user should complete.

For a 2-body variable, call MakeClass with type = KVVarGlob::kTwoBody. A skeleton fill2(const KVNucleus*,const KVNucleus*) method will be generated.

For a N-body variable, call MakeClass with type = KVVarGlob::kNBody. A skeleton fillN(KVEvent*) method will be generated.

Definition at line 45 of file KVVarGlob.cpp.

◆ operator double()

KVVarGlob::operator double ( ) const
inline

Definition at line 633 of file KVVarGlob.h.

◆ operator()() [1/3]

Double_t KVVarGlob::operator() ( const Char_t name) const
inline

Definition at line 491 of file KVVarGlob.h.

◆ operator()() [2/3]

Double_t KVVarGlob::operator() ( Int_t  i) const
inline

Definition at line 496 of file KVVarGlob.h.

◆ operator()() [3/3]

Double_t KVVarGlob::operator() ( void  ) const
inline

Definition at line 486 of file KVVarGlob.h.

◆ Print()

void KVVarGlob::Print ( Option_t = "") const
virtual

Reimplemented from KVBase.

Definition at line 277 of file KVVarGlob.cpp.

◆ Reset()

◆ SetDefineGroup()

void KVVarGlob::SetDefineGroup ( const KVString groupname = "")

If called, any particle which is accepted by the selection conditions will be added to a group with the name of this variable.

Parameters
[in]groupname[optional] specify different name of group

Definition at line 333 of file KVVarGlob.cpp.

◆ SetEventSelection()

void KVVarGlob::SetEventSelection ( const EventSelector f)
inline

Call this method with a lambda expression in order to define an event selection criterion based on the value of this variable. The signature of the lambda is

[](const KVVarGlob* var){ return var->GetValue()>20; }

i.e. it evaluates to bool based on the value of the global variable passed to it.

If capture by reference is used, the 'cut' can be defined later:

double my_cut;
[&](const KVVarGlob* var){ return var->GetValue("Mean")<my_cut; }

The condition will be tested by KVGVList just after calculation of this variable; if the condition is not met, no further variables will be calculated and the event will be rejected for further analysis.

Definition at line 699 of file KVVarGlob.h.

◆ SetFrame()

void KVVarGlob::SetFrame ( const Char_t ref)
inline

Sets the reference frame used for kinematical calculations. By default, i.e. if this method is not called, we use the default frame of particles which (usually) corresponds to the 'laboratory' or 'detector' frame.

The frame 'ref' must be defined before calculating global variables. See KVParticle::SetFrame and KVEvent::SetFrame methods for defining new reference frames. See KVParticle::GetFrame how to access particle kinematics in different frames.

Definition at line 505 of file KVVarGlob.h.

◆ SetMaxNumBranches()

void KVVarGlob::SetMaxNumBranches ( Int_t  n)
inline

Used for automatic TTree branch creation for multi-valued variables (see KVGVList::MakeBranches).

Normally a branch will be created for each of the \(N\) values declared with the SetNameIndex() method, but if this method is called before analysis begins with \(n<N\), only the first \(n\) branches will be used.

Note that if SetMaxNumBranches(0) is called, no branch will be created for this variable.

Definition at line 683 of file KVVarGlob.h.

◆ SetNameIndex()

void KVVarGlob::SetNameIndex ( const Char_t name,
Int_t  index 
)
private

For a multi-valued global variable, sets up the correspondance between value name and index.

These can then be used to retrieve values with GetValue("name") or GetValue(index).

When automatic branch creation in a TTree is used (see KVGVList::MakeBranches()), the names given to this method will be used to name the branches as:

  • [varName].[value0_name]
  • [varName].[value1_name]
  • ... etc.

GetNumberOfValues() returns the number of values associated with the variable, corresponding to the number of name-index associations are created by calling this method.

Definition at line 223 of file KVVarGlob.cpp.

◆ SetNewFrameDefinition()

void KVVarGlob::SetNewFrameDefinition ( const FrameSetter f)
inline

Call this method with a lambda expression in order to define a new frame for events based on the calculated value(s) of this variable.

The signature of the lambda is (the KVVarGlob pointer passed will be 'this')

[](KVEvent* e, const KVVarGlob* vg){ e->SetFrame("_frame_name_", ...); }

Definition at line 734 of file KVVarGlob.h.

◆ SetNormalization()

virtual void KVVarGlob::SetNormalization ( Double_t  norm)
inlinevirtual

Set a normalization factor for the variable.

The type of the variable's value automatically becomes 'D' (float/double).

Reimplemented in KVReactionPlaneEstimator.

Definition at line 564 of file KVVarGlob.h.

◆ SetOption()

void KVVarGlob::SetOption ( const Char_t option,
const Char_t value 
)
inline

Set a value for an option

Definition at line 521 of file KVVarGlob.h.

◆ SetParameter()

void KVVarGlob::SetParameter ( const Char_t par,
Double_t  value 
)
inline

Set the value for a parameter

before v1.12, certain global variables used a parameter to select particles force analysis to abort in case user has not updated an old analysis class

Definition at line 549 of file KVVarGlob.h.

◆ SetSelection()

void KVVarGlob::SetSelection ( const KVParticleCondition sel)
inline

Use this method to define the condition(s) which will be applied to select particles to contribute to the global variable.

Any previously set conditions are replaced by this.

Note
if a reference frame is defined for this variable, it will automatically be applied to the kinematics of the particle used for the selection. E.g. if the selection is "_NUC_->GetVpar()>0" and the reference frame is "CM", the condition will be applied to the CM parallel velocities.
See also
KVParticleCondition

Definition at line 600 of file KVVarGlob.h.

◆ TestEventSelection()

bool KVVarGlob::TestEventSelection ( ) const
inline

Called by KVGVList just after calculation of this variable; if the condition is not met, no further variables will be calculated and the event will be rejected for further analysis.

Definition at line 719 of file KVVarGlob.h.

◆ UnsetOption()

void KVVarGlob::UnsetOption ( const Char_t opt)
inline

Removes the option 'opt' from the internal lists, as if it had never been set

Definition at line 542 of file KVVarGlob.h.

◆ UnsetParameter()

void KVVarGlob::UnsetParameter ( const Char_t par)
inline

Removes the parameter 'par' from the internal lists, as if it had never been set

Definition at line 592 of file KVVarGlob.h.

Member Data Documentation

◆ fDefineGroupFromSelection

Bool_t KVVarGlob::fDefineGroupFromSelection {kFALSE}
private

Definition at line 262 of file KVVarGlob.h.

◆ fEventSelector

EventSelector KVVarGlob::fEventSelector
private

used to select events in analysis based on value of variable

Definition at line 257 of file KVVarGlob.h.

◆ fFrame

KVString KVVarGlob::fFrame
private

(optional) name of reference frame used for kinematics

Definition at line 248 of file KVVarGlob.h.

◆ fFrameSetter

FrameSetter KVVarGlob::fFrameSetter
private

used to define a new kinematical frame for event based on variable

Definition at line 259 of file KVVarGlob.h.

◆ fIsInitialized

Bool_t KVVarGlob::fIsInitialized
private

flag set after initialisation

Definition at line 247 of file KVVarGlob.h.

◆ fMaxNumBranches

Int_t KVVarGlob::fMaxNumBranches
private

max number of branches to create for multi-valued variable

Definition at line 252 of file KVVarGlob.h.

◆ fNormalization

Double_t KVVarGlob::fNormalization
private

optional normalization parameter

Definition at line 253 of file KVVarGlob.h.

◆ fOptions

KVNameValueList KVVarGlob::fOptions
private

list of options

Definition at line 249 of file KVVarGlob.h.

◆ fParameters

KVNameValueList KVVarGlob::fParameters
private

list of parameters

Definition at line 250 of file KVVarGlob.h.

◆ fSelection

KVParticleCondition KVVarGlob::fSelection
private

(optional) condition used to select particles

Definition at line 251 of file KVVarGlob.h.

◆ fType

Int_t KVVarGlob::fType
private

type of variable global; = kOneBody, kTwoBody or kNBody

Definition at line 243 of file KVVarGlob.h.

◆ fValueType

Char_t KVVarGlob::fValueType
private

type (='I' integer or 'D' double) of global variable value

Definition at line 244 of file KVVarGlob.h.

◆ nameList

KVNameValueList KVVarGlob::nameList
private

correspondence between variable name and index

Definition at line 246 of file KVVarGlob.h.