CbmRoot
PStaticData.h
Go to the documentation of this file.
1 // Author: M.A. Kagarlis
2 // Written: 31.01.99
3 // Revised: (IF)
4 // PDataUtil Class Header
5 
6 #ifndef _PSTATICDATA_H_
7 #define _PSTATICDATA_H_
8 
9 #include "TF1.h"
10 #include "TROOT.h"
11 #include <iostream>
12 
13 #include "PDataBase.h"
14 #include "PMesh.h"
15 
16 
17 #define MAX_DAUGHTERS 7
18 
19 using namespace std;
20 
21 class PStaticData;
24 
25 
26 void listParticle(int = -1);
27 void listParticle(const char* id);
28 void listModes(int id = -1);
29 void listModes(const char* id);
30 
31 
32 class PStaticData : public TObject {
33 
34 public:
35  PStaticData();
36 
37  //Freeze out -> Important to check this
38  void SetFreezeOut(void) { freeze = kTRUE; };
39 
40  void clearFreezeOut(void) {
41  //re-loop PStdModels
42  freeze = kFALSE;
43  };
44 
45  bool GetFreezeOut(void) { return freeze; }
46 
47  //Common stuff
48  int AddAlias(const char* old_name,
49  const char* new_name); //adds an alias, ret value is alias key
50  int GetAliasParent(const char* alias_name);
51  int GetAliasParent(int key);
52 
53  int MakeDirectoryEntry(
54  const char* name,
55  const char* n,
56  const char* l,
57  const char* ename); //adds a directory, ret value is key
58  Double_t* GetBatchValue(const char* name, Int_t make_val = 1);
59  int GetSecondaryKey(
60  int key,
61  int defkey); //Loops over the alias entries and look for matching defkey
62 
63  //Particle get methods
64  int GetParticleID(const char* id, int warn = 1); // pid by name
65  int GetParticleIDByKey(int key); // pid by key
66  const char* GetParticleName(const int& id); // name by pid
67  int GetParticleKey(const int& id); // data base key by pid
68  int GetParticleKey(const char* id) {
69  return GetParticleKey(GetParticleID(id));
70  };
71  int IsParticle(const int& id,
72  const char* name); // does pid correspond to given name?
73  int IsParticleValid(const int& id); // check id range by id
74  int IsParticleValid(const char* n); // check id range by name
75 
76  int AddParticle(int pid, const char* name, double mass);
77  void PrintParticle(int pid);
78  void PrintParticleByKey(int pid);
79  void PrintParticle(const char* id) { PrintParticle(GetParticleID(id)); };
80 
81  int GetParticleKF(const int Id); // return Pythia6 kf code
82  int GetParticleIDbyKF(
83  const int kf); // return Id corresponding to Pythia6 kf code
84 
85  int IsParticleMeson(const int& id); // is meson?, by pid
86  void SetParticleMeson(const char* id, Int_t num = 1); // set meson number
87 
88  int IsParticleHadron(const int& id); // is hadron?, by pid
89  int GetParticleBaryon(const int& id); // baryon number by pid
90  void SetParticleBaryon(const char* id,
91  Int_t num = 1); // baryon number by name
92 
93  int GetParticleLepton(const int& id); // lepton number by pid
94  void SetParticleLepton(const char* id, Int_t num = 1);
95 
96  int GetParticleCharge(const int& id); // charge by pid
97  int GetParticleCharge(const char* id); // charge by name
98  void SetParticleCharge(const char* id, Int_t charge);
99 
100  int GetParticleSpin(const int& id); // 2 x J by pid
101  int GetParticleSpin(const char* id); // 2 x J by name
102  void SetParticleSpin(const char* id, Int_t spin);
103 
104  int GetParticleIsospin(const int& id); // 2 x I by pid
105  int GetParticleIsospin(const char* id); // 2 x I by name
106  void SetParticleIsospin(const char* id, Int_t isospin);
107 
108  int GetParticleParity(const int& id); // parity (0 if irrelevant)
109  int GetParticleParity(const char* id); // parity (0 if irrelevant)
110  void SetParticleParity(const char* id, Int_t parity);
111 
112  double GetParticleMass(const int& id); // mass by id
113  double GetParticleMass(const char* id); // mass by name
114  double GetParticleMassByKey(const int& id);
115  void SetParticleMass(Int_t id, Float_t mass); //reset mass
116  void SetParticleMass(const char* id, Float_t mass); //reset mass
117 
118  int GetParticleNChannels(const int& id); // number of decay channels by pid
119  int GetParticleNChannels(const char* id); // number of decay channels by name
120  int GetParticleNChannelsByKey(int id);
121 
122  void SetParticleTotalWidth(Int_t id, Float_t wid);
123  void SetParticleTotalWidth(const char* id, Float_t wid);
124  double GetParticleTotalWidth(const int& id); // -->PWidth[id]
125  double GetParticleTotalWidth(const char* id) {
126  return GetParticleTotalWidth(GetParticleID(id));
127  };
128  double GetParticleTotalWidthByKey(const int& id);
129 
130  double GetParticleEmin(
131  const int& id); // Returns the energy threshold for the particle
132  void SetParticleEmin(const int& id, const double v);
133 
134  //Change particle range:
135  double GetParticleLMass(
136  const int& id); // Returns lower mass (used in all samplings)
137  double GetParticleLMass(const char* id) {
138  return GetParticleLMass(GetParticleID(id));
139  };
140  double GetParticleUMass(
141  const int& id); // Returns upper mass (used in all samplings)
142  double GetParticleUMass(const char* id) {
143  return GetParticleUMass(GetParticleID(id));
144  };
145  void
146  SetParticleLMass(const int& id,
147  const double v) { // Set lower mass (used in all samplings)
148  SetParticleLMass(GetParticleName(id), v);
149  };
150  void
151  SetParticleLMass(const char* id,
152  const double v); // Set lower mass (used in all samplings)
153 
154  void
155  SetParticleUMass(const int& id,
156  const double v) { // Set upper mass (used in all samplings)
157  SetParticleUMass(GetParticleName(id), v);
158  };
159  void
160  SetParticleUMass(const char* id,
161  const double v); // Set upper mass (used in all samplings)
162 
163 
164  bool NormParticleBR(Int_t id); // normalize branching ratios for particle id
165  bool NormParticleBRbyKey(Int_t key);
166  void SetTotalNormalization(char* p, int flag = 1);
167 
168  //Decay methods
169  void FreezeDecayBR(Int_t id,
170  Int_t brn); // Set BR (BUGBUG->brn nomally unknown)
171  bool SetDecayBR(int didx, double br, int mode);
172  bool
173  SetDecayBR(const char* parent, const char* daughters, double br, int mode);
174  bool SetDecayBRByKey(int key, double br, int mode);
175 
176  Double_t GetDecayBR(Int_t id);
177  Double_t GetDecayPartialWidth(Int_t id);
178  Double_t GetDecayPartialWidthByKey(Int_t id);
179  const char* GetDecayName(Int_t id);
180  const char* GetDecayNameByKey(Int_t key);
181 
182  Int_t IsDecayHadronic(Int_t didx);
183 
184 
196  void PrintDecayByKey(int key);
197 
198  int GetDecayNProducts(
199  const int&); // retrieve number of products by mode index
200  int GetDecayNProducts(const char*); // number of products by name
201  int GetDecayNProductsByKey(const int& key);
202 
203  int GetDecayParent(const int&); // parent pid from decay mode index
204  int GetDecayParentByKey(const int&);
205  void GetDecayMode(const int,
206  int* n); // retrieve product number, pids, by mode index
207  void GetDecayModeByKey(const int, int* n);
208 
209  int GetDecayIdx(
210  int* pid,
211  int n); // decay-mode index from parent and product ids; ->getChannel
212  int GetDecayKey(int* pid, int n);
213  int GetDecayKey(const int& id);
214  int GetDecayIdxByKey(int key);
215 
216  int GetDecayBRFlag(int didx);
217  void SetDecayBRFlag(int didx, int flag);
218 
219 
220  double GetDecayEmin(
221  const int&
222  idx); // Returns the energy threshold for the decay mode with index=idx
223  void SetDecayEmin(const int& idx, const double v);
224 
225  //for dynamic stuff
226  int GetTWidx(const int&); // total width flag from index
227  int GetPWidx(const int&); // partial width flag from index
228  void SetTWidx(const int&, const int&); // total width flag from index
229  void SetPWidx(const int&, const int&); // partial width flag from index
230 
231  int GetTDepth(const int&);
232  void SetTDepth(const int&, const int&);
233  int GetHDepth(const int&);
234  void SetHDepth(const int&, const int&);
235 
236  void SetTWidthMesh(const int&, PMesh* mesh);
237  PMesh* GetTWidthMesh(const int&);
238 
239  void SetPWidthMesh(const int&, PMesh* mesh);
240  PMesh* GetPWidthMesh(const int&);
241 
242  void SetTF1(const int&, TF1* mesh);
243  TF1* GetTF1(const int&);
244 
245  static Bool_t
246  Tokenize(const char* options, const char* delimiter, char** array, int* size);
247  static void remove_spaces(char** partc);
248 
249  static void dsort(Double_t*, int);
250  static void isort(int* i, int n) {
251  // Sort in ascending order the first (int) entries of the array (int *).
252 
253  //BUGBUG: Quickersort is unstable
254  //see example:
255  //Int_t a[3]={8,9,9};
256  //PUtils::isort(a,3);
257 
258  //workaround: add very small number
259 
260  Double_t x[n];
261 
262  for (int j = 0; j < n; ++j)
263  x[j] = ((Double_t) i[j]) + ((Double_t) j) * 0.00001;
264  dsort(x, n);
265  for (int j = 0; j < n; ++j)
266  i[j] = (int) x[j];
267  }
268 
269  // global friend functions
270  //Keeping for backward compatibility
271 
272  friend void listParticle(int id);
273  // list particles in data base and their properties, by particle pid
274 
275  friend void listParticle(const char* id) {
276  listParticle(makeStaticData()->GetParticleID(id));
277  };
278  // list particles in data base and their properties, by particle code name
279 
280  friend void listModes(int id);
281  // list decay modes in data base, by particle pid
282 
283  friend void listModes(const char* id) {
284  listModes(makeStaticData()->GetParticleID(id));
285  };
286  // list decay modes in data base, by particle name
287 
288 
289 private:
290  Int_t* i_result;
291  const char* c_result;
292  Double_t* d_result;
293  TObject* t_result;
294  Int_t pid_param;
295  Int_t name_param;
296  Int_t meson_param, baryon_param, lepton_param;
297  Int_t charge_param, spin_param, ispin_param;
298  Int_t parity_param, mass_param, width_param;
299  Int_t pkf_param, didx_param;
300  Int_t widx_param, mesh_param, tf1_param, ethreshold_param, lmass_param,
302  Int_t tdepth_param, hdepth_param, br_param, brorig_param, count_param;
303  Int_t d1_param, d2_param, d3_param, pnmodes_param, ppid_param;
304  Int_t d4_param, d5_param, d6_param, d7_param;
306  Int_t nalias_param, lalias_param, defkey_param;
307 
308  Bool_t freeze;
309 
311 
312  ClassDef(PStaticData, 0); //Pluto Static Data Wrapper
313 };
314 
315 #endif // _PDATAUTIL_H_
PStaticData::pkf_param
Int_t pkf_param
Definition: PStaticData.h:299
PStaticData::widx_param
Int_t widx_param
Definition: PStaticData.h:300
PStaticData::pid_param
Int_t pid_param
Definition: PStaticData.h:294
PStaticData::GetParticleUMass
double GetParticleUMass(const char *id)
Definition: PStaticData.h:142
PStaticData::SetFreezeOut
void SetFreezeOut(void)
Definition: PStaticData.h:38
PStaticData::d_result
Double_t * d_result
Definition: PStaticData.h:292
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
fStaticData
PStaticData & fStaticData()
Definition: PStaticData.cxx:24
PStaticData::GetFreezeOut
bool GetFreezeOut(void)
Definition: PStaticData.h:45
listModes
void listModes(int id=-1)
Definition: PStaticData.cxx:1732
PStaticData
Definition: PStaticData.h:32
PStaticData::isort
static void isort(int *i, int n)
Definition: PStaticData.h:250
PStaticData::meson_param
Int_t meson_param
Definition: PStaticData.h:296
PStaticData::SetParticleUMass
void SetParticleUMass(const int &id, const double v)
Definition: PStaticData.h:155
PMesh.h
PDataBase.h
PStaticData::ppid_param
Int_t ppid_param
Definition: PStaticData.h:303
PStaticData::c_result
const char * c_result
Definition: PStaticData.h:291
makeStaticData
PStaticData * makeStaticData()
Definition: PStaticData.cxx:29
PStaticData::name_param
Int_t name_param
Definition: PStaticData.h:295
PStaticData::freeze
Bool_t freeze
Definition: PStaticData.h:308
PMesh
Definition: PMesh.h:13
PStaticData::brflag_param
Int_t brflag_param
Definition: PStaticData.h:305
PStaticData::spin_param
Int_t spin_param
Definition: PStaticData.h:297
PStaticData::i_result
Int_t * i_result
Definition: PStaticData.h:285
PStaticData::system_alloc_verbosity
Double_t * system_alloc_verbosity
Definition: PStaticData.h:310
PStaticData::GetParticleLMass
double GetParticleLMass(const char *id)
Definition: PStaticData.h:137
PStaticData::GetParticleKey
int GetParticleKey(const char *id)
Definition: PStaticData.h:68
PStaticData::nalias_param
Int_t nalias_param
Definition: PStaticData.h:306
PStaticData::tdepth_param
Int_t tdepth_param
Definition: PStaticData.h:302
PStaticData::d7_param
Int_t d7_param
Definition: PStaticData.h:304
PStaticData::PrintParticle
void PrintParticle(const char *id)
Definition: PStaticData.h:79
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
listParticle
void listParticle(int=-1)
Definition: PStaticData.cxx:1723
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
PStaticData::SetParticleLMass
void SetParticleLMass(const int &id, const double v)
Definition: PStaticData.h:146
PStaticData::t_result
TObject * t_result
Definition: PStaticData.h:293
PStaticData::ClassDef
ClassDef(PStaticData, 0)
PStaticData::clearFreezeOut
void clearFreezeOut(void)
Definition: PStaticData.h:40
PStaticData::GetParticleTotalWidth
double GetParticleTotalWidth(const char *id)
Definition: PStaticData.h:125
PStaticData::width_param
Int_t width_param
Definition: PStaticData.h:298
PStaticData::umass_param
Int_t umass_param
Definition: PStaticData.h:301