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