00001 #include "SensitiveDetector.hh"
00002 #include "DetectorConstruction.hh"
00003 #include "RunAction.hh"
00004
00005 #include "G4Step.hh"
00006 #include "Randomize.hh"
00007 #include "G4RunManager.hh"
00008
00009 SensitiveDetector::SensitiveDetector(G4String SDname)
00010 : G4VSensitiveDetector(SDname)
00011 {
00012
00013 m_detector = (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
00014 m_runAction = (RunAction*)(G4RunManager::GetRunManager()->GetUserRunAction());
00015 }
00016
00017 SensitiveDetector::~SensitiveDetector()
00018 {}
00019
00020 G4bool SensitiveDetector::ProcessHits(G4Step *step, G4TouchableHistory *)
00021 {
00022
00023
00024 G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
00025
00026 G4double edep = step->GetTotalEnergyDeposit();
00027
00028 if (edep <= 0.) return false;
00029
00030
00031 G4ThreeVector point1 = step->GetPreStepPoint()->GetPosition();
00032 G4ThreeVector point2 = step->GetPostStepPoint()->GetPosition();
00033
00034
00035 G4ThreeVector pointE = point1 + G4UniformRand()*(point2 - point1);
00036
00037 G4ThreeVector localPointE
00038 = touchable->GetHistory()->GetTopTransform().TransformPoint(pointE);
00039
00040
00041 G4double zLocal = 0.5*(m_detector->GetAstronautHeight()) - localPointE.z();
00042
00043
00044 m_runAction->SumDepthDoseSD(zLocal,edep);
00045
00046 return true;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 // sum edep in EventAction
00065 m_eventAction->AddEdep(edep);
00066
00067 //---------for depth dose distribution---------------------------------------
00068
00069 // get step points in world coordinate system
00070 G4ThreeVector point1 = step->GetPreStepPoint()->GetPosition();
00071 G4ThreeVector point2 = step->GetPostStepPoint()->GetPosition();
00072
00073 // randomize point of energy deposition
00074 G4ThreeVector pointE = point1 + G4UniformRand()*(point2 - point1);
00075 // transform it in local coordinate system
00076 G4ThreeVector localPointE
00077 = touchable->GetHistory()->GetTopTransform().TransformPoint(pointE);
00078
00079 // extract z and offset
00080 G4double zLocal = 0.5*(m_detector->GetAstronautHeight()) - localPointE.z();
00081
00082 // sum edep in RunAction
00083 m_runAction->SumDepthDose(zLocal,edep);
00084
00085 //----------end of depth dose distribution-------------------------------------
00086 }
00087
00088 <<--- */
00089
00090 }