File indexing completed on 2025-02-23 09:20:54
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
0032
0033 #include "SteppingAction.hh"
0034
0035 #include "HistoManager.hh"
0036 #include "Run.hh"
0037
0038 #include "G4EmProcessSubType.hh"
0039 #include "G4ParticleTypes.hh"
0040 #include "G4RunManager.hh"
0041 #include "G4SteppingManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4UnitsTable.hh"
0044 #include "G4VProcess.hh"
0045
0046
0047
0048 SteppingAction::SteppingAction() : G4UserSteppingAction() {}
0049
0050
0051
0052 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0053 {
0054 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0055
0056 const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
0057 if (process == nullptr) return;
0058
0059 G4int eventID = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
0060 G4Track* trk = aStep->GetTrack();
0061
0062 thread_local G4int iCalled = 0;
0063 const G4int nprint = 10;
0064 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0065
0066 if (fSynchrotronRadiation == process->GetProcessSubType()) {
0067 const G4StepPoint* PrePoint = aStep->GetPreStepPoint();
0068 const G4TrackVector* secondary = fpSteppingManager->GetSecondary();
0069 size_t lp = (*secondary).size();
0070 if (lp) {
0071 G4double Egamma = (*secondary)[lp - 1]->GetTotalEnergy();
0072 run->f_n_gam_sync++;
0073 run->f_e_gam_sync += Egamma;
0074 run->f_e_gam_sync2 += Egamma * Egamma;
0075 if (Egamma > run->f_e_gam_sync_max) run->f_e_gam_sync_max = Egamma;
0076 run->f_lam_gam_sync += aStep->GetStepLength();
0077 if (iCalled < nprint) {
0078 G4double Eelec = PrePoint->GetTotalEnergy();
0079 G4ThreeVector Pelec = PrePoint->GetMomentum();
0080 G4ThreeVector PGamma = (*secondary)[lp - 1]->GetMomentum();
0081 G4bool IsGamma = ((*secondary)[lp - 1]->GetDefinition() == G4Gamma::Gamma());
0082 const G4int wid = 8;
0083 if (analysisManager->GetVerboseLevel() > 1 && iCalled < nprint)
0084 G4cout << __FILE__ << " line " << __LINE__ << " " << __FUNCTION__
0085 << " processName=" << process->GetProcessName()
0086 << " Step Length=" << std::setw(wid)
0087 << G4BestUnit(aStep->GetStepLength(), "Length") << " Eelec=" << std::setw(wid)
0088 << G4BestUnit(Eelec, "Energy") << " Pelec=" << G4BestUnit(Pelec, "Energy")
0089 << " IsGamma=" << IsGamma << " Egamma=" << std::setw(8)
0090 << G4BestUnit(Egamma, "Energy") << " PGamma=" << std::setw(8)
0091 << G4BestUnit(PGamma, "Energy") << " #secondaries lp=" << lp << '\n';
0092 }
0093 analysisManager->FillH1(1, Egamma);
0094 analysisManager->FillH1(2, Egamma,
0095 Egamma / keV);
0096 analysisManager->FillH1(3, aStep->GetStepLength());
0097 }
0098 }
0099
0100 thread_local G4ThreeVector IncomingPhotonDirection;
0101 if (fGammaReflection == process->GetProcessSubType()) {
0102 const G4TrackVector* secondary = fpSteppingManager->GetSecondary();
0103 size_t lp = (*secondary).size();
0104 if (lp) {
0105 G4double Egamma = (*secondary)[lp - 1]->GetTotalEnergy();
0106 ++run->f_n_Xray_Refl;
0107 analysisManager->FillH1(1, Egamma, 1. / run->GetNumberOfEventToBeProcessed());
0108 if (analysisManager->GetVerboseLevel() > 1 && run->f_n_Xray_Refl < nprint)
0109 G4cout << __FILE__ << " line " << __LINE__ << " " << __FUNCTION__
0110 << " iCalled=" << std::setw(3) << iCalled << " eventID=" << std::setw(3) << eventID
0111 << " f_n_Xray_Refl=" << run->f_n_Xray_Refl
0112 << " ProcessName=" << process->GetProcessName()
0113 << " direction=" << trk->GetMomentumDirection() << " Egamma=" << Egamma / keV
0114 << " keV" << G4endl;
0115 IncomingPhotonDirection = trk->GetMomentumDirection();
0116 }
0117 }
0118
0119 const G4VProcess* creator = trk->GetCreatorProcess();
0120 G4int CreatorProcessSubType = 0;
0121 if (creator != nullptr) CreatorProcessSubType = creator->GetProcessSubType();
0122 if (CreatorProcessSubType == fGammaReflection) {
0123 if (IncomingPhotonDirection != G4ThreeVector(0, 0, 0)) {
0124 G4double cos_angle =
0125 IncomingPhotonDirection * trk->GetMomentumDirection();
0126 G4double IncidentAngle = std::acos(cos_angle) / 2.;
0127 analysisManager->FillH1(4, IncidentAngle, 1. / run->GetNumberOfEventToBeProcessed());
0128 if (analysisManager->GetVerboseLevel() > 1 && iCalled < nprint)
0129 G4cout << __FILE__ << " line " << __LINE__ << " " << __FUNCTION__
0130 << " iCalled=" << std::setw(3) << iCalled << " eventID=" << std::setw(3) << eventID
0131 << " CreatorProcname=" << creator->GetProcessName()
0132 << " ProcessName=" << process->GetProcessName()
0133 << " IncomingPhotonDirection=" << IncomingPhotonDirection
0134 << " outgoing PhotonDirection=" << trk->GetMomentumDirection()
0135 << " IncidentAngle=" << IncidentAngle
0136 << " NumberOfEventToBeProcessed=" << run->GetNumberOfEventToBeProcessed()
0137 << " RunID=" << run->GetRunID() << G4endl;
0138 }
0139 }
0140
0141 ++iCalled;
0142 }
0143
0144