Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:26

0001 #include "SimG4Core/Notification/interface/G4TrackToParticleID.h"
0002 
0003 #include "G4Track.hh"
0004 #include "G4PrimaryParticle.hh"
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 int G4TrackToParticleID::particleID(const G4Track* g4trk) {
0009   int pdg = g4trk->GetDefinition()->GetPDGEncoding();
0010   if (0 == pdg) {
0011     edm::LogWarning("SimG4CoreNotification")
0012         << "G4TrackToParticleID: unknown code 0 for trackId=" << g4trk->GetTrackID();
0013     pdg = -99;
0014   }
0015   return pdg;
0016 }
0017 
0018 int G4TrackToParticleID::particleID(const G4PrimaryParticle* ptr, const int id) {
0019   int pdg = ptr->GetPDGcode();
0020   if (0 == pdg) {
0021     edm::LogWarning("SimG4CoreNotification") << "G4TrackToParticleID: unknown code 0 for trackId=" << id;
0022     pdg = -99;
0023   }
0024   return pdg;
0025 }
0026 
0027 bool G4TrackToParticleID::isGammaElectronPositron(int pdgCode) {
0028   int pdg = std::abs(pdgCode);
0029   return (pdg == 11 || pdg == 22);
0030 }
0031 
0032 bool G4TrackToParticleID::isGammaElectronPositron(const G4Track* g4trk) {
0033   int pdg = std::abs(g4trk->GetDefinition()->GetPDGEncoding());
0034   return (pdg == 11 || pdg == 22);
0035 }
0036 
0037 bool G4TrackToParticleID::isMuon(int pdgCode) { return (std::abs(pdgCode) == 13); }
0038 
0039 bool G4TrackToParticleID::isMuon(const G4Track* g4trk) {
0040   return (std::abs(g4trk->GetDefinition()->GetPDGEncoding()) == 13);
0041 }
0042 
0043 bool G4TrackToParticleID::isStableHadron(int pdgCode) {
0044   // pi+-, p, pbar, n, nbar, KL, K+-, light ions and anti-ions
0045   int pdg = std::abs(pdgCode);
0046   return (pdg == 211 || pdg == 2212 || pdg == 2112 || pdg == 130 || pdg == 321 || pdg == 1000010020 ||
0047           pdg == 1000010030 || pdg == 1000020030 || pdg == 1000020040);
0048 }
0049 
0050 bool G4TrackToParticleID::isStableHadronIon(const G4Track* g4trk) {
0051   // pi+-, p, pbar, n, nbar, KL, K+-, light ion and anti-ion, generic ion
0052   int pdg = std::abs(g4trk->GetDefinition()->GetPDGEncoding());
0053   return (pdg == 211 || pdg == 2212 || pdg == 2112 || pdg == 130 || pdg == 321 || pdg == 1000010020 ||
0054           pdg == 1000010030 || pdg == 1000020030 || pdg == 1000020040 || g4trk->GetDefinition()->IsGeneralIon());
0055 }