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