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