Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:11

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_PHG4SIMPLEEVENTGENERATOR_H
0004 #define G4MAIN_PHG4SIMPLEEVENTGENERATOR_H
0005 
0006 #include "PHG4ParticleGeneratorBase.h"
0007 
0008 #include <cmath>
0009 #include <map>
0010 #include <string>   // for string
0011 #include <utility>  // for pair
0012 #include <vector>
0013 
0014 class PHG4InEvent;
0015 class PHCompositeNode;
0016 
0017 class PHG4SimpleEventGenerator : public PHG4ParticleGeneratorBase
0018 {
0019  public:
0020   //! supported function distributions
0021   enum FUNCTION
0022   {
0023     Uniform,
0024     Gaus
0025   };
0026 
0027   PHG4SimpleEventGenerator(const std::string &name = "EVTGENERATOR");
0028   ~PHG4SimpleEventGenerator() override {}
0029 
0030   int InitRun(PHCompositeNode *topNode) override;
0031   int process_event(PHCompositeNode *topNode) override;
0032 
0033   //! interface for adding particles by name
0034   void add_particles(const std::string &name, const unsigned int count);
0035 
0036   //! interface for adding particle by pid
0037   void add_particles(const int pid, const unsigned int count);
0038 
0039   //! range of randomized eta values (mutually exclusive with theta range)
0040   void set_eta_range(const double eta_min, const double eta_max);
0041 
0042   //! range of randomized theta values (mutually exclusive with eta range)
0043   void set_theta_range(const double theta_min, const double theta_max);
0044 
0045   //! range of randomized phi values
0046   void set_phi_range(const double phi_min, const double phi_max);
0047 
0048   //! power law value of distribution to sample from for pt values
0049   void set_power_law_n(const double n);
0050 
0051   //! range of randomized pt values (mutually exclusive with momentum range)
0052   //! \param[in] pt_gaus_width   if non-zero, further apply a Gauss smearing to the pt_min - pt_max flat distribution
0053   void set_pt_range(const double pt_min, const double pt_max, const double pt_gaus_width = 0);
0054 
0055   //! range of randomized p values (mutually exclusive with pt range)
0056   //! \param[in] p_gaus_width   if non-zero, further apply a Gauss smearing to the p_min - p_max flat distribution
0057   void set_p_range(const double p_min, const double p_max, const double p_gaus_width = 0);
0058 
0059   //! toss a new vertex according to a Uniform or Gaus distribution
0060   void set_vertex_distribution_function(FUNCTION x, FUNCTION y, FUNCTION z);
0061 
0062   //! set the mean value of the vertex distribution
0063   void set_vertex_distribution_mean(const double x, const double y, const double z);
0064 
0065   //! set the width of the vertex distribution function about the mean
0066   void set_vertex_distribution_width(const double x, const double y, const double z);
0067 
0068   //! set an offset vector from the existing vertex
0069   void set_existing_vertex_offset_vector(const double x, const double y, const double z);
0070 
0071   //! set the distribution function of particles about the vertex
0072   void set_vertex_size_function(FUNCTION r) { m_VertexSizeFunc_r = r; }
0073 
0074   //! set the dimensions of the distribution of particles about the vertex
0075   void set_vertex_size_parameters(const double mean, const double width);
0076 
0077  private:
0078   double smearvtx(const double position, const double width, FUNCTION dist) const;
0079 
0080   // these need to be stored separately until run time when the names
0081   // can be translated using the GEANT4 lookup
0082   std::vector<std::pair<int, unsigned int> > _particle_codes;          // <pdgcode, count>
0083   std::vector<std::pair<std::string, unsigned int> > _particle_names;  // <names, count>
0084                                                                        // so we can print out the function names without many if's
0085                                                                        // also used to check if function is implemented
0086   std::map<FUNCTION, std::string> m_FunctionNames = {{Uniform, "Uniform"}, {Gaus, "Gaus"}};
0087 
0088   PHG4InEvent *m_InEvent = nullptr;
0089   FUNCTION m_VertexFunc_x = Uniform;
0090   FUNCTION m_VertexFunc_y = Uniform;
0091   FUNCTION m_VertexFunc_z = Uniform;
0092   double m_Vertex_x = 0.;
0093   double m_Vertex_y = 0.;
0094   double m_Vertex_z = 0.;
0095   double m_VertexWidth_x = 0.;
0096   double m_VertexWidth_y = 0.;
0097   double m_VertexWidth_z = 0.;
0098   double m_VertexOffset_x = 0.;
0099   double m_VertexOffset_y = 0.;
0100   double m_VertexOffset_z = 0.;
0101   FUNCTION m_VertexSizeFunc_r = Uniform;
0102   double m_VertexSizeMean = 0.;
0103   double m_VertexSizeWidth = 0.;
0104   double m_EtaMin = -1.25;
0105   double m_EtaMax = 1.25;
0106   double m_ThetaMin = NAN;
0107   double m_ThetaMax = NAN;
0108   double m_PhiMin = -M_PI;
0109   double m_PhiMax = M_PI;
0110   double m_Pt_Min = 0.;
0111   double m_Pt_Max = 10.;
0112   double m_Pt_GausWidth = 0.;
0113   double m_P_Min = NAN;
0114   double m_P_Max = NAN;
0115   double m_P_GausWidth = NAN;
0116   double m_powerLawN = NAN;
0117 };
0118 
0119 #endif