Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // G4TrackingManager 27 // 28 // Class description: 29 // 30 // This is an interface class between the event, the track and the tracking 31 // categories. It handles necessary message passing between the upper 32 // hierarchical object, which is the event manager (G4EventManager), and 33 // lower hierarchical objects in the tracking category. It receives one track 34 // in an event from the event manager and takes care to finish tracking it. 35 // Used exclusively by the Geant4 kernel. 36 37 // Contact: 38 // Questions and comments to this code should be sent to 39 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 40 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 41 //--------------------------------------------------------------- 42 #ifndef G4TrackingManager_hh 43 #define G4TrackingManager_hh 1 44 45 #include "G4StepStatus.hh" // Include from 'tracking' 46 #include "G4SteppingManager.hh" // Include from 'tracking' 47 #include "G4Track.hh" // Include from 'tracking' 48 #include "G4TrackStatus.hh" // Include from 'tracking' 49 #include "G4TrackVector.hh" // Include from 'tracking' 50 #include "G4TrackingMessenger.hh" 51 #include "G4UserSteppingAction.hh" // Include from 'tracking' 52 #include "G4UserTrackingAction.hh" // Include from 'tracking' 53 #include "G4VTrajectory.hh" // Include from 'tracking' 54 #include "globals.hh" // Include from 'global' 55 56 class G4VUserTrackInformation; 57 58 //////////////////////// 59 class G4TrackingManager 60 //////////////////////// 61 { 62 public: 63 // Constructor/Destructor 64 65 // G4TrackingManger should be dynamically allocated, therefore you 66 // need to invoke new() when you call this constructor. 67 // G4SteppingManger and G4UserTrackingAction will be created 68 // in this constructor. "This" pointer will be passed to 69 // G4UserTrackingAction. 70 G4TrackingManager(); 71 ~G4TrackingManager(); 72 73 // Get/Set functions 74 75 G4Track* GetTrack() const; 76 77 G4int GetStoreTrajectory() const; 78 void SetStoreTrajectory(G4int value); 79 80 G4SteppingManager* GetSteppingManager() const; 81 82 G4UserTrackingAction* GetUserTrackingAction() const; 83 84 G4VTrajectory* GimmeTrajectory() const; 85 void SetTrajectory(G4VTrajectory* aTrajectory); 86 87 G4TrackVector* GimmeSecondaries() const; 88 89 void SetUserAction(G4UserTrackingAction* apAction); 90 void SetUserAction(G4UserSteppingAction* apAction); 91 92 void SetVerboseLevel(G4int vLevel); 93 G4int GetVerboseLevel() const; 94 95 // Other member functions 96 97 void ProcessOneTrack(G4Track* apValueG4Track); 98 // Invoking this function, a G4Track given by the argument 99 // will be tracked. 100 101 void EventAborted(); 102 // Invoking this function, the current tracking will be 103 // aborted immediately. The tracking will return the 104 // G4TrackStatus in 'fUserKillTrackAndSecondaries'. 105 // By this the EventManager deletes the current track and all 106 // its associated secondaries. 107 108 void SetUserTrackInformation(G4VUserTrackInformation* aValue); 109 // This method can be invoked from the user's G4UserTrackingAction 110 // implementation to set his/her own G4VUserTrackInformation concrete 111 // class object to a G4Track object. 112 113 private: 114 void TrackBanner(); // verbose 115 116 // Member data 117 118 G4Track* fpTrack = nullptr; 119 G4SteppingManager* fpSteppingManager = nullptr; 120 G4UserTrackingAction* fpUserTrackingAction = nullptr; 121 G4VTrajectory* fpTrajectory = nullptr; 122 G4int StoreTrajectory = 0; 123 G4int verboseLevel = 0; 124 G4TrackingMessenger* messenger = nullptr; 125 G4bool EventIsAborted = false; 126 }; 127 128 //******************************************************************* 129 // 130 // Inline function 131 // 132 //******************************************************************* 133 134 inline G4Track* G4TrackingManager::GetTrack() const { return fpTrack; } 135 136 inline G4int G4TrackingManager::GetStoreTrajectory() const { return StoreTrajectory; } 137 138 inline G4SteppingManager* G4TrackingManager::GetSteppingManager() const 139 { 140 return fpSteppingManager; 141 } 142 143 inline G4UserTrackingAction* G4TrackingManager::GetUserTrackingAction() const 144 { 145 return fpUserTrackingAction; 146 } 147 148 inline G4VTrajectory* G4TrackingManager::GimmeTrajectory() const { return fpTrajectory; } 149 150 inline G4TrackVector* G4TrackingManager::GimmeSecondaries() const 151 { 152 return fpSteppingManager->GetfSecondary(); 153 } 154 155 inline void G4TrackingManager::SetUserAction(G4UserTrackingAction* apAction) 156 { 157 fpUserTrackingAction = apAction; 158 if (apAction != nullptr) { 159 apAction->SetTrackingManagerPointer(this); 160 } 161 } 162 163 inline void G4TrackingManager::SetUserAction(G4UserSteppingAction* apAction) 164 { 165 fpSteppingManager->SetUserAction(apAction); 166 if (apAction != nullptr) { 167 apAction->SetSteppingManagerPointer(fpSteppingManager); 168 } 169 } 170 171 inline void G4TrackingManager::SetVerboseLevel(G4int vLevel) 172 { 173 verboseLevel = vLevel; 174 fpSteppingManager->SetVerboseLevel(vLevel); 175 } 176 177 inline G4int G4TrackingManager::GetVerboseLevel() const { return verboseLevel; } 178 179 inline void G4TrackingManager::SetUserTrackInformation(G4VUserTrackInformation* aValue) 180 { 181 if (fpTrack != nullptr) fpTrack->SetUserInformation(aValue); 182 } 183 184 #endif 185