ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4ParticleGeneratorBase.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4ParticleGeneratorBase.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4MAIN_PHG4PARTICLEGENERATORBASE_H
4 #define G4MAIN_PHG4PARTICLEGENERATORBASE_H
5 
6 #include <fun4all/SubsysReco.h>
7 
8 #include <gsl/gsl_rng.h>
9 
10 #include <string> // for string
11 #include <vector>
12 
13 class PHCompositeNode;
14 class PHG4InEvent;
15 class PHG4Particle;
16 
18 {
19  public:
20  ~PHG4ParticleGeneratorBase() override;
21 
22  int InitRun(PHCompositeNode *topNode) override;
23  int process_event(PHCompositeNode *topNode) override;
24 
25  virtual void set_name(const std::string &particle = "proton");
26  virtual void set_pid(const int pid);
27  virtual void set_mom(const double x, const double y, const double z);
28  virtual void set_vtx(const double x, const double y, const double z);
29  virtual void set_vtx_z(const double z) { m_Vtx_z = z; }
30  virtual void set_t0(const double t) { m_TZero = t; }
31 
32  virtual double get_vtx_x() const { return m_Vtx_x; }
33  virtual double get_vtx_y() const { return m_Vtx_y; }
34  virtual double get_vtx_z() const { return m_Vtx_z; }
35  virtual double get_t0() const { return m_TZero; }
36 
37  void Print(const std::string &what = "ALL") const override { PrintParticles(what); }
38  virtual void PrintParticles(const std::string &what = "ALL") const;
39  virtual void AddParticle(const std::string &particle, const double x, const double y, const double z);
40  virtual void AddParticle(const int pid, const double x, const double y, const double z);
41  virtual void Embed(const int i = 1) { m_EmbedFlag = i; }
42  virtual int ReuseExistingVertex(PHCompositeNode *topNode);
43 
46  void set_seed(const unsigned int iseed);
47  unsigned int get_seed() const { return m_Seed; }
48 
49  protected:
50  PHG4ParticleGeneratorBase(const std::string &name = "GENERATORBASE");
51  int get_pdgcode(const std::string &name) const;
52  std::string get_pdgname(const int pdgcode) const;
53  double get_mass(const int pdgcode) const;
56  gsl_rng *RandomGenerator() const { return m_RandomGenerator; }
57  int EmbedFlag() const { return m_EmbedFlag; }
58  std::vector<PHG4Particle *>::iterator particlelist_begin() { return particlelist.begin(); }
59  std::vector<PHG4Particle *>::iterator particlelist_end() { return particlelist.end(); }
60  void ResetParticleList();
61 
62  private:
63  gsl_rng *m_RandomGenerator = nullptr;
64  int m_EmbedFlag = 0;
66  unsigned int m_Seed = 0;
67  double m_Vtx_x = 0.;
68  double m_Vtx_y = 0.;
69  double m_Vtx_z = 0.;
70  double m_TZero = 0.;
71  std::vector<PHG4Particle *> particlelist;
72 };
73 
74 #endif