CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DatabasePDG Class Reference

#include <DatabasePDG.h>

Public Member Functions

int CheckImpossibleDecays (bool dump=kFALSE)
 
 DatabasePDG ()
 
void DumpData (bool dumpAll=kFALSE)
 
char * GetDecayFilename ()
 
double GetMaximumMass ()
 
double GetMaximumWidth ()
 
double GetMinimumMass ()
 
double GetMinimumWidth ()
 
int GetNAllowedChannels (ParticlePDG *particle, double motherMass)
 
int GetNParticles (bool all=kFALSE)
 
char * GetParticleFilename ()
 
ParticlePDGGetPDGParticle (char *name)
 
ParticlePDGGetPDGParticle (int pdg)
 
ParticlePDGGetPDGParticleByIndex (int index)
 
bool GetPDGParticleStatus (char *name)
 
bool GetPDGParticleStatus (int pdg)
 
bool GetPDGParticleStatusByIndex (int index)
 
bool GetUseCharmParticles ()
 
bool IsChannelAllowed (DecayChannel *channel, double motherMass)
 
bool LoadData ()
 
void SetDecayFilename (char *filename)
 
void SetMassRange (double min, double max)
 
void SetMaximumMass (double value)
 
void SetMaximumWidth (double value)
 
void SetMinimumMass (double value)
 
void SetMinimumWidth (double value)
 
void SetParticleFilename (char *filename)
 
void SetUseCharmParticles (bool flag)
 
void SetWidthRange (double min, double max)
 
void UseThisListOfParticles (char *filename, bool exclusive=kTRUE)
 
 ~DatabasePDG ()
 

Private Member Functions

bool LoadDecays ()
 
bool LoadParticles ()
 
void SortParticles ()
 

Private Attributes

char fDecayFilename [256]
 
double fMaximumMass
 
double fMaximumWidth
 
double fMinimumMass
 
double fMinimumWidth
 
int fNParticles
 
char fParticleFilename [256]
 
ParticlePDGfParticles [kMaxParticles]
 
bool fStatus [kMaxParticles]
 
bool fUseCharmParticles
 

Detailed Description

Definition at line 34 of file DatabasePDG.h.

Constructor & Destructor Documentation

◆ DatabasePDG()

DatabasePDG::DatabasePDG ( )

Definition at line 28 of file DatabasePDG.cc.

28  {
29  fNParticles = 0;
30 
31  std::string file1 = "GeneratorInterface/Hydjet2Interface/data/particles.data";
33  particlesDATAstr = ((f1.fullPath()).c_str());
34 
35  std::string file2 = "GeneratorInterface/Hydjet2Interface/data/tabledecay.txt";
37  tableDECAYstr = ((f2.fullPath()).c_str());
38 
41  for (int i = 0; i < kMaxParticles; i++) {
42  fParticles[i] = new ParticlePDG();
43  fStatus[i] = kFALSE;
44  }
45  fUseCharmParticles = kTRUE;
46  fMinimumWidth = 0.;
47  fMaximumWidth = 10.;
48  fMinimumMass = 0.;
49  fMaximumMass = 200.;
50 }

References DeadROC_duringRun::f1, DeadROC_duringRun::f2, timingPdfMaker::file1, edmOneToOneComparison::file2, mps_fire::i, kMaxParticles, particlesDATAstr, AlCaHLTBitMon_QueryRunRegistry::string, and tableDECAYstr.

◆ ~DatabasePDG()

DatabasePDG::~DatabasePDG ( )

Definition at line 52 of file DatabasePDG.cc.

52  {
53  for (int i = 0; i < kMaxParticles; i++)
54  delete fParticles[i];
55 }

References mps_fire::i, and kMaxParticles.

Member Function Documentation

◆ CheckImpossibleDecays()

int DatabasePDG::CheckImpossibleDecays ( bool  dump = kFALSE)

Definition at line 385 of file DatabasePDG.cc.

385  {
386  // Check the database for impossible decays
387  int nImpossibleDecays = 0;
388  for (int currPart = 0; currPart < fNParticles; currPart++) {
389  if (!fStatus[currPart])
390  continue;
391  int allChannels = fParticles[currPart]->GetNDecayChannels();
392  int allowedChannels = GetNAllowedChannels(fParticles[currPart], fParticles[currPart]->GetMass());
393  if (dump) {
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;
397  }
398  if (dump && allChannels > 0 && allowedChannels == 0) {
399  cout << "**********************************************************************" << endl;
400  cout << " All channels for this particles are not allowed" << endl;
401  cout << "**********************************************************************" << endl;
402  }
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;
407  }
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();
412  currDaughter++) {
413  ParticlePDG *daughter =
414  GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
415  daughtersSumMass += daughter->GetMass();
416  }
417  if (daughtersSumMass >= motherMass) {
418  nImpossibleDecays++;
419  if (dump) {
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();
423  currDaughter++) {
424  ParticlePDG *daughter =
425  GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
426  cout << daughter->GetPDG() << " ";
427  }
428  cout << endl;
429  cout << " Mother particle mass = " << motherMass << endl;
430  cout << " Daughters sum mass = " << daughtersSumMass << endl;
431  }
432  }
433  }
434  }
435  return nImpossibleDecays;
436 }

References gather_cfg::cout, FrontierConditions_GlobalTag_cff::dump, ParticlePDG::GetMass(), and ParticlePDG::GetPDG().

◆ DumpData()

void DatabasePDG::DumpData ( bool  dumpAll = kFALSE)

Definition at line 320 of file DatabasePDG.cc.

320  {
321  cout << "***********************************************************************************************************"
322  << endl;
323  cout << "Dumping all the information contained in the database..." << endl;
324  int nDecays = 0;
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])))
332  continue;
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();
359  currDaughter++) {
360  cout << fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter) << "\t";
361  ParticlePDG *daughter =
362  GetPDGParticle(fParticles[currPart]->GetDecayChannel(currChannel)->GetDaughterPDG(currDaughter));
363  daughtersMass += daughter->GetMass();
364  }
365  cout << endl;
366  cout << " daughters sum mass = " << daughtersMass << endl;
367  }
368  }
369  if (dumpAll) {
370  cout << "Finished dumping information for " << fNParticles << " particles with " << nDecays
371  << " decay channels in total." << endl;
372  cout << "**********************************************************************************************************"
373  "***"
374  << endl;
375  } else {
376  cout << "Finished dumping information for " << nGoodStatusParticles << "(" << fNParticles << ")"
377  << " particles with " << nGoodStatusDecays << "(" << nDecays << ")"
378  << " decay channels in total." << endl;
379  cout << "**********************************************************************************************************"
380  "***"
381  << endl;
382  }
383 }

References gather_cfg::cout, ParticlePDG::GetMass(), and createfilelist::int.

◆ GetDecayFilename()

char* DatabasePDG::GetDecayFilename ( )
inline

Definition at line 82 of file DatabasePDG.h.

82 { return fDecayFilename; }

References fDecayFilename.

◆ GetMaximumMass()

double DatabasePDG::GetMaximumMass ( )
inline

Definition at line 94 of file DatabasePDG.h.

94 { return fMaximumMass; };

References fMaximumMass.

◆ GetMaximumWidth()

double DatabasePDG::GetMaximumWidth ( )
inline

Definition at line 92 of file DatabasePDG.h.

92 { return fMaximumWidth; };

References fMaximumWidth.

◆ GetMinimumMass()

double DatabasePDG::GetMinimumMass ( )
inline

Definition at line 93 of file DatabasePDG.h.

93 { return fMinimumMass; };

References fMinimumMass.

◆ GetMinimumWidth()

double DatabasePDG::GetMinimumWidth ( )
inline

Definition at line 91 of file DatabasePDG.h.

91 { return fMinimumWidth; };

References fMinimumWidth.

◆ GetNAllowedChannels()

int DatabasePDG::GetNAllowedChannels ( ParticlePDG particle,
double  motherMass 
)

Definition at line 657 of file DatabasePDG.cc.

657  {
658  int nAllowedChannels = 0;
659  for (int i = 0; i < particle->GetNDecayChannels(); i++)
660  nAllowedChannels += (IsChannelAllowed(particle->GetDecayChannel(i), motherMass) ? 1 : 0);
661  return nAllowedChannels;
662 }

References ParticlePDG::GetDecayChannel(), ParticlePDG::GetNDecayChannels(), and mps_fire::i.

Referenced by Decay().

◆ GetNParticles()

int DatabasePDG::GetNParticles ( bool  all = kFALSE)

Definition at line 582 of file DatabasePDG.cc.

582  {
583  if (all)
584  return fNParticles;
585 
586  int nGoodStatus = 0;
587  for (int i = 0; i < fNParticles; i++)
588  if (fStatus[i])
589  nGoodStatus++;
590  return nGoodStatus;
591 }

References python.cmstools::all(), and mps_fire::i.

Referenced by GrandCanonical::BaryonDensity(), GrandCanonical::CharmDensity(), GrandCanonical::ElectroDensity(), GrandCanonical::EnergyDensity(), gen::Hydjet2Hadronizer::initializeForInternalPartons(), GrandCanonical::StrangeDensity(), and NAStrangeDensity::StrangenessDensity().

◆ GetParticleFilename()

char* DatabasePDG::GetParticleFilename ( )
inline

Definition at line 81 of file DatabasePDG.h.

81 { return fParticleFilename; }

References fParticleFilename.

◆ GetPDGParticle() [1/2]

ParticlePDG * DatabasePDG::GetPDGParticle ( char *  name)

Definition at line 268 of file DatabasePDG.cc.

268  {
269  int nFindings = 0;
270  int firstTimeIndex = 0;
271  for (int i = 0; i < fNParticles; i++) {
272  if (!strcmp(name, fParticles[i]->GetName())) {
273  if (nFindings == 0)
274  firstTimeIndex = i;
275  nFindings++;
276  }
277  }
278  if (nFindings == 1)
279  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 nullptr;
284  }
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];
290  }
291  return nullptr;
292 }

References mps_fire::i, and Skims_PA_cff::name.

◆ GetPDGParticle() [2/2]

ParticlePDG * DatabasePDG::GetPDGParticle ( int  pdg)

Definition at line 218 of file DatabasePDG.cc.

218  {
219  int nFindings = 0;
220  int firstTimeIndex = 0;
221  for (int i = 0; i < fNParticles; i++) {
222  if (pdg == fParticles[i]->GetPDG()) {
223  if (nFindings == 0)
224  firstTimeIndex = i;
225  nFindings++;
226  }
227  }
228  if (nFindings == 1)
229  return fParticles[firstTimeIndex];
230  if (nFindings == 0) {
231  edm::LogWarning("DatabasePDG") << "The particle required with PDG: " << pdg << " was not found in the database!!";
232  return nullptr;
233  }
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];
239  }
240  return nullptr;
241 }

References mps_fire::i.

Referenced by Decay(), gen::Hydjet2Hadronizer::generatePartonsAndHadronize(), and gen::Hydjet2Hadronizer::initializeForInternalPartons().

◆ GetPDGParticleByIndex()

ParticlePDG * DatabasePDG::GetPDGParticleByIndex ( int  index)

Definition at line 198 of file DatabasePDG.cc.

198  {
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!!";
203  return nullptr;
204  }
205  return fParticles[index];
206 }

Referenced by GrandCanonical::BaryonDensity(), GrandCanonical::CharmDensity(), GrandCanonical::ElectroDensity(), GrandCanonical::EnergyDensity(), gen::Hydjet2Hadronizer::initializeForInternalPartons(), GrandCanonical::StrangeDensity(), and NAStrangeDensity::StrangenessDensity().

◆ GetPDGParticleStatus() [1/2]

bool DatabasePDG::GetPDGParticleStatus ( char *  name)

Definition at line 294 of file DatabasePDG.cc.

294  {
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)
300  firstTimeIndex = i;
301  nFindings++;
302  }
303  }
304  if (nFindings == 1)
305  return fStatus[firstTimeIndex];
306  if (nFindings == 0) {
307  edm::LogWarning("DatabasePDG") << "The particle required with name (" << name
308  << ") was not found in the database!!";
309  return kFALSE;
310  }
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];
316  }
317  return kFALSE;
318 }

References mps_fire::i, and Skims_PA_cff::name.

◆ GetPDGParticleStatus() [2/2]

bool DatabasePDG::GetPDGParticleStatus ( int  pdg)

Definition at line 243 of file DatabasePDG.cc.

243  {
244  int nFindings = 0;
245  int firstTimeIndex = 0;
246  for (int i = 0; i < fNParticles; i++) {
247  if (pdg == fParticles[i]->GetPDG()) {
248  if (nFindings == 0)
249  firstTimeIndex = i;
250  nFindings++;
251  }
252  }
253  if (nFindings == 1)
254  return fStatus[firstTimeIndex];
255  if (nFindings == 0) {
256  edm::LogWarning("DatabasePDG") << "The particle required with PDG: " << pdg << " was not found in the database!!";
257  return kFALSE;
258  }
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];
264  }
265  return kFALSE;
266 }

References mps_fire::i.

◆ GetPDGParticleStatusByIndex()

bool DatabasePDG::GetPDGParticleStatusByIndex ( int  index)

Definition at line 208 of file DatabasePDG.cc.

208  {
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!!";
213  return kFALSE;
214  }
215  return fStatus[index];
216 }

◆ GetUseCharmParticles()

bool DatabasePDG::GetUseCharmParticles ( )
inline

Definition at line 90 of file DatabasePDG.h.

90 { return fUseCharmParticles; };

References fUseCharmParticles.

◆ IsChannelAllowed()

bool DatabasePDG::IsChannelAllowed ( DecayChannel channel,
double  motherMass 
)

Definition at line 648 of file DatabasePDG.cc.

648  {
649  double daughtersSumMass = 0.0;
650  for (int i = 0; i < channel->GetNDaughters(); i++)
651  daughtersSumMass += GetPDGParticle(channel->GetDaughterPDG(i))->GetMass();
652  if (daughtersSumMass <= motherMass)
653  return kTRUE;
654  return kFALSE;
655 }

References DecayChannel::GetDaughterPDG(), DecayChannel::GetNDaughters(), and mps_fire::i.

◆ LoadData()

bool DatabasePDG::LoadData ( )

Definition at line 61 of file DatabasePDG.cc.

61 { return (LoadParticles() && LoadDecays()); }

Referenced by InitialState::InitialState().

◆ LoadDecays()

bool DatabasePDG::LoadDecays ( )
private

Definition at line 138 of file DatabasePDG.cc.

138  {
139  ifstream decayFile;
140  decayFile.open(fDecayFilename);
141  if (!decayFile) {
142  edm::LogError("DatabasePDG") << "The ASCII file containing the decays list " << fDecayFilename << " was not found";
143  return kFALSE;
144  }
145 
146  int mother_pdg, daughter_pdg[3];
147  double branching;
148 
149  decayFile.exceptions(ios::failbit);
150  while (!decayFile.eof()) {
151  mother_pdg = 0;
152  for (int i = 0; i < 3; i++)
153  daughter_pdg[i] = 0;
154  branching = -1.0;
155  try {
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();
162  break;
163  }
164  if ((mother_pdg != 0) && (daughter_pdg[0] != 0) && (branching >= 0)) {
165  int nDaughters = 0;
166  for (int i = 0; i < 3; i++)
167  if (daughter_pdg[i] != 0)
168  nDaughters++;
169  ParticlePDG *particle = GetPDGParticle(mother_pdg);
170  if (!particle) {
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++)
174  LogWarning("DatabasePDG") << daughter_pdg[kk] << " ";
175  return kFALSE;
176  }
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] << " ";
183  }
184  }
185  DecayChannel decay(mother_pdg, branching, nDaughters, daughter_pdg);
186  particle->AddChannel(decay);
187  }
188  }
189  decayFile.close();
190  int nDecayChannels = 0;
191  for (int i = 0; i < fNParticles; i++) {
192  nDecayChannels += fParticles[i]->GetNDecayChannels();
193  }
194  edm::LogInfo("DatabasePDG") << "Number of decays found in the database is " << nDecayChannels;
195  return kTRUE;
196 }

References ParticlePDG::AddChannel(), PA_ZEESkim_cff::decay, mps_fire::i, GetRecoTauVFromDQM_MC_cff::kk, and LogDebug.

◆ LoadParticles()

bool DatabasePDG::LoadParticles ( )
private

Definition at line 63 of file DatabasePDG.cc.

63  {
64  ifstream particleFile;
65  particleFile.open(fParticleFilename);
66  if (!particleFile) {
67  edm::LogError("DatabasePDG") << "The ASCII file containing the PDG particle list " << fParticleFilename
68  << " was not found";
69  return kFALSE;
70  }
71 
72  char name[9];
73  double mass, width, spin, isospin, isospinZ, q, s, aq, as, c, ac;
74  int pdg;
75  int goodStatusParticles = 0;
76 
77  edm::LogInfo("DatabasePDG") << "Start loading particles with the following criteria:" << endl
78  << " Use particles containing charm quarks (1:yes;0:no) : " << fUseCharmParticles
79  << endl
80  << " Mass range : (" << fMinimumMass << "; "
81  << fMaximumMass << ")" << endl
82  << " Width range : (" << fMinimumWidth
83  << "; " << fMaximumWidth << ")";
84 
85  particleFile.exceptions(ios::failbit);
86  while (!particleFile.eof()) {
87  try {
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();
91  break;
92  }
93 
100  fParticles[fNParticles]->SetIsospinZ(isospinZ);
107  goodStatusParticles++;
108  fStatus[fNParticles] = kTRUE;
109  // check if we want charmed particles
110  if (!fUseCharmParticles && (c > 0 || ac > 0)) {
111  fStatus[fNParticles] = kFALSE;
112  goodStatusParticles--;
113  }
114  // check that the particle mass is inside accepted limits
115  if (!(fMinimumMass <= mass && mass <= fMaximumMass)) {
116  fStatus[fNParticles] = kFALSE;
117  goodStatusParticles--;
118  }
119  // check that the particle width is inside accepted limits
120  if (!(fMinimumWidth <= width && width <= fMaximumWidth)) {
121  fStatus[fNParticles] = kFALSE;
122  goodStatusParticles--;
123  }
124 
125  fNParticles++;
126  }
127  particleFile.close();
128  if (fNParticles == 0) {
129  LogWarning("DatabasePDG") << " No particles were found in the file specified!!";
130  return kFALSE;
131  }
132  SortParticles();
133  edm::LogInfo("DatabasePDG") << " Particle definitions found: " << fNParticles
134  << ". Good status particles: " << goodStatusParticles;
135  return kTRUE;
136 }

References c, LogDebug, EgHLTOffHistBins_cfi::mass, Skims_PA_cff::name, dileptonTrigSettings_cff::pdg, submitPVResolutionJobs::q, alignCSCRings::s, and ApeEstimator_cff::width.

◆ SetDecayFilename()

void DatabasePDG::SetDecayFilename ( char *  filename)

Definition at line 59 of file DatabasePDG.cc.

59 { strcpy(fDecayFilename, filename); }

References corrVsCorr::filename.

◆ SetMassRange()

void DatabasePDG::SetMassRange ( double  min,
double  max 
)

Definition at line 527 of file DatabasePDG.cc.

527  {
528  if (fNParticles > 0) {
529  fMinimumMass = min;
530  fMaximumMass = max;
531  for (int i = 0; i < fNParticles; i++) {
532  if ((fParticles[i]->GetMass() < fMinimumMass) || (fParticles[i]->GetMass() > fMaximumMass))
533  fStatus[i] = kFALSE;
534  }
535  SortParticles();
536 
537  return;
538  } else {
539  fMinimumMass = min;
540  fMaximumMass = max;
541  }
542 
543  return;
544 }

References mps_fire::i, SiStripPI::max, and min().

Referenced by InitialState::InitialState().

◆ SetMaximumMass()

void DatabasePDG::SetMaximumMass ( double  value)

Definition at line 513 of file DatabasePDG.cc.

513  {
514  if (fNParticles > 0) {
516  for (int i = 0; i < fNParticles; i++) {
517  if (fParticles[i]->GetMass() > fMaximumMass)
518  fStatus[i] = kFALSE;
519  }
520  SortParticles();
521  return;
522  } else
524  return;
525 }

References mps_fire::i, and relativeConstraints::value.

◆ SetMaximumWidth()

void DatabasePDG::SetMaximumWidth ( double  value)

Definition at line 466 of file DatabasePDG.cc.

466  {
467  if (fNParticles > 0) {
469  for (int i = 0; i < fNParticles; i++) {
470  if (fParticles[i]->GetWidth() > fMaximumWidth)
471  fStatus[i] = kFALSE;
472  }
473  SortParticles();
474  return;
475  } else
477  return;
478 }

References mps_fire::i, and relativeConstraints::value.

◆ SetMinimumMass()

void DatabasePDG::SetMinimumMass ( double  value)

Definition at line 499 of file DatabasePDG.cc.

499  {
500  if (fNParticles > 0) {
502  for (int i = 0; i < fNParticles; i++) {
503  if (fParticles[i]->GetMass() < fMinimumMass)
504  fStatus[i] = kFALSE;
505  }
506  SortParticles();
507  return;
508  } else
510  return;
511 }

References mps_fire::i, and relativeConstraints::value.

◆ SetMinimumWidth()

void DatabasePDG::SetMinimumWidth ( double  value)

Definition at line 452 of file DatabasePDG.cc.

452  {
453  if (fNParticles > 0) {
455  for (int i = 0; i < fNParticles; i++) {
456  if (fParticles[i]->GetWidth() < fMinimumWidth)
457  fStatus[i] = kFALSE;
458  }
459  SortParticles();
460  return;
461  } else
463  return;
464 }

References mps_fire::i, and relativeConstraints::value.

◆ SetParticleFilename()

void DatabasePDG::SetParticleFilename ( char *  filename)

Definition at line 57 of file DatabasePDG.cc.

57 { strcpy(fParticleFilename, filename); }

References corrVsCorr::filename.

◆ SetUseCharmParticles()

void DatabasePDG::SetUseCharmParticles ( bool  flag)

Definition at line 438 of file DatabasePDG.cc.

438  {
439  if (fNParticles > 0) {
441  for (int i = 0; i < fNParticles; i++) {
442  if (fParticles[i]->GetCharmQNumber() > 0 || fParticles[i]->GetCharmAQNumber())
443  fStatus[i] = flag;
444  }
445  SortParticles();
446  return;
447  } else
449  return;
450 }

References RemoveAddSevLevel::flag, and mps_fire::i.

◆ SetWidthRange()

void DatabasePDG::SetWidthRange ( double  min,
double  max 
)

Definition at line 480 of file DatabasePDG.cc.

480  {
481  if (fNParticles > 0) {
482  fMinimumWidth = min;
483  fMaximumWidth = max;
484  for (int i = 0; i < fNParticles; i++) {
485  if ((fParticles[i]->GetWidth() < fMinimumWidth) || (fParticles[i]->GetWidth() > fMaximumWidth))
486  fStatus[i] = kFALSE;
487  }
488  SortParticles();
489 
490  return;
491  } else {
492  fMinimumWidth = min;
493  fMaximumWidth = max;
494  }
495 
496  return;
497 }

References mps_fire::i, SiStripPI::max, and min().

Referenced by InitialState::InitialState().

◆ SortParticles()

void DatabasePDG::SortParticles ( )
private

Definition at line 546 of file DatabasePDG.cc.

546  {
547  if (fNParticles < 2) {
548  edm::LogWarning("DatabasePDG") << "No particles to sort. Load data first!!";
549  return;
550  }
551 
552  int nGoodStatus = 0;
553  for (int i = 0; i < fNParticles; i++)
554  if (fStatus[i])
555  nGoodStatus++;
556 
557  if (nGoodStatus == fNParticles) // if all particles have good status then there is nothing to do
558  return;
559 
560  if (nGoodStatus == 0) // no good status particles, again nothing to do
561  return;
562 
563  int shifts = 1;
564  while (shifts) {
565  shifts = 0;
566  for (int i = 0; i < fNParticles - 1; i++) {
567  if (!fStatus[i] && fStatus[i + 1]) { // switch if false status is imediately before a true status particle
568  ParticlePDG *temporaryPointer = fParticles[i];
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;
574  shifts++;
575  }
576  }
577  }
578 
579  return;
580 }

References mps_fire::i.

◆ UseThisListOfParticles()

void DatabasePDG::UseThisListOfParticles ( char *  filename,
bool  exclusive = kTRUE 
)

Definition at line 593 of file DatabasePDG.cc.

593  {
594  if (fNParticles < 1) {
595  edm::LogError("DatabasePDG") << "You must load the data before calling this function!!";
596  return;
597  }
598 
599  ifstream listFile;
600  listFile.open(filename);
601  if (!listFile) {
602  edm::LogError("DatabasePDG") << "The ASCII file containing the PDG codes list (" << filename
603  << ") was not found !!";
604  return;
605  }
606 
607  bool flaggedIndexes[kMaxParticles];
608  for (int i = 0; i < kMaxParticles; i++)
609  flaggedIndexes[i] = kFALSE;
610  int pdg = 0;
611  listFile.exceptions(ios::failbit);
612  while (!listFile.eof()) {
613  try {
614  listFile >> pdg;
615  } catch (ios::failure const &problem) {
616  LogDebug("DatabasePDG") << "ios:failure in list file" << problem.what();
617  break;
618  }
619  int found = 0;
620  for (int i = 0; i < fNParticles; i++) {
621  if (fParticles[i]->GetPDG() == pdg) {
622  found++;
623  flaggedIndexes[i] = kTRUE;
624  }
625  }
626  if (!found) {
627  edm::LogWarning("DatabasePDG") << "The particle with PDG code " << pdg
628  << " was asked but not found in the database!!";
629  }
630  if (found > 1) {
631  edm::LogWarning("DatabasePDG") << "The particle with PDG code " << pdg
632  << " was found more than once in the database!!";
633  }
634  }
635 
636  if (exclusive) {
637  for (int i = 0; i < kMaxParticles; i++)
638  fStatus[i] = flaggedIndexes[i];
639  } else {
640  for (int i = 0; i < kMaxParticles; i++)
641  fStatus[i] = (fStatus[i] && flaggedIndexes[i]);
642  }
643  SortParticles();
644 
645  return;
646 }

References generator_cfi::exclusive, corrVsCorr::filename, newFWLiteAna::found, mps_fire::i, kMaxParticles, LogDebug, and dileptonTrigSettings_cff::pdg.

Member Data Documentation

◆ fDecayFilename

char DatabasePDG::fDecayFilename[256]
private

Definition at line 40 of file DatabasePDG.h.

Referenced by GetDecayFilename().

◆ fMaximumMass

double DatabasePDG::fMaximumMass
private

Definition at line 45 of file DatabasePDG.h.

Referenced by GetMaximumMass().

◆ fMaximumWidth

double DatabasePDG::fMaximumWidth
private

Definition at line 43 of file DatabasePDG.h.

Referenced by GetMaximumWidth().

◆ fMinimumMass

double DatabasePDG::fMinimumMass
private

Definition at line 44 of file DatabasePDG.h.

Referenced by GetMinimumMass().

◆ fMinimumWidth

double DatabasePDG::fMinimumWidth
private

Definition at line 42 of file DatabasePDG.h.

Referenced by GetMinimumWidth().

◆ fNParticles

int DatabasePDG::fNParticles
private

Definition at line 36 of file DatabasePDG.h.

◆ fParticleFilename

char DatabasePDG::fParticleFilename[256]
private

Definition at line 39 of file DatabasePDG.h.

Referenced by GetParticleFilename().

◆ fParticles

ParticlePDG* DatabasePDG::fParticles[kMaxParticles]
private

Definition at line 37 of file DatabasePDG.h.

◆ fStatus

bool DatabasePDG::fStatus[kMaxParticles]
private

Definition at line 38 of file DatabasePDG.h.

◆ fUseCharmParticles

bool DatabasePDG::fUseCharmParticles
private

Definition at line 41 of file DatabasePDG.h.

Referenced by GetUseCharmParticles().

DatabasePDG::fDecayFilename
char fDecayFilename[256]
Definition: DatabasePDG.h:40
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
ParticlePDG::SetSpin
void SetSpin(double value)
Definition: ParticlePDG.h:58
mps_fire.i
i
Definition: mps_fire.py:428
ParticlePDG::SetWidth
void SetWidth(double value)
Definition: ParticlePDG.h:57
ParticlePDG::GetFullBranching
double GetFullBranching()
Definition: ParticlePDG.cc:49
tableDECAYstr
const char * tableDECAYstr
Definition: DatabasePDG.cc:26
ParticlePDG::AddChannel
void AddChannel(DecayChannel &channel)
Definition: ParticlePDG.cc:56
ParticlePDG::GetDecayChannel
DecayChannel * GetDecayChannel(int i)
Definition: ParticlePDG.h:92
DatabasePDG::fMinimumMass
double fMinimumMass
Definition: DatabasePDG.h:44
ParticlePDG::SetStrangeAQNumber
void SetStrangeAQNumber(double value)
Definition: ParticlePDG.h:64
DatabasePDG::fMinimumWidth
double fMinimumWidth
Definition: DatabasePDG.h:42
min
T min(T a, T b)
Definition: MathUtil.h:58
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DecayChannel::GetDaughterPDG
int GetDaughterPDG(int i)
Definition: DecayChannel.cc:69
dileptonTrigSettings_cff.pdg
pdg
Definition: dileptonTrigSettings_cff.py:6
ParticlePDG::GetName
char * GetName()
Definition: ParticlePDG.h:68
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edmOneToOneComparison.file2
file2
Definition: edmOneToOneComparison.py:107
DatabasePDG::fParticleFilename
char fParticleFilename[256]
Definition: DatabasePDG.h:39
DatabasePDG::fNParticles
int fNParticles
Definition: DatabasePDG.h:36
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:26
edm::FileInPath
Definition: FileInPath.h:64
ParticlePDG::GetNDecayChannels
int GetNDecayChannels()
Definition: ParticlePDG.h:72
alignCSCRings.s
s
Definition: alignCSCRings.py:92
ParticlePDG::SetStrangeQNumber
void SetStrangeQNumber(double value)
Definition: ParticlePDG.h:63
DatabasePDG::fMaximumMass
double fMaximumMass
Definition: DatabasePDG.h:45
DecayChannel
Definition: DecayChannel.h:22
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
DatabasePDG::SortParticles
void SortParticles()
Definition: DatabasePDG.cc:546
ParticlePDG
Definition: ParticlePDG.h:24
ParticlePDG::SetIsospinZ
void SetIsospinZ(double value)
Definition: ParticlePDG.h:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ParticlePDG::SetCharmQNumber
void SetCharmQNumber(double value)
Definition: ParticlePDG.h:65
DatabasePDG::fParticles
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
DatabasePDG::fMaximumWidth
double fMaximumWidth
Definition: DatabasePDG.h:43
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
DeadROC_duringRun.f2
f2
Definition: DeadROC_duringRun.py:220
FrontierConditions_GlobalTag_cff.dump
dump
Definition: FrontierConditions_GlobalTag_cff.py:12
createfilelist.int
int
Definition: createfilelist.py:10
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
ParticlePDG::GetMass
double GetMass()
Definition: ParticlePDG.h:70
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
ParticlePDG::GetWidth
double GetWidth()
Definition: ParticlePDG.h:71
particlesDATAstr
const char * particlesDATAstr
Definition: DatabasePDG.cc:25
DatabasePDG::IsChannelAllowed
bool IsChannelAllowed(DecayChannel *channel, double motherMass)
Definition: DatabasePDG.cc:648
ParticlePDG::SetName
void SetName(char *name)
Definition: ParticlePDG.h:48
PA_ZEESkim_cff.decay
decay
Definition: PA_ZEESkim_cff.py:26
kMaxParticles
const int kMaxParticles
Definition: DatabasePDG.h:32
generator_cfi.exclusive
exclusive
Definition: generator_cfi.py:24
timingPdfMaker.file1
file1
Definition: timingPdfMaker.py:79
relativeConstraints.value
value
Definition: relativeConstraints.py:53
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
DecayChannel::GetBranching
double GetBranching()
Definition: DecayChannel.h:40
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pdg
Definition: pdg_functions.h:28
DatabasePDG::LoadParticles
bool LoadParticles()
Definition: DatabasePDG.cc:63
ParticlePDG::SetLightQNumber
void SetLightQNumber(double value)
Definition: ParticlePDG.h:61
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
DecayChannel::GetNDaughters
int GetNDaughters()
Definition: DecayChannel.h:41
ParticlePDG::SetPDG
void SetPDG(int value)
Definition: ParticlePDG.h:55
DatabasePDG::LoadDecays
bool LoadDecays()
Definition: DatabasePDG.cc:138
ParticlePDG::GetPDG
int GetPDG()
Definition: ParticlePDG.h:69
DatabasePDG::GetNAllowedChannels
int GetNAllowedChannels(ParticlePDG *particle, double motherMass)
Definition: DatabasePDG.cc:657
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
DatabasePDG::GetPDGParticle
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:218
ParticlePDG::SetIsospin
void SetIsospin(double value)
Definition: ParticlePDG.h:59
DatabasePDG::fStatus
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
DeadROC_duringRun.f1
f1
Definition: DeadROC_duringRun.py:219
ParticlePDG::SetLightAQNumber
void SetLightAQNumber(double value)
Definition: ParticlePDG.h:62
ParticlePDG::SetMass
void SetMass(double value)
Definition: ParticlePDG.h:56
DatabasePDG::fUseCharmParticles
bool fUseCharmParticles
Definition: DatabasePDG.h:41
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
ParticlePDG::SetCharmAQNumber
void SetCharmAQNumber(double value)
Definition: ParticlePDG.h:66