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 #include "Par04DefineMeshModel.hh" 27 28 #include "Par04EventInformation.hh" // for Par04EventInformation 29 30 #include "G4Event.hh" // for G4Event 31 #include "G4EventManager.hh" // for G4EventManager 32 33 #include <G4FastTrack.hh> // for G4FastTrack 34 #include <G4Track.hh> // for G4Track 35 #include <G4VFastSimulationModel.hh> // for G4VFastSimulationModel 36 #include <G4VUserEventInformation.hh> // for G4VUserEventInformation 37 class G4FastStep; 38 class G4ParticleDefinition; 39 class G4Region; 40 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 42 43 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName, G4Region* aEnvelope) 44 : G4VFastSimulationModel(aModelName, aEnvelope) 45 {} 46 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 49 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName) : G4VFastSimulationModel(aModelName) 50 {} 51 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 54 Par04DefineMeshModel::~Par04DefineMeshModel() = default; 55 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 58 G4bool Par04DefineMeshModel::IsApplicable(const G4ParticleDefinition&) 59 { 60 return true; 61 } 62 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 65 G4bool Par04DefineMeshModel::ModelTrigger(const G4FastTrack&) 66 { 67 auto info = dynamic_cast<Par04EventInformation*>( 68 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation()); 69 // check if particle direction and position were already set for this event 70 if (info != nullptr) 71 return !info->GetFlag(); 72 else 73 return true; 74 } 75 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 77 78 void Par04DefineMeshModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep&) 79 { 80 auto info = dynamic_cast<Par04EventInformation*>( 81 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation()); 82 if (info == nullptr) { 83 info = new Par04EventInformation(); 84 G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetUserInformation(info); 85 } 86 info->SetPosition(aFastTrack.GetPrimaryTrack()->GetPosition()); 87 info->SetDirection(aFastTrack.GetPrimaryTrack()->GetMomentumDirection()); 88 info->SetFlag(true); 89 } 90