Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 08:29:35

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 /// \file Par04DefineMeshModel.cc
0027 /// \brief Implementation of the Par04DefineMeshModel class
0028 
0029 #include "Par04DefineMeshModel.hh"
0030 
0031 #include "Par04EventInformation.hh"  // for Par04EventInformation
0032 
0033 #include "G4Event.hh"  // for G4Event
0034 #include "G4EventManager.hh"  // for G4EventManager
0035 
0036 #include <G4FastTrack.hh>  // for G4FastTrack
0037 #include <G4Track.hh>  // for G4Track
0038 #include <G4VFastSimulationModel.hh>  // for G4VFastSimulationModel
0039 #include <G4VUserEventInformation.hh>  // for G4VUserEventInformation
0040 class G4FastStep;
0041 class G4ParticleDefinition;
0042 class G4Region;
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName, G4Region* aEnvelope)
0047   : G4VFastSimulationModel(aModelName, aEnvelope)
0048 {}
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 Par04DefineMeshModel::Par04DefineMeshModel(G4String aModelName) : G4VFastSimulationModel(aModelName)
0053 {}
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 Par04DefineMeshModel::~Par04DefineMeshModel() = default;
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 G4bool Par04DefineMeshModel::IsApplicable(const G4ParticleDefinition&)
0062 {
0063   return true;
0064 }
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 G4bool Par04DefineMeshModel::ModelTrigger(const G4FastTrack&)
0069 {
0070   auto info = dynamic_cast<Par04EventInformation*>(
0071     G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0072   // check if particle direction and position were already set for this event
0073   if (info != nullptr)
0074     return !info->GetFlag();
0075   else
0076     return true;
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 void Par04DefineMeshModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep&)
0082 {
0083   auto info = dynamic_cast<Par04EventInformation*>(
0084     G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetUserInformation());
0085   if (info == nullptr) {
0086     info = new Par04EventInformation();
0087     G4EventManager::GetEventManager()->GetNonconstCurrentEvent()->SetUserInformation(info);
0088   }
0089   info->SetPosition(aFastTrack.GetPrimaryTrack()->GetPosition());
0090   info->SetDirection(aFastTrack.GetPrimaryTrack()->GetMomentumDirection());
0091   info->SetFlag(true);
0092 }