36 std::string file2=
"GeneratorInterface/Hydjet2Interface/data/tabledecay.txt";
46 fUseCharmParticles = kTRUE;
59 strcpy(fParticleFilename, filename);
63 strcpy(fDecayFilename, filename);
67 return (LoadParticles() && LoadDecays());
71 ifstream particleFile;
72 particleFile.open(fParticleFilename);
74 edm::LogError(
"DatabasePDG")<<
"The ASCII file containing the PDG particle list " << fParticleFilename <<
" was not found";
79 double mass,
width,
spin, isospin, isospinZ,
q,
s, aq, as,
c, ac;
81 int goodStatusParticles = 0;
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 <<
")";
88 particleFile.exceptions(ios::failbit);
89 while(!particleFile.eof()) {
91 particleFile >> name >> mass >> width >> spin >> isospin >> isospinZ >> q >> s >> aq >> as >> c >> ac >> pdg;
93 catch (ios::failure
const &problem) {
94 LogDebug(
"DatabasePDG")<<
" ios:failure in particle file "<< problem.what();
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;
114 if(!fUseCharmParticles && (c>0 || ac>0)) {
115 fStatus[fNParticles] = kFALSE;
116 goodStatusParticles--;
119 if(!(fMinimumMass<=mass && mass<=fMaximumMass)) {
120 fStatus[fNParticles] = kFALSE;
121 goodStatusParticles--;
124 if(!(fMinimumWidth<=width && width<=fMaximumWidth)) {
125 fStatus[fNParticles] = kFALSE;
126 goodStatusParticles--;
131 particleFile.close();
134 LogWarning(
"DatabasePDG")<<
" No particles were found in the file specified!!";
138 edm::LogInfo(
"DatabasePDG")<<
" Particle definitions found: " << fNParticles <<
". Good status particles: " << goodStatusParticles;
144 decayFile.open(fDecayFilename);
146 edm::LogError(
"DatabasePDG")<<
"The ASCII file containing the decays list " << fDecayFilename <<
" was not found";
150 int mother_pdg, daughter_pdg[3];
153 decayFile.exceptions(ios::failbit);
154 while(!decayFile.eof()) {
156 for(
int i=0;
i<3;
i++) daughter_pdg[
i] = 0;
159 decayFile >> mother_pdg;
160 for(
int i=0;
i<3;
i++)
161 decayFile >> daughter_pdg[
i];
162 decayFile >> branching;
164 catch (ios::failure
const &problem) {
165 LogDebug(
"DatabasePDG")<<
" ios:failure in decay file "<< problem.what();
168 if((mother_pdg!=0) && (daughter_pdg[0]!=0) && (branching>=0)) {
170 for(
int i=0;
i<3;
i++)
171 if(daughter_pdg[
i]!=0)
173 ParticlePDG* particle = GetPDGParticle(mother_pdg);
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++)
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] <<
" ";
189 DecayChannel decay(mother_pdg, branching, nDaughters, daughter_pdg);
194 int nDecayChannels = 0;
195 for(
int i=0;
i<fNParticles;
i++) {
196 nDecayChannels += fParticles[
i]->GetNDecayChannels();
198 edm::LogInfo(
"DatabasePDG")<<
"Number of decays found in the database is " << nDecayChannels;
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!!";
209 return fParticles[
index];
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!!";
219 return fStatus[
index];
224 int firstTimeIndex = 0;
225 for(
int i=0;
i<fNParticles;
i++) {
226 if(pdg == fParticles[
i]->GetPDG()) {
227 if(nFindings == 0) firstTimeIndex =
i;
231 if(nFindings == 1)
return fParticles[firstTimeIndex];
233 edm::LogWarning(
"DatabasePDG")<<
"The particle required with PDG: " << pdg
234 <<
" was not found in the database!!";
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];
248 int firstTimeIndex = 0;
249 for(
int i=0;
i<fNParticles;
i++) {
250 if(pdg == fParticles[
i]->GetPDG()) {
251 if(nFindings == 0) firstTimeIndex =
i;
255 if(nFindings == 1)
return fStatus[firstTimeIndex];
257 edm::LogWarning(
"DatabasePDG")<<
"The particle required with PDG: " << pdg
258 <<
" was not found in the database!!";
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];
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;
279 if(nFindings == 1)
return fParticles[firstTimeIndex];
281 edm::LogWarning(
"DatabasePDG")<<
"The particle required with name (" << name
282 <<
") was not found in the database!!";
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];
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;
303 if(nFindings == 1)
return fStatus[firstTimeIndex];
305 edm::LogWarning(
"DatabasePDG")<<
"The particle required with name (" << name
306 <<
") was not found in the database!!";
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];
319 cout <<
"***********************************************************************************************************" << endl;
320 cout <<
"Dumping all the information contained in the database..." << endl;
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();
358 cout <<
" daughters sum mass = " << daughtersMass << endl;
362 cout <<
"Finished dumping information for " << fNParticles <<
" particles with " << nDecays <<
" decay channels in total." << endl;
363 cout <<
"*************************************************************************************************************" << endl;
366 cout <<
"Finished dumping information for " << nGoodStatusParticles <<
"(" << fNParticles <<
")"
367 <<
" particles with " << nGoodStatusDecays <<
"(" << nDecays <<
")" <<
" decay channels in total." << endl;
368 cout <<
"*************************************************************************************************************" << endl;
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());
380 cout <<
"Particle " << fParticles[currPart]->GetPDG() <<
" has " << allChannels <<
" decay channels specified in the database" << endl;
381 cout <<
" Allowed channels assuming table mass = " << allowedChannels << endl;
383 if(dump && allChannels>0 && allowedChannels == 0) {
384 cout <<
"**********************************************************************" << endl;
385 cout <<
" All channels for this particles are not allowed" << endl;
386 cout <<
"**********************************************************************" << endl;
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;
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();
400 if(daughtersSumMass >= motherMass) {
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));
410 cout <<
" Mother particle mass = " << motherMass << endl;
411 cout <<
" Daughters sum mass = " << daughtersSumMass << endl;
416 return nImpossibleDecays;
421 fUseCharmParticles = flag;
422 for(
int i=0;
i<fNParticles;
i++) {
423 if(fParticles[
i]->GetCharmQNumber()>0 || fParticles[
i]->GetCharmAQNumber())
430 fUseCharmParticles = flag;
436 fMinimumWidth =
value;
437 for(
int i=0;
i<fNParticles;
i++) {
438 if(fParticles[
i]->GetWidth() < fMinimumWidth)
445 fMinimumWidth =
value;
451 fMaximumWidth =
value;
452 for(
int i=0;
i<fNParticles;
i++) {
453 if(fParticles[
i]->GetWidth() > fMaximumWidth)
460 fMaximumWidth =
value;
468 for(
int i=0;
i<fNParticles;
i++) {
469 if((fParticles[
i]->GetWidth()<fMinimumWidth) || (fParticles[
i]->GetWidth()>fMaximumWidth))
486 fMinimumMass =
value;
487 for(
int i=0;
i<fNParticles;
i++) {
488 if(fParticles[
i]->GetMass() < fMinimumMass)
495 fMinimumMass =
value;
501 fMaximumMass =
value;
502 for(
int i=0;
i<fNParticles;
i++) {
503 if(fParticles[
i]->GetMass() > fMaximumMass)
510 fMaximumMass =
value;
521 for(
int i=0;
i<fNParticles;
i++) {
522 if((fParticles[
i]->GetMass()<fMinimumMass) || (fParticles[
i]->GetMass()>fMaximumMass))
541 edm::LogWarning(
"DatabasePDG")<<
"No particles to sort. Load data first!!";
546 for(
int i=0;
i<fNParticles;
i++)
547 if(fStatus[
i]) nGoodStatus++;
549 if(nGoodStatus==fNParticles)
558 for(
int i=0; i<fNParticles-1; i++) {
559 if(!fStatus[i] && fStatus[i+1]) {
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;
579 for(
int i=0;
i<fNParticles;
i++)
580 if(fStatus[
i]) nGoodStatus++;
586 edm::LogError(
"DatabasePDG")<<
"You must load the data before calling this function!!";
591 listFile.open(filename);
593 edm::LogError(
"DatabasePDG")<<
"The ASCII file containing the PDG codes list ("
594 << filename <<
") was not found !!";
600 flaggedIndexes[
i] = kFALSE;
602 listFile.exceptions(ios::failbit);
603 while(!listFile.eof()) {
607 catch (ios::failure
const &problem) {
608 LogDebug(
"DatabasePDG")<<
"ios:failure in list file"<< problem.what();
612 for(
int i=0;
i<fNParticles;
i++) {
613 if(fParticles[
i]->GetPDG()==pdg) {
615 flaggedIndexes[
i] = kTRUE;
620 << pdg <<
" was asked but not found in the database!!";
624 << pdg <<
" was found more than once in the database!!";
630 fStatus[
i] = flaggedIndexes[
i];
634 fStatus[
i] = (fStatus[
i] && flaggedIndexes[
i]);
642 double daughtersSumMass = 0.0;
644 daughtersSumMass += GetPDGParticle(channel->
GetDaughterPDG(
i))->GetMass();
645 if(daughtersSumMass<=motherMass)
651 int nAllowedChannels = 0;
653 nAllowedChannels += (IsChannelAllowed(particle->
GetDecayChannel(
i), motherMass) ? 1:0);
654 return nAllowedChannels;
void SetParticleFilename(char *filename)
void UseThisListOfParticles(char *filename, bool exclusive=kTRUE)
ParticlePDG * GetPDGParticle(int pdg)
int GetNParticles(bool all=kFALSE)
void SetMassRange(double min, double max)
DecayChannel * GetDecayChannel(int i)
const char * particlesDATAstr
void AddChannel(DecayChannel &channel)
bool GetPDGParticleStatusByIndex(int index)
int CheckImpossibleDecays(bool dump=kFALSE)
ParticlePDG * GetPDGParticleByIndex(int index)
void SetUseCharmParticles(bool flag)
void SetMaximumMass(double value)
void DumpData(bool dumpAll=kFALSE)
int GetDaughterPDG(int i)
void SetMinimumMass(double value)
bool GetPDGParticleStatus(int pdg)
void SetDecayFilename(char *filename)
bool IsChannelAllowed(DecayChannel *channel, double motherMass)
void SetWidthRange(double min, double max)
const char * tableDECAYstr
std::string fullPath() const
void SetMinimumWidth(double value)
int GetNAllowedChannels(ParticlePDG *particle, double motherMass)
void SetMaximumWidth(double value)