KaliVeda
Toolkit for HIC analysis
KVGVList.h
1 #ifndef KVGVList_h
2 #define KVGVList_h
3 #include "KVVarGlob.h"
4 #include "KVUniqueNameList.h"
5 #include "KVParticleCondition.h"
6 #include "TTree.h"
7 #include "KVEventClassifier.h"
8 
9 #include <KVUnownedList.h>
10 
26 
48 
56 
101 
138 
143 
178 
226 
227 class KVGVList: public KVUniqueNameList {
228 
230  std::vector<Double_t> fBranchVar;
231  std::vector<Int_t> fIBranchVar;
235 
237  TString NameSanitizer(const Char_t* s) const
238  {
239  TString _s(s);
240  _s.ReplaceAll("+", "_");
241  _s.ReplaceAll("*", "_");
242  _s.ReplaceAll("-", "_");
243  _s.ReplaceAll("/", "_");
244  _s.ReplaceAll("=", "_");
245  return _s;
246  }
247  KVVarGlob* prepareGVforAdding(const Char_t* class_name, const Char_t* name);
248 #ifdef KVGVLIST_OPTIMIZE_GVLIST
249  KVList fOptimList;
250  struct optigvlist : public TObject {
251  KVUnownedList one_body;
252  KVUnownedList two_body;
253  KVUnownedList N_body;
254  bool has_two_body = false;
255  bool has_N_body = false;
256  void ls(Option_t* option = "") const
257  {
258  one_body.ls(option);
259  two_body.ls(option);
260  N_body.ls(option);
261  }
262  template<typename call_func>
263  void iterate(KVUnownedList* l, call_func F)
264  {
265  KVVarGlob* vg;
266  TIter it(l);
267  while ((vg = (KVVarGlob*)it())) {
268  F(vg);
269  }
270  }
271  template<typename call_func>
272  void iterate_with_test(KVUnownedList* l, call_func F)
273  {
274  KVVarGlob* vg;
275  TIter it(l);
276  while ((vg = (KVVarGlob*)it())) {
277  if (!F(vg)) break;
278  }
279  }
280  template<typename call_func>
281  void iterate_one_body(call_func F)
282  {
283  iterate(&one_body, F);
284  }
285  template<typename call_func>
286  void iterate_two_body(call_func F)
287  {
288  iterate(&two_body, F);
289  }
290  template<typename call_func>
291  void iterate_N_body(call_func F)
292  {
293  iterate(&N_body, F);
294  }
295  template<typename call_func>
296  void iterate_one_body_with_test(call_func F)
297  {
298  iterate_with_test(&one_body, F);
299  }
300  template<typename call_func>
301  void iterate_two_body_with_test(call_func F)
302  {
303  iterate_with_test(&two_body, F);
304  }
305  template<typename call_func>
306  void iterate_N_body_with_test(call_func F)
307  {
308  iterate_with_test(&N_body, F);
309  }
310  };
311  void optimise_variable_lists();
312 #endif
313 protected:
314  void init_KVGVList(void);
318  void Fill(const KVNucleus* c);
319  void Fill2(const KVNucleus* c1, const KVNucleus* c2);
320  void FillN(const KVEvent* e);
321  void Calculate();
322  void Calculate2();
323  void CalculateN();
324 
325 public:
326  KVGVList(const KVString& name = "default", const KVParticleCondition& selection
327  = KVParticleCondition{"OK", [](const KVNucleus * n)
328  {
329  return n->IsOK();
330  }});
331  KVGVList(const KVGVList& a);
332 
333  KVVarGlob* AddGV(const Char_t* class_name, const Char_t* name);
334  KVVarGlob* AddGVFirst(const Char_t* class_name, const Char_t* name);
335 
336  void Init(void);
337  void Reset(void);
338 
340 
341  KVVarGlob* GetGV(const Char_t* nom) const; //find global variable with name 'nom'
342 
344  KVVarGlob* GetGVType(const Char_t* class_name)
345  {
346  return (KVVarGlob*)FindObjectByClass(class_name);
347  }
348  virtual void Add(TObject* obj) ;
349  virtual void AddFirst(TObject* obj) ;
350 
353  {
354  return (fVG1.GetEntries() > 0);
355  }
356 
359  {
360  return (fVG2.GetEntries() > 0);
361  }
362 
365  {
366  return (fVGN.GetEntries() > 0);
367  }
368 
369  void MakeBranches(TTree*);
370  void FillBranches();
371 
372  bool AbortEventAnalysis() const
373  {
374  return fAbortEventAnalysis;
375  }
376  KVEventClassifier* AddEventClassifier(const TString& varname, const TString& value = "");
377 
378  ClassDef(KVGVList, 3) // List of global variables
379 };
380 #endif
int Int_t
bool Bool_t
char Char_t
const char Option_t
#define ClassDef(name, id)
Simple class for sorting events according to global variables.
Abstract base class container for multi-particle events.
Definition: KVEvent.h:67
#define KVGVLIST_OPTIMIZE_GVLIST
Definition: KVGVList.h:227
Bool_t Has1BodyVariables()
returns kTRUE if list contains 1-body variables
Definition: KVGVList.h:352
void FillBranches()
Definition: KVGVList.cpp:516
KVParticleCondition fSelection
used to select particles to iterate over in event
Definition: KVGVList.h:229
KVVarGlob * AddGVFirst(const Char_t *class_name, const Char_t *name)
Definition: KVGVList.cpp:843
Int_t fNbIBranch
Definition: KVGVList.h:233
void Reset(void)
Reset all variables before treating an event.
Definition: KVGVList.cpp:83
void Init(void)
Definition: KVGVList.cpp:66
std::vector< Double_t > fBranchVar
used for automatic creation & filling of TTree branches
Definition: KVGVList.h:230
Bool_t HasNBodyVariables()
returns kTRUE if list contains N-body variables
Definition: KVGVList.h:364
TList fVG2
two-body variables
Definition: KVGVList.h:316
TString NameSanitizer(const Char_t *s) const
Definition: KVGVList.h:237
Int_t fNbBranch
Definition: KVGVList.h:232
virtual void AddFirst(TObject *obj)
Definition: KVGVList.cpp:373
void Calculate2()
Calculate all 2-body observables after filling.
Definition: KVGVList.cpp:158
void CalculateN()
Calculate all N-body observables after filling.
Definition: KVGVList.cpp:177
void CalculateGlobalVariables(KVEvent *e)
Definition: KVGVList.cpp:206
KVGVList(const KVString &name="default", const KVParticleCondition &selection=KVParticleCondition{"OK", [](const KVNucleus *n) { return n->IsOK();}})
Definition: KVGVList.cpp:33
bool fAbortEventAnalysis
set to false if a global variable fails its own event selection criterion
Definition: KVGVList.h:234
void FillN(const KVEvent *e)
Calls KVVarGlob::FillN(KVEvent*) method of all N-body variables in the list.
Definition: KVGVList.cpp:128
std::vector< Int_t > fIBranchVar
used for automatic creation & filling of TTree branches
Definition: KVGVList.h:231
KVEventClassifier * AddEventClassifier(const TString &varname, const TString &value="")
Definition: KVGVList.cpp:612
TList fVGN
N-body variables.
Definition: KVGVList.h:317
void Calculate()
Calculate all 1-body observables after filling.
Definition: KVGVList.cpp:139
KVVarGlob * prepareGVforAdding(const Char_t *class_name, const Char_t *name)
Definition: KVGVList.cpp:747
TList fVG1
one-body variables
Definition: KVGVList.h:315
KVVarGlob * AddGV(const Char_t *class_name, const Char_t *name)
Definition: KVGVList.cpp:705
virtual void Add(TObject *obj)
Definition: KVGVList.cpp:336
void Fill(const KVNucleus *c)
Definition: KVGVList.cpp:97
void init_KVGVList(void)
Definition: KVGVList.cpp:16
KVVarGlob * GetGVType(const Char_t *class_name)
Returns first global variable in list with given class.
Definition: KVGVList.h:344
void MakeBranches(TTree *)
Definition: KVGVList.cpp:418
KVVarGlob * GetGV(const Char_t *nom) const
Return pointer to global variable in list with name 'nom'.
Definition: KVGVList.cpp:319
Bool_t Has2BodyVariables()
returns kTRUE if list contains 2-body variables
Definition: KVGVList.h:358
bool AbortEventAnalysis() const
Definition: KVGVList.h:372
void Fill2(const KVNucleus *c1, const KVNucleus *c2)
Definition: KVGVList.cpp:114
Extended TList class which owns its objects by default.
Definition: KVList.h:28
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:126
TObject * FindObjectByClass(const Char_t *) const
Return (first) object in embedded list with given class.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Optimised list in which named objects can only be placed once.
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:17
Base class for all global variable implementations.
Definition: KVVarGlob.h:233
void ls(Option_t *option="") const override
virtual Int_t GetEntries() const
TString & ReplaceAll(const char *s1, const char *s2)
const Int_t n
#define F(x, y, z)
int iterate(rng_state_t *X)