00001 //---------------------------------------------------------------------------// 00002 //Description: In charge of McTruth 00003 //Author: Wu Chen(wuchen@mail.ihep.ac.cn) 00004 //Created: 17 Oct, 2012 00005 //Comment: 00006 //---------------------------------------------------------------------------// 00007 00008 #ifndef McTruthSvc_h 00009 #define McTruthSvc_h 1 00010 00011 #include "myglobals.hh" 00012 00013 #include <string> 00014 #include <vector> 00015 00016 class G4Event; 00017 class G4Track; 00018 00019 class McTruthSvc 00020 { 00021 public: 00022 McTruthSvc(); 00023 ~McTruthSvc(); 00024 00025 static McTruthSvc* GetMcTruthSvc(); 00026 00027 void SetBranch(); 00028 00029 void ReadOutputCard(G4String filename); 00030 00031 void SetValuePre(const G4Track*); 00032 void SetValuePost(const G4Track*); 00033 00034 void Initialize(); 00035 00036 int get_nTracks(){return m_nTracks;} 00037 int get_nTracksAll(){return m_nTracksAll;} 00038 int get_pid( int i ){ if(i<m_nTracks) return m_pid[i]; else return 0; } 00039 double get_px( int i ){ if(i<m_nTracks) return m_px[i]; else return 0; } 00040 double get_py( int i ){ if(i<m_nTracks) return m_py[i]; else return 0; } 00041 double get_pz( int i ){ if(i<m_nTracks) return m_pz[i]; else return 0; } 00042 00043 int tid2pid(int tid){ 00044 for (int i = 0; i< m_dicttid.size(); i++){ 00045 if (tid==m_dicttid[i]) 00046 return m_dictpid[i]; 00047 } 00048 return 0; 00049 } 00050 00051 double tid2time(int tid){ 00052 for (int i = 0; i< m_dicttid.size(); i++){ 00053 if (tid==m_dicttid[i]) 00054 return m_dicttime[i]; 00055 } 00056 return 0; 00057 } 00058 00059 private: 00060 00061 void ReSet(); 00062 void ShowOutCard(); 00063 00064 static McTruthSvc* fMcTruthSvc; 00065 00066 //for output setting 00067 bool flag_tid2pid; 00068 bool flag_tid2time; 00069 bool flag_nTracks; 00070 bool flag_pid; 00071 bool flag_tid; 00072 bool flag_ptid; 00073 bool flag_ppid; 00074 bool flag_time; 00075 bool flag_px; 00076 bool flag_py; 00077 bool flag_pz; 00078 bool flag_e; 00079 bool flag_x; 00080 bool flag_y; 00081 bool flag_z; 00082 bool flag_charge; 00083 bool flag_particleName; 00084 bool flag_process; 00085 bool flag_volume; 00086 //for filter 00087 bool m_Switch; 00088 double m_minp; 00089 double m_mine; 00090 int m_maxnTracks; 00091 double m_mint; 00092 double m_maxt; 00093 std::vector<int> white_list; 00094 std::vector<int> black_list; 00095 //For root objects 00096 int m_nTracksAll; 00097 int m_nTracks; 00098 std::vector<double> m_dicttime; 00099 std::vector<int> m_dictpid; 00100 std::vector<int> m_dicttid; 00101 std::vector<int> m_pid; 00102 std::vector<int> m_tid; 00103 std::vector<int> m_ptid; 00104 std::vector<int> m_ppid; 00105 std::vector<double> m_time; 00106 std::vector<double> m_px; 00107 std::vector<double> m_py; 00108 std::vector<double> m_pz; 00109 std::vector<double> m_e; 00110 std::vector<double> m_ekin; 00111 std::vector<double> m_x; 00112 std::vector<double> m_y; 00113 std::vector<double> m_z; 00114 std::vector<std::string> m_particleName; 00115 std::vector<int> m_charge; 00116 std::vector<std::string> m_process; 00117 std::vector<std::string> m_volume; 00118 std::string unitName_time; 00119 std::string unitName_px; 00120 std::string unitName_py; 00121 std::string unitName_pz; 00122 std::string unitName_e; 00123 std::string unitName_x; 00124 std::string unitName_y; 00125 std::string unitName_z; 00126 double unit_time; 00127 double unit_px; 00128 double unit_py; 00129 double unit_pz; 00130 double unit_e; 00131 double unit_x; 00132 double unit_y; 00133 double unit_z; 00134 }; 00135 00136 #endif 00137