CbmRoot
Loading...
Searching...
No Matches
PStaticData.cxx
Go to the documentation of this file.
1/* Copyright (C) 1999-2019 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: M.A. Kagarlis, Florian Uhlig [committer] */
4
6// Pluto Data Wrapper
7// Provides a lot of helpfull wrapper function to deal with the data
8// base.
9//
10//
11// Author: M.A. Kagarlis
12// Written: 31/01/99
13// Revised: 24/05/2004 R.H.
14// Reimplemented: 3/5/2007 IF
15//
17
18#include "PStaticData.h"
19
20#include "PStdData.h"
21//#include "PUtils.h"
22#include "TObjArray.h"
23#include "TObjString.h"
24#include "TString.h"
25
26#include "Pdefines.h"
27
28//extern char*version_string;
29
31{
32 static PStaticData* ans = new PStaticData();
33 return *ans;
34}
35
37
39{
40 if (!makeStdData()->fillDataBase()) {
41 Error("PStaticData", "Data base could not be filled");
42 exit(1);
43 }
44 PDataBase* base = makeDataBase();
45 i_result = nullptr;
46 c_result = nullptr;
47 d_result = nullptr;
48 t_result = nullptr;
49
50 freeze = kFALSE;
51
52 pid_param = base->GetParamInt("pid");
53 name_param = base->GetParamString("name");
54 meson_param = base->GetParamInt("meson");
55 baryon_param = base->GetParamInt("baryon");
56 lepton_param = base->GetParamInt("lepton");
57 charge_param = base->GetParamInt("charge");
58 spin_param = base->GetParamInt("spin");
59 ispin_param = base->GetParamInt("ispin");
60 parity_param = base->GetParamInt("parity");
61 mass_param = base->GetParamDouble("mass");
62 width_param = base->GetParamDouble("width");
63 pkf_param = base->GetParamInt("pkf");
64 didx_param = base->GetParamInt("didx");
65 widx_param = base->GetParamInt("widx");
66 mesh_param = base->GetParamTObj("mesh");
67 tf1_param = base->GetParamTObj("tf1");
68 ethreshold_param = base->GetParamDouble("ethreshold");
69 lmass_param = base->GetParamDouble("lmass");
70 umass_param = base->GetParamDouble("umass");
71 brflag_param = base->GetParamInt("brflag");
72 tdepth_param = base->GetParamInt("tdepth");
73 hdepth_param = base->GetParamInt("hdepth");
74 br_param = base->GetParamDouble("br");
75 brorig_param = base->GetParamDouble("brorig");
76 count_param = base->GetParamInt("pnmodes");
77 d1_param = base->GetParamInt("d1");
78 d2_param = base->GetParamInt("d2");
79 d3_param = base->GetParamInt("d3");
80 d4_param = base->GetParamInt("d4");
81 d5_param = base->GetParamInt("d5");
82 d6_param = base->GetParamInt("d6");
83 d7_param = base->GetParamInt("d7");
84 pnmodes_param = base->GetParamInt("pnmodes");
85 ppid_param = base->GetParamInt("ppid");
86
87 nalias_param = base->GetParamInt("nalias");
88 lalias_param = base->GetParamInt("lalias");
89
90
91 //now loop over particles and normalize BRs
92 //This is very important for the mass sampling
93 Int_t pids = 0;
94 Int_t key = makeDataBase()->GetEntry("std_set");
95 if (key < 0) Warning("PStaticData", "std_set not found");
96 Int_t listkey = -1;
97 while (makeDataBase()->MakeListIterator(key, "snpart", "slink", &listkey)) {
98 //loop over all particles
99 NormParticleBRbyKey(listkey);
100 pids++;
101 }
102
103 //This is for the ctor of the PChannelModel
104 defkey_param = base->MakeParamInt("defkey", "Model Def Key");
105
106 //Add some useful aliases
107 //no idea if this is the correct place, it the moment it should be OK
108 AddAlias("dilepton", "dielectron");
109 AddAlias("g", "gamma");
110
111 AddAlias("w", "omega");
112 AddAlias("D0", "Delta0");
113 AddAlias("D+", "Delta+");
114 AddAlias("D++", "Delta++");
115 AddAlias("D-", "Delta-");
116 AddAlias("D0", "Delta(1232)0");
117 AddAlias("D+", "Delta(1232)+");
118 AddAlias("D++", "Delta(1232)++");
119 AddAlias("D-", "Delta(1232)-");
120
121
122 AddAlias("DP330", "Delta(1600)0");
123 AddAlias("DP33+", "Delta(1600)+");
124 AddAlias("DP33++", "Delta(1600)++");
125 AddAlias("DP33-", "Delta(1600)-");
126
127 AddAlias("DS310", "Delta(1620)0");
128 AddAlias("DS31+", "Delta(1620)+");
129 AddAlias("DS31++", "Delta(1620)++");
130 AddAlias("DS31-", "Delta(1620)-");
131
132 AddAlias("NP11+", "N*(1440)+");
133 AddAlias("NP110", "N*(1440)0");
134 AddAlias("ND13+", "N*(1520)+");
135 AddAlias("ND130", "N*(1520)0");
136 AddAlias("NS11+", "N*(1535)+");
137 AddAlias("NS110", "N*(1535)0");
138
139 //Ingo's additions:
140 makeDataBase()->SetParamDouble("D+", "lmass", 1.);
141 //--> lmass=0 leads to endless loop in PHadronDecayM1:: maxBWWeight
142 makeDataBase()->SetParamDouble("D+", "umass", 3.);
143
144 system_alloc_verbosity = GetBatchValue("_system_alloc_verbosity");
145 (*system_alloc_verbosity) = 1.;
146
147 *GetBatchValue("_system_weight_version") = 1.;
148 *GetBatchValue("_system_unstable_width") = 0.0001;
149
150 *GetBatchValue("_event_plane") = 0.;
151 *GetBatchValue("_event_impact_param") = 0.;
152 *GetBatchValue("_event_vertex_x") = 0.;
153 *GetBatchValue("_event_vertex_y") = 0.;
154 *GetBatchValue("_event_vertex_z") = 0.;
155 *GetBatchValue("_event_seqnr") = -1.;
156
157
158 /*
159 Double_t *version= GetBatchValue("_system_version");
160
161 if (!strncmp("CVS",version_string,3)) {
162 (*version)=999.;
163 } else {
164 sscanf(version_string,"%lf",version);
165 }
166*/
167}
168
169
170int PStaticData::MakeDirectoryEntry(const char* name, const char* n, const char* l, const char* ename)
171{
172 // Adds an entry of the form "dir"
173 // if entry/dir is existing, the key w/o warning is returned
174 // n and l are the data base columns of the list
175
176 Int_t skey = -1;
177
178 if (makeDataBase()->GetParamInt(n) < 0) makeDataBase()->MakeParamInt(n, "number of links");
179 if (makeDataBase()->GetParamInt(l) < 0) makeDataBase()->MakeParamInt(l, "links");
180
181 skey = makeDataBase()->GetEntry(name);
182 if (skey < 0) skey = makeDataBase()->AddEntry(name);
183 if (skey < 0) return -1; //failed
184
185 skey = makeDataBase()->GetEntry(ename);
186 if (skey < 0) skey = makeDataBase()->AddEntry(ename);
187 if (skey < 0) return -1; //failed
188
189 Int_t* dummy;
190 if (!makeDataBase()->GetParamInt(skey, l, &dummy)) {
191 //fresh entry
192 skey = makeDataBase()->AddListEntry(name, n, l, ename);
193 }
194 return skey;
195}
196
197
198Double_t* PStaticData::GetBatchValue(const char* name, Int_t make_val)
199{
200 Int_t key_a = MakeDirectoryEntry("batch_objects", NBATCH_NAME, LBATCH_NAME, name);
201 //Check if double is existing
202 Double_t* val;
203 Int_t batch_value_param = makeDataBase()->GetParamDouble("batch_value");
204 if (batch_value_param < 0)
205 batch_value_param = makeDataBase()->MakeParamDouble("batch_value", "Double storage for batch");
206 //cout << key_a << ":" << makeDataBase()->GetParamDouble(key_a ,batch_value_param,&val) << endl;
207 if (!makeDataBase()->GetParamDouble(key_a, batch_value_param, &val)) {
208 if (make_val) {
209 Double_t* delme = new Double_t(0.);
210 makeDataBase()->SetParamDouble(key_a, "batch_value", delme);
211 return delme;
212 }
213 else
214 return nullptr;
215 }
216 return val;
217};
218
219
220int PStaticData::GetParticleID(const char* id, int warn)
221{
222 // pid by name
223 if (!id) return 0;
224 if (!makeDataBase()->GetParamInt(makeDataBase()->GetEntry((char*) id), pid_param, &i_result)) {
225 Int_t key = GetAliasParent(id);
226 if (key < 0) {
227 if (warn) { Warning("GetParticleID", "%s not found", id); }
228 return 0;
229 }
230 return GetParticleIDByKey(key);
231 }
232 return *i_result;
233};
234
235const char* PStaticData::GetParticleName(const int& id)
236{
237 // name by pid
238 Int_t key = -1;
239 if ((key = makeDataBase()->GetEntryInt(pid_param, id)) < 0) {
240 Warning("GetParticleName", "id %i not found", id);
241 return "";
242 }
244 return c_result;
245};
246
248{
249 // pid by key
250 // -1 if unvalid
251 if (!makeDataBase()->GetParamInt(key, pid_param, &i_result)) return -1;
252 return *i_result;
254
256{
257 // data base key by pid
258 Int_t key = -1;
259 if ((key = makeDataBase()->GetEntryInt(pid_param, id)) < 0) { Warning("GetParticleKey", "id %i not found", id); }
260 return key;
261}
262
263int PStaticData::GetDecayKey(const int& id)
264{
265 // data base key by pid
266 Int_t key = -1;
267 if ((key = makeDataBase()->GetEntryInt(didx_param, id)) < 0) { Warning("GetDecayKey", "id %i not found", id); }
268 return key;
269}
270
271int PStaticData::IsParticle(const int& id, const char* name)
272{
273 // does pid correspond to given name?
274 if (strcmp(name, GetParticleName(id)) == 0) return 1;
275 return 0;
276};
277
279{
280 // check id range by id
281 // Returns a "1" in any case if data base is filled with id
282 // PFireball particles return 0;
283
284 Int_t key = -1;
285 if ((key = makeDataBase()->GetEntryInt(pid_param, id)) >= 0) {
286 return id; //if in data base in any case say yes
287 }
288
289 if ((id > 500) && (id < 1000)) return id;
290
291 return 0;
292}
293
295{
296 // check id range by name
297
298 if (!n) return 0;
299 int pid = GetParticleID(n, 0);
300 if (pid < 0) return 0;
301
302 return IsParticleValid(pid);
303}
304
305int PStaticData::AddAlias(const char* old_name, const char* new_name)
306{
307 //adds an alias to primary_key, ret value is alias key
308 PDataBase* base = makeDataBase();
309 Int_t pkey = -1;
310
311 if ((pkey = base->AddListEntry(old_name, "nalias", "lalias", new_name)) < 0) {
312 Warning("AddAlias", "Name %s not found", old_name);
313 return -1;
314 }
315
316 return pkey;
317}
318
319int PStaticData::GetAliasParent(const char* alias_name)
320{
321 Int_t listkey = -1, *dummy;
322 Int_t key = makeDataBase()->GetEntry(alias_name);
323 if (key < 0) return -1;
324 while (makeDataBase()->MakeListIterator(key, -1, lalias_param, &listkey)) {
325 if (makeDataBase()->GetParamInt(listkey, nalias_param, &dummy)) {
326 //count found
327 return listkey;
328 }
329 }
330 return -1;
331}
332
334{
335 Int_t listkey = -1, *dummy;
336 if (key < 0) return -1;
337 if (!makeDataBase()->GetParamInt(key, lalias_param, &dummy)) return -1;
338 while (makeDataBase()->MakeListIterator(key, -1, lalias_param, &listkey)) {
339 if (makeDataBase()->GetParamInt(listkey, nalias_param, &dummy)) {
340 //count found
341 return listkey;
342 }
343 }
344 return -1;
345}
346
347int PStaticData::GetSecondaryKey(int key, int defkey)
348{
349 Int_t listkey = -1;
350
351 Int_t* dummy;
352 if (!makeDataBase()->GetParamInt(key, nalias_param, &dummy)) {
353 //Warning("MakeListIterator","count %s not found",count);
354 //try to find parent
355 //cout << "orig key=" << key;
356 key = GetAliasParent(key);
357 //cout << " now: " << key << endl;
358 if (key < 0) return -1; //avoid messages
359 }
360
361 while (makeDataBase()->MakeListIterator(key, nalias_param, lalias_param, &listkey)) {
362
363 //cout << "listkey " << listkey << endl;
364
365 //loop over all secondaries
366 if (makeDataBase()->GetParamInt(listkey, defkey_param, &dummy)) {
367 if (*dummy == defkey) return listkey;
368 }
369 }
370 return -1;
371}
372
373
374int PStaticData::AddParticle(int pid, const char* name, double mass)
375{
377 PDataBase* base = makeDataBase();
378 Int_t pkey = -1;
379
380 //check if pid already exists
381 if (pid >= 0)
382 if (base->GetEntryInt("pid", pid) >= 0) {
383 Warning("AddParticle", "pid %i already used in data base", pid);
384 return -1;
385 }
386
387 if (base->GetEntry(name) >= 0) {
388 Warning("AddParticle", "Name %s already used in data base", name);
389 return -1;
390 }
391
392 if (pid < 0) {
393 pid = 0;
394 while (makeDataBase()->GetEntryInt("pid", pid) >= 0) {
395 pid++;
396 }
397 if (*system_alloc_verbosity) Info("AddParticle", "(%s) PID: %i", PRINT_AUTO_ALLOC, pid);
398 }
399
400 if ((pkey = base->AddListEntry("std_set", "snpart", "slink", name)) < 0) {
401 Warning("AddParticle", "particle header not found");
402 return -1;
403 }
404
405 Int_t* ii = new int(pid); //never destructed, but called only once!
406 if (!base->SetParamInt(pkey, "pid", ii)) {
407 delete ii;
408 return -1;
409 }
410 Double_t* dd = new double(0.);
411 if (!base->SetParamDouble(pkey, "width", dd)) {
412 delete dd;
413 return -1;
414 }
415 dd = new Double_t(mass);
416 if (!base->SetParamDouble(pkey, "mass", dd)) {
417 delete dd;
418 return -1;
419 }
420 dd = new Double_t(mass);
421 if (!base->SetParamDouble(pkey, "ethreshold", dd)) {
422 delete dd;
423 return -1;
424 }
425 ii = new int(0);
426 if (!base->SetParamInt(pkey, "meson", ii)) return -1;
427 ii = new int(0);
428 if (!base->SetParamInt(pkey, "baryon", ii)) return -1;
429 ii = new int(0); //Meson by default: No limitation in LMass
430 if (!base->SetParamInt(pkey, "lepton", ii)) return -1;
431 ii = new int(0);
432 if (!base->SetParamInt(pkey, "charge", ii)) return -1;
433 ii = new int(0);
434 if (!base->SetParamInt(pkey, "spin", ii)) return -1;
435 ii = new int(0);
436 if (!base->SetParamInt(pkey, "parity", ii)) return -1;
437 ii = new int(0);
438 if (!base->SetParamInt(pkey, "ispin", ii)) return -1;
439 ii = new int(0);
440 if (!base->SetParamInt(pkey, "pythiakf", ii)) return -1;
441 ii = new int(0);
442 if (!base->SetParamInt(pkey, "widx", ii)) return -1;
443 ii = new int(0);
444 if (!base->SetParamInt(pkey, "tdepth", ii)) return -1;
445 ii = new int(0);
446 if (!base->SetParamInt(pkey, "hdepth", ii)) return -1;
447 return pid;
448}
449
450
451void PStaticData::PrintParticle(int pid) { return PrintParticleByKey(makeDataBase()->GetEntryInt("pid", pid)); };
452
453
455{
456 makeDataBase()->ListEntries(key, 0, "name,pid,width,mass");
457
458 Int_t listkey = -1, alias_printed = 0;
459 Int_t* dummy;
460 if (makeDataBase()->GetParamInt(key, nalias_param, &dummy)) {
461 while (makeDataBase()->MakeListIterator(key, "nalias", "lalias", &listkey)) {
462 alias_printed = 1;
463 cout << "Alias: " << makeDataBase()->GetName(listkey) << endl;
464 ;
465 }
466 }
467 if (alias_printed) cout << endl;
468
469 if (!GetParticleNChannelsByKey(key)) {
470 cout << "This particle is stable" << endl;
471 return;
472 }
473
474 cout << "This particle decays via the following modes:" << endl;
475
476 //now loop over decay modes
477 listkey = -1;
478
479 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
480 PrintDecayByKey(listkey);
481 }
482};
483
485{
486 // return Pythia6 kf code
487 if (!id) return 0;
488 if (!makeDataBase()->GetParamInt(pid_param, id, pkf_param, &i_result)) {
489 Warning("GetParticleKF", "id %i not found", id);
490 return 0;
491 }
492 return *i_result;
493}
494
496{
497 // return Id corresponding to Pythia6 kf code
498 if (!kf) return 0;
499 int* id = nullptr;
500 int key;
501
502 if ((key = makeDataBase()->GetEntryInt(pkf_param, kf)) < 0) {
503 Warning("GetParticleIDbyKF", "invalid kf code %i", *id);
504 return 0;
505 }
506 if (!makeDataBase()->GetParamInt(key, pid_param, &id)) return 0;
507 return *id;
508}
509
510
512{
513 // is meson?, by pid
514 if (!id) return 0;
515 if (!makeDataBase()->GetParamInt(pid_param, id, meson_param, &i_result)) {
516 // if not found obviously not a meson
517 return 0;
518 }
519 return *i_result;
520};
521
523{
524 // is hadron?, by pid
525 if (IsParticleMeson(id) || GetParticleBaryon(id)) return 1;
526 return 0;
527};
528
530{
531 // baryon number by pid
532 if (!makeDataBase()->GetParamInt(pid_param, id, baryon_param, &i_result)) {
533 // if not found obviously not a baryon
534 return 0;
535 }
536 return *i_result;
537};
538
539void PStaticData::SetParticleBaryon(const char* id, Int_t num)
540{
541 // baryon number by name
542 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), baryon_param, &i_result)) {
543 // if not found, set param
544 makeDataBase()->SetParamInt((char*) id, "baryon", num);
545 }
546 *i_result = num;
547}
548
549void PStaticData::SetParticleMeson(const char* id, Int_t num)
550{
551 // set meson number
552 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), meson_param, &i_result)) {
553 // if not found, set param
554 makeDataBase()->SetParamInt((char*) id, "meson", num);
555 }
556 *i_result = num;
557}
558
559void PStaticData::SetParticleLepton(const char* id, Int_t num)
560{
561 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), lepton_param, &i_result)) {
562 // if not found, set param
563 makeDataBase()->SetParamInt((char*) id, "lepton", num);
564 }
565 *i_result = num;
566}
567
568void PStaticData::SetParticleCharge(const char* id, Int_t charge)
569{
570 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), charge_param, &i_result)) {
571 // if not found, set param
572 makeDataBase()->SetParamInt((char*) id, "charge", charge);
573 }
574 *i_result = charge;
575}
576
577void PStaticData::SetParticleSpin(const char* id, Int_t spin)
578{
579 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), spin_param, &i_result)) {
580 // if not found, set param
581 makeDataBase()->SetParamInt((char*) id, "spin", spin);
582 }
583 *i_result = spin;
584}
585
586void PStaticData::SetParticleIsospin(const char* id, Int_t isospin)
587{
588 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), ispin_param, &i_result)) {
589 // if not found, set param
590 makeDataBase()->SetParamInt((char*) id, "ispin", isospin);
591 }
592 *i_result = isospin;
593}
594
595void PStaticData::SetParticleParity(const char* id, Int_t parity)
596{
597 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID((char*) id), parity_param, &i_result)) {
598 // if not found, set param
599 makeDataBase()->SetParamInt((char*) id, "parity", parity);
600 }
601 *i_result = parity;
602}
603
605{
606 // lepton number by pid
607 if (!makeDataBase()->GetParamInt(pid_param, id, lepton_param, &i_result)) {
608 // if not found obviously not a lepton
609 return 0;
610 }
611 return *i_result;
612};
613
615{
616 // charge by pid
617 if (!makeDataBase()->GetParamInt(pid_param, id, charge_param, &i_result)) {
618 cout << "PStaticData::Charge: " << id << " not found" << endl;
619 return 0;
620 }
621 return *i_result;
622};
623
625{
626 // charge by name
627 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID(id), charge_param, &i_result)) {
628 cout << "PStaticData::Charge: " << id << " not found" << endl;
629 return 0;
630 }
631 return *i_result;
632};
633
635{
636 // 2 x J by pid
637 if (!makeDataBase()->GetParamInt(pid_param, id, spin_param, &i_result)) {
638 cout << "PStaticData::GetParticleSpin: " << id << " not found" << endl;
639 return 0;
640 }
641 return *i_result;
642};
643
645{
646 // 2 x J by name
647 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID(id), spin_param, &i_result)) {
648 cout << "PStaticData::GetParticleSpin: " << id << " not found" << endl;
649 return 0;
650 }
651 return *i_result;
652};
653
655{
656 // 2 x I by pid
657 if (!makeDataBase()->GetParamInt(pid_param, id, ispin_param, &i_result)) {
658 cout << "PStaticData::GetParticleIsospin: " << id << " not found" << endl;
659 return 0;
660 }
661 return *i_result;
662};
663
665{
666 // 2 x I by name
667 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID(id), ispin_param, &i_result)) {
668 cout << "PStaticData::GetParticleIsospin: " << id << " not found" << endl;
669 return 0;
670 }
671 return *i_result;
672};
673
675{
676 // parity (0 if irrelevant)
677 if (!makeDataBase()->GetParamInt(pid_param, id, parity_param, &i_result)) {
678 cout << "PStaticData::GetParticleParity: " << id << " not found" << endl;
679 return 0;
680 }
681 return *i_result;
682};
683
685{
686 // parity (0 if irrelevant)
687 if (!makeDataBase()->GetParamInt(pid_param, GetParticleID(id), parity_param, &i_result)) {
688 cout << "PStaticData::GetParticleParity: " << id << " not found" << endl;
689 return 0;
690 }
691 return *i_result;
692};
693
694double PStaticData::GetParticleMass(const int& id)
695{
696 // mass by id
697
698 if (!makeDataBase()->GetParamDouble(pid_param, id, mass_param, &d_result)) {
699 cout << "PStaticData::GetParticleMass: " << id << " not found" << endl;
700 return 0;
701 }
702 return *d_result;
703};
704
705double PStaticData::GetParticleMass(const char* id)
706{
707 // mass by name
708 if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID(id), mass_param, &d_result)) {
709 cout << "PStaticData::GetParticleMass: " << id << " not found" << endl;
710 return 0;
711 }
712 return *d_result;
713};
714
716{
717 // mass by key
718 if (!makeDataBase()->GetParamDouble(id, mass_param, &d_result)) {
719 cout << "PStaticData::GetParticleMassByKey: " << id << " not found" << endl;
720 return 0;
721 }
722 return *d_result;
723};
724
725void PStaticData::SetParticleMass(Int_t id, Float_t mass)
726{
727 //reset mass
728 if (!makeDataBase()->GetParamDouble(pid_param, id, mass_param, &d_result)) {
729 cout << "PStaticData::SetParticleMass: " << id << " not found" << endl;
730 }
731 *d_result = mass;
732}
733
734void PStaticData::SetParticleMass(const char* id, Float_t mass)
735{
736 //reset mass
737 if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID(id), mass_param, &d_result)) {
738 cout << "PStaticData::SetParticleMass: " << id << " not found" << endl;
739 }
740 *d_result = mass;
741}
742
743
744const char* PStaticData::GetDecayName(Int_t id)
745{
746 if (!makeDataBase()->GetParamString(didx_param, id, name_param, &c_result)) { return "NONAME"; }
747 return c_result;
748}
749
750const char* PStaticData::GetDecayNameByKey(Int_t key)
751{
752 if (!makeDataBase()->GetParamString(key, name_param, &c_result)) { return "NONAME"; }
753 return c_result;
754}
755
756void PStaticData::SetParticleTotalWidth(const char* id, Float_t wid)
757{ // set new total width
758 if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID(id), width_param, &d_result)) {
759 cout << "PStaticData::SetTWidth: " << id << " not found" << endl;
760 }
761 *d_result = wid;
762
764
765 //TODO
766 // Int_t n=PNModes[id], p0=GetPosition(id), p;
767 // for (p=p0; p<p0+n; ++p) if (PWidx[p]!=-1) PWidx[p]=0;
768 // TWidx[id]=0;
769 //printf("\n*** Warning: Use only at start of macro! ***\n\n");
770}
771
772void PStaticData::SetParticleTotalWidth(Int_t id, Float_t wid)
773{ // set new total width
774 if (!makeDataBase()->GetParamDouble(pid_param, id, width_param, &d_result)) {
775 cout << "PStaticData::SetTWidth: " << id << " not found" << endl;
776 }
777 *d_result = wid;
778 //TODO
779 // Int_t n=PNModes[id], p0=GetPosition(id), p;
780 // for (p=p0; p<p0+n; ++p) if (PWidx[p]!=-1) PWidx[p]=0;
781 // TWidx[id]=0;
782 printf("\n*** Warning: Use only at start of macro! ***\n\n");
783}
784
785
786int PStaticData::GetTWidx(const int& id)
787{
788 // width flag from index
789 // 0: static width only
790 // 1: use dynamic width
791 //-1: Disabled
792 if (!makeDataBase()->GetParamInt(pid_param, id, widx_param, &i_result)) {
793 cout << "PStaticData::GetTWidx: " << id << " not found" << endl;
794 return 0;
795 }
796
797 return *i_result;
798}
799
800int PStaticData::GetPWidx(const int& id)
801{
802 // width flag from index
803 // 0: static width only
804 // 1: use dynamic width
805 //-1: Disabled
806 if (!makeDataBase()->GetParamInt(didx_param, id, widx_param, &i_result)) {
807 cout << "PStaticData::GetPWidx: " << id << " not found" << endl;
808 return 0;
809 }
810 return *i_result;
811}
812
813void PStaticData::SetTWidx(const int& id, const int& v)
814{
815 // width flag from index
816 // 0: static width only
817 // 1: use dynamic width
818
819 if (!makeDataBase()->GetParamInt(pid_param, id, widx_param, &i_result)) {
820 cout << "PStaticData::SetTWidx: " << id << " not found" << endl;
821 }
822 *i_result = v;
823}
824
825void PStaticData::SetPWidx(const int& id, const int& v)
826{
827 // width flag from index
828 // 0: static width only
829 // 1: use dynamic width
830
831 if (!makeDataBase()->GetParamInt(didx_param, id, widx_param, &i_result)) {
832 cout << "PStaticData::GetPWidx: " << id << " not found" << endl;
833 }
834 *i_result = v;
835}
836
837void PStaticData::SetTWidthMesh(const int& id, PMesh* mesh)
838{
839
840 Int_t key = makeDataBase()->GetEntryInt("pid", id);
841 if (!makeDataBase()->SetParamTObj(key, "mesh", mesh)) {
842 cout << "PStaticData::SetTWidx: " << id << " not possible" << endl;
843 }
844};
845
846
848{
849 if (!makeDataBase()->GetParamTObj(pid_param, id, mesh_param, &t_result)) {
850 cout << "PStaticData::GetTWidthMesh: " << id << " not found" << endl;
851 return nullptr;
852 }
853 return (PMesh*) t_result;
854};
855
856void PStaticData::SetPWidthMesh(const int& id, PMesh* mesh)
857{
858 Int_t key = makeDataBase()->GetEntryInt("didx", id);
859 if (!makeDataBase()->SetParamTObj(key, "mesh", mesh)) {
860 cout << "PStaticData::SetPWidthMesh: " << id << " not possible" << endl;
861 }
862};
863
864
866{
867 if (!makeDataBase()->GetParamTObj(didx_param, id, mesh_param, &t_result)) {
868 cout << "PStaticData::GetPWidthMesh: " << id << " not found" << endl;
869 return nullptr;
870 }
871 return (PMesh*) t_result;
872};
873
874
875void PStaticData::SetTF1(const int& id, TF1* mesh)
876{
877 Int_t key = makeDataBase()->GetEntryInt("pid", id);
878 if (!makeDataBase()->SetParamTObj(key, "tf1", mesh)) {
879 cout << "PStaticData::SetTF1: " << id << " not possible" << endl;
880 }
881};
882
883
884TF1* PStaticData::GetTF1(const int& id)
885{
886 if (!makeDataBase()->GetParamTObj(pid_param, id, tf1_param, &t_result)) {
887 // cout << "PStaticData::GetTF1: " << id << " not found" << endl;
888 return nullptr;
889 }
890 return (TF1*) t_result;
891};
892
893
894Double_t PStaticData::GetDecayEmin(const int& id)
895{
896 if (!makeDataBase()->GetParamDouble(didx_param, id, ethreshold_param, &d_result)) {
897 cout << "PStaticData::GetDecayEmin: " << id << " not found" << endl;
898 return 0;
899 }
900 return *d_result;
901}
902
904{
905 if (!makeDataBase()->GetParamInt(didx_param, didx, brflag_param, &i_result)) { return 0; }
906 return *i_result;
907}
908
909void PStaticData::SetDecayBRFlag(int didx, int flag)
910{
911 //Set the BR flag for the "didx", thus the total normalization
912 //is used (when flag=1) instead of the pole mass
913 if (!makeDataBase()->GetParamInt(didx_param, didx, brflag_param, &i_result)) {
914 Int_t* ii = new Int_t(flag);
915 if (!makeDataBase()->SetParamInt(GetDecayKey(didx), "brflag", ii)) {
916 delete ii;
917 return;
918 }
919 }
920 else {
921 *i_result = flag;
922 }
923}
924
926{
927 //Wrapper function which enables the total normalization
928 //for a particle "p"
929 Int_t listkey = -1;
930 Int_t key = GetParticleKey(p);
931 if (key < 0) {
932 Warning("SetTotalNormalization", "Invalid particle");
933 return;
934 }
935
936 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
937 if (!makeDataBase()->GetParamInt(listkey, brflag_param, &i_result)) {
938 Int_t* ii = new Int_t(flag);
939 if (!makeDataBase()->SetParamInt(listkey, "brflag", ii)) {
940 delete ii;
941 return;
942 }
943 }
944 else {
945 *i_result = flag;
946 }
947 }
948}
949
950void PStaticData::SetDecayEmin(const int& id, const double v)
951{
952 if (!makeDataBase()->GetParamDouble(didx_param, id, ethreshold_param, &d_result)) {
953 cout << "PStaticData::SetDecayEmin: " << id << " not found" << endl;
954 }
955 *d_result = v;
956}
957
958Double_t PStaticData::GetParticleEmin(const int& id)
959{
960 if (!makeDataBase()->GetParamDouble(pid_param, id, ethreshold_param, &d_result)) {
961 cout << "PStaticData::GetParticleEmin: " << id << " not found" << endl;
962 return 0;
963 }
964 return *d_result;
965}
966
967void PStaticData::SetParticleEmin(const int& id, const double v)
968{
969 if (!makeDataBase()->GetParamDouble(pid_param, id, ethreshold_param, &d_result)) {
970 cout << "PStaticData::SetParticleEmin: " << id << " not found" << endl;
971 }
972 *d_result = v;
973}
974
975Double_t PStaticData::GetParticleLMass(const int& id)
976{
977 if (!makeDataBase()->GetParamDouble(pid_param, id, lmass_param, &d_result)) {
978 Warning("GetParticleLMass", "id %i not found", id);
979 return 0;
980 }
981 return *d_result;
982}
983
984void PStaticData::SetParticleLMass(const char* id, const double v)
985{
986 if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID((char*) id), lmass_param, &d_result)) {
987 // if not found, set param
988 makeDataBase()->SetParamDouble((char*) id, "lmass", v);
989 return;
990 }
991 *d_result = v;
992}
993
994Double_t PStaticData::GetParticleUMass(const int& id)
995{
996 if (!makeDataBase()->GetParamDouble(pid_param, id, umass_param, &d_result)) {
997 Warning("GetParticleUMass", "id %i not found", id);
998 return 0;
999 }
1000 return *d_result;
1001}
1002
1003void PStaticData::SetParticleUMass(const char* id, const double v)
1004{
1005 if (!makeDataBase()->GetParamDouble(pid_param, GetParticleID((char*) id), umass_param, &d_result)) {
1006 // if not found, set param
1007 makeDataBase()->SetParamDouble((char*) id, "umass", v);
1008 return;
1009 }
1010 *d_result = v;
1011}
1012
1013int PStaticData::GetTDepth(const int& id)
1014{
1015 if (!makeDataBase()->GetParamInt(pid_param, id, tdepth_param, &i_result)) {
1016 cout << "PStaticData::GetTDepth: " << id << " not found" << endl;
1017 return 0;
1018 }
1019 return *i_result;
1020}
1021
1022void PStaticData::SetTDepth(const int& id, const int& depth)
1023{
1024 if (!makeDataBase()->GetParamInt(pid_param, id, tdepth_param, &i_result)) {
1025 cout << "PStaticData::GetTDepth: " << id << " not found" << endl;
1026 }
1027 *i_result = depth;
1028}
1029
1030int PStaticData::GetHDepth(const int& id)
1031{
1032 if (!makeDataBase()->GetParamInt(pid_param, id, hdepth_param, &i_result)) {
1033 cout << "PStaticData::GetHDepth: " << id << " not found" << endl;
1034 return 0;
1035 }
1036 return *i_result;
1037}
1038
1039void PStaticData::SetHDepth(const int& id, const int& depth)
1040{
1041 if (!makeDataBase()->GetParamInt(pid_param, id, hdepth_param, &i_result)) {
1042 cout << "PStaticData::GetHDepth: " << id << " not found" << endl;
1043 }
1044 *i_result = depth;
1045}
1046
1047Double_t PStaticData::GetDecayBR(Int_t id)
1048{
1049 if (!makeDataBase()->GetParamDouble(didx_param, id, br_param, &d_result)) {
1050 cout << "PStaticData::GetDecayBR: " << id << " not found" << endl;
1051 }
1052 return *d_result;
1053};
1054
1056{
1057 double res = GetDecayBR(id) * GetParticleTotalWidth(GetDecayParent(id));
1058 return res;
1059};
1060
1062{
1064 return res;
1065};
1066
1067
1068bool PStaticData::SetDecayBR(int didx, double br, int mode)
1069{
1070 //Mode: see SetDecayBR(const char *parent, const char * daughters)
1071
1073 Int_t key = GetDecayKey(didx);
1074 Double_t* brorig;
1075 if (!makeDataBase()->GetParamDouble(key, "brorig", &brorig)) return kFALSE;
1076
1077 if (mode) {
1078 Double_t other = 1. - GetDecayBR(didx);
1079 br = (other * br) / (1. - br);
1080 }
1081
1082 *brorig = br;
1083
1085}
1086
1087bool PStaticData::SetDecayBRByKey(int key, double br, int mode)
1088{
1089 //Mode: see SetDecayBR(const char *parent, const char * daughters)
1091 Double_t* brorig;
1092 if (!makeDataBase()->GetParamDouble(key, "brorig", &brorig)) return kFALSE;
1093
1094 if (mode) {
1095 Double_t other = 1. - GetDecayBR(GetDecayIdxByKey(key));
1096 br = (other * br) / (1. - br);
1097 }
1098
1099 *brorig = br;
1101}
1102
1103bool PStaticData::SetDecayBR(const char* parent, const char* daughters, double br, int mode)
1104{
1105 // Resets the decay branching ratio of an existing decay
1106 // Handle this functon with care!
1107 // Do not use this function to change the weighting etc.
1108 // because the change of the decay b.r. will affect the
1109 // shape of the parent resonance
1110 //
1111 // If you have really physics arguments to change the b.r.
1112 // (e.g. update of PDG values)
1113 // you *must* use this function at the very beginning of your macro,
1114 // but at least before the "GetWidth" is called
1115 //
1116 // Mode flag:
1117 // 0: Add the new b.r. to the existing ones + re-weighting
1118 // 1: No re-weighting (in this case br must be <1.)
1119
1120
1121 //get parent key
1122 Int_t parent_key = makeDataBase()->GetEntry(parent);
1123 if (parent_key < 0) {
1124 cout << "PStaticData::SetDecayBR: parent " << parent << " not found in data base" << endl;
1125 return kFALSE;
1126 }
1127
1128 Int_t pid = GetParticleIDByKey(parent_key);
1129 if (pid < 0) { return kFALSE; }
1130
1131 //now check the daughters
1132 //TODO: All this should go into a help function
1133 char* arr1[7];
1134 Int_t arr1_s = 7; //max 7 decay products
1135
1136 Tokenize(daughters, ",", arr1, &arr1_s);
1137
1138 Int_t pids[8];
1139 pids[0] = pid;
1140 for (int pat = 0; pat < arr1_s; pat++) {
1141 pids[pat + 1] = GetParticleID(arr1[pat]);
1142 //cout << pids[pat+1]<<endl;
1143 }
1144
1145 Int_t decay_key = GetDecayKey(pids, arr1_s);
1146
1147 if (decay_key < 0) {
1148 Warning("SetDecayBR", "Decay %s -> %s not defined", parent, daughters);
1149 return kFALSE;
1150 }
1151
1152 return SetDecayBRByKey(decay_key, br, mode);
1153}
1154
1155
1156// This was the old Kagarlis method:
1157// if (brn<1 || brn>PNModes[id]) return;
1158// Int_t pos = GetPosition(id);
1159// if (pos!=-1) {
1160// Int_t idx = pos+brn-1;
1161// PBR[idx] = br;
1162// if (freeze) {
1163// PWidx[idx] = -1; // Set BR flag to static
1164// printf("Branch %3i set static to %f\n",idx,br);
1165// }
1166// printf("\n*** Warning: Use only at start of macro! ***\n\n");
1167// }
1168//}
1169
1171{
1172 // normalize branching ratios for particle id
1173 //TODO: check if this works
1174 Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
1175 return NormParticleBRbyKey(key);
1176}
1177
1179{
1180 // normalize branching ratios for particle id
1181
1182 Int_t listkey = -1;
1183 double sum = 0.;
1184 Double_t *br, *brorig, *width;
1185 Double_t twidth = GetParticleTotalWidthByKey(key);
1186
1187 if (GetParticleNChannelsByKey(key) == 0) return kFALSE;
1188
1189 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
1190 if (!makeDataBase()->GetParamDouble(listkey, "brorig", &brorig)) return kFALSE;
1191 sum += *brorig;
1192 }
1193
1194 listkey = -1;
1195 if (sum > 0.)
1196 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
1197 if (!makeDataBase()->GetParamDouble(listkey, "brorig", &brorig)) return kFALSE;
1198 if (!makeDataBase()->GetParamDouble(listkey, "br", &br)) return kFALSE;
1199 *br = *brorig / sum;
1200 if (makeDataBase()->GetParamDouble(listkey, "width", &width)) { *width = *br * twidth; }
1201 }
1202 return kTRUE;
1203}
1204
1205
1206void PStaticData::FreezeDecayBR(Int_t /*id*/, Int_t /*brn*/)
1207{ // set BR static
1208 Fatal("FreezeDecayBR", "not implemented");
1209
1210 //TODO
1211 // Int_t pos = GetPosition(id);
1212 // if (pos!=-1) {
1213 // Int_t idx = pos+brn-1;
1214 // PWidx[idx] = -1;
1215 // printf("Branch %3i set static\n",idx);
1216 // printf("\n*** Warning: Use only at start of macro! ***\n\n");
1217 // }
1218}
1219
1221{
1222 // number of decay channels by pid
1223 if (!makeDataBase()->GetParamInt(pid_param, id, pnmodes_param, &i_result)) {
1224 // if not found obviously no decay
1225 return 0;
1226 }
1227 return *i_result;
1228};
1229
1231{
1232 // number of decay channels by name
1233 if (!makeDataBase()->GetParamInt((char*) id, "pnmodes", &i_result)) { return 0; }
1234 return *i_result;
1235};
1236
1238{
1239 // number of decay channels by key
1240 if (!makeDataBase()->GetParamInt(key, "pnmodes", &i_result)) { return 0; }
1241 return *i_result;
1242};
1243
1245{
1246 Int_t tid[11];
1247 tid[0] = 10;
1248
1249 GetDecayMode(didx, tid);
1250 for (int i = 1; i < tid[0]; i++) {
1251 // cout << didx << ":" << IsParticleHadron(tid[1]) << endl;
1252 if (!IsParticleHadron(tid[1])) return 0;
1253 }
1254 return 1;
1255}
1256
1288/*
1289int PStaticData::AddDecay(int didx, const char * name, const char *parent,
1290 const char * daughters , double br) {
1291 //make new decay with decay index "didx"
1292 //the didx should be a free number (or set to -1 for auto-alloc)
1293 //parent particle is "parent", which must be existing
1294 //"name" is the new unique string identifier of the decay
1295 //daughers is an particle array of the format "p1,p2,p3,..."
1296 //br is the branching ratio
1297 //all branching ratios are re-normalized
1298 clearFreezeOut();
1299 PDataBase *base=makeDataBase();
1300
1301 //get parent key
1302 Int_t parent_key = makeDataBase()->GetEntry(parent);
1303 if (parent_key < 0) {
1304 cout << "PStaticData::addDecay: parent " << parent << " not found in data base" << endl;
1305 return -1;
1306 }
1307
1308 Int_t pid=GetParticleIDByKey(parent_key);
1309 if (pid<0) {
1310 return -1;
1311 }
1312 if (didx<0) {
1313 if (pid<1000) didx=pid*32;
1314 else didx=pid;
1315 while (makeDataBase()->GetEntryInt("didx",didx) >=0 ) {
1316 didx++;
1317 }
1318 if (*system_alloc_verbosity)
1319 Info("AddDecay","(%s) Decay index %i: %s", PRINT_AUTO_ALLOC,didx,name);
1320 }
1321
1322
1323
1324 //check if didx already exists
1325 if (makeDataBase()->GetEntryInt("didx",didx) >=0 ) {
1326 cout << "PStaticData::addDecay: didx " << didx << " already used in data base" << endl;
1327 return -1;
1328 }
1329 Int_t dkey = makeDataBase()->AddListEntry(parent,"pnmodes", "link",name);
1330 if (dkey < 0) {
1331 Warning("AddDecay","Unable to add decay entry to data base");
1332 return -1;
1333 }
1334
1335 //now add the daughters
1336 char *arr1[7];
1337 Int_t arr1_s=7; //max 7 decay products
1338
1339
1340 Tokenize(daughters, ",", arr1, &arr1_s);
1341 //does decay already exist?
1342
1343 Int_t pids[8];
1344 pids[0] = pid;
1345 // cout << pid << endl;
1346 for (int pat = 0; pat < arr1_s; pat++) {
1347 pids[pat+1] = GetParticleID(arr1[pat]);
1348 //cout << pids[pat+1]<<endl;
1349 }
1350 if (GetDecayKey(pids, arr1_s)>=0) {
1351 Warning("AddDecay","Decay already defined");
1352 return -1;
1353 }
1354
1355
1356 for (int pat = 0; pat < arr1_s; pat++) {
1357 char * partc=arr1[pat];
1358 // Int_t *pkey = new int(base->GetEntry(partc));
1359 //This takes into account aliases:
1360 Int_t *pkey = new int( makeStaticData()->GetParticleKey(partc));
1361 if (*pkey<0) {
1362 cout << "Error: processing decay: do not find pid " << partc << endl;
1363 }
1364 const char *ds;
1365 if (pat==0) ds="d1";
1366 if (pat==1) ds="d2";
1367 if (pat==2) ds="d3";
1368 if (pat==3) ds="d4";
1369 if (pat==4) ds="d5";
1370 if (pat==5) ds="d6";
1371 if (pat==6) ds="d7";
1372 if (pat>6) {
1373 Warning("AddDecay","Too many particles");
1374 return -1;
1375 }
1376
1377 base->SetParamInt (dkey,ds,pkey);
1378 }
1379 //set default values
1380 Int_t *ii;
1381 makeDataBase()->GetParamInt(parent_key,"pid",&ii);
1382 base->SetParamInt (dkey, "ppid",ii); //set parent id
1383
1384 ii=new int(didx);
1385 base->SetParamInt (dkey, "didx",ii); //decay mode index
1386
1387 ii=new int(0); //never destructed, but called only once!
1388 if (!base->SetParamInt (dkey, "widx", ii))
1389 return -1;
1390
1391 Double_t * dd=new double(br);
1392 if (!base->SetParamDouble (dkey, "br", dd))
1393 return -1;
1394 if (!base->SetParamDouble (dkey, "brorig", new Double_t(br)))
1395 return -1;
1396 dd=new Double_t(0.);
1397 if (!base->SetParamDouble (dkey, "ethreshold", dd))
1398 return -1;
1399 dd=new Double_t(1.);
1400 if (!base->SetParamDouble (dkey, "scfactor", dd))
1401 return -1;
1402
1403 if (pid>1000) //Do not norm compostite
1404 return didx;
1405
1406 if (! NormParticleBRbyKey(parent_key) ) return -1;
1407 return didx;
1408
1409}
1410*/
1411
1413{
1414 Int_t products = GetDecayNProductsByKey(key);
1415 // cout << products << endl;
1416 if (products == 1) makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name");
1417 if (products == 2) makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name");
1418 if (products == 3) makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name");
1419 if (products == 4) makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name");
1420 if (products == 5) makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name");
1421 if (products == 6)
1422 makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name,d6:name");
1423 if (products == 7)
1424 makeDataBase()->ListEntries(key, 0, "name,didx,br,d1:name,d2:name,d3:name,d4:name,d5:name,d6:name,d7:name");
1425};
1426
1428{
1429 // retrieve number of products by mode key
1430 if (makeDataBase()->GetParamInt(key, d7_param, &i_result)) return 7;
1431 if (makeDataBase()->GetParamInt(key, d6_param, &i_result)) return 6;
1432 if (makeDataBase()->GetParamInt(key, d5_param, &i_result)) return 5;
1433 if (makeDataBase()->GetParamInt(key, d4_param, &i_result)) return 4;
1434 if (makeDataBase()->GetParamInt(key, d3_param, &i_result)) return 3;
1435 if (makeDataBase()->GetParamInt(key, d2_param, &i_result)) return 2;
1436 if (makeDataBase()->GetParamInt(key, d1_param, &i_result)) return 1;
1437 return 0;
1438};
1439
1441{
1442 // retrieve number of products by mode index
1443 if (makeDataBase()->GetParamInt(didx_param, id, d7_param, &i_result)) return 7;
1444 if (makeDataBase()->GetParamInt(didx_param, id, d6_param, &i_result)) return 6;
1445 if (makeDataBase()->GetParamInt(didx_param, id, d5_param, &i_result)) return 5;
1446 if (makeDataBase()->GetParamInt(didx_param, id, d4_param, &i_result)) return 4;
1447 if (makeDataBase()->GetParamInt(didx_param, id, d3_param, &i_result)) return 3;
1448 if (makeDataBase()->GetParamInt(didx_param, id, d2_param, &i_result)) return 2;
1449 if (makeDataBase()->GetParamInt(didx_param, id, d1_param, &i_result)) return 1;
1450 return 0;
1451};
1452
1454{
1455 // number of products by name
1456 if (makeDataBase()->GetParamInt((char*) id, "d7", &i_result)) return 7;
1457 if (makeDataBase()->GetParamInt((char*) id, "d6", &i_result)) return 6;
1458 if (makeDataBase()->GetParamInt((char*) id, "d5", &i_result)) return 5;
1459 if (makeDataBase()->GetParamInt((char*) id, "d4", &i_result)) return 4;
1460 if (makeDataBase()->GetParamInt((char*) id, "d3", &i_result)) return 3;
1461 if (makeDataBase()->GetParamInt((char*) id, "d2", &i_result)) return 2;
1462 if (makeDataBase()->GetParamInt((char*) id, "d1", &i_result)) return 1;
1463 return 0;
1464}
1465
1467{
1468 if (!makeDataBase()->GetParamInt(didx_param, id, ppid_param, &i_result)) {
1469 // if not found obviously no parent
1470 return 0;
1471 }
1472 return *i_result;
1473}
1474
1476{
1477 if (!makeDataBase()->GetParamInt(id, ppid_param, &i_result)) {
1478 // if not found obviously no parent
1479 return 0;
1480 }
1481 return *i_result;
1482}
1483
1485{
1486 // return value is -1 on failure
1487
1488 Int_t* pos;
1489 if (!makeDataBase()->GetParamInt(key, didx_param, &pos)) return -1;
1490 return *pos;
1491}
1492
1493int PStaticData::GetDecayIdx(int* pid, int n)
1494{
1495 // decay-mode index from parent and product ids;
1496 // n is the size of the array
1497 // arguments: pointer to pid array of parent & products,
1498 // number of products
1499
1500 int i, nid[n];
1501 if (n < 2 || !pid) return -1;
1502 for (i = 0; i <= n; ++i) {
1503 if (!PStaticData::IsParticleValid(pid[i])) {
1504 cout << "PStaticData:: GetDecayIdx: id not found:" << pid[i] << endl;
1505 return -2;
1506 }
1507 else if (i)
1508 nid[i - 1] = pid[i]; // make own copy of product array
1509 }
1510 isort(nid, n); // sort the array entries
1511
1512 int id = pid[0], *nm; // parent id, number of decay modes
1513 //Get count info
1514
1515 if (!makeDataBase()->GetParamInt(pid_param, id, count_param, &nm)) { return -3; }
1516 if (!nm) return -4;
1517 Int_t count;
1518 //now loop over decay modes
1519 Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
1520 Int_t listkey = -1;
1521 Int_t tid[11];
1522 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
1523 tid[0] = 10;
1524 GetDecayModeByKey(listkey, tid); // retrieve current mode info
1525 if (tid[0] == n) { // number of products matches input
1526 isort(tid + 1, n); // sort the current mode product pid array
1527 count = 0; // reset the match counter
1528 for (i = 0; i < n; ++i)
1529 count += (tid[i + 1] == nid[i]);
1530 if (count == n) { // input matched
1531 return GetDecayIdxByKey(listkey);
1532 }
1533 }
1534 }
1535
1536 return -1;
1537}
1538
1539int PStaticData::GetDecayKey(int* pid, int n)
1540{
1541 // decay-mode key from parent and product ids;
1542 // n is the size of the daughters array
1543 // arguments: pointer to pid array of parent & products,
1544 // number of products
1545
1546 int i, nid[n];
1547 if (n < 1 || !pid) return -1;
1548 for (i = 0; i <= n; ++i) {
1549 if (!PStaticData::IsParticleValid(pid[i])) {
1550 Warning("GetDecayKey", "id %i not found", pid[i]);
1551 return -2;
1552 }
1553 else if (i) {
1554 nid[i - 1] = pid[i]; // make own copy of product array
1555 }
1556 }
1557
1558 isort(nid, n); // sort the array entries
1559
1560 int id = pid[0], *nm; // parent id, number of decay modes
1561 //Get count info
1562 if (!makeDataBase()->GetParamInt(pid_param, id, count_param, &nm)) { return -3; }
1563 if (!nm) return -4;
1564 Int_t count;
1565 //now loop over decay modes
1566 Int_t key = makeDataBase()->GetEntryInt(pid_param, id);
1567 Int_t listkey = -1;
1568 Int_t tid[11];
1569 while (makeDataBase()->MakeListIterator(key, "pnmodes", "link", &listkey)) {
1570 tid[0] = 10;
1571 GetDecayModeByKey(listkey, tid); // retrieve current mode info
1572 if (tid[0] == n) { // number of products matches input
1573 isort(tid + 1, n); // sort the current mode product pid array
1574 count = 0; // reset the match counter
1575 for (i = 0; i < n; ++i)
1576 count += (tid[i + 1] == nid[i]);
1577 if (count == n) { // input matched
1578 return listkey;
1579 }
1580 }
1581 }
1582
1583 return -1;
1584}
1585
1586
1587void PStaticData::GetDecayMode(int idx, int* id)
1588{
1589 // Retrieves the decay mode info for a given channel n.
1590 // _______________________________________________________________________
1591 // ARGUMENTS: 1. decay-mode index (PPosition),
1592 // 2. pointer to existing integer array (must have large
1593 // enough dimension), 3. pointer to existing double (optional).
1594 // _______________________________________________________________________
1595 // RETURNS: int array with N, i_1, i_2,..., i_N, where N is
1596 // the number of products for the decay mode with index n,
1597 // followed by the pids of these products
1598 //
1599 // N should contain the maximum number of the array-size of before
1600 // calling this function
1601 // if the maximum is exceeded, or any other error occurs, N is set to 0
1602 Int_t *d1_key, *d2_key, *d3_key, *d4_key, *d5_key, *d6_key, *d7_key, found = 0;
1603 ;
1604 if (makeDataBase()->GetParamInt(didx_param, idx, d1_param, &d1_key)) found = 1;
1605 if (makeDataBase()->GetParamInt(didx_param, idx, d2_param, &d2_key)) found = 2;
1606 if (makeDataBase()->GetParamInt(didx_param, idx, d3_param, &d3_key)) found = 3;
1607 if (makeDataBase()->GetParamInt(didx_param, idx, d4_param, &d4_key)) found = 4;
1608 if (makeDataBase()->GetParamInt(didx_param, idx, d5_param, &d5_key)) found = 5;
1609 if (makeDataBase()->GetParamInt(didx_param, idx, d6_param, &d6_key)) found = 6;
1610 if (makeDataBase()->GetParamInt(didx_param, idx, d7_param, &d7_key)) found = 7;
1611
1612 if (found > *id) {
1613 cout << "PStaticData:: size too low" << endl;
1614 *id = 0;
1615 return;
1616 }
1617 else
1618 *id = found;
1619 Int_t *d1_p = nullptr, *d2_p = nullptr, *d3_p = nullptr, *d4_p = nullptr, *d5_p = nullptr, *d6_p = nullptr,
1620 *d7_p = nullptr;
1621 if ((found > 0) && !makeDataBase()->GetParamInt(*d1_key, pid_param, &d1_p)) {
1622 cout << "PStaticData:: Mode: unable to unpack key1 " << *d1_key << endl;
1623 *id = 0;
1624 }
1625 else if ((found > 1) && !makeDataBase()->GetParamInt(*d2_key, pid_param, &d2_p)) {
1626 cout << "PStaticData:: Mode: unable to unpack key2 " << *d2_key << endl;
1627 *id = 0;
1628 }
1629 else if ((found > 2) && !makeDataBase()->GetParamInt(*d3_key, pid_param, &d3_p)) {
1630 cout << "PStaticData:: Mode: unable to unpack key3 " << *d3_key << endl;
1631 *id = 0;
1632 }
1633 else if ((found > 3) && !makeDataBase()->GetParamInt(*d4_key, pid_param, &d4_p)) {
1634 cout << "PStaticData:: Mode: unable to unpack key4 " << *d4_key << endl;
1635 *id = 0;
1636 }
1637 else if ((found > 4) && !makeDataBase()->GetParamInt(*d5_key, pid_param, &d5_p)) {
1638 cout << "PStaticData:: Mode: unable to unpack key5 " << *d5_key << endl;
1639 *id = 0;
1640 }
1641 else if ((found > 5) && !makeDataBase()->GetParamInt(*d6_key, pid_param, &d6_p)) {
1642 cout << "PStaticData:: Mode: unable to unpack key6 " << *d6_key << endl;
1643 *id = 0;
1644 }
1645 else if ((found > 6) && !makeDataBase()->GetParamInt(*d7_key, pid_param, &d7_p)) {
1646 cout << "PStaticData:: Mode: unable to unpack key7 " << *d7_key << endl;
1647 *id = 0;
1648 }
1649 if (d1_p) id[1] = *d1_p;
1650 if (d2_p) id[2] = *d2_p;
1651 if (d3_p) id[3] = *d3_p;
1652 if (d4_p) id[4] = *d4_p;
1653 if (d5_p) id[5] = *d5_p;
1654 if (d6_p) id[6] = *d6_p;
1655 if (d7_p) id[7] = *d7_p;
1656}
1657
1658
1660{
1661 //same as above, but by data base key
1662 Int_t *d1_key, *d2_key, *d3_key, *d4_key, *d5_key, *d6_key, *d7_key, found = 0;
1663 if (makeDataBase()->GetParamInt(idx, d1_param, &d1_key)) found = 1;
1664 if (makeDataBase()->GetParamInt(idx, d2_param, &d2_key)) found = 2;
1665 if (makeDataBase()->GetParamInt(idx, d3_param, &d3_key)) found = 3;
1666 if (makeDataBase()->GetParamInt(idx, d4_param, &d4_key)) found = 4;
1667 if (makeDataBase()->GetParamInt(idx, d5_param, &d5_key)) found = 5;
1668 if (makeDataBase()->GetParamInt(idx, d6_param, &d6_key)) found = 6;
1669 if (makeDataBase()->GetParamInt(idx, d7_param, &d7_key)) found = 7;
1670
1671 if (found > *id) {
1672 cout << "PStaticData:: size too low" << endl;
1673 *id = 0;
1674 return;
1675 }
1676 else
1677 *id = found;
1678 // cout << "id is " << *id << endl;
1679 Int_t *d1_p = nullptr, *d2_p = nullptr, *d3_p = nullptr, *d4_p = nullptr, *d5_p = nullptr, *d6_p = nullptr,
1680 *d7_p = nullptr;
1681 if (*id > 0 && !makeDataBase()->GetParamInt(*d1_key, pid_param, &d1_p)) {
1682 cout << "PStaticData:: ModeByKey: unable to unpack key1 " << *d1_key << endl;
1683 *id = 0;
1684 }
1685 else if (*id > 1 && !makeDataBase()->GetParamInt(*d2_key, pid_param, &d2_p)) {
1686 cout << "PStaticData:: ModeByKey: unable to unpack key2 " << *d2_key << endl;
1687 *id = 0;
1688 }
1689 else if (*id > 2 && !makeDataBase()->GetParamInt(*d3_key, pid_param, &d3_p)) {
1690 cout << "PStaticData:: ModeByKey: unable to unpack key3 " << *d3_key << endl;
1691 *id = 0;
1692 }
1693 else if (*id > 3 && !makeDataBase()->GetParamInt(*d4_key, pid_param, &d4_p)) {
1694 cout << "PStaticData:: ModeByKey: unable to unpack key4 " << *d4_key << endl;
1695 *id = 0;
1696 }
1697 else if (*id > 4 && !makeDataBase()->GetParamInt(*d5_key, pid_param, &d5_p)) {
1698 cout << "PStaticData:: ModeByKey: unable to unpack key5 " << *d5_key << endl;
1699 *id = 0;
1700 }
1701 else if (*id > 5 && !makeDataBase()->GetParamInt(*d6_key, pid_param, &d6_p)) {
1702 cout << "PStaticData:: ModeByKey: unable to unpack key6 " << *d6_key << endl;
1703 *id = 0;
1704 }
1705 else if (*id > 6 && !makeDataBase()->GetParamInt(*d7_key, pid_param, &d7_p)) {
1706 cout << "PStaticData:: ModeByKey: unable to unpack key7 " << *d7_key << endl;
1707 *id = 0;
1708 }
1709 if (d1_p) id[1] = *d1_p;
1710 if (d2_p) id[2] = *d2_p;
1711 if (d3_p) id[3] = *d3_p;
1712 if (d4_p) id[4] = *d4_p;
1713 if (d5_p) id[5] = *d5_p;
1714 if (d6_p) id[6] = *d6_p;
1715 if (d7_p) id[7] = *d7_p;
1716}
1717
1718
1720{
1721 // PWidth[id]
1722 if (!makeDataBase()->GetParamDouble(pid_param, id, width_param, &d_result)) {
1723 cout << "PStaticData::GetParticleTotalWidth: " << id << " not found" << endl;
1724 return 0;
1725 }
1726 return *d_result;
1727}
1728
1730{
1731 // PWidth[id]
1732 if (!makeDataBase()->GetParamDouble(key, width_param, &d_result)) {
1733 cout << "PStaticData::GetParticleTotalWidthByKey: " << key << " not found" << endl;
1734 return 0;
1735 }
1736 return *d_result;
1737}
1738
1739
1740void listParticle(int id)
1741{
1742
1743 if (id < 0) {
1744 makeStaticData(); //this fill data base
1745 makeDataBase()->ListEntries(-1, 1, "pid,*name");
1746 }
1747 else
1749}
1750
1752
1753
1754Bool_t PStaticData::Tokenize(const char* options, const char* delimiter, char** array, int* size)
1755{
1756 for (int i = 0; i < *size; i++)
1757 array[i] = nullptr;
1758
1759 char* mystack = new char[strlen(options) + 1];
1760 strcpy(mystack, options);
1761
1762 Int_t pat = 1;
1763 array[0] = mystack;
1764
1765 while (strstr(mystack, delimiter)) {
1766 if (pat == *size) {
1767 cout << "Tokenize: size " << *size << " is too small for " << options << " ,delim:" << delimiter << endl;
1768 }
1769 char* pos = strstr(mystack, delimiter);
1770 *pos = '\0';
1771 mystack = pos + strlen(delimiter);
1772 array[pat] = mystack;
1773 //cout << "+-: "<<array[pat] << endl;
1774 pat++;
1775 }
1776
1777 *size = pat;
1778
1779 for (int i = 0; i < *size; i++) {
1780 //remove leading/trailing spaces
1781
1782 remove_spaces(&array[i]);
1783 }
1784
1785 return kTRUE;
1786}
1787
1789{
1790
1791 while (**partc == ' ')
1792 (*partc)++;
1793 if (strlen(*partc)) {
1794 int partend = strlen(*partc) - 1;
1795 // cout << partc << ":" << partc[partend] << endl;
1796 while ((*partc)[partend] == ' ' && partend >= 0) {
1797 (*partc)[partend] = '\0';
1798 partend--;
1799 }
1800 }
1801}
1802
1803void PStaticData::dsort(Double_t* a, int n)
1804{
1805 // Sort in ascending order the first n entries of the array *a.
1806 int i, j, l, m, r, rt[20], lt[20], level = 1;
1807 Double_t x, w;
1808 lt[0] = 1;
1809 rt[0] = n;
1810a:
1811 l = lt[level - 1];
1812 r = rt[level - 1];
1813 --level;
1814b:
1815 if (r <= l) {
1816 if (level > 0) goto a;
1817 else
1818 return;
1819 }
1820 i = l;
1821 j = r;
1822 m = (l + r) / 2;
1823 x = *(a + m - 1);
1824 // cout << "X: " << x << endl;
1825c:
1826 while (*(a + i - 1) < x)
1827 ++i;
1828 while (*(a + j - 1) > x)
1829 --j;
1830 while (i <= j) {
1831 w = *(a + i - 1);
1832 *(a + i - 1) = *(a + j - 1);
1833 *(a + j - 1) = w;
1834 ++i;
1835 --j;
1836 if (i < j) goto c;
1837 }
1838 ++level;
1839 if (r - i >= j - l) {
1840 lt[level - 1] = i;
1841 rt[level - 1] = r;
1842 r = j;
1843 }
1844 else {
1845 lt[level - 1] = l;
1846 rt[level - 1] = j;
1847 }
1848 goto b;
1849}
1850
ClassImp(CbmConverterManager)
static constexpr size_t size()
Definition KfSimdPseudo.h:2
fscal v[fmask::Size]
Definition KfSimdPseudo.h:4
PDataBase * makeDataBase()
Definition PDataBase.cxx:22
void listParticle(int id)
PStaticData * makeStaticData()
PStaticData & fStaticData()
void listModes(int id)
PStdData * makeStdData()
Definition PStdData.cxx:47
#define LBATCH_NAME
Definition Pdefines.h:23
#define PRINT_AUTO_ALLOC
Definition Pdefines.h:6
#define NBATCH_NAME
Definition Pdefines.h:22
Int_t MakeParamDouble(const char *paramname, const char *descr)
Bool_t AddEntry(Int_t key, const char *name)
Int_t GetParamDouble(const char *paramname)
Int_t GetParamString(const char *paramname)
Int_t GetParamTObj(const char *paramname)
Int_t MakeParamInt(const char *paramname, const char *descr)
Bool_t SetParamDouble(Int_t key, const char *paramname, Double_t *result)
Bool_t ListEntries(Int_t key=-1, Int_t option=0, const char *pattern=nullptr)
Int_t GetEntry(const char *name)
Int_t AddListEntry(const char *name, const char *count, const char *link, const char *newname)
const char * GetName(Int_t key)
Definition PDataBase.cxx:96
Int_t GetEntryInt(const char *paramname, Int_t value)
Int_t GetParamInt(const char *paramname, Int_t length=-1)
Bool_t SetParamInt(Int_t key, const char *paramname, Int_t *result)
Definition PMesh.h:13
static void remove_spaces(char **partc)
int GetParticleCharge(const int &id)
double GetParticleLMass(const int &id)
void SetParticleIsospin(const char *id, Int_t isospin)
double GetParticleTotalWidthByKey(const int &id)
void SetParticleSpin(const char *id, Int_t spin)
int GetDecayBRFlag(int didx)
const char * GetParticleName(const int &id)
int GetDecayNProducts(const int &)
bool SetDecayBRByKey(int key, double br, int mode)
int GetDecayNProductsByKey(const int &key)
Int_t name_param
int IsParticle(const int &id, const char *name)
void SetTDepth(const int &, const int &)
int GetParticleIDByKey(int key)
void SetTWidx(const int &, const int &)
Double_t GetDecayPartialWidth(Int_t id)
void SetPWidthMesh(const int &, PMesh *mesh)
int MakeDirectoryEntry(const char *name, const char *n, const char *l, const char *ename)
Int_t mesh_param
Int_t tdepth_param
double GetParticleMass(const int &id)
bool SetDecayBR(int didx, double br, int mode)
static Bool_t Tokenize(const char *options, const char *delimiter, char **array, int *size)
Int_t nalias_param
void SetParticleMass(Int_t id, Float_t mass)
int GetDecayIdxByKey(int key)
Int_t widx_param
Int_t umass_param
bool NormParticleBRbyKey(Int_t key)
int GetDecayIdx(int *pid, int n)
void SetDecayBRFlag(int didx, int flag)
int GetParticleID(const char *id, int warn=1)
Double_t * d_result
double GetParticleTotalWidth(const int &id)
Int_t ispin_param
int IsParticleMeson(const int &id)
void SetTWidthMesh(const int &, PMesh *mesh)
void SetTotalNormalization(char *p, int flag=1)
int GetParticleIsospin(const int &id)
void SetParticleLMass(const int &id, const double v)
void SetParticleLepton(const char *id, Int_t num=1)
void SetParticleMeson(const char *id, Int_t num=1)
static void isort(int *i, int n)
Int_t tf1_param
int GetSecondaryKey(int key, int defkey)
Int_t pnmodes_param
PMesh * GetTWidthMesh(const int &)
static void dsort(Double_t *, int)
int GetDecayParentByKey(const int &)
Int_t lepton_param
void FreezeDecayBR(Int_t id, Int_t brn)
int GetParticleLepton(const int &id)
Int_t charge_param
Int_t didx_param
int GetHDepth(const int &)
void SetParticleTotalWidth(Int_t id, Float_t wid)
void SetParticleCharge(const char *id, Int_t charge)
int GetPWidx(const int &)
const char * GetDecayNameByKey(Int_t key)
int GetParticleNChannels(const int &id)
PMesh * GetPWidthMesh(const int &)
int GetAliasParent(const char *alias_name)
Int_t IsDecayHadronic(Int_t didx)
void PrintParticle(int pid)
int GetTWidx(const int &)
int GetParticleKey(const int &id)
int GetDecayParent(const int &)
double GetParticleMassByKey(const int &id)
void SetTF1(const int &, TF1 *mesh)
double GetParticleEmin(const int &id)
Int_t lmass_param
int IsParticleValid(const int &id)
Int_t brorig_param
Bool_t freeze
Int_t parity_param
Double_t * GetBatchValue(const char *name, Int_t make_val=1)
void clearFreezeOut(void)
Definition PStaticData.h:45
void SetParticleBaryon(const char *id, Int_t num=1)
void SetParticleEmin(const int &id, const double v)
Int_t width_param
const char * c_result
Int_t count_param
int GetParticleBaryon(const int &id)
Int_t baryon_param
Int_t lalias_param
int GetTDepth(const int &)
void SetPWidx(const int &, const int &)
Double_t GetDecayBR(Int_t id)
int GetParticleKF(const int Id)
double GetDecayEmin(const int &idx)
double GetParticleUMass(const int &id)
void GetDecayModeByKey(const int, int *n)
Int_t ppid_param
Double_t * system_alloc_verbosity
Int_t * i_result
int GetParticleIDbyKF(const int kf)
void GetDecayMode(const int, int *n)
const char * GetDecayName(Int_t id)
void SetDecayEmin(const int &idx, const double v)
Int_t pkf_param
int GetParticleNChannelsByKey(int id)
int GetParticleSpin(const int &id)
Int_t mass_param
void SetParticleParity(const char *id, Int_t parity)
int AddParticle(int pid, const char *name, double mass)
Int_t meson_param
bool NormParticleBR(Int_t id)
Int_t defkey_param
Int_t hdepth_param
Int_t brflag_param
void SetHDepth(const int &, const int &)
void PrintParticleByKey(int pid)
int GetParticleParity(const int &id)
TObject * t_result
Int_t spin_param
int GetDecayKey(int *pid, int n)
void SetParticleUMass(const int &id, const double v)
Int_t ethreshold_param
TF1 * GetTF1(const int &)
int AddAlias(const char *old_name, const char *new_name)
Int_t pid_param
void PrintDecayByKey(int key)
int IsParticleHadron(const int &id)
Double_t GetDecayPartialWidthByKey(Int_t id)