GENIEGenerator
Loading...
Searching...
No Matches
genie::PDGCodeList Class Reference

A list of PDG codes. More...

#include <PDGCodeList.h>

Inheritance diagram for genie::PDGCodeList:
[legend]
Collaboration diagram for genie::PDGCodeList:
[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.
bool ExistsInPDGLibrary (int pdg_code) const
bool ExistsInPDGCodeList (int pdg_code) const
void Copy (const PDGCodeList &list)
 copy / print
void Print (ostream &stream) const
bool DuplEntriesAllowed (void) const
 check state
PDGCodeListoperator= (const PDGCodeList &list)
 overloaded operators

Private Attributes

bool fAllowDuplicateEntries
 allow duplicate entries in the list?

Friends

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

Detailed Description

A list of PDG codes.

Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n May 13, 2005
License:\n Copyright (c) 2003-2025, 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() [1/3]

PDGCodeList::PDGCodeList ( bool allowdup = false)

Definition at line 35 of file PDGCodeList.cxx.

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

References fAllowDuplicateEntries.

Referenced by Copy(), operator<<, operator=(), and PDGCodeList().

◆ PDGCodeList() [2/3]

PDGCodeList::PDGCodeList ( size_type n,
bool allowdup = false )

Definition at line 41 of file PDGCodeList.cxx.

41 :
42vector<int>(n)
43{
44 fAllowDuplicateEntries = allowdup;
45}

References fAllowDuplicateEntries.

◆ PDGCodeList() [3/3]

PDGCodeList::PDGCodeList ( const PDGCodeList & list)

Definition at line 47 of file PDGCodeList.cxx.

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

References Copy(), and PDGCodeList().

◆ ~PDGCodeList()

PDGCodeList::~PDGCodeList ( )

Definition at line 53 of file PDGCodeList.cxx.

54{
55
56}

Member Function Documentation

◆ CheckPDGCode()

bool PDGCodeList::CheckPDGCode ( int pdg_code) const

PDG code checks used by PDGCodeList.

Definition at line 71 of file PDGCodeList.cxx.

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
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
bool ExistsInPDGCodeList(int pdg_code) const
bool ExistsInPDGLibrary(int pdg_code) const

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

Referenced by insert(), and push_back().

◆ Copy()

void PDGCodeList::Copy ( const PDGCodeList & list)

copy / print

Definition at line 145 of file PDGCodeList.cxx.

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}
vector< vector< double > > clear
void push_back(int pdg_code)

References clear, fAllowDuplicateEntries, PDGCodeList(), and push_back().

Referenced by operator=(), and PDGCodeList().

◆ DuplEntriesAllowed()

bool genie::PDGCodeList::DuplEntriesAllowed ( void ) const
inline

check state

Definition at line 56 of file PDGCodeList.h.

56{ return fAllowDuplicateEntries; }

References fAllowDuplicateEntries.

◆ ExistsInPDGCodeList()

bool PDGCodeList::ExistsInPDGCodeList ( int pdg_code) const

Definition at line 103 of file PDGCodeList.cxx.

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}

Referenced by CheckDecayerConsistency(), and CheckPDGCode().

◆ ExistsInPDGLibrary()

bool PDGCodeList::ExistsInPDGLibrary ( int pdg_code) const

Definition at line 93 of file PDGCodeList.cxx.

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)
TParticlePDG * Find(int pdgc, bool must_exist=true)

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

Referenced by CheckPDGCode().

◆ insert()

void PDGCodeList::insert ( iterator pos,
size_type n,
const int & x )

Definition at line 63 of file PDGCodeList.cxx.

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.

References CheckPDGCode().

◆ operator=()

PDGCodeList & PDGCodeList::operator= ( const PDGCodeList & list)

overloaded operators

Definition at line 158 of file PDGCodeList.cxx.

159{
160 this->Copy(list);
161 return (*this);
162}

References Copy(), and PDGCodeList().

◆ Print()

void PDGCodeList::Print ( ostream & stream) const

Definition at line 120 of file PDGCodeList.cxx.

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}

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

Referenced by operator<<.

◆ push_back()

◆ operator<<

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

References PDGCodeList(), and Print().

Member Data Documentation

◆ fAllowDuplicateEntries

bool genie::PDGCodeList::fAllowDuplicateEntries
private

allow duplicate entries in the list?

Definition at line 64 of file PDGCodeList.h.

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


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