CMS 3D CMS Logo

G4TrackToParticleID.cc
Go to the documentation of this file.
2 
3 #include "G4Track.hh"
4 
6 
7 int G4TrackToParticleID::particleID(const G4Track * g4trk)
8 {
9  int particleID_ = g4trk->GetDefinition()->GetPDGEncoding();
10  if (0 == particleID_) {
11  edm::LogWarning("SimG4CoreNotification")
12  << "G4TrackToParticleID: unknown code 0 for track Id = " << g4trk->GetTrackID();
13  particleID_ = -99;
14  }
15  return particleID_;
16 }
17 
19 {
20  int pdg = std::abs(pdgCode);
21  return (pdg == 11 || pdg == 22);
22 }
23 
25 {
26  int pdg = std::abs(g4trk->GetDefinition()->GetPDGEncoding());
27  return (pdg == 11 || pdg == 22);
28 }
29 
30 bool G4TrackToParticleID::isMuon(int pdgCode)
31 {
32  return (std::abs(pdgCode) == 13);
33 }
34 
35 bool G4TrackToParticleID::isMuon(const G4Track * g4trk)
36 {
37  return (std::abs(g4trk->GetDefinition()->GetPDGEncoding()) == 13);
38 }
39 
41 {
42  // pi+-, p, pbar, n, nbar, KL, K+-, light ions and anti-ions
43  int pdg = std::abs(pdgCode);
44  return (pdg == 211 || pdg == 2212 || pdg == 2112 || pdg == 130 || pdg == 321
45  || pdg == 1000010020 || pdg == 1000010030
46  || pdg == 1000020030 || pdg == 1000020040);
47 }
48 
49 bool G4TrackToParticleID::isStableHadronIon(const G4Track * g4trk)
50 {
51  // pi+-, p, pbar, n, nbar, KL, K+-, light ion and anti-ion, generic ion
52  int pdg = std::abs(g4trk->GetDefinition()->GetPDGEncoding());
53  return (pdg == 211 || pdg == 2212 || pdg == 2112 || pdg == 130 || pdg == 321
54  || pdg == 1000010020 || pdg == 1000010030
55  || pdg == 1000020030 || pdg == 1000020040
56  || g4trk->GetDefinition()->IsGeneralIon());
57 }
58 
static bool isMuon(int pdgCode)
static bool isStableHadron(int pdgCode)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static int particleID(const G4Track *)
static bool isStableHadronIon(const G4Track *)
static bool isGammaElectronPositron(int pdgCode)