GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
genie::PDGCodeList Class Reference

A list of PDG codes. More...

#include <PDGCodeList.h>

Inheritance diagram for genie::PDGCodeList:
Inheritance graph
[legend]
Collaboration diagram for genie::PDGCodeList:
Collaboration graph
[legend]

Public Member Functions

 PDGCodeList (bool allowdup=false)
 
 PDGCodeList (size_type n, bool allowdup=false)
 
 PDGCodeList (const PDGCodeList &list)
 
 ~PDGCodeList ()
 
void push_back (int pdg_code)
 
void insert (iterator pos, size_type n, const int &x)
 
bool CheckPDGCode (int pdg_code) const
 PDG code checks used by PDGCodeList. More...
 
bool ExistsInPDGLibrary (int pdg_code) const
 
bool ExistsInPDGCodeList (int pdg_code) const
 
void Copy (const PDGCodeList &list)
 copy / print More...
 
void Print (ostream &stream) const
 
bool DuplEntriesAllowed (void) const
 check state More...
 
PDGCodeListoperator= (const PDGCodeList &list)
 overloaded operators More...
 

Private Attributes

bool fAllowDuplicateEntries
 allow duplicate entries in the list? More...
 

Friends

ostream & operator<< (ostream &stream, const PDGCodeList &list)
 

Detailed Description

A list of PDG codes.

Author
Costas Andreopoulos <c.andreopoulos cern.ch> University of Liverpool
Created:
May 13, 2005
License:
Copyright (c) 2003-2024, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 32 of file PDGCodeList.h.

Constructor & Destructor Documentation

PDGCodeList::PDGCodeList ( bool  allowdup = false)

Definition at line 35 of file PDGCodeList.cxx.

References fAllowDuplicateEntries.

35  :
36 vector<int>()
37 {
38  fAllowDuplicateEntries = allowdup;
39 }
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
PDGCodeList::PDGCodeList ( size_type  n,
bool  allowdup = false 
)

Definition at line 41 of file PDGCodeList.cxx.

References fAllowDuplicateEntries.

41  :
42 vector<int>(n)
43 {
44  fAllowDuplicateEntries = allowdup;
45 }
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
PDGCodeList::PDGCodeList ( const PDGCodeList list)

Definition at line 47 of file PDGCodeList.cxx.

References Copy().

47  :
48 vector<int>()
49 {
50  this->Copy(list);
51 }
void Copy(const PDGCodeList &list)
copy / print
PDGCodeList::~PDGCodeList ( )

Definition at line 53 of file PDGCodeList.cxx.

54 {
55 
56 }

Member Function Documentation

bool PDGCodeList::CheckPDGCode ( int  pdg_code) const

PDG code checks used by PDGCodeList.

Definition at line 71 of file PDGCodeList.cxx.

References ExistsInPDGCodeList(), ExistsInPDGLibrary(), fAllowDuplicateEntries, LOG, pDEBUG, and pERROR.

Referenced by insert(), and push_back().

72 {
73 // check whether the PDG code can be inserted
74 
75  bool exists = this->ExistsInPDGLibrary(pdg_code);
76  if(!exists) {
77  LOG("PDG", pERROR)
78  << "Can't add non-existent particle [pdgc = " << pdg_code << "]";
79  return false;
80  }
81 
83  bool added = this->ExistsInPDGCodeList(pdg_code);
84  if(added) {
85  LOG("PDG", pDEBUG)
86  << "Particle [pdgc = " << pdg_code << "] was already added";
87  return false;
88  }
89  }
90  return true;
91 }
#define pERROR
Definition: Messenger.h:59
bool ExistsInPDGCodeList(int pdg_code) const
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool ExistsInPDGLibrary(int pdg_code) const
Definition: PDGCodeList.cxx:93
#define pDEBUG
Definition: Messenger.h:63
void PDGCodeList::Copy ( const PDGCodeList list)

copy / print

Definition at line 145 of file PDGCodeList.cxx.

References clear, fAllowDuplicateEntries, and push_back().

Referenced by operator=(), PDGCodeList(), genie::flux::GJPARCNuFlux::SetFluxParticles(), and genie::flux::GFluxFileConfigI::SetFluxParticles().

146 {
147  this->clear();
148 
149  PDGCodeList::const_iterator iter;
150  for(iter = list.begin(); iter != list.end(); ++iter) {
151  int code = *iter;
152  this->push_back(code);
153  }
154 
156 }
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
vector< vector< double > > clear
void push_back(int pdg_code)
Definition: PDGCodeList.cxx:58
bool genie::PDGCodeList::DuplEntriesAllowed ( void  ) const
inline

check state

Definition at line 56 of file PDGCodeList.h.

References fAllowDuplicateEntries.

56 { return fAllowDuplicateEntries; }
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
bool PDGCodeList::ExistsInPDGCodeList ( int  pdg_code) const

Definition at line 103 of file PDGCodeList.cxx.

Referenced by CheckDecayerConsistency(), CheckPDGCode(), genie::flux::GCylindTH1Flux::GenerateNext(), genie::flux::GJPARCNuFlux::GenerateNext_weighted(), genie::flux::GSimpleNtpFlux::GenerateNext_weighted(), genie::geometry::ROOTGeomAnalyzer::GetWeight(), and genie::Decayer::IsUnstable().

104 {
105 // check whether the PDG code already exists in the list
106 
107  PDGCodeList::const_iterator bci = this->begin();
108  PDGCodeList::const_iterator eci = this->end();
109 
110  if(find(bci,eci,pdg_code) != eci) return true;
111 
112  return false;
113 /*
114  int n = count(this->begin(), this->end(), pdg_code);
115  if(n!=0) return true;
116  return false;
117 */
118 }
bool PDGCodeList::ExistsInPDGLibrary ( int  pdg_code) const

Definition at line 93 of file PDGCodeList.cxx.

References genie::PDGLibrary::Find(), and genie::PDGLibrary::Instance().

Referenced by CheckPDGCode().

94 {
95 // check whether the PDG code is a valid one (exists in PDGLibrary)
96 
97  PDGLibrary * pdglib = PDGLibrary::Instance();
98  TParticlePDG * particle = pdglib->Find(pdg_code);
99  if(!particle) return false;
100  return true;
101 }
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
Singleton class to load &amp; serve a TDatabasePDG.
Definition: PDGLibrary.h:35
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:86
void PDGCodeList::insert ( iterator  pos,
size_type  n,
const int &  x 
)

Definition at line 63 of file PDGCodeList.cxx.

References CheckPDGCode().

64 {
65  if(this->CheckPDGCode(pdg_code)) {
66  if(n>1) n = 1;
67  vector<int>::insert(pos,n,pdg_code);
68  }
69 }
bool CheckPDGCode(int pdg_code) const
PDG code checks used by PDGCodeList.
Definition: PDGCodeList.cxx:71
PDGCodeList & PDGCodeList::operator= ( const PDGCodeList list)

overloaded operators

Definition at line 158 of file PDGCodeList.cxx.

References Copy().

159 {
160  this->Copy(list);
161  return (*this);
162 }
void Copy(const PDGCodeList &list)
copy / print
void PDGCodeList::Print ( ostream &  stream) const

Definition at line 120 of file PDGCodeList.cxx.

References genie::PDGLibrary::Find(), and genie::PDGLibrary::Instance().

Referenced by genie::operator<<().

121 {
122  stream << "\n[-]" << endl;
123 
124  PDGLibrary * pdglib = PDGLibrary::Instance();
125 
126  PDGCodeList::const_iterator iter;
127  size_t nc = this->size();
128 
129  for(iter = this->begin(); iter != this->end(); ++iter) {
130  int pdg_code = *iter;
131  TParticlePDG * p = pdglib->Find(pdg_code);
132 
133  if(!p) {
134  stream << " |---o ** ERR: no particle with PDG code: " << pdg_code;
135  } else {
136  string name = p->GetName();
137  stream << " |---o "
138  << setfill(' ') << setw(15) << name
139  << " (PDG code = " << pdg_code << ")";
140  }
141  if( (--nc) > 0) stream << endl;
142  }
143 }
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:68
const char * name
Singleton class to load &amp; serve a TDatabasePDG.
Definition: PDGLibrary.h:35
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:86
void PDGCodeList::push_back ( int  pdg_code)

override the vector<int> insertion methods to explicitly check for PDG code validity and that no PDG code is listed more than once

Definition at line 58 of file PDGCodeList.cxx.

References CheckPDGCode().

Referenced by genie::flux::GCylindTH1Flux::AddEnergySpectrum(), genie::geometry::ROOTGeomAnalyzer::BuildListOfTargetNuclei(), CheckDecayerConsistency(), Configure(), Copy(), genie::utils::nnbar_osc::DecayProductList(), genie::utils::intranuke::Equilibrium(), genie::utils::intranuke2018::Equilibrium(), genie::flux::GFluxBlender::FluxParticles(), genie::hnl::Decayer::GenerateDecayProducts(), genie::AGKYLowW2019::GenerateHadronCodes(), genie::flux::GSimpleNtpFlux::GenerateNext_weighted(), GetNeutrinoCodes(), GetPDGCodeListFromString(), GetTargetCodes(), genie::AGCharm2019::Hadronize(), genie::hnl::FluxCreator::HNLEnergy(), genie::HAIntranuke::Inelastic(), genie::HAIntranuke2018::Inelastic(), genie::geometry::PointGeomAnalyzer::Initialize(), genie::flux::GPowerLawFlux::Initialize(), genie::flux::GMonoEnergeticFlux::Initialize(), genie::Decayer::LoadConfig(), main(), genie::MECGenerator::NucleonClusterConstituents(), ParseFluxFileConfig(), genie::utils::intranuke::PreEquilibrium(), genie::utils::intranuke2018::PreEquilibrium(), genie::flux::GSimpleNtpFlux::ProcessMeta(), genie::flux::GJPARCNuFlux::SetDefaults(), and genie::flux::GNuMIFlux::SetDefaults().

59 {
60  if(this->CheckPDGCode(pdg_code)) vector<int>::push_back(pdg_code);
61 }
bool CheckPDGCode(int pdg_code) const
PDG code checks used by PDGCodeList.
Definition: PDGCodeList.cxx:71

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const PDGCodeList list 
)
friend

Definition at line 28 of file PDGCodeList.cxx.

29  {
30  list.Print(stream);
31  return stream;
32  }
void Print(ostream &stream) const

Member Data Documentation

bool genie::PDGCodeList::fAllowDuplicateEntries
private

allow duplicate entries in the list?

Definition at line 64 of file PDGCodeList.h.

Referenced by CheckPDGCode(), Copy(), DuplEntriesAllowed(), and PDGCodeList().


The documentation for this class was generated from the following files: