CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DatabasePDG.cc
Go to the documentation of this file.
1 /*
2  Copyright : The FASTMC and SPHMC Collaboration
3  Author : Ionut Cristian Arsene
4  Affiliation : Oslo University, Norway & Institute for Space Sciences, Bucharest, Romania
5  e-mail : i.c.arsene@fys.uio.no
6  Date : 2007/05/30
7 
8  This class is using the particle and decay lists provided by the
9  THERMINATOR (Computer Physics Communications 174 669 (2006)) and
10  SHARE (Computer Physics Communications 167 229 (2005)) collaborations.
11 */
12 
13 
14 #ifndef DATABASE_PDG
16 #endif
17 
18 #include <cstring>
19 #include <iostream>
20 #include <string>
21 #include <fstream>
22 
23 using namespace std;
24 using namespace edm;
25 
26 const char* particlesDATAstr;
27 const char* tableDECAYstr;
28 
30  fNParticles = 0;
31 
32  std::string file1="GeneratorInterface/Hydjet2Interface/data/particles.data";
33  edm::FileInPath f1(file1);
34  particlesDATAstr = ( (f1.fullPath()).c_str() );
35 
36  std::string file2="GeneratorInterface/Hydjet2Interface/data/tabledecay.txt";
37  edm::FileInPath f2(file2);
38  tableDECAYstr = ( (f2.fullPath()).c_str() );
39 
40  strcpy(fParticleFilename, particlesDATAstr);
41  strcpy(fDecayFilename, tableDECAYstr);
42  for(int i=0; i<kMaxParticles; i++) {
43  fParticles[i] = new ParticlePDG();
44  fStatus[i] = kFALSE;
45  }
46  fUseCharmParticles = kTRUE;
47  fMinimumWidth = 0.;
48  fMaximumWidth = 10.;
49  fMinimumMass = 0.;
50  fMaximumMass = 200.;
51 }
52 
54  for(int i=0; i<kMaxParticles; i++)
55  delete fParticles[i];
56 }
57 
59  strcpy(fParticleFilename, filename);
60 }
61 
63  strcpy(fDecayFilename, filename);
64 }
65 
67  return (LoadParticles() && LoadDecays());
68 }
69 
71  ifstream particleFile;
72  particleFile.open(fParticleFilename);
73  if(!particleFile) {
74  edm::LogError("DatabasePDG")<< "The ASCII file containing the PDG particle list " << fParticleFilename << " was not found";
75  return kFALSE;
76  }
77 
78  char name[9];
79  double mass, width, spin, isospin, isospinZ, q, s, aq, as, c, ac;
80  int pdg;
81  int goodStatusParticles = 0;
82 
83  edm::LogInfo("DatabasePDG")<< "Start loading particles with the following criteria:" << endl
84  << " Use particles containing charm quarks (1:yes;0:no) : " << fUseCharmParticles << endl
85  << " Mass range : (" << fMinimumMass << "; " << fMaximumMass << ")" << endl
86  << " Width range : (" << fMinimumWidth << "; " << fMaximumWidth << ")";
87 
88  particleFile.exceptions(ios::failbit);
89  while(!particleFile.eof()) {
90  try {
91  particleFile >> name >> mass >> width >> spin >> isospin >> isospinZ >> q >> s >> aq >> as >> c >> ac >> pdg;
92  }
93  catch (ios::failure const &problem) {
94  LogDebug("DatabasePDG")<<" ios:failure in particle file "<< problem.what();
95  break;
96  }
97 
98  fParticles[fNParticles]->SetName(name);
99  fParticles[fNParticles]->SetPDG(pdg);
100  fParticles[fNParticles]->SetMass(mass);
101  fParticles[fNParticles]->SetWidth(width);
102  fParticles[fNParticles]->SetSpin(spin);
103  fParticles[fNParticles]->SetIsospin(isospin);
104  fParticles[fNParticles]->SetIsospinZ(isospinZ);
105  fParticles[fNParticles]->SetLightQNumber(q);
106  fParticles[fNParticles]->SetStrangeQNumber(s);
107  fParticles[fNParticles]->SetLightAQNumber(aq);
108  fParticles[fNParticles]->SetStrangeAQNumber(as);
109  fParticles[fNParticles]->SetCharmQNumber(c);
110  fParticles[fNParticles]->SetCharmAQNumber(ac);
111  goodStatusParticles++;
112  fStatus[fNParticles] = kTRUE;
113  // check if we want charmed particles
114  if(!fUseCharmParticles && (c>0 || ac>0)) {
115  fStatus[fNParticles] = kFALSE;
116  goodStatusParticles--;
117  }
118  // check that the particle mass is inside accepted limits
119  if(!(fMinimumMass<=mass && mass<=fMaximumMass)) {
120  fStatus[fNParticles] = kFALSE;
121  goodStatusParticles--;
122  }
123  // check that the particle width is inside accepted limits
124  if(!(fMinimumWidth<=width && width<=fMaximumWidth)) {
125  fStatus[fNParticles] = kFALSE;
126  goodStatusParticles--;
127  }
128 
129  fNParticles++;
130  }
131  particleFile.close();
132  if(fNParticles==0) {
133 
134  LogWarning("DatabasePDG")<<" No particles were found in the file specified!!";
135  return kFALSE;
136  }
137  SortParticles();
138  edm::LogInfo("DatabasePDG")<< " Particle definitions found: " << fNParticles << ". Good status particles: " << goodStatusParticles;
139  return kTRUE;
140 }
141 
143  ifstream decayFile;
144  decayFile.open(fDecayFilename);
145  if(!decayFile) {
146  edm::LogError("DatabasePDG")<< "The ASCII file containing the decays list " << fDecayFilename << " was not found";
147  return kFALSE;
148  }
149 
150  int mother_pdg, daughter_pdg[3];
151  double branching;
152 
153  decayFile.exceptions(ios::failbit);
154  while(!decayFile.eof()) {
155  mother_pdg = 0;
156  for(int i=0; i<3; i++) daughter_pdg[i] = 0;
157  branching = -1.0;
158  try {
159  decayFile >> mother_pdg;
160  for(int i=0; i<3; i++)
161  decayFile >> daughter_pdg[i];
162  decayFile >> branching;
163  }
164  catch (ios::failure const &problem) {
165  LogDebug("DatabasePDG")<<" ios:failure in decay file "<< problem.what();
166  break;
167  }
168  if((mother_pdg!=0) && (daughter_pdg[0]!=0) && (branching>=0)) {
169  int nDaughters = 0;
170  for(int i=0; i<3; i++)
171  if(daughter_pdg[i]!=0)
172  nDaughters++;
173  ParticlePDG* particle = GetPDGParticle(mother_pdg);
174  if(!particle) {
175  LogWarning("DatabasePDG")<<" Mother particle PDG (" << mother_pdg
176  << ") not found in the particle definition list:"<< mother_pdg << " >>> ";
177  for(int kk=0; kk<nDaughters; kk++)
178  LogWarning("DatabasePDG")<< daughter_pdg[kk] << " ";
179  return kFALSE;
180  }
181  for(int kk=0; kk<nDaughters; kk++) {
182  if(!GetPDGParticle(daughter_pdg[kk])) {
183  LogWarning("DatabasePDG")<<"Daughter particle PDG (" << daughter_pdg[kk]
184  << ") not found in the particle definition list: " << mother_pdg << ">>> ";
185  for(int kkk=0; kkk<nDaughters; kkk++)
186  LogWarning("DatabasePDG")<< daughter_pdg[kkk] << " ";
187  }
188  }
189  DecayChannel decay(mother_pdg, branching, nDaughters, daughter_pdg);
190  particle->AddChannel(decay);
191  }
192  }
193  decayFile.close();
194  int nDecayChannels = 0;
195  for(int i=0; i<fNParticles; i++) {
196  nDecayChannels += fParticles[i]->GetNDecayChannels();
197  }
198  edm::LogInfo("DatabasePDG")<< "Number of decays found in the database is " << nDecayChannels;
199  return kTRUE;
200 }
201 
203  if(index<0 || index>fNParticles) {
204  edm::LogWarning("DatabasePDG")<< "Particle index is negative or too big !!" << endl
205  << " It must be inside this range: (0, " << fNParticles-1 << ")" << endl
206  << " Returning null pointer!!";
207  return 0x0;
208  }
209  return fParticles[index];
210 }
211 
213  if(index<0 || index>fNParticles) {
214  edm::LogWarning("DatabasePDG")<< "Particle index is negative or too big !!" << endl
215  << " It must be inside this range: (0, " << fNParticles-1 << ")" << endl
216  << " Returning null pointer!!";
217  return kFALSE;
218  }
219  return fStatus[index];
220 }
221 
223  int nFindings = 0;
224  int firstTimeIndex = 0;
225  for(int i=0; i<fNParticles; i++) {
226  if(pdg == fParticles[i]->GetPDG()) {
227  if(nFindings == 0) firstTimeIndex = i;
228  nFindings++;
229  }
230  }
231  if(nFindings == 1) return fParticles[firstTimeIndex];
232  if(nFindings == 0) {
233  edm::LogWarning("DatabasePDG")<< "The particle required with PDG: " << pdg
234  << " was not found in the database!!";
235  return 0x0;
236  }
237  if(nFindings >= 2) {
238  edm::LogWarning("DatabasePDG")<< "The particle required with PDG: " << pdg
239  << " was found with " << nFindings << " entries in the database. Check it out !!" << endl
240  << "Returning the first instance found";
241  return fParticles[firstTimeIndex];
242  }
243  return 0x0;
244 }
245 
247  int nFindings = 0;
248  int firstTimeIndex = 0;
249  for(int i=0; i<fNParticles; i++) {
250  if(pdg == fParticles[i]->GetPDG()) {
251  if(nFindings == 0) firstTimeIndex = i;
252  nFindings++;
253  }
254  }
255  if(nFindings == 1) return fStatus[firstTimeIndex];
256  if(nFindings == 0) {
257  edm::LogWarning("DatabasePDG")<< "The particle required with PDG: " << pdg
258  << " was not found in the database!!";
259  return kFALSE;
260  }
261  if(nFindings >= 2) {
262  edm::LogWarning("DatabasePDG")<< "The particle status required for PDG: " << pdg
263  << " was found with " << nFindings << " entries in the database. Check it out !!" << endl
264  << "Returning the status of first instance found";
265  return fStatus[firstTimeIndex];
266  }
267  return kFALSE;
268 }
269 
271  int nFindings = 0;
272  int firstTimeIndex = 0;
273  for(int i=0; i<fNParticles; i++) {
274  if(!strcmp(name, fParticles[i]->GetName())) {
275  if(nFindings == 0) firstTimeIndex = i;
276  nFindings++;
277  }
278  }
279  if(nFindings == 1) return fParticles[firstTimeIndex];
280  if(nFindings == 0) {
281  edm::LogWarning("DatabasePDG")<< "The particle required with name (" << name
282  << ") was not found in the database!!";
283  return 0x0;
284  }
285  if(nFindings >= 2) {
286  edm::LogWarning("DatabasePDG")<< "The particle required with name (" << name
287  << ") was found with " << nFindings << " entries in the database. Check it out !!" << endl
288  << "Returning the first instance found";
289  return fParticles[firstTimeIndex];
290  }
291  return 0x0;
292 }
293 
295  int nFindings = 0;
296  int firstTimeIndex = 0;
297  for(int i=0; i<fNParticles; i++) {
298  if(!strcmp(name, fParticles[i]->GetName())) {
299  if(nFindings == 0) firstTimeIndex = i;
300  nFindings++;
301  }
302  }
303  if(nFindings == 1) return fStatus[firstTimeIndex];
304  if(nFindings == 0) {
305  edm::LogWarning("DatabasePDG")<< "The particle required with name (" << name
306  << ") was not found in the database!!";
307  return kFALSE;
308  }
309  if(nFindings >= 2) {
310  edm::LogWarning("DatabasePDG")<< "The particle status required for name (" << name
311  << ") was found with " << nFindings << " entries in the database. Check it out !!" << endl
312  << "Returning the first instance found";
313  return fStatus[firstTimeIndex];
314  }
315  return kFALSE;
316 }
317 
318 void DatabasePDG::DumpData(bool dumpAll) {
319  cout << "***********************************************************************************************************" << endl;
320  cout << "Dumping all the information contained in the database..." << endl;
321  int nDecays = 0;
322  int nGoodStatusDecays = 0;
323  int nGoodStatusParticles = 0;
324  for(int currPart=0; currPart<fNParticles; currPart++) {
325  nGoodStatusParticles += (fStatus[currPart] ? 1:0);
326  nGoodStatusDecays += (fStatus[currPart] ? fParticles[currPart]->GetNDecayChannels() : 0);
327  nDecays += fParticles[currPart]->GetNDecayChannels();
328  if(!(dumpAll || (!dumpAll && fStatus[currPart]))) continue;
329  cout << "###### Particle: " << fParticles[currPart]->GetName() << " with PDG code " << fParticles[currPart]->GetPDG() << endl;
330  cout << " status = " << fStatus[currPart] << endl;
331  cout << " mass = " << fParticles[currPart]->GetMass() << " GeV" << endl;
332  cout << " width = " << fParticles[currPart]->GetWidth() << " GeV" << endl;
333  cout << " 2*spin = " << int(2.*fParticles[currPart]->GetSpin()) << endl;
334  cout << " 2*isospin = " << int(2.*fParticles[currPart]->GetIsospin()) << endl;
335  cout << " 2*isospin3 = " << int(2.*fParticles[currPart]->GetIsospinZ()) << endl;
336  cout << " u,d quarks = " << int(fParticles[currPart]->GetLightQNumber()) << endl;
337  cout << " s quarks = " << int(fParticles[currPart]->GetStrangeQNumber()) << endl;
338  cout << " c quarks = " << int(fParticles[currPart]->GetCharmQNumber()) << endl;
339  cout << " anti u,d quarks = " << int(fParticles[currPart]->GetLightAQNumber()) << endl;
340  cout << " anti s quarks = " << int(fParticles[currPart]->GetStrangeAQNumber()) << endl;
341  cout << " anti c quarks = " << int(fParticles[currPart]->GetCharmAQNumber()) << endl;
342  cout << " baryon number = " << int(fParticles[currPart]->GetBaryonNumber()) << endl;
343  cout << " strangeness = " << int(fParticles[currPart]->GetStrangeness()) << endl;
344  cout << " charmness = " << int(fParticles[currPart]->GetCharmness()) << endl;
345  cout << " electric charge = " << int(fParticles[currPart]->GetElectricCharge()) << endl;
346  cout << " full branching = " << fParticles[currPart]->GetFullBranching() << endl;
347  cout << " decay modes = " << fParticles[currPart]->GetNDecayChannels() << endl;
348  for(int currChannel=0; currChannel<fParticles[currPart]->GetNDecayChannels(); currChannel++) {
349  cout << " channel " << currChannel+1 << " with branching " << fParticles[currPart]->GetDecayChannel(currChannel)->GetBranching() << endl;
350  cout << " daughters PDG codes: ";
351  double daughtersMass = 0.0;
352  for(int currDaughter=0; currDaughter<fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters(); currDaughter++) {
353  cout << fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter) << "\t";
354  ParticlePDG *daughter = GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
355  daughtersMass += daughter->GetMass();
356  }
357  cout << endl;
358  cout << " daughters sum mass = " << daughtersMass << endl;
359  }
360  }
361  if(dumpAll) {
362  cout << "Finished dumping information for " << fNParticles << " particles with " << nDecays << " decay channels in total." << endl;
363  cout << "*************************************************************************************************************" << endl;
364  }
365  else {
366  cout << "Finished dumping information for " << nGoodStatusParticles << "(" << fNParticles << ")"
367  << " particles with " << nGoodStatusDecays << "(" << nDecays << ")" << " decay channels in total." << endl;
368  cout << "*************************************************************************************************************" << endl;
369  }
370 }
371 
373  // Check the database for impossible decays
374  int nImpossibleDecays = 0;
375  for(int currPart=0; currPart<fNParticles; currPart++) {
376  if(!fStatus[currPart]) continue;
377  int allChannels = fParticles[currPart]->GetNDecayChannels();
378  int allowedChannels = GetNAllowedChannels(fParticles[currPart], fParticles[currPart]->GetMass());
379  if(dump) {
380  cout << "Particle " << fParticles[currPart]->GetPDG() << " has " << allChannels << " decay channels specified in the database" << endl;
381  cout << " Allowed channels assuming table mass = " << allowedChannels << endl;
382  }
383  if(dump && allChannels>0 && allowedChannels == 0) {
384  cout << "**********************************************************************" << endl;
385  cout << " All channels for this particles are not allowed" << endl;
386  cout << "**********************************************************************" << endl;
387  }
388  if(dump && fParticles[currPart]->GetWidth() > 0. && allChannels == 0) {
389  cout << "**********************************************************************" << endl;
390  cout << " Particle has finite width but no decay channels specified" << endl;
391  cout << "**********************************************************************" << endl;
392  }
393  for(int currChannel=0; currChannel<fParticles[currPart]->GetNDecayChannels(); currChannel++) {
394  double motherMass = fParticles[currPart]->GetMass();
395  double daughtersSumMass = 0.;
396  for(int currDaughter=0; currDaughter<fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters(); currDaughter++) {
397  ParticlePDG *daughter = GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
398  daughtersSumMass += daughter->GetMass();
399  }
400  if(daughtersSumMass >= motherMass) {
401  nImpossibleDecays++;
402  if(dump) {
403  cout << "Imposible decay for particle " << fParticles[currPart]->GetPDG() << endl;
404  cout << " Channel: " << fParticles[currPart]->GetPDG() << " --> ";
405  for(int currDaughter=0; currDaughter<fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters(); currDaughter++) {
406  ParticlePDG *daughter = GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
407  cout << daughter->GetPDG() << " ";
408  }
409  cout << endl;
410  cout << " Mother particle mass = " << motherMass << endl;
411  cout << " Daughters sum mass = " << daughtersSumMass << endl;
412  }
413  }
414  }
415  }
416  return nImpossibleDecays;
417 }
418 
420  if(fNParticles>0) {
421  fUseCharmParticles = flag;
422  for(int i=0; i<fNParticles; i++) {
423  if(fParticles[i]->GetCharmQNumber()>0 || fParticles[i]->GetCharmAQNumber())
424  fStatus[i] = flag;
425  }
426  SortParticles();
427  return;
428  }
429  else
430  fUseCharmParticles = flag;
431  return;
432 }
433 
435  if(fNParticles>0) {
436  fMinimumWidth = value;
437  for(int i=0; i<fNParticles; i++) {
438  if(fParticles[i]->GetWidth() < fMinimumWidth)
439  fStatus[i] = kFALSE;
440  }
441  SortParticles();
442  return;
443  }
444  else
445  fMinimumWidth = value;
446  return;
447 }
448 
450  if(fNParticles>0) {
451  fMaximumWidth = value;
452  for(int i=0; i<fNParticles; i++) {
453  if(fParticles[i]->GetWidth() > fMaximumWidth)
454  fStatus[i] = kFALSE;
455  }
456  SortParticles();
457  return;
458  }
459  else
460  fMaximumWidth = value;
461  return;
462 }
463 
464 void DatabasePDG::SetWidthRange(double min, double max) {
465  if(fNParticles>0) {
466  fMinimumWidth = min;
467  fMaximumWidth = max;
468  for(int i=0; i<fNParticles; i++) {
469  if((fParticles[i]->GetWidth()<fMinimumWidth) || (fParticles[i]->GetWidth()>fMaximumWidth))
470  fStatus[i] = kFALSE;
471  }
472  SortParticles();
473 
474  return;
475  }
476  else {
477  fMinimumWidth = min;
478  fMaximumWidth = max;
479  }
480 
481  return;
482 }
483 
485  if(fNParticles>0) {
486  fMinimumMass = value;
487  for(int i=0; i<fNParticles; i++) {
488  if(fParticles[i]->GetMass() < fMinimumMass)
489  fStatus[i] = kFALSE;
490  }
491  SortParticles();
492  return;
493  }
494  else
495  fMinimumMass = value;
496  return;
497 }
498 
500  if(fNParticles>0) {
501  fMaximumMass = value;
502  for(int i=0; i<fNParticles; i++) {
503  if(fParticles[i]->GetMass() > fMaximumMass)
504  fStatus[i] = kFALSE;
505  }
506  SortParticles();
507  return;
508  }
509  else
510  fMaximumMass = value;
511  return;
512 }
513 
514 void DatabasePDG::SetMassRange(double min, double max) {
515 
516 
517 
518  if(fNParticles>0) {
519  fMinimumMass = min;
520  fMaximumMass = max;
521  for(int i=0; i<fNParticles; i++) {
522  if((fParticles[i]->GetMass()<fMinimumMass) || (fParticles[i]->GetMass()>fMaximumMass))
523  fStatus[i] = kFALSE;
524  }
525  SortParticles();
526 
527  return;
528  }
529  else {
530  fMinimumMass = min;
531  fMaximumMass = max;
532  }
533 
534  return;
535 }
536 
538 
539 
540  if(fNParticles<2) {
541  edm::LogWarning("DatabasePDG")<< "No particles to sort. Load data first!!";
542  return;
543  }
544 
545  int nGoodStatus = 0;
546  for(int i=0; i<fNParticles; i++)
547  if(fStatus[i]) nGoodStatus++;
548 
549  if(nGoodStatus==fNParticles) // if all particles have good status then there is nothing to do
550  return;
551 
552  if(nGoodStatus==0) // no good status particles, again nothing to do
553  return;
554 
555  int shifts = 1;
556  while(shifts) {
557  shifts = 0;
558  for(int i=0; i<fNParticles-1; i++) {
559  if(!fStatus[i] && fStatus[i+1]) { // switch if false status is imediately before a true status particle
560  ParticlePDG *temporaryPointer = fParticles[i];
561  fParticles[i] = fParticles[i+1];
562  fParticles[i+1] = temporaryPointer;
563  bool temporaryStatus = fStatus[i];
564  fStatus[i] = fStatus[i+1];
565  fStatus[i+1] = temporaryStatus;
566  shifts++;
567  }
568  }
569  }
570 
571  return;
572 }
573 
575  if(all)
576  return fNParticles;
577 
578  int nGoodStatus = 0;
579  for(int i=0; i<fNParticles; i++)
580  if(fStatus[i]) nGoodStatus++;
581  return nGoodStatus;
582 }
583 
584 void DatabasePDG::UseThisListOfParticles(char *filename, bool exclusive) {
585  if(fNParticles<1) {
586  edm::LogError("DatabasePDG")<< "You must load the data before calling this function!!";
587  return;
588  }
589 
590  ifstream listFile;
591  listFile.open(filename);
592  if(!listFile) {
593  edm::LogError("DatabasePDG")<< "The ASCII file containing the PDG codes list ("
594  << filename << ") was not found !!";
595  return;
596  }
597 
598  bool flaggedIndexes[kMaxParticles];
599  for(int i=0; i<kMaxParticles; i++)
600  flaggedIndexes[i] = kFALSE;
601  int pdg = 0;
602  listFile.exceptions(ios::failbit);
603  while(!listFile.eof()) {
604  try {
605  listFile >> pdg;
606  }
607  catch (ios::failure const &problem) {
608  LogDebug("DatabasePDG")<< "ios:failure in list file"<< problem.what();
609  break;
610  }
611  int found = 0;
612  for(int i=0; i<fNParticles; i++) {
613  if(fParticles[i]->GetPDG()==pdg) {
614  found++;
615  flaggedIndexes[i] = kTRUE;
616  }
617  }
618  if(!found) {
619  edm::LogWarning("DatabasePDG")<< "The particle with PDG code "
620  << pdg << " was asked but not found in the database!!";
621  }
622  if(found>1) {
623  edm::LogWarning("DatabasePDG")<< "The particle with PDG code "
624  << pdg << " was found more than once in the database!!";
625  }
626  }
627 
628  if(exclusive) {
629  for(int i=0; i<kMaxParticles; i++)
630  fStatus[i] = flaggedIndexes[i];
631  }
632  else {
633  for(int i=0; i<kMaxParticles; i++)
634  fStatus[i] = (fStatus[i] && flaggedIndexes[i]);
635  }
636  SortParticles();
637 
638  return;
639 }
640 
641 bool DatabasePDG::IsChannelAllowed(DecayChannel *channel, double motherMass) {
642  double daughtersSumMass = 0.0;
643  for(int i=0; i<channel->GetNDaughters(); i++)
644  daughtersSumMass += GetPDGParticle(channel->GetDaughterPDG(i))->GetMass();
645  if(daughtersSumMass<=motherMass)
646  return kTRUE;
647  return kFALSE;
648 }
649 
650 int DatabasePDG::GetNAllowedChannels(ParticlePDG *particle, double motherMass) {
651  int nAllowedChannels = 0;
652  for(int i=0; i<particle->GetNDecayChannels(); i++)
653  nAllowedChannels += (IsChannelAllowed(particle->GetDecayChannel(i), motherMass) ? 1:0);
654  return nAllowedChannels;
655 }
#define LogDebug(id)
void SetParticleFilename(char *filename)
Definition: DatabasePDG.cc:58
int i
Definition: DBlmapReader.cc:9
void UseThisListOfParticles(char *filename, bool exclusive=kTRUE)
Definition: DatabasePDG.cc:584
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
int GetNParticles(bool all=kFALSE)
Definition: DatabasePDG.cc:574
int GetNDaughters()
Definition: DecayChannel.h:41
int GetPDG()
Definition: ParticlePDG.h:67
const int kMaxParticles
Definition: DatabasePDG.h:32
void SetMassRange(double min, double max)
Definition: DatabasePDG.cc:514
DecayChannel * GetDecayChannel(int i)
Definition: ParticlePDG.h:87
const char * particlesDATAstr
Definition: DatabasePDG.cc:26
void AddChannel(DecayChannel &channel)
Definition: ParticlePDG.cc:54
bool GetPDGParticleStatusByIndex(int index)
Definition: DatabasePDG.cc:212
int CheckImpossibleDecays(bool dump=kFALSE)
Definition: DatabasePDG.cc:372
ParticlePDG * GetPDGParticleByIndex(int index)
Definition: DatabasePDG.cc:202
void SetUseCharmParticles(bool flag)
Definition: DatabasePDG.cc:419
void SetMaximumMass(double value)
Definition: DatabasePDG.cc:499
int GetNDecayChannels()
Definition: ParticlePDG.h:70
void SortParticles()
Definition: DatabasePDG.cc:537
T min(T a, T b)
Definition: MathUtil.h:58
void DumpData(bool dumpAll=kFALSE)
Definition: DatabasePDG.cc:318
int GetDaughterPDG(int i)
Definition: DecayChannel.cc:64
void SetMinimumMass(double value)
Definition: DatabasePDG.cc:484
bool LoadData()
Definition: DatabasePDG.cc:66
bool GetPDGParticleStatus(int pdg)
Definition: DatabasePDG.cc:246
void SetDecayFilename(char *filename)
Definition: DatabasePDG.cc:62
bool IsChannelAllowed(DecayChannel *channel, double motherMass)
Definition: DatabasePDG.cc:641
void SetWidthRange(double min, double max)
Definition: DatabasePDG.cc:464
bool LoadDecays()
Definition: DatabasePDG.cc:142
const char * tableDECAYstr
Definition: DatabasePDG.cc:27
double GetMass()
Definition: ParticlePDG.h:68
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
std::string fullPath() const
Definition: FileInPath.cc:165
void SetMinimumWidth(double value)
Definition: DatabasePDG.cc:434
int GetNAllowedChannels(ParticlePDG *particle, double motherMass)
Definition: DatabasePDG.cc:650
void SetMaximumWidth(double value)
Definition: DatabasePDG.cc:449
float spin(float ph)
bool LoadParticles()
Definition: DatabasePDG.cc:70