Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:50

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