Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:28:00

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 F04SteppingAction.cc
0027 /// \brief Implementation of the F04SteppingAction class
0028 
0029 #include "F04SteppingAction.hh"
0030 
0031 #include "F04UserTrackInformation.hh"
0032 
0033 #include "G4LogicalVolumeStore.hh"
0034 #include "G4ParticleTypes.hh"
0035 #include "G4SteppingManager.hh"
0036 #include "G4Track.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 void F04SteppingAction::UserSteppingAction(const G4Step* theStep)
0041 {
0042   G4Track* theTrack = theStep->GetTrack();
0043 
0044   // Get pointers to test volumes (only once)
0045   if (!fTargetVolume) {
0046     fTargetVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("Target");
0047     fTestPlaneVolume = G4LogicalVolumeStore::GetInstance()->GetVolume("TestPlane");
0048   }
0049 
0050   if (theTrack->GetParentID() == 0) {
0051     // This is a primary track
0052     G4LogicalVolume* theVolume =
0053       theStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
0054     if (theVolume != fTargetVolume) {
0055       theTrack->SetTrackStatus(fStopAndKill);
0056       return;
0057     }
0058   }
0059 
0060   //  G4ParticleDefinition* particleType = theTrack->GetDefinition();
0061 
0062   // check if it is entering the test volume
0063   G4StepPoint* thePrePoint = theStep->GetPreStepPoint();
0064   G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
0065   G4LogicalVolume* thePreLV = thePrePV->GetLogicalVolume();
0066 
0067   G4LogicalVolume* thePostLV = nullptr;
0068   G4StepPoint* thePostPoint = theStep->GetPostStepPoint();
0069 
0070   if (thePostPoint) {
0071     G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
0072     if (thePostPV) thePostLV = thePostPV->GetLogicalVolume();
0073   }
0074 
0075   if (thePostLV == fTestPlaneVolume && thePreLV != fTestPlaneVolume) {
0076     //     G4double x = theTrack->GetPosition().x();
0077     //     G4double y = theTrack->GetPosition().y();
0078 
0079     G4ThreeVector theMomentumDirection = theTrack->GetDynamicParticle()->GetMomentumDirection();
0080     //     G4double theTotalMomentum = theTrack->GetDynamicParticle()->
0081     //                                                    GetTotalMomentum();
0082 
0083     // then kill the track
0084     theTrack->SetTrackStatus(fStopAndKill);
0085     return;
0086   }
0087 
0088   //  G4double z = theTrack->GetPosition().z();
0089 
0090   auto trackInformation = (F04UserTrackInformation*)theTrack->GetUserInformation();
0091 
0092   if (trackInformation->GetTrackStatusFlag() != reverse) {
0093     if (thePreLV != fTargetVolume) {
0094       if (theTrack->GetMomentumDirection().z() > 0.0
0095           && theTrack->GetVertexMomentumDirection().z() < 0.0)
0096       {
0097         trackInformation->SetTrackStatusFlag(reverse);
0098       }
0099     }
0100   }
0101 
0102   // check if it is alive
0103   if (theTrack->GetTrackStatus() == fAlive) {
0104     return;
0105   }
0106 
0107   if (thePostPoint->GetProcessDefinedStep() != nullptr) {
0108     if (thePostPoint->GetProcessDefinedStep()->GetProcessName() != "Decay") return;
0109   }
0110 }