From 6e4adcc1868d91accb7c8e4f2e4f5a78a5d001b5 Mon Sep 17 00:00:00 2001
From: Your Name <angerami@cern.ch>
Date: Wed, 23 Aug 2023 16:58:59 +0200
Subject: [PATCH] adding keepStrongVertices option, see ATLHI-483

---
 Generators/Hijing_i/Hijing_i/Hijing.h |  1 +
 Generators/Hijing_i/src/Hijing.cxx    | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Generators/Hijing_i/Hijing_i/Hijing.h b/Generators/Hijing_i/Hijing_i/Hijing.h
index 30b34cf46489..a8f7c94017f1 100644
--- a/Generators/Hijing_i/Hijing_i/Hijing.h
+++ b/Generators/Hijing_i/Hijing_i/Hijing.h
@@ -81,6 +81,7 @@ protected:
   bool m_rand{false};
   bool m_wide{false}; // True allows particles with x,y distributions
   bool m_prand{false}; //BPK mirror event randomly
+  bool m_keepAllDecayVertices{true};
 
   // Limit settings
   double m_partonStoreMinPt{5.0};
diff --git a/Generators/Hijing_i/src/Hijing.cxx b/Generators/Hijing_i/src/Hijing.cxx
index a12caa78a8e5..c7cc10f82beb 100644
--- a/Generators/Hijing_i/src/Hijing.cxx
+++ b/Generators/Hijing_i/src/Hijing.cxx
@@ -17,6 +17,7 @@
 //          - this fixed bug #30991 for release 13.1.0 and for HepMC 2.3.0 where the 'set's comparison operates
 //            on the barcode rather than on the pointer.
 //     2008-Jul Borut Kersevan:  randomizing the left<->right direction by mirroring momenta settable in jobOpts for beamgas
+//     2023-Aug Aaron Angerami: adding keepAllDecayVertices option to keep decay vertices for strong decays (default=true) 
 
 #include "Hijing_i/Hijing.h"
 #include "Hijing_i/VertexShift.h"
@@ -78,6 +79,7 @@ Hijing::Hijing(const std::string& name,
   declareProperty("z", m_z);
   declareProperty("keepSpectators", m_spec);
   declareProperty("randomizeP", m_prand); //BPK randomizes the left<->right direction by mirroring momenta for beam gas
+  declareProperty("keepAllDecayVertices", m_keepAllDecayVertices);
 }
 
 StatusCode Hijing::genInitialize()
@@ -344,7 +346,7 @@ Hijing::fillEvt(HepMC::GenEvent* evt)
     v1->add_particle_in( part_t );
 
     evt->set_beam_particles(part_p,part_t);
-
+    ATH_MSG_INFO("So far so good");
     ATH_MSG_DEBUG( "Hijing particles for event # " << m_events << ":\n"
            << " px,      "
            << " py,      "
@@ -472,7 +474,6 @@ Hijing::fillEvt(HepMC::GenEvent* evt)
              //  Now compare the distance between the vertex FROM which the parent originates and the
              //    start of this particle
              //
-
              HepGeom::Point3D<double> vertex_pos(vertexPtrVec[parentOriginIndex]->position().x(),
                                       vertexPtrVec[parentOriginIndex]->position().y(),
                                       vertexPtrVec[parentOriginIndex]->position().z());
@@ -503,12 +504,12 @@ Hijing::fillEvt(HepMC::GenEvent* evt)
                 particleVertexIndex = parentOriginIndex;
                 //std::cout << "ML-> case 2 distane = " << distance <<"  particleVertexIndex = "<<particleVertexIndex<< std::endl;
               }
-             if(distance > m_vertexOffsetCut || parentOriginIndex !=0)
+             if( parentIndex!=-1 && ((distance > m_vertexOffsetCut || parentOriginIndex !=0) || m_keepAllDecayVertices ) )
               {
                 // We need to create a new vertex
                 //
                 HepMC::GenVertexPtr newVertex_p = HepMC::newGenVertexPtr(HepMC::FourVector(particleStart.x(),particleStart.y(),particleStart.z(),particleStart.t()));
-                  evt->add_vertex(newVertex_p);
+		evt->add_vertex(newVertex_p);
                 vertexPtrVec.push_back(newVertex_p);
                 particleVertexIndex = vertexPtrVec.size() - 1;
 
@@ -518,6 +519,7 @@ Hijing::fillEvt(HepMC::GenEvent* evt)
 
                 //  Now tell the vertex about the particle that created it
                 //
+
                 newVertex_p->add_particle_in(particleHepPartPtr_vec[parentIndex]);
               }
              else {
-- 
GitLab