00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "G4PSDoseDeposit.hh"
00032 #include "G4VSolid.hh"
00033 #include "G4VPhysicalVolume.hh"
00034 #include "G4VPVParameterisation.hh"
00035 #include "G4UnitsTable.hh"
00036
00038
00039
00040
00041
00042
00043
00044
00046
00047 G4PSDoseDeposit::G4PSDoseDeposit(G4String name, G4int depth)
00048 :G4VPrimitiveScorer(name,depth),HCID(-1)
00049 {
00050 SetUnit("Gy");
00051 }
00052
00053 G4PSDoseDeposit::G4PSDoseDeposit(G4String name, const G4String& unit,
00054 G4int depth)
00055 :G4VPrimitiveScorer(name,depth),HCID(-1)
00056 {
00057 SetUnit(unit);
00058 }
00059
00060 G4PSDoseDeposit::~G4PSDoseDeposit()
00061 {;}
00062
00063 G4bool G4PSDoseDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00064 {
00065 G4double edep = aStep->GetTotalEnergyDeposit();
00066 if ( edep == 0. ) return FALSE;
00067
00068 G4int idx = ((G4TouchableHistory*)
00069 (aStep->GetPreStepPoint()->GetTouchable()))
00070 ->GetReplicaNumber(indexDepth);
00071 G4double cubicVolume = ComputeVolume(aStep, idx);
00072
00073
00074 G4double density = aStep->GetTrack()->GetStep()->GetPreStepPoint()->GetMaterial()->GetDensity();
00075 G4double dose = edep / ( density * cubicVolume );
00076 dose *= aStep->GetPreStepPoint()->GetWeight();
00077 G4int index = GetIndex(aStep);
00078 EvtMap->add(index,dose);
00079 return TRUE;
00080 }
00081
00082 void G4PSDoseDeposit::Initialize(G4HCofThisEvent* HCE)
00083 {
00084 EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
00085 GetName());
00086 if(HCID < 0) {HCID = GetCollectionID(0);}
00087 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00088 }
00089
00090 void G4PSDoseDeposit::EndOfEvent(G4HCofThisEvent*)
00091 {;}
00092
00093 void G4PSDoseDeposit::clear()
00094 {
00095 EvtMap->clear();
00096 }
00097
00098 void G4PSDoseDeposit::DrawAll()
00099 {;}
00100
00101 void G4PSDoseDeposit::PrintAll()
00102 {
00103 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
00104 G4cout << " PrimitiveScorer " << GetName() << G4endl;
00105 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00106 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00107 for(; itr != EvtMap->GetMap()->end(); itr++) {
00108 G4cout << " copy no.: " << itr->first
00109 << " dose deposit: "
00110 << *(itr->second)/GetUnitValue()
00111 << " ["<<GetUnit() <<"]"
00112 << G4endl;
00113 }
00114 }
00115
00116 void G4PSDoseDeposit::SetUnit(const G4String& unit)
00117 {
00118 CheckAndSetUnit(unit,"Dose");
00119 }
00120
00121 G4double G4PSDoseDeposit::ComputeVolume(G4Step* aStep, G4int idx){
00122
00123 G4VPhysicalVolume* physVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
00124 G4VPVParameterisation* physParam = physVol->GetParameterisation();
00125 G4VSolid* solid = 0;
00126 if(physParam)
00127 {
00128 if(idx<0)
00129 {
00130 G4ExceptionDescription ED;
00131 ED << "Incorrect replica number --- GetReplicaNumber : " << idx << G4endl;
00132 G4Exception("G4PSDoseDeposit::ComputeVolume","DetPS0004",JustWarning,ED);
00133 }
00134 solid = physParam->ComputeSolid(idx, physVol);
00135 solid->ComputeDimensions(physParam,idx,physVol);
00136 }
00137 else
00138 {
00139 solid = physVol->GetLogicalVolume()->GetSolid();
00140 }
00141
00142 return solid->GetCubicVolume();
00143 }
00144
00145
00146