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 G4cout << std::setw( 5) << step->GetTrack()->GetCurrentStepNumber()
00024 << " ->> Sensitive detector `" << GetName() << "' ProcessHits(...) method called." << G4endl;
00025
00026
00027
00028
00029
00030
00031
00032 G4double edep = step->GetTotalEnergyDeposit();
00033
00034 if (edep <= 0.) return false;
00035
00036
00037
00038
00039 return true;
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 // sum edep in EventAction
00063 m_eventAction->AddEdep(edep);
00064
00065 //---------for depth dose distribution---------------------------------------
00066
00067 // get step points in world coordinate system
00068 G4ThreeVector point1 = step->GetPreStepPoint()->GetPosition();
00069 G4ThreeVector point2 = step->GetPostStepPoint()->GetPosition();
00070
00071 // randomize point of energy deposition
00072 G4ThreeVector pointE = point1 + G4UniformRand()*(point2 - point1);
00073 // transform it in local coordinate system
00074 G4ThreeVector localPointE
00075 = touchable->GetHistory()->GetTopTransform().TransformPoint(pointE);
00076
00077 // extract z and offset
00078 G4double zLocal = 0.5*(m_detector->GetAstronautHeight()) - localPointE.z();
00079
00080 // sum edep in RunAction
00081 m_runAction->SumDepthDose(zLocal,edep);
00082
00083 //----------end of depth dose distribution-------------------------------------
00084 }
00085
00086 <<--- */
00087
00088 }