5#include "KVNucleusEvent.h"
7#include <KVUnownedList.h>
73#ifdef KVGVLIST_OPTIMIZE_GVLIST
74 optimise_variable_lists();
222#ifdef KVGVLIST_OPTIMIZE_GVLIST
223 TIter nxt_list(&fOptimList);
224 optigvlist* current_list;
225 while (current_list = (optigvlist*)nxt_list()) {
227 current_list->iterate_one_body([&it](
KVVarGlob * vg) {
229 vg->
Fill(it.get_const_pointer());
232 if (current_list->has_two_body) {
233 for (
auto it2 = it; it2 != KVNucleusEvent::Iterator::End(); ++it2) {
235 current_list->iterate_two_body([&it, &it2](
KVVarGlob * vg) {
236 vg->
Fill2(it.get_const_pointer(), it2.get_const_pointer());
242 if (current_list->has_N_body) {
243 current_list->iterate_N_body([
e](
KVVarGlob * vg) {
249 current_list->iterate_one_body_with_test([&](
KVVarGlob * vg) {
258 if (current_list->has_two_body) {
259 current_list->iterate_two_body_with_test([&](
KVVarGlob * vg) {
269 if (current_list->has_N_body) {
270 current_list->iterate_N_body_with_test([&](
KVVarGlob * vg) {
294 for (
auto it2 = it; it2 != KVNucleusEvent::Iterator::End(); ++it2) {
296 vg->
Fill2(it.get_const_pointer(), it2.get_const_pointer());
300 vg->
Fill(it.get_const_pointer());
347 Warning(
"Add",
"You tried to add a global variable with the same name as one already in the list");
348 Warning(
"Add",
"Only the first variable added to the list will be used: name=%s class=%s",
350 Warning(
"Add",
"The following global variable (the one you tried to add) will be ignored:");
384 Warning(
"AddFirst",
"You tried to add a global variable with the same name as one already in the list");
385 Warning(
"AddFirst",
"Only the first variable added to the list will be used: name=%s class=%s",
387 Warning(
"AddFirst",
"The following global variable (the one you tried to add) will be ignored:");
664 Warning(
"AddEventClassifier",
"Variable %s not found in list. No classification possible.", varname.
Data());
750 TClass* clas = TClass::GetClass(class_name);
756 Error(
"AddGV(const Char_t*,const Char_t*)",
757 "Called with class_name=%s.\nClass is unknown: not in standard libraries, and plugin (user-defined class) not found",
766 Error(
"AddGV(const Char_t*,const Char_t*)",
767 "%s is not a valid class deriving from KVVarGlob.",
776 gPluginMgr->
AddHandler(
"KVVarGlob", class_name, class_name,
"KVMultiDetglobvars",
Form(
"%s(const char*)", class_name));
785#ifdef KVGVLIST_OPTIMIZE_GVLIST
794void KVGVList::optimise_variable_lists()
802 if (fOptimList.GetEntries())
return;
804 optigvlist* current_list =
new optigvlist;
805 fOptimList.Add(current_list);
807 TIter next_var(
this);
811 if ((last_vg->IsSelectingEvents() && !vg->
IsSelectingEvents()) || (last_vg->IsDefiningNewFrame())) {
814 current_list =
new optigvlist;
815 fOptimList.Add(current_list);
819 current_list->N_body.Add(vg);
820 current_list->has_N_body =
true;
823 current_list->two_body.Add(vg);
824 current_list->has_two_body =
true;
827 current_list->one_body.Add(vg);
831 Info(
"optimise_variable_lists",
"After optimization, global variables have been separated into %d lists as follows:", fOptimList.GetEntries());
#define R__FOR_EACH(type, proc)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TPluginManager * gPluginMgr
char * Form(const char *fmt,...)
Class for iterating over nuclei in events accessed through base pointer/reference.
static TPluginHandler * LoadPlugin(const Char_t *base, const Char_t *uri="0")
Simple class for sorting events according to global variables.
Abstract base class container for multi-particle events.
#define KVGVLIST_OPTIMIZE_GVLIST
KVParticleCondition fSelection
used to select particles to iterate over in event
KVVarGlob * AddGVFirst(const Char_t *class_name, const Char_t *name)
void Reset(void)
Reset all variables before treating an event.
std::vector< Double_t > fBranchVar
used for automatic creation & filling of TTree branches
TList fVG2
two-body variables
TString NameSanitizer(const Char_t *s) const
virtual void AddFirst(TObject *obj)
void Calculate2()
Calculate all 2-body observables after filling.
void CalculateN()
Calculate all N-body observables after filling.
void CalculateGlobalVariables(KVEvent *e)
KVGVList(const KVString &name="default", const KVParticleCondition &selection=KVParticleCondition{"OK", [](const KVNucleus *n) { return n->IsOK();}})
bool fAbortEventAnalysis
set to false if a global variable fails its own event selection criterion
void FillN(const KVEvent *e)
Calls KVVarGlob::FillN(KVEvent*) method of all N-body variables in the list.
std::vector< Int_t > fIBranchVar
used for automatic creation & filling of TTree branches
KVEventClassifier * AddEventClassifier(const TString &varname, const TString &value="")
TList fVGN
N-body variables.
void Calculate()
Calculate all 1-body observables after filling.
KVVarGlob * prepareGVforAdding(const Char_t *class_name, const Char_t *name)
TList fVG1
one-body variables
KVVarGlob * AddGV(const Char_t *class_name, const Char_t *name)
virtual void Add(TObject *obj)
void Fill(const KVNucleus *c)
void MakeBranches(TTree *)
KVVarGlob * GetGV(const Char_t *nom) const
Return pointer to global variable in list with name 'nom'.
void Fill2(const KVNucleus *c1, const KVNucleus *c2)
Description of properties and kinematics of atomic nuclei.
virtual TObject * FindObject(const char *name) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Optimised list in which named objects can only be placed once.
Bool_t ObjectAdded() const
virtual void Add(TObject *obj)
virtual void AddFirst(TObject *obj)
Base class for all global variable implementations.
virtual void Calculate()=0
virtual Int_t GetNumberOfValues() const
Double_t GetValue(void) const
void Fill(const KVNucleus *c)
virtual void FillN(const KVEvent *)
Int_t GetNumberOfBranches() const
bool IsSelectingEvents() const
void Fill2(const KVNucleus *n1, const KVNucleus *n2)
virtual Bool_t IsGlobalVariable() const
virtual TString GetValueName(Int_t i) const
virtual Char_t GetValueType(Int_t) const
void DefineNewFrame(KVEvent *e) const
bool TestEventSelection() const
void Copy(TObject &arc) const override
Bool_t InheritsFrom(const char *cl) const override
void SetName(const char *name)
void Add(TObject *obj) override
const char * GetName() const override
virtual const char * GetName() const
virtual const char * ClassName() const
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Error(const char *method, const char *msgfmt,...) const
virtual void Print(Option_t *option="") const
virtual void Info(const char *method, const char *msgfmt,...) const
Longptr_t ExecPlugin(int nargs)
void AddHandler(const char *base, const char *regexp, const char *className, const char *pluginName, const char *ctor=nullptr, const char *origin=nullptr)
const char * Data() const
TString & ReplaceAll(const char *s1, const char *s2)