KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVVarGlob1.cpp
Go to the documentation of this file.
1 #include "KVVarGlob1.h"
2 #include "TMath.h"
3 #include "TString.h"
4 #include "Riostream.h"
5 #include "KVClassFactory.h"
6 
8 
9 
10 
23 void KVVarGlob1::MakeClass(const Char_t* classname, const Char_t* classdesc, int type)
24 {
25  //Creates skeleton '.h' and '.cpp' files for a new global variable class which
26  //inherits from this class. Give a name for the new class and a short description
27  //which will be used to document the class.
28  //
29  // By default the new class will be of type 1-body. A Fill(KVNucleus*) method
30  // will be generated which the user should complete.
31  // For a 2-body variable, call MakeClass with type = KVVarGlob::kTwoBody.
32  // A skeleton Fill2(KVNucleus*,KVNucleus*) method will be generated.
33  // For a N-body variable, call MakeClass with type = KVVarGlob::kNBody.
34  // A skeleton FillN(KVEvent*) method will be generated.
35 
36  // basic class template
37  KVClassFactory cf(classname, classdesc, "KVVarGlob1", kTRUE);
38 
39  KVString body;
40 
41  // add 'init' method
42  KVVarGlob::AddInitMethod(cf, body);
44 
45  // add 'Fill', 'Fill2', or 'FillN' method
47 
48  // body of 'Fill', 'Fill2', or 'FillN' method
50 
51  // add body of method
53 
54  cf.GenerateCode();
55 }
56 
57 
58 
62 
63 void KVVarGlob1::FillMethodBody(KVString& body, int type)
64 {
65  // PRIVATE method used by MakeClass.
66  // body of 'Fill', 'Fill2', or 'FillN' method
67 
69  switch (type) {
70  case kTwoBody:
71  body += "\n";
72  body += "Use the FillVar(v) method to increment the quantity of the global variable.\n";
73  body += "The value, v, is to be evaluated from the properties of the\n";
74  body += "two KVNucleus pointers passed as arguments.\n";
75  break;
76  case kNBody:
77  body += "\n";
78  body += "Use the FillVar(v) method to increment the quantity of the global variable.\n";
79  body += "The value, v, is to be evaluated from the properties of the\n";
80  body += "KVEvent pointer passed as argument.\n";
81  break;
82  default:
83  body += "\n";
84  body += "Use the FillVar(v) method to increment the quantity of the global variable.\n";
85  body += "The value, v, is to be evaluated from the properties of the \n";
86  body += "KVNucleus passed as argument. For example, to evaluate the sum of the charge\n";
87  body += "of all fragments, you may proceed as follows:\n";
88  body += "\n";
89  body += "FillVar(n->GetZ());\n";
90  }
91 }
92 
93 
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
char Char_t
const Bool_t kTRUE
int 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:72
Abstract base class for global variables which calculate a single value.
Definition: KVVarGlob1.h:13
static void FillMethodBody(KVString &body, int type)
Definition: KVVarGlob1.cpp:63
static void AddInitMethod(KVClassFactory &cf, KVString &body)
Definition: KVVarGlob.cpp:148
static void AddFillMethodBody(KVClassFactory &cf, KVString &body, int type)
Definition: KVVarGlob.cpp:191
static void ImplementInitMethod(KVClassFactory &cf, KVString &body, int type)
Definition: KVVarGlob.cpp:111
static void AddFillMethod(KVClassFactory &cf, int type)
Definition: KVVarGlob.cpp:164
static void FillMethodBody(KVString &body, int type)
Definition: KVVarGlob.cpp:87