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