00001 //-*-C++-*- 00002 // $Id: MyStackingAction.hh 80 2007-12-09 10:01:09Z comet $ 00003 00004 #ifndef MyStackingAction_HH 00005 #define MyStackingAction_HH 1 00006 00007 static const char* MyStackingAction_hh = 00008 "@(#) $Id: MyStackingAction.hh 80 2007-12-09 10:01:09Z comet $"; 00009 00010 #include <map> 00011 #include <vector> 00012 #include "myglobals.hh" 00013 00014 class MyStackingActionMessenger; 00015 00016 #include "G4UserStackingAction.hh" 00017 class G4StackManager; 00018 class G4Track; 00019 #include "G4ClassificationOfNewTrack.hh" 00020 00021 // class description: 00022 // 00023 // This is the base class of one of the user's optional action classes. 00024 // This class gives the hooks for G4StackManager which controls the stacks 00025 // of G4Track objects. 00026 // 00027 00028 typedef std::map<G4int, G4int> TTrackIDMap; 00029 typedef TTrackIDMap::value_type TTrackIDMapValue; 00030 00031 class MyStackingAction : public G4UserStackingAction { 00032 public: 00033 MyStackingAction(); 00034 ~MyStackingAction(); 00035 00036 inline void SetStackManager(G4StackManager * value) 00037 { stackManager = value; } 00038 00039 public: // with description 00040 //--------------------------------------------------------------- 00041 // vitual methods to be implemented by user 00042 //--------------------------------------------------------------- 00043 // 00044 G4ClassificationOfNewTrack 00045 ClassifyNewTrack(const G4Track* aTrack); 00046 // 00047 // Extended to store the (daughter_ID,parent_ID) for 00048 // keeping the track_ID history, by M. Aoki. 00049 // 00050 // 00051 // Reply G4ClassificationOfNewTrack determined by the 00052 // newly coming G4Track. 00053 // 00054 // enum G4ClassificationOfNewTrack 00055 // { 00056 // fUrgent, // put into the urgent stack 00057 // fWaiting, // put into the waiting stack 00058 // fPostpone, // postpone to the next event 00059 // fKill // kill without stacking 00060 // }; 00061 // 00062 // The parent_ID of the track indicates the origin of it. 00063 // 00064 // G4int parent_ID = aTrack->get_parentID(); 00065 // 00066 // parent_ID = 0 : primary particle 00067 // > 0 : secondary particle 00068 // < 0 : postponed from the previous event 00069 // 00070 //--------------------------------------------------------------- 00071 // 00072 00073 void NewStage(); 00074 // 00075 // This method is called by G4StackManager when the urgentStack 00076 // becomes empty and contents in the waitingStack are transtered 00077 // to the urgentStack. 00078 // Note that this method is not called at the begining of each 00079 // event, but "PrepareNewEvent" is called. 00080 // 00081 // In case re-classification of the stacked tracks is needed, 00082 // use the following method to request to G4StackManager. 00083 // 00084 // stackManager->ReClassify(); 00085 // 00086 // All of the stacked tracks in the waitingStack will be re-classified 00087 // by "ClassifyNewTrack" method. 00088 // To abort current event, use the following method. 00089 // 00090 // stackManager->clear(); 00091 // 00092 // Note that this way is valid and safe only for the case it is called 00093 // from this user class. The more global way of event abortion is 00094 // 00095 // G4UImanager * UImanager = G4UImanager::GetUIpointer(); 00096 // UImanager->ApplyCommand("/event/abort"); 00097 // 00098 //--------------------------------------------------------------- 00099 // 00100 00101 void PrepareNewEvent(); 00102 // 00103 // This method is called by G4StackManager at the begining of 00104 // each event. 00105 // Be careful that the urgentStack and the waitingStack of 00106 // G4StackManager are empty at this moment, because this method 00107 // is called before accepting primary particles. Also, note that 00108 // the postponeStack of G4StackManager may have some postponed 00109 // tracks. 00110 // 00111 //--------------------------------------------------------------- 00112 00113 public: 00114 void SetEleCut(G4double val) {fEleCut = val;}; 00115 void SetPosCut(G4double val) {fPosCut = val;}; 00116 void SetGamCut(G4double val) {fGamCut = val;}; 00117 00118 G4double GetEleCut() {return fEleCut;}; 00119 G4double GetPosCut() {return fPosCut;}; 00120 G4double GetGamCut() {return fGamCut;}; 00121 00122 void add_white_list(int val) {m_white_list.push_back(val);}; 00123 void add_black_list(int val) {m_black_list.push_back(val);}; 00124 void clear_white_list() {m_white_list.clear();}; 00125 void clear_black_list() {m_black_list.clear();}; 00126 void set_no_PC(bool val) {m_no_PC=val;}; 00127 void set_no_MC(bool val) {m_no_MC=val;}; 00128 void set_no_sec(bool val) {m_no_sec=val;}; 00129 00130 public: 00131 00132 G4int GetDepthFromParent(G4int aTrack, G4int parentTrack); 00133 // return 0 -- if aTrack == parentTrack 00134 // return -1 -- if aTrack <= 0 || parentTrack <= 0 ... error 00135 // return 1 -- if a parent track of aTrack is parentTrack itself. 00136 // return 2 -- if a grand-parent track of aTrack is parentTrack. 00137 // and so on. 00138 // 00139 00140 private: 00141 00142 MyStackingActionMessenger* fStackingActionMessenger; 00143 00144 TTrackIDMap* fTrackIDMap; 00145 00146 G4double fEleCut; 00147 G4double fPosCut; 00148 G4double fGamCut; 00149 00150 bool m_no_PC; 00151 bool m_no_MC; 00152 bool m_no_sec; 00153 std::vector<int> m_white_list; 00154 std::vector<int> m_black_list; 00155 00156 }; 00157 #endif