00001 #include "SimG4Core/KillSecondaries/interface/KillSecondariesTrackAction.h" 00002 00003 #include "SimG4Core/Notification/interface/BeginOfTrack.h" 00004 #include "SimG4Core/Notification/interface/TrackInformation.h" 00005 00006 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00007 00008 #include "G4Track.hh" 00009 00010 KillSecondariesTrackAction::KillSecondariesTrackAction(edm::ParameterSet const & p) { 00011 00012 killHeavy = p.getParameter<bool>("KillHeavy"); 00013 kmaxIon = p.getParameter<double>("IonThreshold")*MeV; 00014 kmaxProton = p.getParameter<double>("ProtonThreshold")*MeV; 00015 kmaxNeutron = p.getParameter<double>("NeutronThreshold")*MeV; 00016 00017 edm::LogInfo("KillSecondaries") << "KillSecondariesTrackAction:: Killing" 00018 << " Flag " << killHeavy << " protons below " 00019 << kmaxProton << " MeV, neutrons below " 00020 << kmaxNeutron << " MeV and ions below " 00021 << kmaxIon << " MeV\n"; 00022 } 00023 00024 KillSecondariesTrackAction::~KillSecondariesTrackAction() {} 00025 00026 void KillSecondariesTrackAction::update(const BeginOfTrack * trk) { 00027 00028 if (killHeavy) { 00029 G4Track* theTrack = (G4Track*)((*trk)()); 00030 TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation()); 00031 if (trkInfo) { 00032 int pdg = theTrack->GetDefinition()->GetPDGEncoding(); 00033 if (!(trkInfo->isPrimary())) { // Only secondary particles 00034 double ke = theTrack->GetKineticEnergy()/MeV; 00035 if ((((pdg/1000000000 == 1 && ((pdg/10000)%100) > 0 && 00036 ((pdg/10)%100) > 0)) && (ke<kmaxIon)) || 00037 ((pdg == 2212) && (ke < kmaxProton)) || 00038 ((pdg == 2112) && (ke < kmaxNeutron))) { 00039 theTrack->SetTrackStatus(fStopAndKill); 00040 edm::LogInfo("KillSecondaries") << "Kill Track " << theTrack->GetTrackID() 00041 << " Type " << theTrack->GetDefinition()->GetParticleName() 00042 << " Kinetic Energy " << ke <<" MeV"; 00043 } 00044 } 00045 } 00046 } 00047 } 00048