00001 #include "BDSPhotonCounter.hh" 00002 #include "G4OpticalPhoton.hh" 00003 #include "G4ParticleDefinition.hh" 00004 00005 BDSPhotonCounter* BDSPhotonCounter::_instance = 0; 00006 00007 BDSPhotonCounter* BDSPhotonCounter::Instance(){ 00008 if(_instance==0) { 00009 _instance = new BDSPhotonCounter(); 00010 } 00011 return _instance; 00012 } 00013 00014 BDSPhotonCounter::BDSPhotonCounter(){ 00015 _nPhotons=0; 00016 _energy=0; 00017 } 00018 00019 BDSPhotonCounter::~BDSPhotonCounter(){ 00020 } 00021 00022 void BDSPhotonCounter::countPhoton(const G4Track* aTrack){ 00023 if(aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) 00024 { // particle is optical photon 00025 if(aTrack->GetParentID()>0) 00026 { // particle is secondary 00027 _nPhotons++; 00028 _energy+=aTrack->GetTotalEnergy(); 00029 } 00030 } 00031 } 00032 00033