From de18abb448cfc23104452aef3f9cca462aa63fba Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Sun, 8 Sep 2019 15:21:37 +0800
Subject: [PATCH] WIP: add units: GeV, mm, ns

---
 Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
index 7ff3004a..3a79e9d9 100644
--- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
+++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
@@ -25,8 +25,11 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) {
 
         // vertex
         const plcio::DoubleThree& vertex = p.getVertex();
-        double t = p.getMass();
-        G4PrimaryVertex* g4vtx = new G4PrimaryVertex(vertex.x, vertex.y, vertex.z, t);
+        double t = p.getTime()*CLHEP::ns;
+        G4PrimaryVertex* g4vtx = new G4PrimaryVertex(vertex.x*CLHEP::mm,
+                                                     vertex.y*CLHEP::mm,
+                                                     vertex.z*CLHEP::mm,
+                                                     t);
         // pdg/particle
         int pdgcode = p.getPDG();
         G4ParticleTable* particletbl = G4ParticleTable::GetParticleTable();
@@ -35,9 +38,9 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) {
         // momentum
         const plcio::FloatThree& momentum = p.getMomentum();
         G4PrimaryParticle* g4prim = new G4PrimaryParticle(particle_def,
-                                                          momentum.x,
-                                                          momentum.y,
-                                                          momentum.z);
+                                                          momentum.x*CLHEP::GeV,
+                                                          momentum.y*CLHEP::GeV,
+                                                          momentum.z*CLHEP::GeV);
 
         g4vtx->SetPrimary(g4prim);
 
-- 
GitLab