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

Selection of particle data book entries. More...

#include <JPDB.hh>

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

Public Member Functions

 JPDBSelection (const std::vector< int > &pdgs)
 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 JPDBSelection &pdb)
 Print selection.
 

Detailed Description

Selection of particle data book entries.

Definition at line 275 of file JPDB.hh.

Constructor & Destructor Documentation

◆ JPDBSelection()

JAANET::JPDBSelection::JPDBSelection ( const std::vector< int > & pdgs)
inline

Constructor.

Parameters
pdgspdg codes

Definition at line 283 of file JPDB.hh.

284 {
285 using namespace JPP;
286
287 const JPDB& PDB = JPDB::getInstance();
288
289 for (std::vector<int>::const_iterator pdg = pdgs.begin(); pdg != pdgs.end(); ++pdg) {
290
291 const JParticle& particle = PDB.getPDG(*pdg);
292
293 this->push_back(particle);
294 }
295 }
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Collection of particles.
Definition JPDB.hh:112
static const JPDB & getInstance()
Get particle data book.
Definition JPDB.hh:126
const JParticle & getPDG(const int pdg) const
Get particle corresponding to given PDG code.
Definition JPDB.hh:235
Auxiliary class to handle particle name, codes and mass.
Definition JPDB.hh:42

Member Function Documentation

◆ getInstance()

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

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 }
static int convertPDGtoGEANT(const int pdg)
Retrieve GEANT code for a given PDG code.
Definition JPDB.hh:186

◆ hasGEANT()

bool JAANET::JPDB::hasGEANT ( const int geant) const
inlineinherited

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
inlineinherited

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)
inlinestaticinherited

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
inlineinherited

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
inlineinherited

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 JPDBSelection & pdb )
friend

Print selection.

Parameters
outoutput stream
pdbparticle data book selection
Returns
output stream

Definition at line 305 of file JPDB.hh.

306 {
307 return out << static_cast<const JPDB&>(pdb);
308 }

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