Jpp 21.0.0
the software that should make you happy
Loading...
Searching...
No Matches
JAANET::JPDB Struct Reference

Collection of particles. More...

#include <JPDB.hh>

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

Public Member Functions

 JPDB ()
 Default constructor.
 
bool hasGEANT (const int geant) const
 Check if PDB has particle corresponding to given GEANT code.
 
const JParticle & getGEANT (const int geant) const
 Get particle corresponding to given GEANT code.
 
bool hasPDG (const int pdg) const
 Check if PDB has particle corresponding to given PDG code.
 
const JParticle & getPDG (const int pdg) const
 Get particle corresponding to given PDG code.
 

Static Public Member Functions

static const JPDB & getInstance ()
 Get particle data book.
 
static int convertPDGtoGEANT (const int pdg)
 Retrieve GEANT code for a given PDG code.
 

Friends

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

Detailed Description

Collection of particles.

Definition at line 110 of file JPDB.hh.

Constructor & Destructor Documentation

◆ JPDB()

JAANET::JPDB::JPDB ( )
inline

Default constructor.

Definition at line 116 of file JPDB.hh.

117 {}

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

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

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

157 {
158 return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant)) != this->end());
159 }
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
int geant
GEANT code of particle.
Definition JPDB.hh:91

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

170 {
171 const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::geant, geant));
172
173 if (p != this->end())
174 return *p;
175 else
176 THROW(JException, "Invalid GEANT particle code " << geant);
177 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

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

187 {
188 switch (pdg) {
189
190 case TRACK_TYPE_NUE:
191 case TRACK_TYPE_NUMU:
192 case TRACK_TYPE_NUTAU:
197
200
203
206
209
210 default:
211 return TDatabasePDG::Instance()->ConvertPdgToGeant3(pdg);
212 }
213 }
@ GEANT4_TYPE_NEUTRAL_ANTISIGMA
@ GEANT4_TYPE_ANTISIGMA_PLUS
@ GEANT4_TYPE_NEUTRINO
@ GEANT4_TYPE_ANTISIGMA_MINUS
@ GEANT4_TYPE_NEUTRAL_ANTIXI
@ TRACK_TYPE_ANTINUMU
@ TRACK_TYPE_NEUTRAL_ANTISIGMA
@ TRACK_TYPE_ANTINUTAU
@ TRACK_TYPE_ANTISIGMA_MINUS
@ TRACK_TYPE_NEUTRAL_ANTIXI
@ TRACK_TYPE_ANTISIGMA_PLUS

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

223 {
224 return (find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg)) != this->end());
225 }
int pdg
PDG code of particle.
Definition JPDB.hh:90

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

236 {
237 const_iterator p = find_if(this->begin(), this->end(), JLANG::make_predicate(&JParticle::pdg, pdg));
238
239 if (p != this->end())
240 return *p;
241 else
242 THROW(JException, "Invalid PDG particle code " << pdg);
243 }

Friends And Related Symbol 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 253 of file JPDB.hh.

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

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