Jpp  19.1.0-rc.1
the software that should make you happy
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 115 of file JPDB.hh.

Constructor & Destructor Documentation

◆ JPDB()

JAANET::JPDB::JPDB ( )
inline

Default constructor.

Definition at line 121 of file JPDB.hh.

122  {}

Member Function Documentation

◆ getInstance()

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 131 of file JPDB.hh.

132  {
133  using namespace JPP;
134 
135  static JPDB pdb;
136 
137  if (pdb.empty()) {
138 
139  TDatabasePDG::Instance()->ReadPDGTable();
140 
141  TIter next(TDatabasePDG::Instance()->ParticleList());
142 
143  while (TParticlePDG* p = (TParticlePDG*) next()) {
144 
145  const JParticle particle(p->GetName(), p->PdgCode(), convertPDGtoGEANT(p->PdgCode()), p->Mass(), p->Charge());
146 
147  pdb.push_back(particle);
148  }
149  }
150 
151  return pdb;
152  }
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Collection of particles.
Definition: JPDB.hh:117
static int convertPDGtoGEANT(const int pdg)
Retrieve GEANT code for a given PDG code.
Definition: JPDB.hh:191
Auxiliary class to handle particle name, codes and mass.
Definition: JPDB.hh:37

◆ hasGEANT()

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 161 of file JPDB.hh.

162  {
163  return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant)) != this->end());
164  }
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:96

◆ getGEANT()

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 174 of file JPDB.hh.

175  {
176  const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant));
177 
178  if (p != this->end())
179  return *p;
180  else
181  THROW(JException, "Invalid GEANT particle code " << geant);
182  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
General exception.
Definition: JException.hh:24

◆ convertPDGtoGEANT()

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 191 of file JPDB.hh.

192  {
193  switch (pdg) {
194 
195  case TRACK_TYPE_NUE:
196  case TRACK_TYPE_NUMU:
197  case TRACK_TYPE_NUTAU:
198  case TRACK_TYPE_ANTINUE:
199  case TRACK_TYPE_ANTINUMU:
201  return GEANT4_TYPE_NEUTRINO;
202 
205 
208 
211 
214 
215  default:
216  return TDatabasePDG::Instance()->ConvertPdgToGeant3(pdg);
217  }
218  }
@ GEANT4_TYPE_NEUTRAL_ANTISIGMA
@ GEANT4_TYPE_ANTISIGMA_PLUS
@ GEANT4_TYPE_NEUTRINO
@ GEANT4_TYPE_ANTISIGMA_MINUS
@ GEANT4_TYPE_NEUTRAL_ANTIXI
@ TRACK_TYPE_NUTAU
@ TRACK_TYPE_ANTINUMU
@ TRACK_TYPE_NEUTRAL_ANTISIGMA
@ TRACK_TYPE_ANTINUE
@ TRACK_TYPE_ANTINUTAU
@ TRACK_TYPE_NUE
@ TRACK_TYPE_ANTISIGMA_MINUS
@ TRACK_TYPE_NEUTRAL_ANTIXI
@ TRACK_TYPE_ANTISIGMA_PLUS
@ TRACK_TYPE_NUMU

◆ hasPDG()

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 227 of file JPDB.hh.

228  {
229  return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg)) != this->end());
230  }
int pdg
PDG code of particle.
Definition: JPDB.hh:95

◆ getPDG()

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 240 of file JPDB.hh.

241  {
242  const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg));
243 
244  if (p != this->end())
245  return *p;
246  else
247  THROW(JException, "Invalid PDG particle code " << pdg);
248  }

Friends And Related Function Documentation

◆ operator<<

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 258 of file JPDB.hh.

259  {
260  using namespace std;
261 
262  out << setw(32) << left << "particle" << " "
263  << setw( 8) << right << "PDG" << " "
264  << setw( 6) << right << "GEANT" << " "
265  << setw(16) << right << "Mass [GeV]" << " "
266  << setw( 5) << right << "Charge [|e|/3]" << endl;
267 
268  for (JPDB::const_iterator i = pdb.begin(); i != pdb.end(); ++i) {
269  out << *i << endl;
270  }
271 
272  return out;
273  }
Definition: JSTDTypes.hh:14

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