CbmRoot
Loading...
Searching...
No Matches
PDataBase.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: I. Froehlich, Florian Uhlig [committer] */
4
5// Author: I. Froehlich
6// Written: 11.04.2007
7// Revised:
8// PDataBase
9// Replacement for the particle data base in PData
10
11#ifndef _PDATABASE_H_
12#define _PDATABASE_H_
13
14#include "TROOT.h"
15
16#include <iostream>
17
18#include "Pdefines.h"
19
20#define PDATABASE_MAX_DOUBLE_PARAM 20
21#define PDATABASE_MAX_STRING_PARAM 20
22#define PDATABASE_MAX_INT_PARAM 150
23#define PDATABASE_MAX_TOBJ_PARAM 10
24
25#define PDATABASE_MAX_LINES 1000
26
27using namespace std;
28
29class PDataBase;
32
33class PDataBase : public TObject {
34
35private:
36 //Entries properties
37 const char* param_double_name[PDATABASE_MAX_DOUBLE_PARAM]; //the parameter name matching the ID
41 const char* param_double_descr[PDATABASE_MAX_DOUBLE_PARAM]; //the parameter long description
49
50 //TODO: Params need description
51
54
55 //The entries array itself
56 //for each entry, we add the pointer array to our params
61
62 Int_t lastkey;
63
64 Bool_t CheckEntry(Int_t key); //check if key with unique name already existing
65 Int_t ConvertParamKey(const char*& newparamname, Int_t key);
66
67public:
68 //constructor
69 PDataBase();
70
71 void Performance(void);
72
73 void SetFastKey(Int_t pkey, Int_t maxkey);
74
75 //return value of the makeParam's: the param_id of -1 on failure
76 Int_t MakeParamDouble(const char* paramname,
77 const char* descr); //add "paramname" to double database
78 Int_t MakeParamString(const char* paramname,
79 const char* descr); //add "paramname" to string database
80 Int_t MakeParamInt(const char* paramname,
81 const char* descr); //add "paramname" to int database
82 Int_t MakeParamTObj(const char* paramname,
83 const char* descr); //add "paramname" to object database
84
85 Int_t GetParamDouble(const char* paramname); //get "paramname" from double database
86 Int_t GetParamString(const char* paramname); //get "paramname" from string database
87 Int_t GetParamInt(const char* paramname,
88 Int_t length = -1); //get "paramname" from string database
89 Int_t GetParamTObj(const char* paramname);
90
91 TString GetDescription(const char* paramname);
92
93 void GetFastParamInt(const char* paramname, Int_t* pkey)
94 {
95 if ((*pkey) < 0) *pkey = GetParamInt(paramname);
96 };
97 void GetFastParamString(const char* paramname, Int_t* pkey)
98 {
99 if ((*pkey) < 0) *pkey = GetParamString(paramname);
100 };
101 void GetFastParamDouble(const char* paramname, Int_t* pkey)
102 {
103 if ((*pkey) < 0) *pkey = GetParamDouble(paramname);
104 };
105 void GetFastParamTObj(const char* paramname, Int_t* pkey)
106 {
107 if ((*pkey) < 0) *pkey = GetParamTObj(paramname);
108 };
109
110 using TObject::GetName;
111 const char* GetName(Int_t key);
112 //getting particle/decay properties from data base
113 //return kFALSE if 1.) key not existing or 2.) Param not existing or 3.) Param not used for entry
114 Bool_t GetParamDouble(Int_t key, const char* paramname, Double_t** result);
115 Bool_t GetParamString(Int_t key, const char* paramname, const char** result);
116 Bool_t GetParamInt(Int_t key, const char* paramname, Int_t** result, Int_t length = -1);
117 Bool_t GetParamTObj(Int_t key, const char* paramname, TObject** result);
118
119 //same as above but with the pkey as obtained by the getFastParam's
120 Bool_t GetParamInt(Int_t key, Int_t pkey, Int_t** result);
121 Bool_t GetParamString(Int_t key, Int_t pkey, const char** result);
122 Bool_t GetParamDouble(Int_t key, Int_t pkey, Double_t** result);
123 Bool_t GetParamTObj(Int_t key, Int_t pkey, TObject** result);
124
125 //setting value instead of pointer
126 Bool_t GetParamInt(Int_t key, Int_t pkey, Int_t* result)
127 {
128 Int_t* p;
129 Bool_t b = GetParamInt(key, pkey, &p);
130 if (b && p) *result = *p;
131 else
132 *result = 0;
133 return b;
134 };
135
136 //getting param by primary name
137 Bool_t GetParamInt(const char* name, const char* paramname, Int_t** result)
138 {
139 return GetParamInt(GetEntry(name), paramname, result);
140 };
141 Bool_t GetParamDouble(const char* name, const char* paramname, Double_t** result)
142 {
143 return GetParamDouble(GetEntry(name), paramname, result);
144 };
145 Bool_t GetParamString(const char* name, const char* paramname, const char** result)
146 {
147 return GetParamString(GetEntry(name), paramname, result);
148 };
149 Bool_t GetParamTObj(const char* name, const char* paramname, TObject** result)
150 {
151 return GetParamTObj(GetEntry(name), paramname, result);
152 };
153
154 //Getting param by matching integer value
155 Bool_t GetParamInt(const char* paramname1, Int_t value1, const char* paramname2, Int_t** result)
156 {
157 return GetParamInt(GetEntryInt(paramname1, value1), paramname2, result);
158 };
159 Bool_t GetParamDouble(const char* paramname1, Int_t value1, const char* paramname2, Double_t** result)
160 {
161 return GetParamDouble(GetEntryInt(paramname1, value1), paramname2, result);
162 };
163 Bool_t GetParamString(const char* paramname1, Int_t value1, const char* paramname2, const char** result)
164 {
165 return GetParamString(GetEntryInt(paramname1, value1), paramname2, result);
166 };
167 Bool_t GetParamTObj(const char* paramname1, Int_t value1, const char* paramname2, TObject** result)
168 {
169 return GetParamTObj(GetEntryInt(paramname1, value1), paramname2, result);
170 };
171
172 //same as above when the pkey are known...
173 Bool_t GetParamInt(Int_t pkey1, Int_t value1, Int_t pkey2, Int_t** result)
174 {
175 // cout << pkey1 << ":" << value1<< ":" << pkey2<< ":" << endl;
176 return GetParamInt(GetEntryInt(pkey1, value1), pkey2, result);
177 };
178 Bool_t GetParamDouble(Int_t pkey1, Int_t value1, Int_t pkey2, Double_t** result)
179 {
180 return GetParamDouble(GetEntryInt(pkey1, value1), pkey2, result);
181 };
182 Bool_t GetParamString(Int_t pkey1, Int_t value1, Int_t pkey2, const char** result)
183 {
184 return GetParamString(GetEntryInt(pkey1, value1), pkey2, result);
185 };
186 Bool_t GetParamTObj(Int_t pkey1, Int_t value1, Int_t pkey2, TObject** result)
187 {
188 return GetParamTObj(GetEntryInt(pkey1, value1), pkey2, result);
189 };
190
191
192 Bool_t SetParamDouble(Int_t key, const char* paramname, Double_t* result);
193 Bool_t SetParamString(Int_t key, const char* paramname, char* result);
194 Bool_t SetParamInt(Int_t key, const char* paramname, Int_t* result);
195 Bool_t SetParamTObj(Int_t key, const char* paramname, TObject* result);
196
197 //faster:
198 Bool_t SetParamTObj(Int_t key, Int_t pp, TObject* result);
199
200 Bool_t SetParamDouble(const char* name, const char* paramname, Double_t result)
201 {
202 Int_t key = GetEntry(name);
203 if (key < 0) return kFALSE;
204 return SetParamDouble(key, paramname, new Double_t(result));
205 }
206 Bool_t SetParamInt(const char* name, const char* paramname, Int_t result)
207 {
208 Int_t key = GetEntry(name);
209 if (key < 0) return kFALSE;
210 return SetParamInt(key, paramname, new Int_t(result));
211 }
212 Bool_t SetParamString(const char* name, const char* paramname, char* result)
213 {
214 Int_t key = GetEntry(name);
215 if (key < 0) return kFALSE;
216 return SetParamString(key, paramname, result);
217 };
218 Bool_t SetParamTObj(const char* name, const char* paramname, TObject* result)
219 {
220 Int_t key = GetEntry(name);
221 if (key < 0) return kFALSE;
222 return SetParamTObj(key, paramname, result);
223 };
224
225 //Dealing with the entries
226 Bool_t AddEntry(Int_t key, const char* name);
227 Int_t AddEntry(const char* name);
228 Int_t GetEntry(const char* name);
229 Int_t GetEntryInt(const char* paramname, Int_t value);
230 Int_t GetEntryInt(Int_t pkey, Int_t value);
231
232 //listings
233 Int_t AddListEntry(const char* name, const char* count, const char* link, const char* newname);
234 Bool_t MakeListIterator(Int_t key, const char* count, const char* link, Int_t* listkey);
235 Bool_t MakeListIterator(Int_t key, Int_t count, Int_t link, Int_t* listkey);
236
237 Bool_t ListEntries(Int_t key = -1, Int_t option = 0, const char* pattern = nullptr);
238
239 void Print(const Option_t* delme) const;
240
241
242 ClassDef(PDataBase, 0); //Relational data base for pluto
243};
244
245#endif
#define PDATABASE_MAX_INT_PARAM
Definition PDataBase.h:22
#define PDATABASE_MAX_TOBJ_PARAM
Definition PDataBase.h:23
#define PDATABASE_MAX_LINES
Definition PDataBase.h:25
PDataBase * makeDataBase()
Definition PDataBase.cxx:22
#define PDATABASE_MAX_STRING_PARAM
Definition PDataBase.h:21
PDataBase & fDataBase()
Definition PDataBase.cxx:16
#define PDATABASE_MAX_DOUBLE_PARAM
Definition PDataBase.h:20
const char * param_double_descr[PDATABASE_MAX_DOUBLE_PARAM]
Definition PDataBase.h:41
Int_t param_int_pointer
Definition PDataBase.h:47
ClassDef(PDataBase, 0)
Bool_t SetParamTObj(Int_t key, const char *paramname, TObject *result)
Bool_t SetParamInt(const char *name, const char *paramname, Int_t result)
Definition PDataBase.h:206
Bool_t GetParamString(const char *name, const char *paramname, const char **result)
Definition PDataBase.h:145
Int_t MakeParamDouble(const char *paramname, const char *descr)
void GetFastParamDouble(const char *paramname, Int_t *pkey)
Definition PDataBase.h:101
Bool_t GetParamDouble(const char *name, const char *paramname, Double_t **result)
Definition PDataBase.h:141
Bool_t SetParamTObj(const char *name, const char *paramname, TObject *result)
Definition PDataBase.h:218
TObject * tobjs[PDATABASE_MAX_LINES][PDATABASE_MAX_TOBJ_PARAM]
Definition PDataBase.h:60
Int_t param_tobj_pointer
Definition PDataBase.h:48
Bool_t GetParamTObj(Int_t pkey1, Int_t value1, Int_t pkey2, TObject **result)
Definition PDataBase.h:186
Bool_t AddEntry(Int_t key, const char *name)
Int_t MakeParamTObj(const char *paramname, const char *descr)
Bool_t GetParamTObj(const char *paramname1, Int_t value1, const char *paramname2, TObject **result)
Definition PDataBase.h:167
Int_t * param_int_key[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:52
void Print(const Option_t *delme) const
Definition PDataBase.cxx:56
Double_t * doubles[PDATABASE_MAX_LINES][PDATABASE_MAX_DOUBLE_PARAM]
Definition PDataBase.h:58
Int_t GetParamDouble(const char *paramname)
Int_t GetParamString(const char *paramname)
Int_t GetParamTObj(const char *paramname)
Bool_t SetParamString(const char *name, const char *paramname, char *result)
Definition PDataBase.h:212
Int_t MakeParamInt(const char *paramname, const char *descr)
TString GetDescription(const char *paramname)
const char * param_string_descr[PDATABASE_MAX_STRING_PARAM]
Definition PDataBase.h:42
const char * param_tobj_descr[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:44
const char * param_string_name[PDATABASE_MAX_STRING_PARAM]
Definition PDataBase.h:38
Bool_t GetParamInt(Int_t key, Int_t pkey, Int_t *result)
Definition PDataBase.h:126
void GetFastParamInt(const char *paramname, Int_t *pkey)
Definition PDataBase.h:93
Bool_t SetParamDouble(Int_t key, const char *paramname, Double_t *result)
Bool_t GetParamInt(const char *name, const char *paramname, Int_t **result)
Definition PDataBase.h:137
Int_t MakeParamString(const char *paramname, const char *descr)
const char * param_int_descr[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:43
Bool_t ListEntries(Int_t key=-1, Int_t option=0, const char *pattern=nullptr)
Bool_t GetParamString(const char *paramname1, Int_t value1, const char *paramname2, const char **result)
Definition PDataBase.h:163
Int_t GetEntry(const char *name)
const char * param_tobj_name[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:40
void Performance(void)
const char * strings[PDATABASE_MAX_LINES][PDATABASE_MAX_STRING_PARAM]
Definition PDataBase.h:57
void SetFastKey(Int_t pkey, Int_t maxkey)
Definition PDataBase.cxx:75
Int_t AddListEntry(const char *name, const char *count, const char *link, const char *newname)
Int_t param_int_key_max[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:53
Int_t param_double_pointer
Definition PDataBase.h:45
Bool_t GetParamString(Int_t pkey1, Int_t value1, Int_t pkey2, const char **result)
Definition PDataBase.h:182
Int_t lastkey
Definition PDataBase.h:62
Int_t * ints[PDATABASE_MAX_LINES][PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:59
Bool_t GetParamDouble(const char *paramname1, Int_t value1, const char *paramname2, Double_t **result)
Definition PDataBase.h:159
void GetFastParamString(const char *paramname, Int_t *pkey)
Definition PDataBase.h:97
Bool_t SetParamDouble(const char *name, const char *paramname, Double_t result)
Definition PDataBase.h:200
const char * GetName(Int_t key)
Definition PDataBase.cxx:96
Bool_t CheckEntry(Int_t key)
Definition PDataBase.cxx:86
Bool_t MakeListIterator(Int_t key, const char *count, const char *link, Int_t *listkey)
Int_t ConvertParamKey(const char *&newparamname, Int_t key)
Bool_t GetParamInt(const char *paramname1, Int_t value1, const char *paramname2, Int_t **result)
Definition PDataBase.h:155
const char * param_int_name[PDATABASE_MAX_INT_PARAM]
Definition PDataBase.h:39
Bool_t GetParamTObj(const char *name, const char *paramname, TObject **result)
Definition PDataBase.h:149
Bool_t SetParamString(Int_t key, const char *paramname, char *result)
Int_t GetEntryInt(const char *paramname, Int_t value)
const char * param_double_name[PDATABASE_MAX_DOUBLE_PARAM]
Definition PDataBase.h:37
Int_t GetParamInt(const char *paramname, Int_t length=-1)
void GetFastParamTObj(const char *paramname, Int_t *pkey)
Definition PDataBase.h:105
Bool_t SetParamInt(Int_t key, const char *paramname, Int_t *result)
Int_t param_string_pointer
Definition PDataBase.h:46
Bool_t GetParamInt(Int_t pkey1, Int_t value1, Int_t pkey2, Int_t **result)
Definition PDataBase.h:173
Bool_t GetParamDouble(Int_t pkey1, Int_t value1, Int_t pkey2, Double_t **result)
Definition PDataBase.h:178
Hash for CbmL1LinkKey.