CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (int pdg)
 
ParticlePDGGetPDGParticle (char *name)
 
ParticlePDGGetPDGParticleByIndex (int index)
 
bool GetPDGParticleStatus (int pdg)
 
bool GetPDGParticleStatus (char *name)
 
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 ( )

Definition at line 29 of file DatabasePDG.cc.

References python.connectstrParser::f1, python.connectstrParser::f2, timingPdfMaker::file1, edm::FileInPath::fullPath(), i, kMaxParticles, particlesDATAstr, AlCaHLTBitMon_QueryRunRegistry::string, and tableDECAYstr.

29  {
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 
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 }
int i
Definition: DBlmapReader.cc:9
double fMinimumWidth
Definition: DatabasePDG.h:42
int fNParticles
Definition: DatabasePDG.h:36
const int kMaxParticles
Definition: DatabasePDG.h:32
const char * particlesDATAstr
Definition: DatabasePDG.cc:26
char fParticleFilename[256]
Definition: DatabasePDG.h:39
double fMaximumMass
Definition: DatabasePDG.h:45
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double fMaximumWidth
Definition: DatabasePDG.h:43
const char * tableDECAYstr
Definition: DatabasePDG.cc:27
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
bool fUseCharmParticles
Definition: DatabasePDG.h:41
double fMinimumMass
Definition: DatabasePDG.h:44
char fDecayFilename[256]
Definition: DatabasePDG.h:40
DatabasePDG::~DatabasePDG ( )

Definition at line 53 of file DatabasePDG.cc.

References i, and kMaxParticles.

53  {
54  for(int i=0; i<kMaxParticles; i++)
55  delete fParticles[i];
56 }
int i
Definition: DBlmapReader.cc:9
const int kMaxParticles
Definition: DatabasePDG.h:32
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37

Member Function Documentation

int DatabasePDG::CheckImpossibleDecays ( bool  dump = kFALSE)

Definition at line 372 of file DatabasePDG.cc.

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

372  {
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 }
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
int fNParticles
Definition: DatabasePDG.h:36
int GetNDaughters()
Definition: DecayChannel.h:41
int GetPDG()
Definition: ParticlePDG.h:67
DecayChannel * GetDecayChannel(int i)
Definition: ParticlePDG.h:87
int GetNDecayChannels()
Definition: ParticlePDG.h:70
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double GetMass()
Definition: ParticlePDG.h:68
tuple cout
Definition: gather_cfg.py:121
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
int GetNAllowedChannels(ParticlePDG *particle, double motherMass)
Definition: DatabasePDG.cc:650
void DatabasePDG::DumpData ( bool  dumpAll = kFALSE)

Definition at line 318 of file DatabasePDG.cc.

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

318  {
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 }
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
int fNParticles
Definition: DatabasePDG.h:36
int GetNDaughters()
Definition: DecayChannel.h:41
int GetPDG()
Definition: ParticlePDG.h:67
double GetBranching()
Definition: DecayChannel.h:40
DecayChannel * GetDecayChannel(int i)
Definition: ParticlePDG.h:87
char * GetName()
Definition: ParticlePDG.h:66
double GetWidth()
Definition: ParticlePDG.h:69
int GetNDecayChannels()
Definition: ParticlePDG.h:70
int GetDaughterPDG(int i)
Definition: DecayChannel.cc:64
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double GetMass()
Definition: ParticlePDG.h:68
double GetFullBranching()
Definition: ParticlePDG.cc:47
tuple cout
Definition: gather_cfg.py:121
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
char* DatabasePDG::GetDecayFilename ( )
inline

Definition at line 82 of file DatabasePDG.h.

References fDecayFilename.

82 {return fDecayFilename;}
char fDecayFilename[256]
Definition: DatabasePDG.h:40
double DatabasePDG::GetMaximumMass ( )
inline

Definition at line 94 of file DatabasePDG.h.

References fMaximumMass.

94 {return fMaximumMass;};
double fMaximumMass
Definition: DatabasePDG.h:45
double DatabasePDG::GetMaximumWidth ( )
inline

Definition at line 92 of file DatabasePDG.h.

References fMaximumWidth.

92 {return fMaximumWidth;};
double fMaximumWidth
Definition: DatabasePDG.h:43
double DatabasePDG::GetMinimumMass ( )
inline

Definition at line 93 of file DatabasePDG.h.

References fMinimumMass.

93 {return fMinimumMass;};
double fMinimumMass
Definition: DatabasePDG.h:44
double DatabasePDG::GetMinimumWidth ( )
inline

Definition at line 91 of file DatabasePDG.h.

References fMinimumWidth.

91 {return fMinimumWidth;};
double fMinimumWidth
Definition: DatabasePDG.h:42
int DatabasePDG::GetNAllowedChannels ( ParticlePDG particle,
double  motherMass 
)

Definition at line 650 of file DatabasePDG.cc.

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

Referenced by Decay().

650  {
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 }
int i
Definition: DBlmapReader.cc:9
DecayChannel * GetDecayChannel(int i)
Definition: ParticlePDG.h:87
int GetNDecayChannels()
Definition: ParticlePDG.h:70
bool IsChannelAllowed(DecayChannel *channel, double motherMass)
Definition: DatabasePDG.cc:641
int DatabasePDG::GetNParticles ( bool  all = kFALSE)

Definition at line 574 of file DatabasePDG.cc.

References i.

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

574  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
char* DatabasePDG::GetParticleFilename ( )
inline

Definition at line 81 of file DatabasePDG.h.

References fParticleFilename.

81 {return fParticleFilename;}
char fParticleFilename[256]
Definition: DatabasePDG.h:39
ParticlePDG * DatabasePDG::GetPDGParticle ( int  pdg)

Definition at line 222 of file DatabasePDG.cc.

References i.

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

222  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
ParticlePDG * DatabasePDG::GetPDGParticle ( char *  name)

Definition at line 270 of file DatabasePDG.cc.

References i.

270  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
ParticlePDG * DatabasePDG::GetPDGParticleByIndex ( int  index)

Definition at line 202 of file DatabasePDG.cc.

References cmsHarvester::index.

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

202  {
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 }
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool DatabasePDG::GetPDGParticleStatus ( int  pdg)

Definition at line 246 of file DatabasePDG.cc.

References i.

246  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
bool DatabasePDG::GetPDGParticleStatus ( char *  name)

Definition at line 294 of file DatabasePDG.cc.

References i.

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) 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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
bool DatabasePDG::GetPDGParticleStatusByIndex ( int  index)

Definition at line 212 of file DatabasePDG.cc.

References cmsHarvester::index.

212  {
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 }
int fNParticles
Definition: DatabasePDG.h:36
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
bool DatabasePDG::GetUseCharmParticles ( )
inline

Definition at line 90 of file DatabasePDG.h.

References fUseCharmParticles.

90 {return fUseCharmParticles;};
bool fUseCharmParticles
Definition: DatabasePDG.h:41
bool DatabasePDG::IsChannelAllowed ( DecayChannel channel,
double  motherMass 
)

Definition at line 641 of file DatabasePDG.cc.

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

641  {
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 }
int i
Definition: DBlmapReader.cc:9
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
int GetNDaughters()
Definition: DecayChannel.h:41
int GetDaughterPDG(int i)
Definition: DecayChannel.cc:64
bool DatabasePDG::LoadData ( )

Definition at line 66 of file DatabasePDG.cc.

Referenced by InitialState::InitialState().

66  {
67  return (LoadParticles() && LoadDecays());
68 }
bool LoadDecays()
Definition: DatabasePDG.cc:142
bool LoadParticles()
Definition: DatabasePDG.cc:70
bool DatabasePDG::LoadDecays ( )
private

Definition at line 142 of file DatabasePDG.cc.

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

142  {
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 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
ParticlePDG * GetPDGParticle(int pdg)
Definition: DatabasePDG.cc:222
int fNParticles
Definition: DatabasePDG.h:36
void AddChannel(DecayChannel &channel)
Definition: ParticlePDG.cc:54
int GetNDecayChannels()
Definition: ParticlePDG.h:70
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
char fDecayFilename[256]
Definition: DatabasePDG.h:40
bool DatabasePDG::LoadParticles ( )
private

Definition at line 70 of file DatabasePDG.cc.

References EnergyCorrector::c, LogDebug, mergeVDriftHistosByStation::name, lumiQueryAPI::q, alignCSCRings::s, spin(), and create_public_lumi_plots::width.

70  {
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 
103  fParticles[fNParticles]->SetIsospin(isospin);
104  fParticles[fNParticles]->SetIsospinZ(isospinZ);
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 }
#define LogDebug(id)
double fMinimumWidth
Definition: DatabasePDG.h:42
void SetLightQNumber(double value)
Definition: ParticlePDG.h:59
int fNParticles
Definition: DatabasePDG.h:36
void SetStrangeQNumber(double value)
Definition: ParticlePDG.h:61
void SetIsospin(double value)
Definition: ParticlePDG.h:57
void SetLightAQNumber(double value)
Definition: ParticlePDG.h:60
void SetMass(double value)
Definition: ParticlePDG.h:54
char fParticleFilename[256]
Definition: DatabasePDG.h:39
void SortParticles()
Definition: DatabasePDG.cc:537
double fMaximumMass
Definition: DatabasePDG.h:45
void SetName(char *name)
Definition: ParticlePDG.h:48
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double fMaximumWidth
Definition: DatabasePDG.h:43
void SetIsospinZ(double value)
Definition: ParticlePDG.h:58
void SetPDG(int value)
Definition: ParticlePDG.h:53
void SetCharmAQNumber(double value)
Definition: ParticlePDG.h:64
void SetCharmQNumber(double value)
Definition: ParticlePDG.h:63
void SetStrangeAQNumber(double value)
Definition: ParticlePDG.h:62
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void SetSpin(double value)
Definition: ParticlePDG.h:56
bool fUseCharmParticles
Definition: DatabasePDG.h:41
void SetWidth(double value)
Definition: ParticlePDG.h:55
double fMinimumMass
Definition: DatabasePDG.h:44
float spin(float ph)
void DatabasePDG::SetDecayFilename ( char *  filename)

Definition at line 62 of file DatabasePDG.cc.

62  {
63  strcpy(fDecayFilename, filename);
64 }
tuple filename
Definition: lut2db_cfg.py:20
char fDecayFilename[256]
Definition: DatabasePDG.h:40
void DatabasePDG::SetMassRange ( double  min,
double  max 
)

Definition at line 514 of file DatabasePDG.cc.

References i, bookConverter::max, and min().

Referenced by InitialState::InitialState().

514  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
T min(T a, T b)
Definition: MathUtil.h:58
double fMaximumMass
Definition: DatabasePDG.h:45
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
double fMinimumMass
Definition: DatabasePDG.h:44
void DatabasePDG::SetMaximumMass ( double  value)

Definition at line 499 of file DatabasePDG.cc.

References i, and relativeConstraints::value.

499  {
500  if(fNParticles>0) {
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
511  return;
512 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
double fMaximumMass
Definition: DatabasePDG.h:45
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void DatabasePDG::SetMaximumWidth ( double  value)

Definition at line 449 of file DatabasePDG.cc.

References i, and relativeConstraints::value.

449  {
450  if(fNParticles>0) {
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
461  return;
462 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double fMaximumWidth
Definition: DatabasePDG.h:43
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void DatabasePDG::SetMinimumMass ( double  value)

Definition at line 484 of file DatabasePDG.cc.

References i, and relativeConstraints::value.

484  {
485  if(fNParticles>0) {
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
496  return;
497 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
double fMinimumMass
Definition: DatabasePDG.h:44
void DatabasePDG::SetMinimumWidth ( double  value)

Definition at line 434 of file DatabasePDG.cc.

References i, and relativeConstraints::value.

434  {
435  if(fNParticles>0) {
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
446  return;
447 }
int i
Definition: DBlmapReader.cc:9
double fMinimumWidth
Definition: DatabasePDG.h:42
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void DatabasePDG::SetParticleFilename ( char *  filename)

Definition at line 58 of file DatabasePDG.cc.

58  {
59  strcpy(fParticleFilename, filename);
60 }
char fParticleFilename[256]
Definition: DatabasePDG.h:39
tuple filename
Definition: lut2db_cfg.py:20
void DatabasePDG::SetUseCharmParticles ( bool  flag)

Definition at line 419 of file DatabasePDG.cc.

References i.

419  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
bool fUseCharmParticles
Definition: DatabasePDG.h:41
void DatabasePDG::SetWidthRange ( double  min,
double  max 
)

Definition at line 464 of file DatabasePDG.cc.

References i, bookConverter::max, and min().

Referenced by InitialState::InitialState().

464  {
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 }
int i
Definition: DBlmapReader.cc:9
double fMinimumWidth
Definition: DatabasePDG.h:42
int fNParticles
Definition: DatabasePDG.h:36
void SortParticles()
Definition: DatabasePDG.cc:537
T min(T a, T b)
Definition: MathUtil.h:58
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
double fMaximumWidth
Definition: DatabasePDG.h:43
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void DatabasePDG::SortParticles ( )
private

Definition at line 537 of file DatabasePDG.cc.

References i.

537  {
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 }
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38
void DatabasePDG::UseThisListOfParticles ( char *  filename,
bool  exclusive = kTRUE 
)

Definition at line 584 of file DatabasePDG.cc.

References newFWLiteAna::found, i, kMaxParticles, and LogDebug.

584  {
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 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int fNParticles
Definition: DatabasePDG.h:36
const int kMaxParticles
Definition: DatabasePDG.h:32
void SortParticles()
Definition: DatabasePDG.cc:537
ParticlePDG * fParticles[kMaxParticles]
Definition: DatabasePDG.h:37
tuple filename
Definition: lut2db_cfg.py:20
bool fStatus[kMaxParticles]
Definition: DatabasePDG.h:38

Member Data Documentation

char DatabasePDG::fDecayFilename[256]
private

Definition at line 40 of file DatabasePDG.h.

Referenced by GetDecayFilename().

double DatabasePDG::fMaximumMass
private

Definition at line 45 of file DatabasePDG.h.

Referenced by GetMaximumMass().

double DatabasePDG::fMaximumWidth
private

Definition at line 43 of file DatabasePDG.h.

Referenced by GetMaximumWidth().

double DatabasePDG::fMinimumMass
private

Definition at line 44 of file DatabasePDG.h.

Referenced by GetMinimumMass().

double DatabasePDG::fMinimumWidth
private

Definition at line 42 of file DatabasePDG.h.

Referenced by GetMinimumWidth().

int DatabasePDG::fNParticles
private

Definition at line 36 of file DatabasePDG.h.

char DatabasePDG::fParticleFilename[256]
private

Definition at line 39 of file DatabasePDG.h.

Referenced by GetParticleFilename().

ParticlePDG* DatabasePDG::fParticles[kMaxParticles]
private

Definition at line 37 of file DatabasePDG.h.

bool DatabasePDG::fStatus[kMaxParticles]
private

Definition at line 38 of file DatabasePDG.h.

bool DatabasePDG::fUseCharmParticles
private

Definition at line 41 of file DatabasePDG.h.

Referenced by GetUseCharmParticles().