Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:34

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 #include "Par04DefineMeshModel.hh"
0027 
0028 #include "Par04EventInformation.hh"  // for Par04EventInformation
0029 
0030 #include "G4Event.hh"  // for G4Event
0031 #include "G4EventManager.hh"  // for G4EventManager
0032 
0033 #include <G4FastTrack.hh>  // for G4FastTrack
0034 #include <G4Track.hh>  // for G4Track
0035 #include <G4VFastSimulationModel.hh>  // for G4VFastSimulationModel
0036 #include <G4VUserEventInformation.hh>  // for G4VUserEventInformation
0037 class G4FastStep;
0038 class G4ParticleDefinition;
0039 class G4Region;
0040 
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0042 
0043 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName, G4Region* aEnvelope)
0044   : G4VFastSimulationModel(aModelName, aEnvelope)
0045 {}
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 
0049 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName) : G4VFastSimulationModel(aModelName)
0050 {}
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 Par04DefineMeshModel::~Par04DefineMeshModel() = default;
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 G4bool Par04DefineMeshModel::IsApplicable(const G4ParticleDefinition&)
0059 {
0060   return true;
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 G4bool Par04DefineMeshModel::ModelTrigger(const G4FastTrack&)
0066 {
0067   auto info = dynamic_cast<Par04EventInformation*>(
0068     G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0069   // check if particle direction and position were already set for this event
0070   if (info != nullptr)
0071     return !info->GetFlag();
0072   else
0073     return true;
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 
0078 void Par04DefineMeshModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep&)
0079 {
0080   auto info = dynamic_cast<Par04EventInformation*>(
0081     G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0082   if (info == nullptr) {
0083     info = new Par04EventInformation();
0084     G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetUserInformation(info);
0085   }
0086   info->SetPosition(aFastTrack.GetPrimaryTrack()->GetPosition());
0087   info->SetDirection(aFastTrack.GetPrimaryTrack()->GetMomentumDirection());
0088   info->SetFlag(true);
0089 }