File indexing completed on 2026-09-17 08:30:48
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
0034
0035
0036
0037
0038
0039 #include "RMC01SD.hh"
0040
0041 #include "G4HCofThisEvent.hh"
0042 #include "G4LogicalVolume.hh"
0043 #include "G4LogicalVolumeStore.hh"
0044 #include "G4ParticleDefinition.hh"
0045 #include "G4PhysicalVolumeStore.hh"
0046 #include "G4SDManager.hh"
0047 #include "G4Step.hh"
0048 #include "G4Track.hh"
0049 #include "G4VPhysicalVolume.hh"
0050 #include "G4VProcess.hh"
0051 #include "G4ios.hh"
0052
0053
0054 #include "G4Electron.hh"
0055 #include "G4Gamma.hh"
0056 #include "G4Proton.hh"
0057 #include "G4RunManager.hh"
0058 #include "G4THitsCollection.hh"
0059
0060 class G4Step;
0061
0062
0063
0064 RMC01SD::RMC01SD(G4String name)
0065 : G4VSensitiveDetector(name),
0066 fTotalEventEdep(0.),
0067 fEventEdepCollection(0),
0068 fProtonCurrentCollection(0),
0069 fGammaCurrentCollection(0),
0070 fElectronCurrentCollection(0)
0071 {
0072 collectionName.insert("edep");
0073 collectionName.insert("current_electron");
0074 collectionName.insert("current_proton");
0075 collectionName.insert("current_gamma");
0076 }
0077
0078
0079
0080 RMC01SD::~RMC01SD()
0081 {
0082 ;
0083 }
0084
0085
0086
0087 void RMC01SD::Initialize(G4HCofThisEvent* HCE)
0088 {
0089 fTotalEventEdep = 0.;
0090 static G4int HCID = -1;
0091
0092 fEventEdepCollection =
0093 new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[0]);
0094 HCID = GetCollectionID(0);
0095 HCE->AddHitsCollection(HCID, fEventEdepCollection);
0096
0097 fElectronCurrentCollection =
0098 new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[1]);
0099 HCID = GetCollectionID(1);
0100 HCE->AddHitsCollection(HCID, fElectronCurrentCollection);
0101
0102 fProtonCurrentCollection =
0103 new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[2]);
0104 HCID = GetCollectionID(2);
0105 HCE->AddHitsCollection(HCID, fProtonCurrentCollection);
0106
0107 fGammaCurrentCollection =
0108 new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[3]);
0109 HCID = GetCollectionID(3);
0110 HCE->AddHitsCollection(HCID, fGammaCurrentCollection);
0111 }
0112
0113
0114
0115 G4bool RMC01SD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0116 {
0117 G4double weight = aStep->GetTrack()->GetWeight();
0118 G4double edep = aStep->GetTotalEnergyDeposit();
0119 if (edep > 0) fEventEdepCollection->insert(new RMC01DoubleWithWeightHit(edep, weight));
0120
0121 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
0122
0123 if (preStepPoint->GetStepStatus() == fGeomBoundary) {
0124
0125 weight = preStepPoint->GetWeight();
0126 G4double eKin = preStepPoint->GetKineticEnergy();
0127 G4ParticleDefinition* thePartDef = aStep->GetTrack()->GetDefinition();
0128 if (thePartDef == G4Electron::Electron())
0129 fElectronCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0130 else if (thePartDef == G4Gamma::Gamma())
0131 fGammaCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0132 else if (thePartDef == G4Proton::Proton())
0133 fProtonCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0134 }
0135 return true;
0136 }
0137
0138
0139
0140 void RMC01SD::EndOfEvent(G4HCofThisEvent*)
0141 {
0142 fEventEdepCollection->insert(new RMC01DoubleWithWeightHit(fTotalEventEdep, 1.));
0143 }
0144
0145
0146
0147 void RMC01SD::Clear()
0148 {
0149 ;
0150 }
0151
0152
0153
0154 void RMC01SD::DrawAll()
0155 {
0156 ;
0157 }
0158
0159
0160
0161 void RMC01SD::PrintAll()
0162 {
0163 ;
0164 }
0165
0166