Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 //....oooOO0OOooo........oooOO0OOooo........oo 28 //....oooOO0OOooo........oooOO0OOooo........oo 29 30 #include "SpecializedTrackingManager.hh" 31 32 #include "G4EventManager.hh" 33 #include "G4ProcessManager.hh" 34 #include "G4RegionStore.hh" 35 #include "G4StackManager.hh" 36 #include "G4SystemOfUnits.hh" 37 #include "G4TrackingManager.hh" 38 39 //....oooOO0OOooo........oooOO0OOooo........oo 40 41 SpecializedTrackingManager::SpecializedTrackin 42 43 //....oooOO0OOooo........oooOO0OOooo........oo 44 45 SpecializedTrackingManager::~SpecializedTracki 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 48 49 void SpecializedTrackingManager::BuildPhysicsT 50 { 51 if (fBackRegion == nullptr) { 52 fBackRegion = G4RegionStore::GetInstance() 53 } 54 55 G4ProcessManager* pManager = part.GetProcess 56 G4ProcessManager* pManagerShadow = part.GetM 57 58 G4ProcessVector* pVector = pManager->GetProc 59 for (std::size_t j = 0; j < pVector->size(); 60 if (pManagerShadow == pManager) { 61 (*pVector)[j]->BuildPhysicsTable(part); 62 } 63 else { 64 (*pVector)[j]->BuildWorkerPhysicsTable(p 65 } 66 } 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 71 void SpecializedTrackingManager::PreparePhysic 72 { 73 G4ProcessManager* pManager = part.GetProcess 74 G4ProcessManager* pManagerShadow = part.GetM 75 76 G4ProcessVector* pVector = pManager->GetProc 77 for (std::size_t j = 0; j < pVector->size(); 78 if (pManagerShadow == pManager) { 79 (*pVector)[j]->PreparePhysicsTable(part) 80 } 81 else { 82 (*pVector)[j]->PrepareWorkerPhysicsTable 83 } 84 } 85 } 86 87 //....oooOO0OOooo........oooOO0OOooo........oo 88 89 void SpecializedTrackingManager::HandOverOneTr 90 { 91 if (aTrack->GetKineticEnergy() < 100 * MeV) 92 // If the particle energy is lower than 10 93 // passing to the generic G4TrackingManage 94 // energy particles in the buffer and feed 95 // tracking. 96 G4EventManager* eventManager = G4EventMana 97 G4TrackingManager* trackManager = eventMan 98 99 trackManager->ProcessOneTrack(aTrack); 100 if (aTrack->GetTrackStatus() != fStopAndKi 101 G4Exception("SpecializedTrackingManager: 102 "track was not stopped"); 103 } 104 105 G4TrackVector* secondaries = trackManager- 106 eventManager->StackTracks(secondaries); 107 delete aTrack; 108 return; 109 } 110 111 fBufferedTracks.push_back(aTrack); 112 } 113 114 //....oooOO0OOooo........oooOO0OOooo........oo 115 116 void SpecializedTrackingManager::FlushEvent() 117 { 118 G4EventManager* eventManager = G4EventManage 119 G4TrackingManager* trackManager = eventManag 120 G4SteppingManager* steppingManager = trackMa 121 G4TrackVector* secondaries = trackManager->G 122 123 for (G4Track* aTrack : fBufferedTracks) { 124 // Clear secondary particle vector 125 for (std::size_t itr = 0; itr < secondarie 126 delete (*secondaries)[itr]; 127 } 128 secondaries->clear(); 129 130 steppingManager->SetInitialStep(aTrack); 131 132 G4UserTrackingAction* userTrackingAction = 133 if (userTrackingAction != nullptr) { 134 userTrackingAction->PreUserTrackingActio 135 } 136 137 // Give SteppingManger the maxmimum number 138 steppingManager->GetProcessNumber(); 139 140 // Give track the pointer to the Step 141 aTrack->SetStep(steppingManager->GetStep() 142 143 // Inform beginning of tracking to physics 144 aTrack->GetDefinition()->GetProcessManager 145 146 // Track the particle Step-by-Step while i 147 while ((aTrack->GetTrackStatus() == fAlive 148 G4Region* region = aTrack->GetVolume()-> 149 if (region == fBackRegion) { 150 StepInBackRegion(aTrack); 151 } 152 else { 153 StepOutside(aTrack); 154 } 155 } 156 157 aTrack->GetDefinition()->GetProcessManager 158 159 if (userTrackingAction != nullptr) { 160 userTrackingAction->PostUserTrackingActi 161 } 162 163 eventManager->StackTracks(secondaries); 164 delete aTrack; 165 } 166 167 fBufferedTracks.clear(); 168 } 169 170 //....oooOO0OOooo........oooOO0OOooo........oo 171 172 void SpecializedTrackingManager::StepInBackReg 173 { 174 G4EventManager* eventManager = G4EventManage 175 G4TrackingManager* trackManager = eventManag 176 G4SteppingManager* steppingManager = trackMa 177 178 // Track the particle Step-by-Step while it 179 // region of the detector. Implement a low-e 180 // below 100 MeV. More specialized handling 181 // as only killing particles in non-sensitiv 182 while ((aTrack->GetTrackStatus() == fAlive) 183 aTrack->IncrementCurrentStepNumber(); 184 steppingManager->Stepping(); 185 186 if (aTrack->GetTrackStatus() != fStopAndKi 187 // Switch the touchable to update the vo 188 // condition below and at the call site. 189 aTrack->SetTouchableHandle(aTrack->GetNe 190 G4Region* region = aTrack->GetVolume()-> 191 if (region != fBackRegion) { 192 return; 193 } 194 195 if (aTrack->GetKineticEnergy() < 100 * M 196 // Kill the particle. 197 aTrack->SetTrackStatus(fStopAndKill); 198 } 199 } 200 } 201 } 202 203 //....oooOO0OOooo........oooOO0OOooo........oo 204 205 void SpecializedTrackingManager::StepOutside(G 206 { 207 G4EventManager* eventManager = G4EventManage 208 G4TrackingManager* trackManager = eventManag 209 G4SteppingManager* steppingManager = trackMa 210 211 // Track the particle Step-by-Step while it 212 // the "Back" region. 213 while ((aTrack->GetTrackStatus() == fAlive) 214 aTrack->IncrementCurrentStepNumber(); 215 steppingManager->Stepping(); 216 217 if (aTrack->GetTrackStatus() != fStopAndKi 218 // Switch the touchable to update the vo 219 // condition below and at the call site. 220 aTrack->SetTouchableHandle(aTrack->GetNe 221 G4Region* region = aTrack->GetVolume()-> 222 if (region == fBackRegion) { 223 return; 224 } 225 } 226 } 227 } 228