File indexing completed on 2026-04-27 07:33:31
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 "EventAction.hh"
0033 #include "HistoManager.hh"
0034 #include "Run.hh"
0035
0036 #include "G4RunManager.hh"
0037
0038
0039
0040 SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
0041 : fDetector(det), fEventAct(evt)
0042 {}
0043
0044
0045
0046 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0047 {
0048
0049
0050 const G4StepPoint* prePoint = aStep->GetPreStepPoint();
0051 const G4StepPoint* endPoint = aStep->GetPostStepPoint();
0052 const G4VProcess* process = endPoint->GetProcessDefinedStep();
0053 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0054 run->CountProcesses(process);
0055
0056
0057
0058 G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
0059
0060 const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
0061 if (mat == fDetector->GetWorldMaterial()) return;
0062
0063 const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
0064
0065
0066
0067 G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
0068 G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
0069
0070
0071 G4double edep = aStep->GetTotalEnergyDeposit();
0072
0073
0074
0075 G4double stepl = 0.;
0076 if (particle->GetPDGCharge() != 0.) stepl = aStep->GetStepLength();
0077
0078
0079 fEventAct->SumEnergy(absorNum, edep, stepl);
0080
0081
0082 if (edep > 0.) {
0083 G4AnalysisManager::Instance()->FillH1(kMaxAbsor + absorNum, G4double(layerNum + 1), edep);
0084 }
0085
0086
0087
0088
0089 G4int Idnow = (fDetector->GetNbOfAbsor()) * layerNum + absorNum;
0090 G4int plane;
0091
0092
0093 if (endPoint->GetStepStatus() == fGeomBoundary) {
0094 G4ThreeVector position = endPoint->GetPosition();
0095 G4ThreeVector direction = endPoint->GetMomentumDirection();
0096 G4double Eflow = endPoint->GetKineticEnergy();
0097 if (direction.x() >= 0.)
0098 run->SumEnergyFlow(plane = Idnow + 1, Eflow);
0099 else
0100 run->SumEnergyFlow(plane = Idnow, -Eflow);
0101 }
0102
0103
0104
0105
0106
0107
0108 }
0109
0110
0111
0112 G4double SteppingAction::BirksAttenuation(const G4Step* aStep)
0113 {
0114
0115
0116
0117 const G4Material* material = aStep->GetTrack()->GetMaterial();
0118 G4double birk1 = material->GetIonisation()->GetBirksConstant();
0119 G4double destep = aStep->GetTotalEnergyDeposit();
0120 G4double stepl = aStep->GetStepLength();
0121 G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
0122
0123 G4double response = destep;
0124 if (birk1 * destep * stepl * charge != 0.) {
0125 response = destep / (1. + birk1 * destep / stepl);
0126 }
0127 return response;
0128 }
0129
0130