Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 // $Id: $
0004 
0005 /*!
0006  * \file PHG4ScoringManager.h
0007  * \brief the connection between Fun4All to G4ScoringManager
0008  * \author Jin Huang <jhuang@bnl.gov>
0009  * \version $Revision:   $
0010  * \date $Date: $
0011  */
0012 
0013 #ifndef G4MAIN_PHG4SCORINGMANAGER_H
0014 #define G4MAIN_PHG4SCORINGMANAGER_H
0015 
0016 #include <fun4all/SubsysReco.h>
0017 
0018 #include <string>
0019 #include <utility>
0020 #include <vector>
0021 
0022 class Fun4AllHistoManager;
0023 class PHCompositeNode;
0024 
0025 /*!
0026  * \brief PHG4ScoringManager is the connection between Fun4All to G4ScoringManager
0027  *  Track primitive score like flux or energy deposition integrated over events and save to histograms
0028  *  More on G4ScoringManager see
0029  *  Manual http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/BackupVersions/V9.6/html/ch04s08.html
0030  *  And talk http://geant4.slac.stanford.edu/JLAB2012/Scoring1.pdf
0031  */
0032 class PHG4ScoringManager : public SubsysReco
0033 {
0034  public:
0035   PHG4ScoringManager();
0036 
0037   ~PHG4ScoringManager() override {}
0038 
0039   //! full initialization
0040   int InitRun(PHCompositeNode *topNode) override;
0041 
0042   //! event processing method
0043   int process_event(PHCompositeNode *) override;
0044 
0045   //! end of run method
0046   int End(PHCompositeNode *) override;
0047 
0048   //! Output result to a ROOT file with this name
0049   void setOutputFileName(const std::string &outputfilename) { m_outputFileName = outputfilename; };
0050 
0051   //! \brief Run this Geant4 command after initialization of G4ScoringManager in the InitRun() stage
0052   //! You can call this command multiple times to stage multiple commands to run
0053   /*!
0054    *  Example
0055       \code{.cpp}
0056 
0057       PHG4ScoringManager * g4score = new PHG4ScoringManager();
0058       g4score->G4Command("/score/create/cylinderMesh cyl_score");
0059       g4score->G4Command("/score/mesh/cylinderSize 100. 400. cm");
0060       g4score->G4Command("/score/mesh/nBin 100 800 8");
0061       g4score->G4Command("/score/quantity/eDep cyl_edep");
0062       g4score->G4Command("/score/quantity/cellFlux cyl_flux");
0063       g4score->G4Command("/score/close");
0064 
0065       \endcode
0066    */
0067   void G4Command(const std::string &cmd);
0068 
0069   void setVertexHistRange(double min, double max)
0070   {
0071     m_vertexHistRange.first = min;
0072     m_vertexHistRange.second = max;
0073   }
0074   void setVertexAcceptanceRange(double min, double max)
0075   {
0076     m_vertexAcceptanceRange.first = min;
0077     m_vertexAcceptanceRange.second = max;
0078   }
0079 
0080  private:
0081   Fun4AllHistoManager *getHistoManager();
0082   void makeScoringHistograms();
0083 
0084   std::vector<std::string> m_commands;
0085 
0086   std::string m_outputFileName;
0087 
0088   std::pair<double, double> m_vertexHistRange{-5e2, 5e2};
0089   std::pair<double, double> m_vertexAcceptanceRange{-5e2, 5e2};
0090 };
0091 
0092 #endif /* PHG4SCORINGMANAGER_H_ */