Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef G4MAIN_ReadSynRadFiles_H
0004 #define G4MAIN_ReadSynRadFiles_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <phhepmc/PHHepMCGenHelper.h>
0009 
0010 #include <fstream>
0011 #include <string>
0012 
0013 class PHCompositeNode;
0014 class TChain;
0015 
0016 namespace erhic
0017 {
0018   class EventMC;
0019 }
0020 
0021 class ReadSynRadFiles : public SubsysReco
0022 {
0023  public:
0024   ReadSynRadFiles(const std::string &name = "ReadSynRadFiles");
0025   virtual ~ReadSynRadFiles();
0026 
0027   int Init(PHCompositeNode *topNode);
0028   int process_event(PHCompositeNode *topNode);
0029 
0030   /** Specify name of input file to open */
0031   bool OpenInputFile(const std::string &name);
0032 
0033   /** Set first entry from input tree to be used */
0034   void SetEntryPerEvent(int e) { nEntries = e; }
0035   /** Set name of output node */
0036   void SetNodeName(const std::string &s) { _node_name = s; }
0037   //! toss a new vertex according to a Uniform or Gaus distribution
0038   void set_vertex_distribution_function(PHHepMCGenHelper::VTXFUNC x, PHHepMCGenHelper::VTXFUNC y, PHHepMCGenHelper::VTXFUNC z, PHHepMCGenHelper::VTXFUNC t)
0039   {
0040     hepmc_helper.set_vertex_distribution_function(x, y, z, t);
0041   }
0042 
0043   //! set the mean value of the vertex distribution, use PHENIX units of cm, ns
0044   void set_vertex_distribution_mean(const double x, const double y, const double z, const double t)
0045   {
0046     hepmc_helper.set_vertex_distribution_mean(x, y, z, t);
0047   }
0048 
0049   //! set the width of the vertex distribution function about the mean, use PHENIX units of cm, ns
0050   void set_vertex_distribution_width(const double x, const double y, const double z, const double t)
0051   {
0052     hepmc_helper.set_vertex_distribution_width(x, y, z, t);
0053   }
0054   //
0055   //! reuse vertex from another PHHepMCGenEvent with embedding_id = src_embedding_id Additional smearing and shift possible with set_vertex_distribution_*()
0056   void set_reuse_vertex(int src_embedding_id)
0057   {
0058     hepmc_helper.set_reuse_vertex(src_embedding_id);
0059   }
0060 
0061   //! embedding ID for the event
0062   //! positive ID is the embedded event of interest, e.g. jetty event from pythia
0063   //! negative IDs are backgrounds, .e.g out of time pile up collisions
0064   //! Usually, ID = 0 means the primary Au+Au collision background
0065   int get_embedding_id() const { return hepmc_helper.get_embedding_id(); }
0066   //
0067   //! embedding ID for the event
0068   //! positive ID is the embedded event of interest, e.g. jetty event from pythia
0069   //! negative IDs are backgrounds, .e.g out of time pile up collisions
0070   //! Usually, ID = 0 means the primary Au+Au collision background
0071   void set_embedding_id(int id) { hepmc_helper.set_embedding_id(id); }
0072 
0073   //! whether to reverse x and z axis directions (rotate around y bay pi)
0074   void set_reverseXZ(bool b = true) { m_reverseXZ = b; }
0075 
0076  protected:
0077   /** Get tree from input file */
0078   void GetTree();
0079 
0080   /** Creade node on node tree */
0081   int CreateNodeTree(PHCompositeNode *topNode);
0082 
0083   /** Name of file containing input tree */
0084   std::string filename;
0085 
0086   /** Input tree created with eic-smear tree builder */
0087   std::ifstream m_csv_input;
0088 
0089   /** Number of events in input tree */
0090   int nEntries;
0091 
0092   /** Number of current event being used from input tree */
0093   int entry;
0094 
0095   /** Pinter to event record in tree (= branch).
0096       Use 'abstract' EventMC class pointer from which all
0097       event types (erhic::EventMilou etc) inherit from. */
0098   erhic::EventMC *GenEvent;
0099 
0100   // output
0101   std::string _node_name;
0102 
0103   //! helper for insert HepMC event to DST node and add vertex smearing
0104   PHHepMCGenHelper hepmc_helper;
0105 
0106   //! whether to reverse x and z axis directions (rotate around y bay pi)
0107   bool m_reverseXZ = false;
0108 };
0109 
0110 #endif /* ReadSynRadFiles_H__ */