File indexing completed on 2025-08-05 08:18:09
0001 #include "PHG4ParticleGun.h"
0002
0003 #include "PHG4InEvent.h"
0004 #include "PHG4Particlev1.h"
0005
0006 #include <phool/getClass.h>
0007
0008 #include <vector> // for vector, vector<>::const_iterator
0009
0010 class PHCompositeNode;
0011 class PHG4Particle;
0012
0013 PHG4ParticleGun::PHG4ParticleGun(const std::string &name)
0014 : PHG4ParticleGeneratorBase(name)
0015 {
0016 return;
0017 }
0018
0019 int PHG4ParticleGun::process_event(PHCompositeNode *topNode)
0020 {
0021 PHG4InEvent *ineve = findNode::getClass<PHG4InEvent>(topNode, "PHG4INEVENT");
0022 ReuseExistingVertex(topNode);
0023 int vtxindex = ineve->AddVtx(get_vtx_x(), get_vtx_y(), get_vtx_z(), get_t0());
0024 std::vector<PHG4Particle *>::const_iterator iter;
0025 for (iter = particlelist_begin(); iter != particlelist_end(); ++iter)
0026 {
0027 PHG4Particle *particle = new PHG4Particlev1(*iter);
0028 SetParticleId(particle, ineve);
0029 ineve->AddParticle(vtxindex, particle);
0030 }
0031 if (Verbosity() > 0)
0032 {
0033 ineve->identify();
0034 }
0035 return 0;
0036 }