Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:52:16

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 SteppingAction.cc
0027 /// \brief Implementation of the SteppingAction class
0028 
0029 #include "SteppingAction.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 #include "HistoManager.hh"
0033 
0034 #include "G4RunManager.hh"
0035 #include "G4DNAChemistryManager.hh"
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 SteppingAction::SteppingAction() {
0039   fpDetector = dynamic_cast<const DetectorConstruction *>(
0040     G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0041   fRNP = fpDetector->GetNPRadius() / CLHEP::nm;
0042   fRAbs = fpDetector->GetAbsRadius() / CLHEP::nm;
0043   fTrackCut = fpDetector->GetTrackingCut() / CLHEP::eV;
0044 }
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 void SteppingAction::UserSteppingAction(const G4Step *aStep) {
0049   // Refresh detector parameters (kept to preserve original behavior)
0050   fpDetector = dynamic_cast<const DetectorConstruction *>(
0051     G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0052   fRNP = fpDetector->GetNPRadius() / CLHEP::nm;
0053   fRAbs = fpDetector->GetAbsRadius() / CLHEP::nm;
0054   fTrackCut = fpDetector->GetTrackingCut() / CLHEP::eV;
0055 
0056   const auto pre = aStep->GetPreStepPoint();
0057   const auto post = aStep->GetPostStepPoint();
0058 
0059   const G4ThreeVector &pos = pre->GetPosition();
0060   const G4ThreeVector &postpos = post->GetPosition();
0061 
0062   const G4double R = pos.mag() / CLHEP::nm;
0063 
0064   G4AnalysisManager *analysisManager = G4AnalysisManager::Instance();
0065 
0066   // Radial energy deposition
0067   if (fRNP < R) {
0068     const G4double energy = aStep->GetTotalEnergyDeposit() / CLHEP::joule;
0069     analysisManager->FillH1(1, R, energy);
0070 
0071     // Angular distribution in the near-equatorial plane
0072     if (std::abs(pos.z()) < 10 * CLHEP::nm) {
0073       const G4double theta = std::atan2(pos.y(), pos.x()) / CLHEP::deg;
0074       if (0 <= theta) {
0075         analysisManager->FillH2(0, theta, R, energy);
0076       } else {
0077         analysisManager->FillH2(0, theta + 360, R, energy);
0078       }
0079     }
0080   }
0081 
0082   // Process tracks crossing NanoParticle boundary
0083   if (pre->GetPhysicalVolume()->GetName() != "NanoParticle") {
0084     return;
0085   }
0086   if (post->GetStepStatus() != fGeomBoundary) {
0087     return;
0088   }
0089 
0090   //*** WARNING: this will kill all incident electrons at the NP surface (as in original code) ***
0091   G4Track *track = aStep->GetTrack();
0092   const G4double trackE = track->GetKineticEnergy() / CLHEP::eV;
0093 
0094   if (track->GetTrackID() == 1) {
0095     if (pos.x() < 0) {
0096       analysisManager->FillH1(8, trackE);
0097     } else {
0098       analysisManager->FillH1(9, trackE);
0099     }
0100     if (!G4DNAChemistryManager::IsActivated()) {
0101       track->SetTrackStatus(fStopAndKill);
0102     }
0103     return;
0104   }
0105 
0106   const G4ThreeVector &dir = post->GetMomentumDirection();
0107   if (dir.dot(postpos) < 0.0) {
0108     return;
0109   }
0110 
0111   if (trackE < fTrackCut) {
0112     track->SetTrackStatus(fStopAndKill);
0113     return;
0114   }
0115 
0116   if (track->GetDefinition()->GetPDGCharge() != 0) {
0117     analysisManager->FillH1(4, trackE);
0118   } else {
0119     analysisManager->FillH1(5, trackE);
0120   }
0121 }
0122 
0123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......