From 90ab0b83717021c99ec693faab0c824359460cf4 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Tue, 24 Nov 2020 21:34:41 +0800 Subject: [PATCH] WIP: save charge of particle in particle gun tool. --- Generator/src/GtGunTool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Generator/src/GtGunTool.cpp b/Generator/src/GtGunTool.cpp index 7ff4dab0..6cdd0f28 100644 --- a/Generator/src/GtGunTool.cpp +++ b/Generator/src/GtGunTool.cpp @@ -83,11 +83,13 @@ GtGunTool::mutate(MyHepMC::GenEvent& event) { const std::string& particle_name = m_particles.value()[i]; int pdgcode = 0; double mass = 0; + double charge = 0; TParticlePDG* particle = db_pdg->GetParticle(particle_name.c_str()); if (particle) { pdgcode = particle->PdgCode(); mass = particle->Mass(); // GeV + charge = particle->Charge()/3; // in ROOT, it is in units of |e|/3 } else { // guess it is pdg code pdgcode = atol(particle_name.c_str()); @@ -104,7 +106,7 @@ GtGunTool::mutate(MyHepMC::GenEvent& event) { mcp.setPDG(pdgcode); mcp.setGeneratorStatus(1); mcp.setSimulatorStatus(1); - // mcp.setCharge(); + mcp.setCharge(static_cast<float>(charge)); mcp.setTime(0.0); mcp.setMass(mass); -- GitLab