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 #include "G4PSEnergyDeposit.hh"
00031 #include "G4UnitsTable.hh"
00033
00034
00035
00036
00037
00038
00040
00041 G4PSEnergyDeposit::G4PSEnergyDeposit(G4String name, G4int depth)
00042 :G4VPrimitiveScorer(name,depth),HCID(-1)
00043 {
00044 SetUnit("MeV");
00045 }
00046
00047 G4PSEnergyDeposit::G4PSEnergyDeposit(G4String name, const G4String& unit,
00048 G4int depth)
00049 :G4VPrimitiveScorer(name,depth),HCID(-1)
00050 {
00051 SetUnit(unit);
00052 }
00053
00054 G4PSEnergyDeposit::~G4PSEnergyDeposit()
00055 {;}
00056
00057 G4bool G4PSEnergyDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00058 {
00059 G4double edep = aStep->GetTotalEnergyDeposit();
00060 if ( edep == 0. ) return FALSE;
00061 edep *= aStep->GetPreStepPoint()->GetWeight();
00062 G4int index = GetIndex(aStep);
00063 EvtMap->add(index,edep);
00064 return TRUE;
00065 }
00066
00067 void G4PSEnergyDeposit::Initialize(G4HCofThisEvent* HCE)
00068 {
00069 EvtMap = new G4THitsMap<G4double>(GetMultiFunctionalDetector()->GetName(),
00070 GetName());
00071 if(HCID < 0) {HCID = GetCollectionID(0);}
00072 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00073 }
00074
00075 void G4PSEnergyDeposit::EndOfEvent(G4HCofThisEvent*)
00076 {;}
00077
00078 void G4PSEnergyDeposit::clear()
00079 {
00080 EvtMap->clear();
00081 }
00082
00083 void G4PSEnergyDeposit::DrawAll()
00084 {;}
00085
00086 void G4PSEnergyDeposit::PrintAll()
00087 {
00088 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
00089 G4cout << " PrimitiveScorer " << GetName() << G4endl;
00090 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00091 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00092 for(; itr != EvtMap->GetMap()->end(); itr++) {
00093 G4cout << " copy no.: " << itr->first
00094 << " energy deposit: "
00095 << *(itr->second)/GetUnitValue()
00096 << " [" << GetUnit()<<"]"
00097 << G4endl;
00098 }
00099 }
00100
00101 void G4PSEnergyDeposit::SetUnit(const G4String& unit)
00102 {
00103 CheckAndSetUnit(unit,"Energy");
00104 }