Skip to content
Snippets Groups Projects
Commit 3edd5e5d authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: update.

parent fe188f7f
No related branches found
No related tags found
No related merge requests found
#include "G4PrimaryCnvTool.h" #include "G4PrimaryCnvTool.h"
#include "G4Event.hh" #include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4IonTable.hh"
#include "G4ParticleDefinition.hh"
DECLARE_COMPONENT(G4PrimaryCnvTool) DECLARE_COMPONENT(G4PrimaryCnvTool)
...@@ -14,6 +17,31 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) { ...@@ -14,6 +17,31 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) {
info() << " " << it->getObjectID().index; info() << " " << it->getObjectID().index;
} }
info() << " ]; " << endmsg; info() << " ]; " << endmsg;
// only the GeneratorStatus == 1 is used.
if (p.getGeneratorStatus() != 1) {
continue;
}
// vertex
const plcio::DoubleThree& vertex = p.getVertex();
double t = p.getMass();
G4PrimaryVertex* g4vtx = new G4PrimaryVertex(vertex.x, vertex.y, vertex.z, t);
// pdg/particle
int pdgcode = p.getPDG();
G4ParticleTable* particletbl = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle_def = particletbl->FindParticle(pdgcode);
// momentum
const plcio::FloatThree& momentum = p.getMomentum();
G4PrimaryParticle* g4prim = new G4PrimaryParticle(particle_def,
momentum.x,
momentum.y,
momentum.z);
g4vtx->SetPrimary(g4prim);
anEvent->AddPrimaryVertex(g4vtx);
} }
return true; return true;
......
...@@ -23,26 +23,25 @@ PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { ...@@ -23,26 +23,25 @@ PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) {
tool->mutate(anEvent); tool->mutate(anEvent);
} }
// // Following is an example:
// Following is an example: // double x = 0.0;
double x = 0.0; // double y = 0.0;
double y = 0.0; // double z = 0.0;
double z = 0.0; // double t = 0.0;
double t = 0.0; // G4PrimaryVertex* g4vtx = new G4PrimaryVertex(x, y, z, t);
G4PrimaryVertex* g4vtx = new G4PrimaryVertex(x, y, z, t);
// G4int pdgcode = 22;
G4int pdgcode = 22; // // check the pdgid
// check the pdgid // G4ParticleTable* particletbl = G4ParticleTable::GetParticleTable();
G4ParticleTable* particletbl = G4ParticleTable::GetParticleTable(); // G4ParticleDefinition* particle_def = particletbl->FindParticle(pdgcode);
G4ParticleDefinition* particle_def = particletbl->FindParticle(pdgcode);
// double px = 0.0;
double px = 0.0; // double py = 0.0;
double py = 0.0; // double pz = 0.0;
double pz = 0.0; // G4PrimaryParticle* g4prim=new G4PrimaryParticle(particle_def, px, py, pz);
G4PrimaryParticle* g4prim=new G4PrimaryParticle(particle_def, px, py, pz); // g4vtx->SetPrimary(g4prim);
g4vtx->SetPrimary(g4prim);
// anEvent->AddPrimaryVertex(g4vtx);
anEvent->AddPrimaryVertex(g4vtx);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment