Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:18

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