KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVVGSum.cpp
1/*
2$Id: KVVGSum.cpp,v 1.2 2009/01/23 15:25:52 franklan Exp $
3$Revision: 1.2 $
4$Date: 2009/01/23 15:25:52 $
5*/
6
7//Created by KVClassFactory on Thu Nov 16 10:42:38 2006
8//Author: John Frankland
9
10#include "KVVGSum.h"
11#include "TClass.h"
12#include "TROOT.h"
13
15
16
17
18
19
20
21void KVVGSum::init(void)
22{
23 ClearNameIndex();
24 SetMaxNumBranches(-1);
25 fClass = nullptr;
26 fVal = 0;
27}
28
29
30
31
33
35{
36 if (fMethod.get()) {
37 fMethod->Execute(const_cast<KVNucleus*>(c), fVal);
38 FillVar(fVal, 1);
39 }
40 else
41 FillVar(1, 1);
42}
43
44
45
46
51
53{
54 //Must be called at least once before beginning calculation in order to
55 //set mode of operation, get pointer to method used to calculate variable,
56 //etc. etc.
57
59
60 if (TestBit(kInitDone)) return;
61
63
64 //Analyse options and set internal flags
65 //Info("Init", "Called for %s", GetName());
66
67 //SET MODE OF OPERATION
68 if (GetOptionString("mode") == "mult") {
70 fValueType = 'I'; // integer type for automatic TTree branch
71 SetNameIndex("Mult", 4);
72 }
73 else if (GetOptionString("mode") == "sum") {
74 SetBit(kSum);
75 SetNameIndex("Sum", 2);
76 }
77 else if (GetOptionString("mode") == "mean") {
79 // redefine "Mean" and "RMS" indices
80 SetNameIndex("Mean", 0);
81 SetNameIndex("RMS", 1);
82 }
83 else SetBit(kSum); //sum by default if unknown mode given
84
85 //Info("Init", "mode=%s", GetOptionString("mode").Data());
86
87 //SET UP METHOD CALL
88 if (IsOptionGiven("class")) fClass = TClass::GetClass(GetOptionString("class"));
89 else fClass = TClass::GetClass("KVNucleus");
90
91 if (!fClass) {
92 Fatal("Init", "Failed to load class requested as option: %s", GetOptionString("class").Data());
93 }
94 if (IsOptionGiven("method")) {
95 if (IsOptionGiven("args"))
96 fMethod.reset(new TMethodCall(fClass, GetOptionString("method").Data(), GetOptionString("args").Data()));
97 else
98 fMethod.reset(new TMethodCall(fClass, GetOptionString("method").Data(), ""));
99 //Info("Init", "Method = %s Params = %s", fMethod->GetMethodName(),
100 // fMethod->GetParams());
101 // if we are summing an integer quantity, make automatic TTree branch with integer type
102 if (fMethod->ReturnType() == TMethodCall::kLong && TestBit(kSum)) fValueType = 'I';
103 }
104}
105
106
107
Cppyy::TCppType_t fClass
#define c(i)
Description of properties and kinematics of atomic nuclei.
Definition KVNucleus.h:126
General global variable for calculating sums of various quantities.
Definition KVVGSum.h:100
void fill(const KVNucleus *c)
Definition KVVGSum.cpp:34
@ kMult
Definition KVVGSum.h:107
@ kInitDone
Definition KVVGSum.h:111
@ kMean
Definition KVVGSum.h:109
Double_t fVal
used to retrieve value of property for each particle
Definition KVVGSum.h:104
void Init()
Definition KVVGSum.cpp:52
std::unique_ptr< TMethodCall > fMethod
method used to extract property of interest from particles
Definition KVVGSum.h:103
TClass * fClass
class used to represent particles
Definition KVVGSum.h:102
void FillVar(Double_t v, Double_t w=1.)
void SetNameIndex(const Char_t *name, Int_t index)
TString GetOptionString(const Char_t *opt) const
Definition KVVarGlob.h:536
Bool_t IsOptionGiven(const Char_t *opt)
Definition KVVarGlob.h:529
Char_t fValueType
type (='I' integer or 'D' double) of global variable value
Definition KVVarGlob.h:244
static const EReturnType kLong
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Fatal(const char *method, const char *msgfmt,...) const
ClassImp(TPyArg)