KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVVarGlobMean.cpp
1#include "Riostream.h"
2#include "KVVarGlobMean.h"
3#include "KVClassFactory.h"
4
6
7
8
9
10void KVVarGlobMean::init(void)
11{
12 SetNameIndex("Mean", 0);
13 SetNameIndex("RMS", 1);
14 SetNameIndex("SumVar", 2);
15 SetNameIndex("SumVarSquared", 3);
16 SetNameIndex("SumOfWeights", 4);
17 SetNameIndex("Min", 5);
18 SetNameIndex("Max", 6);
19
20 SetMaxNumBranches(2);
21}
22
23
24
26
28{
29 svar += w * v;
30 svar2 += w * v * v;
31 sw += w;
32 if (v > max) max = v;
33 if (v < min) min = v;
34 calc = 0;
35}
36
37
38
40
42{
43 if (!calc) {
44 if (sw != 0) {
45 var = svar / sw;
46 if (svar2 / sw >= var * var) {
47 ect = TMath::Sqrt(svar2 / sw - var * var);
48 }
49 else {
50 ect = -1.;
51 }
52 }
53 else {
54 var = 0.;
55 ect = -1.;
56 }
57 calc = 1;
58 }
59}
60
61
62
65
67{
68 // Copy this to a
69
71 KVVarGlobMean& _a = dynamic_cast<KVVarGlobMean&>(a);
72 _a.ect = ect;
73 _a.svar = svar;
74 _a.svar2 = svar2;
75 _a.sw = sw;
76 _a.min = min;
77 _a.max = max;
78 _a.calc = calc;
79}
80
81
82
84
86{
87 var = 0;
88 ect = 0;
89 svar = 0;
90 svar2 = 0;
91 sw = 0;
92 min = 1e6;
93 max = -1e6;
94 calc = 0;
95}
96
97
98
100
102{
103 Reset();
104}
105
106
107
109
111{
112 Double_t rval = 0;
113 switch (i) {
114 case 0:
115 rval = var;
116 break;
117
118 case 1:
119 rval = ect;
120 break;
121
122 case 2:
123 rval = svar;
124 break;
125
126 case 3:
127 rval = svar2;
128 break;
129
130 case 4:
131 rval = sw;
132 break;
133
134 case 5:
135 rval = min;
136 break;
137
138 case 6:
139 rval = max;
140 break;
141
142 default:
143 rval = 0.;
144 break;
145 }
146 return rval;
147}
148
149
150
163
164void KVVarGlobMean::MakeClass(const Char_t* classname, const Char_t* classdesc, int type)
165{
166 //Creates skeleton '.h' and '.cpp' files for a new global variable class which
167 //inherits from this class. Give a name for the new class and a short description
168 //which will be used to document the class.
169 //
170 // By default the new class will be of type 1-body. A Fill(KVNucleus*) method
171 // will be generated which the user should complete.
172 // For a 2-body variable, call MakeClass with type = KVVarGlob::kTwoBody.
173 // A skeleton Fill2(KVNucleus*,KVNucleus*) method will be generated.
174 // For a N-body variable, call MakeClass with type = KVVarGlob::kNBody.
175 // A skeleton FillN(KVEvent*) method will be generated.
176
177 // basic class template
178 KVClassFactory cf(classname, classdesc, "KVVarGlobMean", kTRUE);
179
180 KVString body;
181
182 // add 'init' method
183 KVVarGlob::AddInitMethod(cf, body);
185
186 // add 'Fill', 'Fill2', or 'FillN' method
188
189 // body of 'Fill', 'Fill2', or 'FillN' method
191
192 // add body of method
194
195 cf.GenerateCode();
196}
197
198
199
203
205{
206 // PRIVATE method used by MakeClass.
207 // body of 'Fill', 'Fill2', or 'FillN' method
208
210 switch (type) {
211 case kTwoBody:
212 body += "\n";
213 body += "Use the FillVar(v,w) method to increment the quantity of the global variable.\n";
214 body += "The value, v, and the weight, w, are to be evaluated from the properties of the\n";
215 body += "two KVNucleus pointers passed as argument.\n";
216 break;
217 case kNBody:
218 body += "\n";
219 body += "Use the FillVar(v,w) method to increment the quantity of the global variable.\n";
220 body += "The value, v, and the weight, w, are to be evaluated from the properties of the\n";
221 body += "KVEvent pointer passed as argument.\n";
222 break;
223 default:
224 body += "\n";
225 body += "Use the FillVar(v,w) method to increment the quantity of the global variable.\n";
226 body += "The value, v, and the weight, w, are to be evaluated from the properties of the \n";
227 body += "KVNucleus passed as argument. For example, to evaluate the mean parallel velocity\n";
228 body += "weighted by the charge of the nucleus, you may proceed as follows:\n";
229 body += "\n";
230 body += "FillVar(n->GetVpar(), n->GetZ());\n";
231 }
232}
233
234
235
int Int_t
char Char_t
double Double_t
constexpr Bool_t kTRUE
winID w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Factory class for generating skeleton files for new classes.
void GenerateCode()
Generate header and implementation file for currently-defined class.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73
Abstract base class for global variables which calculate a mean value.
static void MakeClass(const Char_t *classname, const Char_t *classdesc, int type=KVVarGlob::kOneBody)
static void FillMethodBody(KVString &body, int type)
virtual Double_t getvalue_int(Int_t i) const
void FillVar(Double_t v, Double_t w=1.)
void Copy(TObject &obj) const
Copy this to a.
static void AddInitMethod(KVClassFactory &cf, KVString &body)
void Copy(TObject &obj) const
Definition KVVarGlob.h:346
static void AddFillMethodBody(KVClassFactory &cf, KVString &body, int type)
static void ImplementInitMethod(KVClassFactory &cf, KVString &body, int type)
static void AddFillMethod(KVClassFactory &cf, int type)
static void FillMethodBody(KVString &body, int type)
Definition KVVarGlob.cpp:87
Double_t Sqrt(Double_t x)
v
TArc a
ClassImp(TPyArg)