File indexing completed on 2025-08-05 08:18:09
0001
0002
0003 #ifndef G4MAIN_PHG4PARTICLEGENERATORBASE_H
0004 #define G4MAIN_PHG4PARTICLEGENERATORBASE_H
0005
0006 #include <fun4all/SubsysReco.h>
0007
0008 #include <gsl/gsl_rng.h>
0009
0010 #include <string> // for string
0011 #include <vector>
0012
0013 class PHCompositeNode;
0014 class PHG4InEvent;
0015 class PHG4Particle;
0016
0017 class PHG4ParticleGeneratorBase : public SubsysReco
0018 {
0019 public:
0020 ~PHG4ParticleGeneratorBase() override;
0021
0022 int InitRun(PHCompositeNode *topNode) override;
0023 int process_event(PHCompositeNode *topNode) override;
0024
0025 virtual void set_name(const std::string &particle = "proton");
0026 virtual void set_pid(const int pid);
0027 virtual void set_mom(const double x, const double y, const double z);
0028 virtual void set_vtx(const double x, const double y, const double z);
0029 virtual void set_vtx_z(const double z) { m_Vtx_z = z; }
0030 virtual void set_t0(const double t) { m_TZero = t; }
0031
0032 virtual double get_vtx_x() const { return m_Vtx_x; }
0033 virtual double get_vtx_y() const { return m_Vtx_y; }
0034 virtual double get_vtx_z() const { return m_Vtx_z; }
0035 virtual double get_t0() const { return m_TZero; }
0036
0037 void Print(const std::string &what = "ALL") const override { PrintParticles(what); }
0038 virtual void PrintParticles(const std::string &what = "ALL") const;
0039 virtual void AddParticle(const std::string &particle, const double x, const double y, const double z);
0040 virtual void AddParticle(const int pid, const double x, const double y, const double z);
0041 virtual void Embed(const int i = 1) { m_EmbedFlag = i; }
0042 virtual int ReuseExistingVertex(PHCompositeNode *topNode);
0043
0044 int get_reuse_existing_vertex() const { return m_ReUseExistingVertexFlag; }
0045 void set_reuse_existing_vertex(const int i = 1) { m_ReUseExistingVertexFlag = i; }
0046 void set_seed(const unsigned int iseed);
0047 unsigned int get_seed() const { return m_Seed; }
0048
0049 protected:
0050 PHG4ParticleGeneratorBase(const std::string &name = "GENERATORBASE");
0051 static int get_pdgcode(const std::string &name);
0052 static std::string get_pdgname(const int pdgcode);
0053 static double get_mass(const int pdgcode);
0054 void CheckAndCreateParticleVector();
0055 void SetParticleId(PHG4Particle *particle, PHG4InEvent *ineve) const;
0056 gsl_rng *RandomGenerator() const { return m_RandomGenerator; }
0057 int EmbedFlag() const { return m_EmbedFlag; }
0058 std::vector<PHG4Particle *>::iterator particlelist_begin() { return particlelist.begin(); }
0059 std::vector<PHG4Particle *>::iterator particlelist_end() { return particlelist.end(); }
0060 void ResetParticleList();
0061
0062 private:
0063 gsl_rng *m_RandomGenerator = nullptr;
0064 int m_EmbedFlag = 0;
0065 int m_ReUseExistingVertexFlag = 0;
0066 unsigned int m_Seed = 0;
0067 double m_Vtx_x = 0.;
0068 double m_Vtx_y = 0.;
0069 double m_Vtx_z = 0.;
0070 double m_TZero = 0.;
0071 std::vector<PHG4Particle *> particlelist;
0072 };
0073
0074 #endif