File indexing completed on 2023-03-17 11:24:49
0001 #ifndef SimG4Core_CustomPhysics_CustomParticleFactory_h
0002 #define SimG4Core_CustomPhysics_CustomParticleFactory_h 1
0003
0004 #include "G4Threading.hh"
0005 #include <vector>
0006 #include <string>
0007 #include <fstream>
0008
0009 class G4DecayTable;
0010 class G4ParticleDefinition;
0011
0012 class CustomParticleFactory {
0013 public:
0014 explicit CustomParticleFactory();
0015 ~CustomParticleFactory() = default;
0016
0017 void loadCustomParticles(const std::string &filePath);
0018 const std::vector<G4ParticleDefinition *> &getCustomParticles();
0019
0020 private:
0021 void addCustomParticle(int pdgCode, double mass, const std::string &name);
0022 void getMassTable(std::ifstream *configFile);
0023 G4DecayTable *getDecayTable(std::ifstream *configFile, int pdgId);
0024 G4DecayTable *getAntiDecayTable(int pdgId, G4DecayTable *theDecayTable);
0025 std::string ToLower(std::string str);
0026
0027 static bool loaded;
0028 static std::vector<G4ParticleDefinition *> m_particles;
0029 #ifdef G4MULTITHREADED
0030 static G4Mutex customParticleFactoryMutex;
0031 #endif
0032 };
0033
0034 #endif