Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file biasing/ReverseMC01/src/RMC01SD.cc 26 /// \file biasing/ReverseMC01/src/RMC01SD.cc 27 /// \brief Implementation of the RMC01SD class 27 /// \brief Implementation of the RMC01SD class 28 // 28 // 29 // 29 // 30 ////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////// 31 // Class Name: RMC01SD 31 // Class Name: RMC01SD 32 // Author: L. Desorgher 32 // Author: L. Desorgher 33 // Organisation: SpaceIT GmbH 33 // Organisation: SpaceIT GmbH 34 // Contract: ESA contract 21435/ 34 // Contract: ESA contract 21435/08/NL/AT 35 // Customer: ESA/ESTEC 35 // Customer: ESA/ESTEC 36 ////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////// 37 37 38 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 39 //....oooOO0OOooo........oooOO0OOooo........oo 39 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 40 40 41 #include "RMC01SD.hh" 41 #include "RMC01SD.hh" 42 << 42 #include "G4Step.hh" 43 #include "G4HCofThisEvent.hh" 43 #include "G4HCofThisEvent.hh" 44 #include "G4LogicalVolume.hh" << 44 #include "G4Track.hh" 45 #include "G4LogicalVolumeStore.hh" << 45 #include "G4SDManager.hh" >> 46 #include "G4ios.hh" 46 #include "G4ParticleDefinition.hh" 47 #include "G4ParticleDefinition.hh" >> 48 #include "G4VProcess.hh" >> 49 #include "G4LogicalVolumeStore.hh" >> 50 #include "G4LogicalVolume.hh" 47 #include "G4PhysicalVolumeStore.hh" 51 #include "G4PhysicalVolumeStore.hh" 48 #include "G4SDManager.hh" << 49 #include "G4Step.hh" << 50 #include "G4Track.hh" << 51 #include "G4VPhysicalVolume.hh" 52 #include "G4VPhysicalVolume.hh" 52 #include "G4VProcess.hh" << 53 #include "G4ios.hh" << 54 53 55 // #include "G4AdjointAnalysisManager.hh" << 54 //#include "G4AdjointAnalysisManager.hh" >> 55 #include "G4THitsCollection.hh" >> 56 #include "G4RunManager.hh" 56 #include "G4Electron.hh" 57 #include "G4Electron.hh" 57 #include "G4Gamma.hh" 58 #include "G4Gamma.hh" 58 #include "G4Proton.hh" 59 #include "G4Proton.hh" 59 #include "G4RunManager.hh" << 60 #include "G4THitsCollection.hh" << 61 60 62 class G4Step; 61 class G4Step; 63 62 64 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 64 66 RMC01SD::RMC01SD(G4String name) 65 RMC01SD::RMC01SD(G4String name) 67 : G4VSensitiveDetector(name), << 66 :G4VSensitiveDetector(name), 68 fTotalEventEdep(0.), << 67 fTotalEventEdep(0.),fEventEdepCollection(0), 69 fEventEdepCollection(0), << 68 fProtonCurrentCollection(0),fGammaCurrentCollection(0), 70 fProtonCurrentCollection(0), << 69 fElectronCurrentCollection(0) 71 fGammaCurrentCollection(0), << 72 fElectronCurrentCollection(0) << 73 { 70 { 74 collectionName.insert("edep"); 71 collectionName.insert("edep"); 75 collectionName.insert("current_electron"); 72 collectionName.insert("current_electron"); 76 collectionName.insert("current_proton"); 73 collectionName.insert("current_proton"); 77 collectionName.insert("current_gamma"); 74 collectionName.insert("current_gamma"); 78 } 75 } 79 76 80 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 81 78 82 RMC01SD::~RMC01SD() 79 RMC01SD::~RMC01SD() 83 { << 80 {; 84 ; << 85 } 81 } 86 82 87 //....oooOO0OOooo........oooOO0OOooo........oo 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 84 89 void RMC01SD::Initialize(G4HCofThisEvent* HCE) 85 void RMC01SD::Initialize(G4HCofThisEvent* HCE) 90 { 86 { 91 fTotalEventEdep = 0.; << 87 fTotalEventEdep=0.; 92 static G4int HCID = -1; 88 static G4int HCID = -1; 93 << 89 94 fEventEdepCollection = << 90 fEventEdepCollection = new G4THitsCollection<RMC01DoubleWithWeightHit> 95 new G4THitsCollection<RMC01DoubleWithWeigh << 91 (SensitiveDetectorName,collectionName[0]); 96 HCID = GetCollectionID(0); 92 HCID = GetCollectionID(0); 97 HCE->AddHitsCollection(HCID, fEventEdepColle << 93 HCE->AddHitsCollection(HCID,fEventEdepCollection); 98 << 94 99 fElectronCurrentCollection = << 95 fElectronCurrentCollection = new G4THitsCollection<RMC01DoubleWithWeightHit> 100 new G4THitsCollection<RMC01DoubleWithWeigh << 96 (SensitiveDetectorName,collectionName[1]); 101 HCID = GetCollectionID(1); 97 HCID = GetCollectionID(1); 102 HCE->AddHitsCollection(HCID, fElectronCurren << 98 HCE->AddHitsCollection(HCID,fElectronCurrentCollection); 103 << 99 104 fProtonCurrentCollection = << 100 fProtonCurrentCollection = new G4THitsCollection<RMC01DoubleWithWeightHit> 105 new G4THitsCollection<RMC01DoubleWithWeigh << 101 (SensitiveDetectorName,collectionName[2]); 106 HCID = GetCollectionID(2); 102 HCID = GetCollectionID(2); 107 HCE->AddHitsCollection(HCID, fProtonCurrentC << 103 HCE->AddHitsCollection(HCID,fProtonCurrentCollection); 108 << 104 109 fGammaCurrentCollection = << 105 fGammaCurrentCollection = new G4THitsCollection<RMC01DoubleWithWeightHit> 110 new G4THitsCollection<RMC01DoubleWithWeigh << 106 (SensitiveDetectorName,collectionName[3]); 111 HCID = GetCollectionID(3); 107 HCID = GetCollectionID(3); 112 HCE->AddHitsCollection(HCID, fGammaCurrentCo << 108 HCE->AddHitsCollection(HCID,fGammaCurrentCollection); 113 } 109 } 114 110 115 //....oooOO0OOooo........oooOO0OOooo........oo 111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 112 117 G4bool RMC01SD::ProcessHits(G4Step* aStep, G4T << 113 G4bool RMC01SD::ProcessHits(G4Step*aStep,G4TouchableHistory* ) 118 { 114 { 119 G4double weight = aStep->GetTrack()->GetWeig << 115 G4double weight =aStep->GetTrack()->GetWeight(); 120 G4double edep = aStep->GetTotalEnergyDeposit << 116 G4double edep= aStep->GetTotalEnergyDeposit(); 121 if (edep > 0) fEventEdepCollection->insert(n << 117 if (edep >0) fEventEdepCollection->insert( 122 << 118 new RMC01DoubleWithWeightHit(edep,weight)); 123 G4StepPoint* preStepPoint = aStep->GetPreSte << 119 124 << 120 G4StepPoint* preStepPoint =aStep->GetPreStepPoint(); 125 if (preStepPoint->GetStepStatus() == fGeomBo << 121 >> 122 if (preStepPoint->GetStepStatus() == fGeomBoundary ){ 126 // Entering the sensitive volume 123 // Entering the sensitive volume 127 weight = preStepPoint->GetWeight(); << 124 weight=preStepPoint->GetWeight(); 128 G4double eKin = preStepPoint->GetKineticEn 125 G4double eKin = preStepPoint->GetKineticEnergy(); 129 G4ParticleDefinition* thePartDef = aStep-> 126 G4ParticleDefinition* thePartDef = aStep->GetTrack()->GetDefinition(); 130 if (thePartDef == G4Electron::Electron()) << 127 if (thePartDef == G4Electron::Electron()) fElectronCurrentCollection-> 131 fElectronCurrentCollection->insert(new R << 128 insert(new RMC01DoubleWithWeightHit(eKin,weight)); 132 else if (thePartDef == G4Gamma::Gamma()) << 129 else if (thePartDef == G4Gamma::Gamma()) fGammaCurrentCollection-> 133 fGammaCurrentCollection->insert(new RMC0 << 130 insert(new RMC01DoubleWithWeightHit(eKin,weight)); 134 else if (thePartDef == G4Proton::Proton()) << 131 else if (thePartDef == G4Proton::Proton()) fProtonCurrentCollection-> 135 fProtonCurrentCollection->insert(new RMC << 132 insert(new RMC01DoubleWithWeightHit(eKin,weight)); 136 } << 133 } 137 return true; << 134 return true; 138 } << 135 } 139 136 140 //....oooOO0OOooo........oooOO0OOooo........oo 137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 141 138 142 void RMC01SD::EndOfEvent(G4HCofThisEvent*) 139 void RMC01SD::EndOfEvent(G4HCofThisEvent*) 143 { 140 { 144 fEventEdepCollection->insert(new RMC01Double << 141 fEventEdepCollection->insert( >> 142 new RMC01DoubleWithWeightHit(fTotalEventEdep,1.)); 145 } 143 } 146 144 147 //....oooOO0OOooo........oooOO0OOooo........oo 145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 148 146 149 void RMC01SD::Clear() 147 void RMC01SD::Clear() 150 { << 148 {; 151 ; << 152 } 149 } 153 150 154 //....oooOO0OOooo........oooOO0OOooo........oo 151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 155 152 156 void RMC01SD::DrawAll() 153 void RMC01SD::DrawAll() 157 { << 154 {; 158 ; << 155 } 159 } << 160 156 161 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 162 158 163 void RMC01SD::PrintAll() 159 void RMC01SD::PrintAll() 164 { << 160 {; 165 ; << 166 } 161 } 167 162 168 //....oooOO0OOooo........oooOO0OOooo........oo 163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 164 169 165