31 std::string file1 =
"GeneratorInterface/Hydjet2Interface/data/particles.data";
35 std::string file2 =
"GeneratorInterface/Hydjet2Interface/data/tabledecay.txt";
45 fUseCharmParticles = kTRUE;
64 ifstream particleFile;
65 particleFile.open(fParticleFilename);
67 edm::LogError(
"DatabasePDG") <<
"The ASCII file containing the PDG particle list " << fParticleFilename
73 double mass,
width, spin, isospin, isospinZ,
q,
s, aq, as,
c, ac;
75 int goodStatusParticles = 0;
77 edm::LogInfo(
"DatabasePDG") <<
"Start loading particles with the following criteria:" << endl
78 <<
" Use particles containing charm quarks (1:yes;0:no) : " << fUseCharmParticles
80 <<
" Mass range : (" << fMinimumMass <<
"; "
81 << fMaximumMass <<
")" << endl
82 <<
" Width range : (" << fMinimumWidth
83 <<
"; " << fMaximumWidth <<
")";
85 particleFile.exceptions(ios::failbit);
86 while (!particleFile.eof()) {
88 particleFile >>
name >>
mass >>
width >> spin >> isospin >> isospinZ >>
q >>
s >> aq >> as >>
c >> ac >>
pdg;
89 }
catch (ios::failure
const &problem) {
90 LogDebug(
"DatabasePDG") <<
" ios:failure in particle file " << problem.what();
94 fParticles[fNParticles]->SetName(
name);
95 fParticles[fNParticles]->SetPDG(
pdg);
96 fParticles[fNParticles]->SetMass(
mass);
97 fParticles[fNParticles]->SetWidth(
width);
98 fParticles[fNParticles]->SetSpin(spin);
99 fParticles[fNParticles]->SetIsospin(isospin);
100 fParticles[fNParticles]->SetIsospinZ(isospinZ);
101 fParticles[fNParticles]->SetLightQNumber(
q);
102 fParticles[fNParticles]->SetStrangeQNumber(
s);
103 fParticles[fNParticles]->SetLightAQNumber(aq);
104 fParticles[fNParticles]->SetStrangeAQNumber(as);
105 fParticles[fNParticles]->SetCharmQNumber(
c);
106 fParticles[fNParticles]->SetCharmAQNumber(ac);
107 goodStatusParticles++;
108 fStatus[fNParticles] = kTRUE;
110 if (!fUseCharmParticles && (
c > 0 || ac > 0)) {
111 fStatus[fNParticles] = kFALSE;
112 goodStatusParticles--;
115 if (!(fMinimumMass <=
mass &&
mass <= fMaximumMass)) {
116 fStatus[fNParticles] = kFALSE;
117 goodStatusParticles--;
120 if (!(fMinimumWidth <=
width &&
width <= fMaximumWidth)) {
121 fStatus[fNParticles] = kFALSE;
122 goodStatusParticles--;
127 particleFile.close();
128 if (fNParticles == 0) {
129 LogWarning(
"DatabasePDG") <<
" No particles were found in the file specified!!";
133 edm::LogInfo(
"DatabasePDG") <<
" Particle definitions found: " << fNParticles
134 <<
". Good status particles: " << goodStatusParticles;
140 decayFile.open(fDecayFilename);
142 edm::LogError(
"DatabasePDG") <<
"The ASCII file containing the decays list " << fDecayFilename <<
" was not found";
146 int mother_pdg, daughter_pdg[3];
149 decayFile.exceptions(ios::failbit);
150 while (!decayFile.eof()) {
152 for (
int i = 0;
i < 3;
i++)
156 decayFile >> mother_pdg;
157 for (
int i = 0;
i < 3;
i++)
158 decayFile >> daughter_pdg[
i];
159 decayFile >> branching;
160 }
catch (ios::failure
const &problem) {
161 LogDebug(
"DatabasePDG") <<
" ios:failure in decay file " << problem.what();
164 if ((mother_pdg != 0) && (daughter_pdg[0] != 0) && (branching >= 0)) {
166 for (
int i = 0;
i < 3;
i++)
167 if (daughter_pdg[
i] != 0)
169 ParticlePDG *particle = GetPDGParticle(mother_pdg);
171 LogWarning(
"DatabasePDG") <<
" Mother particle PDG (" << mother_pdg
172 <<
") not found in the particle definition list:" << mother_pdg <<
" >>> ";
173 for (
int kk = 0;
kk < nDaughters;
kk++)
177 for (
int kk = 0;
kk < nDaughters;
kk++) {
178 if (!GetPDGParticle(daughter_pdg[
kk])) {
179 LogWarning(
"DatabasePDG") <<
"Daughter particle PDG (" << daughter_pdg[
kk]
180 <<
") not found in the particle definition list: " << mother_pdg <<
">>> ";
181 for (
int kkk = 0; kkk < nDaughters; kkk++)
182 LogWarning(
"DatabasePDG") << daughter_pdg[kkk] <<
" ";
190 int nDecayChannels = 0;
191 for (
int i = 0;
i < fNParticles;
i++) {
192 nDecayChannels += fParticles[
i]->GetNDecayChannels();
194 edm::LogInfo(
"DatabasePDG") <<
"Number of decays found in the database is " << nDecayChannels;
199 if (index < 0 || index > fNParticles) {
200 edm::LogWarning(
"DatabasePDG") <<
"Particle index is negative or too big !!" << endl
201 <<
" It must be inside this range: (0, " << fNParticles - 1 <<
")" << endl
202 <<
" Returning null pointer!!";
205 return fParticles[
index];
209 if (index < 0 || index > fNParticles) {
210 edm::LogWarning(
"DatabasePDG") <<
"Particle index is negative or too big !!" << endl
211 <<
" It must be inside this range: (0, " << fNParticles - 1 <<
")" << endl
212 <<
" Returning null pointer!!";
215 return fStatus[
index];
220 int firstTimeIndex = 0;
221 for (
int i = 0;
i < fNParticles;
i++) {
222 if (
pdg == fParticles[
i]->GetPDG()) {
229 return fParticles[firstTimeIndex];
230 if (nFindings == 0) {
231 edm::LogWarning(
"DatabasePDG") <<
"The particle required with PDG: " <<
pdg <<
" was not found in the database!!";
234 if (nFindings >= 2) {
235 edm::LogWarning(
"DatabasePDG") <<
"The particle required with PDG: " <<
pdg <<
" was found with " << nFindings
236 <<
" entries in the database. Check it out !!" << endl
237 <<
"Returning the first instance found";
238 return fParticles[firstTimeIndex];
245 int firstTimeIndex = 0;
246 for (
int i = 0;
i < fNParticles;
i++) {
247 if (
pdg == fParticles[
i]->GetPDG()) {
254 return fStatus[firstTimeIndex];
255 if (nFindings == 0) {
256 edm::LogWarning(
"DatabasePDG") <<
"The particle required with PDG: " <<
pdg <<
" was not found in the database!!";
259 if (nFindings >= 2) {
260 edm::LogWarning(
"DatabasePDG") <<
"The particle status required for PDG: " <<
pdg <<
" was found with " << nFindings
261 <<
" entries in the database. Check it out !!" << endl
262 <<
"Returning the status of first instance found";
263 return fStatus[firstTimeIndex];
270 int firstTimeIndex = 0;
271 for (
int i = 0;
i < fNParticles;
i++) {
272 if (!strcmp(
name, fParticles[
i]->GetName())) {
279 return fParticles[firstTimeIndex];
280 if (nFindings == 0) {
282 <<
") was not found in the database!!";
285 if (nFindings >= 2) {
286 edm::LogWarning(
"DatabasePDG") <<
"The particle required with name (" <<
name <<
") was found with " << nFindings
287 <<
" entries in the database. Check it out !!" << endl
288 <<
"Returning the first instance found";
289 return fParticles[firstTimeIndex];
296 int firstTimeIndex = 0;
297 for (
int i = 0;
i < fNParticles;
i++) {
298 if (!strcmp(
name, fParticles[
i]->GetName())) {
305 return fStatus[firstTimeIndex];
306 if (nFindings == 0) {
308 <<
") was not found in the database!!";
311 if (nFindings >= 2) {
312 edm::LogWarning(
"DatabasePDG") <<
"The particle status required for name (" <<
name <<
") was found with "
313 << nFindings <<
" entries in the database. Check it out !!" << endl
314 <<
"Returning the first instance found";
315 return fStatus[firstTimeIndex];
321 cout <<
"***********************************************************************************************************"
323 cout <<
"Dumping all the information contained in the database..." << endl;
325 int nGoodStatusDecays = 0;
326 int nGoodStatusParticles = 0;
327 for (
int currPart = 0; currPart < fNParticles; currPart++) {
328 nGoodStatusParticles += (fStatus[currPart] ? 1 : 0);
329 nGoodStatusDecays += (fStatus[currPart] ? fParticles[currPart]->GetNDecayChannels() : 0);
330 nDecays += fParticles[currPart]->GetNDecayChannels();
331 if (!(dumpAll || (!dumpAll && fStatus[currPart])))
333 cout <<
"###### Particle: " << fParticles[currPart]->GetName() <<
" with PDG code "
334 << fParticles[currPart]->GetPDG() << endl;
335 cout <<
" status = " << fStatus[currPart] << endl;
336 cout <<
" mass = " << fParticles[currPart]->GetMass() <<
" GeV" << endl;
337 cout <<
" width = " << fParticles[currPart]->GetWidth() <<
" GeV" << endl;
338 cout <<
" 2*spin = " <<
int(2. * fParticles[currPart]->GetSpin()) << endl;
339 cout <<
" 2*isospin = " <<
int(2. * fParticles[currPart]->GetIsospin()) << endl;
340 cout <<
" 2*isospin3 = " <<
int(2. * fParticles[currPart]->GetIsospinZ()) << endl;
341 cout <<
" u,d quarks = " <<
int(fParticles[currPart]->GetLightQNumber()) << endl;
342 cout <<
" s quarks = " <<
int(fParticles[currPart]->GetStrangeQNumber()) << endl;
343 cout <<
" c quarks = " <<
int(fParticles[currPart]->GetCharmQNumber()) << endl;
344 cout <<
" anti u,d quarks = " <<
int(fParticles[currPart]->GetLightAQNumber()) << endl;
345 cout <<
" anti s quarks = " <<
int(fParticles[currPart]->GetStrangeAQNumber()) << endl;
346 cout <<
" anti c quarks = " <<
int(fParticles[currPart]->GetCharmAQNumber()) << endl;
347 cout <<
" baryon number = " <<
int(fParticles[currPart]->GetBaryonNumber()) << endl;
348 cout <<
" strangeness = " <<
int(fParticles[currPart]->GetStrangeness()) << endl;
349 cout <<
" charmness = " <<
int(fParticles[currPart]->GetCharmness()) << endl;
350 cout <<
" electric charge = " <<
int(fParticles[currPart]->GetElectricCharge()) << endl;
351 cout <<
" full branching = " << fParticles[currPart]->GetFullBranching() << endl;
352 cout <<
" decay modes = " << fParticles[currPart]->GetNDecayChannels() << endl;
353 for (
int currChannel = 0; currChannel < fParticles[currPart]->GetNDecayChannels(); currChannel++) {
354 cout <<
" channel " << currChannel + 1 <<
" with branching "
355 << fParticles[currPart]->GetDecayChannel(currChannel)->GetBranching() << endl;
356 cout <<
" daughters PDG codes: ";
357 double daughtersMass = 0.0;
358 for (
int currDaughter = 0; currDaughter < fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters();
360 cout << fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter) <<
"\t";
362 GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
363 daughtersMass += daughter->
GetMass();
366 cout <<
" daughters sum mass = " << daughtersMass << endl;
370 cout <<
"Finished dumping information for " << fNParticles <<
" particles with " << nDecays
371 <<
" decay channels in total." << endl;
372 cout <<
"**********************************************************************************************************"
376 cout <<
"Finished dumping information for " << nGoodStatusParticles <<
"(" << fNParticles <<
")"
377 <<
" particles with " << nGoodStatusDecays <<
"(" << nDecays <<
")"
378 <<
" decay channels in total." << endl;
379 cout <<
"**********************************************************************************************************"
387 int nImpossibleDecays = 0;
388 for (
int currPart = 0; currPart < fNParticles; currPart++) {
389 if (!fStatus[currPart])
391 int allChannels = fParticles[currPart]->GetNDecayChannels();
392 int allowedChannels = GetNAllowedChannels(fParticles[currPart], fParticles[currPart]->GetMass());
394 cout <<
"Particle " << fParticles[currPart]->GetPDG() <<
" has " << allChannels
395 <<
" decay channels specified in the database" << endl;
396 cout <<
" Allowed channels assuming table mass = " << allowedChannels << endl;
398 if (
dump && allChannels > 0 && allowedChannels == 0) {
399 cout <<
"**********************************************************************" << endl;
400 cout <<
" All channels for this particles are not allowed" << endl;
401 cout <<
"**********************************************************************" << endl;
403 if (
dump && fParticles[currPart]->GetWidth() > 0. && allChannels == 0) {
404 cout <<
"**********************************************************************" << endl;
405 cout <<
" Particle has finite width but no decay channels specified" << endl;
406 cout <<
"**********************************************************************" << endl;
408 for (
int currChannel = 0; currChannel < fParticles[currPart]->GetNDecayChannels(); currChannel++) {
409 double motherMass = fParticles[currPart]->GetMass();
410 double daughtersSumMass = 0.;
411 for (
int currDaughter = 0; currDaughter < fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters();
414 GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
415 daughtersSumMass += daughter->
GetMass();
417 if (daughtersSumMass >= motherMass) {
420 cout <<
"Imposible decay for particle " << fParticles[currPart]->GetPDG() << endl;
421 cout <<
" Channel: " << fParticles[currPart]->GetPDG() <<
" --> ";
422 for (
int currDaughter = 0; currDaughter < fParticles[currPart]->GetDecayChannel(currChannel)->GetNDaughters();
425 GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
429 cout <<
" Mother particle mass = " << motherMass << endl;
430 cout <<
" Daughters sum mass = " << daughtersSumMass << endl;
435 return nImpossibleDecays;
439 if (fNParticles > 0) {
440 fUseCharmParticles =
flag;
441 for (
int i = 0;
i < fNParticles;
i++) {
442 if (fParticles[
i]->GetCharmQNumber() > 0 || fParticles[
i]->GetCharmAQNumber())
448 fUseCharmParticles =
flag;
453 if (fNParticles > 0) {
454 fMinimumWidth =
value;
455 for (
int i = 0;
i < fNParticles;
i++) {
456 if (fParticles[
i]->GetWidth() < fMinimumWidth)
462 fMinimumWidth =
value;
467 if (fNParticles > 0) {
468 fMaximumWidth =
value;
469 for (
int i = 0;
i < fNParticles;
i++) {
470 if (fParticles[
i]->GetWidth() > fMaximumWidth)
476 fMaximumWidth =
value;
481 if (fNParticles > 0) {
484 for (
int i = 0;
i < fNParticles;
i++) {
485 if ((fParticles[
i]->GetWidth() < fMinimumWidth) || (fParticles[
i]->GetWidth() > fMaximumWidth))
500 if (fNParticles > 0) {
501 fMinimumMass =
value;
502 for (
int i = 0;
i < fNParticles;
i++) {
503 if (fParticles[
i]->GetMass() < fMinimumMass)
509 fMinimumMass =
value;
514 if (fNParticles > 0) {
515 fMaximumMass =
value;
516 for (
int i = 0;
i < fNParticles;
i++) {
517 if (fParticles[
i]->GetMass() > fMaximumMass)
523 fMaximumMass =
value;
528 if (fNParticles > 0) {
531 for (
int i = 0;
i < fNParticles;
i++) {
532 if ((fParticles[
i]->GetMass() < fMinimumMass) || (fParticles[
i]->GetMass() > fMaximumMass))
547 if (fNParticles < 2) {
548 edm::LogWarning(
"DatabasePDG") <<
"No particles to sort. Load data first!!";
553 for (
int i = 0;
i < fNParticles;
i++)
557 if (nGoodStatus == fNParticles)
560 if (nGoodStatus == 0)
566 for (
int i = 0;
i < fNParticles - 1;
i++) {
567 if (!fStatus[
i] && fStatus[
i + 1]) {
569 fParticles[
i] = fParticles[
i + 1];
570 fParticles[
i + 1] = temporaryPointer;
571 bool temporaryStatus = fStatus[
i];
572 fStatus[
i] = fStatus[
i + 1];
573 fStatus[
i + 1] = temporaryStatus;
587 for (
int i = 0;
i < fNParticles;
i++)
594 if (fNParticles < 1) {
595 edm::LogError(
"DatabasePDG") <<
"You must load the data before calling this function!!";
603 <<
") was not found !!";
609 flaggedIndexes[
i] = kFALSE;
611 listFile.exceptions(ios::failbit);
612 while (!listFile.eof()) {
615 }
catch (ios::failure
const &problem) {
616 LogDebug(
"DatabasePDG") <<
"ios:failure in list file" << problem.what();
620 for (
int i = 0;
i < fNParticles;
i++) {
621 if (fParticles[
i]->GetPDG() ==
pdg) {
623 flaggedIndexes[
i] = kTRUE;
628 <<
" was asked but not found in the database!!";
632 <<
" was found more than once in the database!!";
638 fStatus[
i] = flaggedIndexes[
i];
641 fStatus[
i] = (fStatus[
i] && flaggedIndexes[
i]);
649 double daughtersSumMass = 0.0;
651 daughtersSumMass += GetPDGParticle(channel->
GetDaughterPDG(
i))->GetMass();
652 if (daughtersSumMass <= motherMass)
658 int nAllowedChannels = 0;
660 nAllowedChannels += (IsChannelAllowed(particle->
GetDecayChannel(
i), motherMass) ? 1 : 0);
661 return nAllowedChannels;