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:
vector< int >

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)
 

Additional Inherited Members

- Public Attributes inherited from vector< int >
void * data
 
size_t size
 
size_t allocsize
 
unsigned typesize
 

Detailed Description

A list of PDG codes.

Author
Costas Andreopoulos <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

May 13, 2005

Copyright (c) 2003-2020, 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.

35  :
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.

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

Definition at line 47 of file PDGCodeList.cxx.

47  :
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.

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 exists(std::string path)
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.

146 {
147  this->clear();
148 
150  for(iter = list.begin(); iter != list.end(); ++iter) {
151  int code = *iter;
152  this->push_back(code);
153  }
154 
156 }
intermediate_table::const_iterator const_iterator
bool fAllowDuplicateEntries
allow duplicate entries in the list?
Definition: PDGCodeList.h:64
CodeOutputInterface * code
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.

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.

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 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
intermediate_table::const_iterator const_iterator
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
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)
Definition: PDGLibrary.cxx:57
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:32
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
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 }
std::void_t< T > n
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.

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.

121 {
122  stream << "\n[-]" << endl;
123 
124  PDGLibrary * pdglib = PDGLibrary::Instance();
125 
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 QCString name
Definition: declinfo.cpp:673
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
intermediate_table::const_iterator const_iterator
size_t size
Definition: lodepng.cpp:55
p
Definition: test.py:223
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
static PDGLibrary * Instance(void)
Definition: PDGLibrary.cxx:57
Singleton class to load & serve a TDatabasePDG.
Definition: PDGLibrary.h:32
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
TParticlePDG * Find(int pdgc, bool must_exist=true)
Definition: PDGLibrary.cxx:75
Q_EXPORT QTSManip setfill(int f)
Definition: qtextstream.h:337
QTextStream & endl(QTextStream &s)
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.

59 {
60  if(this->CheckPDGCode(pdg_code)) vector<int>::push_back(pdg_code);
61 }
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
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.


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