CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
KillSecondariesTrackAction.cc
Go to the documentation of this file.
2 
5 
7 
8 #include "G4Track.hh"
9 
10 using namespace CLHEP;
11 
13 
14  killHeavy = p.getParameter<bool>("KillHeavy");
15  kmaxIon = p.getParameter<double>("IonThreshold")*MeV;
16  kmaxProton = p.getParameter<double>("ProtonThreshold")*MeV;
17  kmaxNeutron = p.getParameter<double>("NeutronThreshold")*MeV;
18 
19  edm::LogInfo("KillSecondaries") << "KillSecondariesTrackAction:: Killing"
20  << " Flag " << killHeavy << " protons below "
21  << kmaxProton << " MeV, neutrons below "
22  << kmaxNeutron << " MeV and ions below "
23  << kmaxIon << " MeV\n";
24 }
25 
27 
29 
30  if (killHeavy) {
31  G4Track* theTrack = (G4Track*)((*trk)());
32  TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
33  if (trkInfo) {
34  int pdg = theTrack->GetDefinition()->GetPDGEncoding();
35  if (!(trkInfo->isPrimary())) { // Only secondary particles
36  double ke = theTrack->GetKineticEnergy()/MeV;
37  if ((((pdg/1000000000 == 1 && ((pdg/10000)%100) > 0 &&
38  ((pdg/10)%100) > 0)) && (ke<kmaxIon)) ||
39  ((pdg == 2212) && (ke < kmaxProton)) ||
40  ((pdg == 2112) && (ke < kmaxNeutron))) {
41  theTrack->SetTrackStatus(fStopAndKill);
42  edm::LogInfo("KillSecondaries") << "Kill Track " << theTrack->GetTrackID()
43  << " Type " << theTrack->GetDefinition()->GetParticleName()
44  << " Kinetic Energy " << ke <<" MeV";
45  }
46  }
47  }
48  }
49 }
50 
T getParameter(std::string const &) const
KillSecondariesTrackAction(edm::ParameterSet const &p)
void update(const BeginOfTrack *trk)
This routine will be called when the appropriate signal arrives.
bool isPrimary() const