File indexing completed on 2025-02-23 09:21:14
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
0030
0031 #ifdef G4MULTITHREADED
0032 # include "G4MTRunManager.hh"
0033 #else
0034 # include "G4RunManager.hh"
0035 #endif
0036
0037 #include "SAXSDetectorConstruction.hh"
0038 #include "SAXSEventAction.hh"
0039 #include "SAXSSteppingAction.hh"
0040
0041 #include "G4AnalysisManager.hh"
0042 #include "G4Event.hh"
0043 #include "G4EventManager.hh"
0044 #include "G4HCofThisEvent.hh"
0045 #include "G4OpticalPhoton.hh"
0046 #include "G4SDManager.hh"
0047 #include "G4Step.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4Track.hh"
0050 #include "G4Trajectory.hh"
0051 #include "G4TrajectoryContainer.hh"
0052 #include "G4UImanager.hh"
0053 #include "G4VHitsCollection.hh"
0054 #include "G4VVisManager.hh"
0055 #include "G4ios.hh"
0056
0057 #include <cmath>
0058
0059
0060
0061 SAXSSteppingAction::SAXSSteppingAction(SAXSEventAction* eventAction)
0062 : G4UserSteppingAction(), fEventAction(eventAction), fPhantom(0), fEventNumber(-1), fNSe(0)
0063 {}
0064
0065
0066
0067 SAXSSteppingAction::~SAXSSteppingAction() {}
0068
0069
0070
0071 void SAXSSteppingAction::UserSteppingAction(const G4Step* step)
0072 {
0073
0074 const SAXSDetectorConstruction* detectorConstruction =
0075 static_cast<const SAXSDetectorConstruction*>(
0076 G4RunManager::GetRunManager()->GetUserDetectorConstruction());
0077
0078
0079 fPhantom = detectorConstruction->GetPhantom();
0080
0081
0082 G4StepPoint* preStepPoint = step->GetPreStepPoint();
0083 G4StepPoint* postStepPoint = step->GetPostStepPoint();
0084
0085
0086 G4LogicalVolume* volume = preStepPoint->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
0087
0088
0089 G4Track* track = step->GetTrack();
0090 G4int ID = track->GetTrackID();
0091 G4String partName = track->GetDefinition()->GetParticleName();
0092
0093
0094 G4double PrimaryWeight = 1.;
0095 if (partName == "gamma" && ID == 1) {
0096 PrimaryWeight = track->GetWeight();
0097 fEventAction->UpdateEventWeight(PrimaryWeight);
0098 }
0099
0100
0101 if (volume != fPhantom || partName != "gamma" || ID != 1) return;
0102
0103
0104 G4int eventNumber = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
0105 if (eventNumber != fEventNumber) {
0106 fEventNumber = eventNumber;
0107 fNSe = 0;
0108 }
0109
0110
0111 G4String Process;
0112 if (postStepPoint->GetProcessDefinedStep() != NULL) {
0113 Process = postStepPoint->GetProcessDefinedStep()->GetProcessName();
0114 }
0115 else {
0116 Process = "UserLimit";
0117 }
0118
0119 G4int ProcIndex = -1;
0120 if (Process == "Transportation" || Process == "CoupledTransportation" || Process == "UserLimit") {
0121 ProcIndex = 0;
0122 }
0123 if (Process == "Rayl" || Process == "biasWrapper(Rayl)") {
0124 ProcIndex = 1;
0125 fNSe++;
0126 fEventAction->AddNRi();
0127 }
0128 if (Process == "compt" || Process == "biasWrapper(compt)") {
0129 ProcIndex = 2;
0130 fNSe++;
0131 fEventAction->AddNCi();
0132 }
0133 if (Process == "phot" || Process == "biasWrapper(phot)") ProcIndex = 3;
0134 if (Process == "conv" || Process == "biasWrapper(conv)") ProcIndex = 4;
0135 if (Process == "photonNuclear" || Process == "biasWrapper(photonNuclear)") {
0136 ProcIndex = 5;
0137 }
0138 if (Process == "PowderDiffraction" || Process == "biasWrapper(PowderDiffraction)") {
0139 ProcIndex = 6;
0140 fNSe++;
0141 fEventAction->AddNDi();
0142 }
0143
0144
0145
0146 G4ThreeVector mom1 = preStepPoint->GetMomentumDirection();
0147 G4ThreeVector mom2 = postStepPoint->GetMomentumDirection();
0148 G4double theta = mom1.angle(mom2);
0149
0150
0151 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0152 if (theta > 1e-6) {
0153 analysisManager->FillNtupleIColumn(1, 0, ProcIndex);
0154 analysisManager->FillNtupleDColumn(1, 1, preStepPoint->GetKineticEnergy() / CLHEP::keV);
0155 analysisManager->FillNtupleDColumn(1, 2, theta / CLHEP::deg);
0156 analysisManager->FillNtupleDColumn(1, 3, track->GetWeight());
0157 analysisManager->AddNtupleRow(1);
0158 }
0159 }
0160
0161