Jpp  18.0.0-rc.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Friends | List of all members
JAANET::JPDB Struct Reference

Collection of particles. More...

#include <JPDB.hh>

Inheritance diagram for JAANET::JPDB:
std::vector< JParticle >

Public Member Functions

 JPDB ()
 Default constructor. More...
 
bool hasGEANT (const int geant) const
 Check if PDB has particle corresponding to given GEANT code. More...
 
const JParticlegetGEANT (const int geant) const
 Get particle corresponding to given GEANT code. More...
 
bool hasPDG (const int pdg) const
 Check if PDB has particle corresponding to given PDG code. More...
 
const JParticlegetPDG (const int pdg) const
 Get particle corresponding to given PDG code. More...
 

Static Public Member Functions

static const JPDBgetInstance ()
 Get particle data book. More...
 
static int convertPDGtoGEANT (const int pdg)
 Retrieve GEANT code for a given PDG code. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const JPDB &pdb)
 Print particle data book. More...
 

Detailed Description

Collection of particles.

Definition at line 109 of file JPDB.hh.

Constructor & Destructor Documentation

JAANET::JPDB::JPDB ( )
inline

Default constructor.

Definition at line 115 of file JPDB.hh.

116  {}

Member Function Documentation

static const JPDB& JAANET::JPDB::getInstance ( )
inlinestatic

Get particle data book.

This particle data book contains all known GEANT particle codes.

Returns
particle data book

Definition at line 125 of file JPDB.hh.

126  {
127  using namespace JPP;
128 
129  static JPDB pdb;
130 
131  if (pdb.empty()) {
132 
133  TDatabasePDG::Instance()->ReadPDGTable();
134 
135  TIter next(TDatabasePDG::Instance()->ParticleList());
136 
137  while (TParticlePDG* p = (TParticlePDG*) next()) {
138 
139  const JParticle particle(p->GetName(), p->PdgCode(), convertPDGtoGEANT(p->PdgCode()), p->Mass());
140 
141  pdb.push_back(particle);
142  }
143  }
144 
145  return pdb;
146  }
static int convertPDGtoGEANT(const int pdg)
Retrieve GEANT code for a given PDG code.
Definition: JPDB.hh:185
Collection of particles.
Definition: JPDB.hh:109
Auxiliary class to handle particle name, codes and mass.
Definition: JPDB.hh:37
bool JAANET::JPDB::hasGEANT ( const int  geant) const
inline

Check if PDB has particle corresponding to given GEANT code.

Parameters
geantGEANT code
Returns
true if available; else false

Definition at line 155 of file JPDB.hh.

156  {
157  return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant)) != this->end());
158  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
static const JGeant geant(geanx, 0.0001)
Function object for the number of photons from EM-shower as a function of emission angle...
int geant
GEANT code of particle.
Definition: JPDB.hh:91
const JParticle& JAANET::JPDB::getGEANT ( const int  geant) const
inline

Get particle corresponding to given GEANT code.


This method throws an error if the particle cannot be found.

Parameters
geantGEANT code
Returns
particle

Definition at line 168 of file JPDB.hh.

169  {
170  const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant));
171 
172  if (p != this->end())
173  return *p;
174  else
175  THROW(JException, "Invalid GEANT particle code " << geant);
176  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
static const JGeant geant(geanx, 0.0001)
Function object for the number of photons from EM-shower as a function of emission angle...
int geant
GEANT code of particle.
Definition: JPDB.hh:91
static int JAANET::JPDB::convertPDGtoGEANT ( const int  pdg)
inlinestatic

Retrieve GEANT code for a given PDG code.

Parameters
pdgPDG code
Returns
GEANT code

Definition at line 185 of file JPDB.hh.

186  {
187  switch (pdg) {
188 
189  case TRACK_TYPE_NUE:
190  case TRACK_TYPE_NUMU:
191  case TRACK_TYPE_NUTAU:
192  case TRACK_TYPE_ANTINUE:
193  case TRACK_TYPE_ANTINUMU:
195  return GEANT4_TYPE_NEUTRINO;
196 
199 
202 
205 
208 
209  default:
210  return TDatabasePDG::Instance()->ConvertPdgToGeant3(pdg);
211  }
212  }
bool JAANET::JPDB::hasPDG ( const int  pdg) const
inline

Check if PDB has particle corresponding to given PDG code.

Parameters
pdgPDG code
Returns
true if available; else false

Definition at line 221 of file JPDB.hh.

222  {
223  return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg)) != this->end());
224  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
int pdg
PDG code of particle.
Definition: JPDB.hh:90
const JParticle& JAANET::JPDB::getPDG ( const int  pdg) const
inline

Get particle corresponding to given PDG code.


This method throws an error if the particle cannot be found.

Parameters
pdgPDG code
Returns
particle

Definition at line 234 of file JPDB.hh.

235  {
236  const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg));
237 
238  if (p != this->end())
239  return *p;
240  else
241  THROW(JException, "Invalid PDG particle code " << pdg);
242  }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:696
int pdg
PDG code of particle.
Definition: JPDB.hh:90

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const JPDB pdb 
)
friend

Print particle data book.

Parameters
outoutput stream
pdbparticle data book
Returns
output stream

Definition at line 252 of file JPDB.hh.

253  {
254  using namespace std;
255 
256  out << setw(32) << left << "particle" << " "
257  << setw( 6) << right << "PDG" << " "
258  << setw( 6) << right << "GEANT" << " "
259  << setw(12) << right << "Mass [GeV]" << endl;
260 
261  for (JPDB::const_iterator i = pdb.begin(); i != pdb.end(); ++i) {
262  out << *i << endl;
263  }
264 
265  return out;
266  }

The documentation for this struct was generated from the following file: