Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:22:14

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