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 "G4PSNofSecondary.hh"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 G4PSNofSecondary::G4PSNofSecondary(G4String name, G4int depth)
00041 :G4VPrimitiveScorer(name,depth),HCID(-1),particleDef(0),
00042 weighted(true)
00043 {;}
00044
00045 G4PSNofSecondary::~G4PSNofSecondary()
00046 {;}
00047
00048 G4bool G4PSNofSecondary::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00049 {
00050
00051 if ( aStep->GetTrack()->GetCurrentStepNumber() != 1) return FALSE;
00052
00053 if ( aStep->GetTrack()->GetParentID() == 0 ) return FALSE;
00054
00055 if ( particleDef && particleDef != aStep->GetTrack()->GetDefinition() )
00056 return FALSE;
00057
00058
00059 G4int index = GetIndex(aStep);
00060 G4double weight = 1.0;
00061 if ( weighted ) weight *= aStep->GetPreStepPoint()->GetWeight();
00062 EvtMap->add(index,weight);
00063 return TRUE;
00064 }
00065
00066 void G4PSNofSecondary::SetParticle(const G4String& particleName){
00067 G4ParticleDefinition* pd =
00068 G4ParticleTable::GetParticleTable()->FindParticle(particleName);
00069 if(!pd) {
00070 G4String msg = "Particle <";
00071 msg += particleName;
00072 msg += "> not found.";
00073 G4Exception("G4PSNofSecondary::SetParticle",
00074 "DetPS0101",FatalException,msg);
00075 }
00076 particleDef = pd;
00077 }
00078
00079 void G4PSNofSecondary::Initialize(G4HCofThisEvent* HCE)
00080 {
00081 EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName());
00082 if(HCID < 0) {HCID = GetCollectionID(0);}
00083 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap);
00084 }
00085
00086 void G4PSNofSecondary::EndOfEvent(G4HCofThisEvent*)
00087 {;}
00088
00089 void G4PSNofSecondary::clear(){
00090 EvtMap->clear();
00091 }
00092
00093 void G4PSNofSecondary::DrawAll()
00094 {;}
00095
00096 void G4PSNofSecondary::PrintAll()
00097 {
00098 G4cout << " PrimitiveScorer " << GetName() << G4endl;
00099 G4cout << " Number of entries " << EvtMap->entries() << G4endl;
00100 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin();
00101 for(; itr != EvtMap->GetMap()->end(); itr++) {
00102 G4cout << " copy no.: " << itr->first
00103 << " num of secondaries: " << *(itr->second)/GetUnitValue()
00104 << G4endl;
00105 }
00106 }
00107
00108 void G4PSNofSecondary::SetUnit(const G4String& unit)
00109 {
00110 if (unit == "" ){
00111 unitName = unit;
00112 unitValue = 1.0;
00113 }else{
00114 G4String msg = "Invalid unit ["+unit+"] (Current unit is [" +GetUnit()+"] ) for " + GetName();
00115 G4Exception("G4PSNofSecondary::SetUnit","DetPS0010",JustWarning,msg);
00116 }
00117 }
00118