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 #include "G4PSCellCharge.hh"
00030 #include "G4Track.hh"
00031
00032
00034
00035
00036
00037
00038
00039
00040
00042
00043 G4PSCellCharge::G4PSCellCharge(G4String name, G4int depth)
00044 :G4VPrimitiveScorer(name,depth),HCID(-1)
00045 {
00046 SetUnit("e+");
00047 }
00048
00049 G4PSCellCharge::G4PSCellCharge(G4String name, const G4String& unit,
00050 G4int depth)
00051 :G4VPrimitiveScorer(name,depth),HCID(-1)
00052 {
00053 SetUnit(unit);
00054 }
00055
00056 G4PSCellCharge::~G4PSCellCharge()
00057 {;}
00058
00059 G4bool G4PSCellCharge::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00060 {
00061
00062
00063 if( aStep->GetPreStepPoint()->GetStepStatus() == fGeomBoundary
00064 || ( aStep->GetTrack()->GetParentID() == 0 &&
00065 aStep->GetTrack()->GetCurrentStepNumber() == 1 ) ){
00066 G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
00067 CellCharge *= aStep->GetPreStepPoint()->GetWeight();
00068 G4int index = GetIndex(aStep);
00069 EvtMap->add(index,CellCharge);
00070 }
00071
00072
00073 if( aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary){
00074 G4double CellCharge = aStep->GetPreStepPoint()->GetCharge();
00075 CellCharge *= aStep->GetPreStepPoint()->GetWeight();
00076 G4int index = GetIndex(aStep);
00077 CellCharge *= -1.0;
00078 EvtMap->add(index,CellCharge);
00079 }
00080
00081 return TRUE;
00082 }
00083
00084 void G4PSCellCharge::Initialize(G4HCofThisEvent* HCE)
00085 {
00086 EvtMap = new G4THitsMap<G4double>(detector->GetName(),
00087 GetName());
00088 if ( HCID < 0 ) HCID = GetCollectionID(0);
00089 HCE->AddHitsCollection(HCID,EvtMap);
00090 }
00091
00092 void G4PSCellCharge::EndOfEvent(G4HCofThisEvent*)
00093 {;}
00094
00095 void G4PSCellCharge::clear(){
00096 EvtMap->clear();
00097 }
00098
00099 void G4PSCellCharge::DrawAll()
00100 {;}
00101
00102 void G4PSCellCharge::PrintAll()
00103 {
00104 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl;
00105 G4cout << " PrimitiveScorer " << GetName() <<G4endl;
00106 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00107 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00108 for(; itr != EvtMap->GetMap()->end(); itr++) {
00109 G4cout << " copy no.: " << itr->first
00110 << " cell charge : " << *(itr->second)/GetUnitValue()
00111 << " [" << GetUnit() << "]"
00112 << G4endl;
00113 }
00114 }
00115
00116 void G4PSCellCharge::SetUnit(const G4String& unit)
00117 {
00118 CheckAndSetUnit(unit,"Electric charge");
00119 }
00120
00121