Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:12:34

0001 #ifndef __PHPYTHIA6_H__
0002 #define __PHPYTHIA6_H__
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <phhepmc/PHHepMCGenHelper.h>
0006 
0007 #include <string>
0008 #include <vector>
0009 
0010 class PHCompositeNode;
0011 class PHHepMCGenEvent;
0012 class PHPy6GenTrigger; 
0013 
0014 namespace HepMC {
0015   class GenEvent;
0016 };
0017 
0018 class PHPythia6: public SubsysReco {
0019 
0020 public:
0021 
0022   PHPythia6(const std::string &name = "PHPythia6");
0023   virtual ~PHPythia6();
0024 
0025   int Init(PHCompositeNode *topNode);
0026 
0027   int process_event(PHCompositeNode *topNode);
0028 
0029   int ResetEvent(PHCompositeNode *topNode);
0030 
0031   int End(PHCompositeNode *topNode);
0032 
0033   void set_config_file( const std::string cfg_file ) { _configFile = cfg_file; }
0034 
0035   void print_config() const;
0036 
0037   void beam_vertex_parameters(double beamX,
0038             double beamY,
0039             double beamZ,
0040             double beamXsigma,
0041             double beamYsigma,
0042             double beamZsigma) {
0043 
0044     set_vertex_distribution_mean(beamX, beamY, beamZ, 0);
0045     set_vertex_distribution_width(beamXsigma, beamYsigma, beamZsigma, 0);
0046   }
0047 
0048   void save_ascii( std::string fname = "pythia_hepmc.dat" )
0049   {
0050     _save_ascii = true;
0051     _filename_ascii = fname;
0052   }
0053 
0054   /// set event selection criteria
0055   void register_trigger(PHPy6GenTrigger *theTrigger);
0056   void set_trigger_OR() { _triggersOR = true; } // default true
0057   void set_trigger_AND() { _triggersAND = true; }
0058 
0059   //! toss a new vertex according to a Uniform or Gaus distribution
0060   void set_vertex_distribution_function(PHHepMCGenHelper::VTXFUNC x, PHHepMCGenHelper::VTXFUNC y, PHHepMCGenHelper::VTXFUNC z, PHHepMCGenHelper::VTXFUNC t)
0061   {
0062     hepmc_helper.set_vertex_distribution_function(x, y, z, t);
0063   }
0064 
0065   //! set the mean value of the vertex distribution, use PHENIX units of cm, ns
0066   void set_vertex_distribution_mean(const double x, const double y, const double z, const double t)
0067   {
0068     hepmc_helper.set_vertex_distribution_mean(x, y, z, t);
0069   }
0070 
0071   //! set the width of the vertex distribution function about the mean, use PHENIX units of cm, ns
0072   void set_vertex_distribution_width(const double x, const double y, const double z, const double t)
0073   {
0074     hepmc_helper.set_vertex_distribution_width(x, y, z, t);
0075   }
0076   //
0077   //! reuse vertex from another PHHepMCGenEvent with embedding_id = src_embedding_id Additional smearing and shift possible with set_vertex_distribution_*()
0078   void set_reuse_vertex(int src_embedding_id)
0079   {
0080     hepmc_helper.set_reuse_vertex(src_embedding_id);
0081   }
0082 
0083   //! embedding ID for the event
0084   //! positive ID is the embedded event of interest, e.g. jetty event from pythia
0085   //! negative IDs are backgrounds, .e.g out of time pile up collisions
0086   //! Usually, ID = 0 means the primary Au+Au collision background
0087   int get_embedding_id() const { return hepmc_helper.get_embedding_id(); }
0088   //
0089   //! embedding ID for the event
0090   //! positive ID is the embedded event of interest, e.g. jetty event from pythia
0091   //! negative IDs are backgrounds, .e.g out of time pile up collisions
0092   //! Usually, ID = 0 means the primary Au+Au collision background
0093   void set_embedding_id(int id) { hepmc_helper.set_embedding_id(id); }
0094 private:
0095 
0096   int ReadConfig(const std::string cfg_file = "");
0097   int CreateNodeTree(PHCompositeNode *topNode);
0098 
0099   /** Certain Pythia switches and parameters only accept integer values
0100    * This function checks if input values are integers and
0101    * warns the user if they are not
0102    */
0103   void IntegerTest(double number );
0104 
0105   int _eventcount;
0106   int _geneventcount;
0107 
0108   // Pythia6 configuration file
0109   std::string _configFile;
0110 
0111   /**
0112    * Save HepMC event to ASCII file?
0113    */
0114   bool _save_ascii;
0115 
0116   /**
0117    * ASCII file name to save HepMC event to
0118    */
0119   std::string _filename_ascii;
0120 
0121   // event selection
0122   std::vector<PHPy6GenTrigger*> _registeredTriggers;
0123   bool _triggersOR;
0124   bool _triggersAND;
0125  
0126   /**
0127    * definition needed to use pythia wrapper headers from HepMC
0128    */
0129   void initPythia();
0130   //! helper for insert HepMC event to DST node and add vertex smearing
0131   PHHepMCGenHelper hepmc_helper;
0132 
0133 };
0134 
0135 #endif  /* __PHPYTHIA6_H__ */
0136