Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_HEPMCNODEREADER_H
0004 #define G4MAIN_HEPMCNODEREADER_H
0005 
0006 #include <TF1.h>
0007 
0008 #include <fun4all/SubsysReco.h>
0009 
0010 // rootcint barfs with this header so we need to hide it
0011 #include <gsl/gsl_rng.h>
0012 
0013 #include <string>
0014 #include <vector>
0015 
0016 class PHCompositeNode;
0017 
0018 //! HepMCNodeReader take input from all subevents from PHHepMCGenEventMap and send them to simulation in Geant4
0019 //! For HepMC subevent which is already simulated, they will not be simulated again in Geant4.
0020 class HepMCNodeReader : public SubsysReco
0021 {
0022  public:
0023   HepMCNodeReader(const std::string &name = "HepMCNodeReader");
0024   ~HepMCNodeReader() override;
0025 
0026   int Init(PHCompositeNode *topNode) override;
0027   int process_event(PHCompositeNode *topNode) override;
0028 
0029   void pythia(const bool pythia) { is_pythia = pythia; }
0030 
0031   //! this function is depreciated.
0032   //! Embedding IDs are controlled for individually HEPMC subevents in Fun4AllHepMCInputManagers and event generators.
0033   void Embed(const int i = 1);
0034 
0035   //! this function is depreciated.
0036   //! HepMCNodeReader::VertexPosition() move all HEPMC subevents to a new vertex location.
0037   //! And the vertex shifts are better controlled for individually HEPMC subevents in Fun4AllHepMCInputManagers and event generators.
0038   void VertexPosition(const double v_x, const double v_y, const double v_z);
0039 
0040   //! HepMCNodeReader::SmearVertex - WARNING - this function is depreciated.
0041   //! HepMCNodeReader::SmearVertex() smear each HEPMC subevents to a new vertex location.
0042   //! And the vertex smears are better controlled for individually HEPMC subevents in Fun4AllHepMCInputManagers and event generators.
0043   //! Positive value is Gauss smear, and negative values are flat smear
0044   void SmearVertex(const double s_x, const double s_y, const double s_z);
0045 
0046   //! Arbitary time shift for all sub-events.
0047   //! And the vertex shifts are better controlled for individually HEPMC subevents in Fun4AllHepMCInputManagers and event generators.
0048   void SetT0(const double t0) { vertex_t0 = t0; }
0049   //
0050   //! Override seed
0051   void SetSeed(const unsigned int i)
0052   {
0053     seed = i;
0054     use_seed = 1;
0055   }
0056 
0057   // Method to add strangeness content of the event: f is the fraction of additional strangeness particles, in percent
0058   void AddStrangeness(const float f) { addfraction = f; }
0059 
0060  private:
0061   double smeargauss(const double width);
0062   double smearflat(const double width);
0063 
0064   // Exponentially modified Gaussian distribution function, modelling pT
0065   static double EMGFunction(double *x, double *par);
0066   // Double Gaussian function, modelling eta
0067   static double DBGFunction(double *x, double *par);
0068 
0069   gsl_rng *RandomGenerator{nullptr};
0070   bool is_pythia{false};
0071   int use_seed{0};
0072   unsigned int seed{0};
0073   double vertex_pos_x{0.0};
0074   double vertex_pos_y{0.0};
0075   double vertex_pos_z{0.0};
0076   double vertex_t0{0.0};
0077   double width_vx{0.0};
0078   double width_vy{0.0};
0079   double width_vz{0.0};
0080 
0081   // Method to change the strangeness content of the event
0082   std::vector<int> list_strangePID = {310, 3122, -3122};                               // K_s0 (PID=310), Lambda (PID=3122)
0083   std::vector<double> list_strangePIDprob = {1 - 0.333, 0.333 / 2., 0.333 / 2.};       // K_s0 (PID=310) has 2/3 probability, Lambda (PID=3122) has 1/3 probability
0084   std::vector<std::pair<int, std::pair<double, double>>> list_strangePID_probrange{};  // list of strange particles and their probability ranges
0085   float addfraction{0.0};                                                              // additional strangeness particles, in percent; default 0
0086   int Nstrange_add{0};                                                                 // number of strange particles to be added; default 0
0087   float sel_eta{1.0};                                                                  // |eta| selection for additional strangeness particles; default 1
0088   float sel_ptmin{0.0};                                                                // min pT selection for additional strangeness particles; default 0
0089   float sel_ptmax{std::numeric_limits<float>::max()};                                  // max pT selection for additional strangeness particles; default infinity
0090   TF1 *fpt{nullptr};
0091   TF1 *feta{nullptr};
0092 };
0093 
0094 #endif