File indexing completed on 2026-03-31 07:50:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "SteppingAction.hh"
0030
0031 #include "DetectorConstruction.hh"
0032 #include "G4RunManager.hh"
0033 #include "G4AnalysisManager.hh"
0034 #include "G4DNAElastic.hh"
0035 #include "G4DNAElectronSolvation.hh"
0036 #include "G4Event.hh"
0037 #include "G4EventManager.hh"
0038 #include "G4ITTrackHolder.hh"
0039 #include "G4Molecule.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4Track.hh"
0042 #include "globals.hh"
0043
0044 #include <map>
0045
0046 using MapOfDelayedLists = std::map<double, std::map<int, G4TrackList*>>;
0047
0048
0049
0050 SteppingAction::SteppingAction()
0051 : G4UserSteppingAction()
0052 {
0053 if (!fpDetector) {
0054 fpDetector = static_cast<const DetectorConstruction*>
0055 (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0056 }
0057 }
0058
0059
0060
0061 void SteppingAction::UserSteppingAction(const G4Step* step)
0062 {
0063 SetupFlags(step);
0064
0065 if (fVolumeType == DNAVolumeType::physWorld) {
0066 step->GetTrack()->SetTrackStatus(fStopAndKill);
0067 }
0068
0069 if (fVolumeType == DNAVolumeType::VoxelStraight) {
0070 return;
0071 }
0072
0073 G4double dE = step->GetTotalEnergyDeposit() / eV;
0074 const G4VProcess* pProcess = step->GetPostStepPoint()->GetProcessDefinedStep();
0075
0076
0077 if ((0 > dE) || (nullptr != dynamic_cast<const G4DNAElectronSolvation*>(pProcess))) {
0078 return;
0079 }
0080
0081 G4double x = step->GetPreStepPoint()->GetPosition().x() / nanometer;
0082 G4double y = step->GetPreStepPoint()->GetPosition().y() / nanometer;
0083 G4double z = step->GetPreStepPoint()->GetPosition().z() / nanometer;
0084
0085 G4double copyNo = G4double(step->GetPreStepPoint()->GetTouchable()->GetVolume()->GetCopyNo());
0086
0087 G4double eventId =
0088 G4double(G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID());
0089
0090 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0091 analysisManager->FillNtupleDColumn(1, 0, x);
0092 analysisManager->FillNtupleDColumn(1, 1, y);
0093 analysisManager->FillNtupleDColumn(1, 2, z);
0094 analysisManager->FillNtupleDColumn(1, 3, dE);
0095 analysisManager->FillNtupleDColumn(
0096 1, 4,
0097 (step->GetPreStepPoint()->GetKineticEnergy() - step->GetPostStepPoint()->GetKineticEnergy())
0098 / eV);
0099 analysisManager->FillNtupleIColumn(1, 5, G4int(fVolumeType));
0100 analysisManager->FillNtupleDColumn(1, 6, copyNo);
0101 analysisManager->FillNtupleIColumn(1, 7, eventId);
0102 analysisManager->AddNtupleRow(1);
0103
0104 MapOfDelayedLists delayList = G4ITTrackHolder::Instance()->GetDelayedLists();
0105 for (auto& delayedmap_it : delayList) {
0106 for (auto& trackList : delayedmap_it.second) {
0107 if (nullptr == trackList.second) {
0108 return;
0109 }
0110 G4TrackList::iterator itt = trackList.second->begin();
0111 G4TrackList::iterator endd = trackList.second->end();
0112 for (; itt != endd; ++itt) {
0113 G4Track* track = *itt;
0114 if (track->GetParentID() != step->GetTrack()->GetTrackID()
0115 || track->GetPosition() != step->GetPostStepPoint()->GetPosition())
0116 {
0117 return;
0118 }
0119
0120 track->SetTrackStatus(fStopAndKill);
0121 }
0122 }
0123 }
0124 }
0125
0126
0127 void SteppingAction::SetupFlags(const G4Step* step)
0128 {
0129 fVolumeType = SetupVolumeType(step->GetPreStepPoint()->GetPhysicalVolume());
0130 }
0131
0132
0133
0134 DNAVolumeType SteppingAction::SetupVolumeType(const G4VPhysicalVolume* pPhyVolume)
0135 {
0136 auto it = (fpDetector->GetGeoDataMap()).find(pPhyVolume);
0137
0138 if (it == (fpDetector->GetGeoDataMap()).end()) {
0139 G4ExceptionDescription exceptionDescription;
0140 exceptionDescription << pPhyVolume->GetName() << " is wrong physical volume";
0141 G4Exception("SteppingAction::SetupVolumeFlag()", "SteppingAction01", FatalException,
0142 exceptionDescription);
0143 }
0144
0145 return it->second;
0146 }
0147