Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 /*!
0004  *  \file       PHG4TrackFastSimEval.h
0005  *  \brief      Evaluation module for PHG4TrackFastSim output
0006  *  \details    input: PHG4TruthInfoContainer, SvtxTrackMap with SvtxTrack_FastSim inside
0007  *  \author     Haiwang Yu <yuhw@nmsu.edu>
0008  */
0009 
0010 #ifndef G4TRACKFASTSIM_PHG4TRACKFASTSIMEVAL_H
0011 #define G4TRACKFASTSIM_PHG4TRACKFASTSIMEVAL_H
0012 
0013 #include <fun4all/SubsysReco.h>
0014 
0015 #include <map>
0016 #include <string>
0017 #include <vector>
0018 
0019 // Forward declarations
0020 class PHCompositeNode;
0021 class PHG4TruthInfoContainer;
0022 class SvtxTrackMap;
0023 class SvtxVertexMap;
0024 class TTree;
0025 class TH2D;
0026 
0027 // Brief: basic ntuple and histogram creation for sim evaluation
0028 class PHG4TrackFastSimEval : public SubsysReco
0029 {
0030  public:
0031   // Default constructor
0032   PHG4TrackFastSimEval(const std::string& name = "PHG4TrackFastSimEval",
0033                        const std::string& filename = "g4eval.root",
0034                        const std::string& trackmapname = "SvtxTrackMap");
0035 
0036   // Initialization, called for initialization
0037   int Init(PHCompositeNode*) override;
0038 
0039   // Initialization, called for initialization
0040   int InitRun(PHCompositeNode*) override;
0041 
0042   // Process Event, called for each event
0043   int process_event(PHCompositeNode*) override;
0044 
0045   // End, write and close files
0046   int End(PHCompositeNode*) override;
0047 
0048   // Change output filename
0049   void set_filename(const std::string& file)
0050   {
0051     m_OutFileName = file;
0052   }
0053 
0054   // set the name of the node with the trackmap
0055   void set_trackmapname(const std::string& name)
0056   {
0057     m_TrackMapName = name;
0058   }
0059 
0060   // User modules
0061   void reset_variables();
0062 
0063   void AddProjection(const std::string& name);
0064 
0065  private:
0066   void fill_track_tree(PHCompositeNode*);
0067   void fill_vertex_tree(PHCompositeNode*);
0068 
0069   // Get all the nodes
0070   int GetNodes(PHCompositeNode*);
0071 
0072   // Node pointers
0073   PHG4TruthInfoContainer* m_TruthInfoContainer;
0074   SvtxTrackMap* m_TrackMap;
0075   SvtxVertexMap* m_VertexMap;
0076 
0077   // TTrees
0078   TTree* m_TracksEvalTree;
0079   TTree* m_VertexEvalTree;
0080 
0081   // Histos
0082   TH2D* m_H2D_DeltaMomVsTruthMom;
0083   TH2D* m_H2D_DeltaMomVsTruthEta;
0084 
0085   // Event counter
0086   int m_EventCounter;
0087 
0088   // TTree variables
0089   int m_TTree_Event{};
0090   //-- truth
0091   int m_TTree_gTrackID{};
0092   int m_TTree_gFlavor{};
0093   float m_TTree_gpx{};
0094   float m_TTree_gpy{};
0095   float m_TTree_gpz{};
0096   float m_TTree_gvx{};
0097   float m_TTree_gvy{};
0098   float m_TTree_gvz{};
0099   float m_TTree_gvt{};
0100 
0101   //-- reco
0102   int m_TTree_TrackID{};
0103   int m_TTree_Charge{};
0104   int m_TTree_nHits{};
0105   float m_TTree_px{};
0106   float m_TTree_py{};
0107   float m_TTree_pz{};
0108   float m_TTree_pcax{};
0109   float m_TTree_pcay{};
0110   float m_TTree_pcaz{};
0111   float m_TTree_dca2d{};
0112 
0113   std::map<int, int> m_TTree_HitContainerID_nHits_map;
0114 
0115   // vertex
0116   float m_TTree_vx{};
0117   float m_TTree_vy{};
0118   float m_TTree_vz{};
0119   float m_TTree_DeltaVx{};
0120   float m_TTree_DeltaVy{};
0121   float m_TTree_DeltaVz{};
0122   int m_TTree_nTracks{};
0123   int m_TTree_nFromTruth{};
0124 
0125   // output filename
0126   std::string m_OutFileName;
0127 
0128   // name of SvtxTrackMap collection
0129   std::string m_TrackMapName;
0130 
0131   // names and index of projections
0132   std::map<std::string, unsigned int> m_ProjectionNameMap;
0133   // projections to cylinders and planes
0134   std::vector<std::vector<float>> m_TTree_proj_vec;
0135   std::vector<std::vector<float>> m_TTree_proj_p_vec;
0136   // hits on reference cylinders and planes
0137   std::vector<std::vector<float>> m_TTree_ref_vec;
0138   std::vector<std::vector<float>> m_TTree_ref_p_vec;
0139 };
0140 
0141 #endif  //* G4TRACKFASTSIM_PHG4TRACKFASTSIMEVAL_H *//