From 3c4f5a1900c3fbbcefb5abc6fd493f5625c4270a Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 31 Mar 2017 21:27:02 +0200
Subject: [PATCH] Add test to dump hits from MultiSegment-MultiCollections
 example. Investigate issue: https://github.com/AIDASoft/DD4hep/issues/141 for
 details

---
 DDG4/include/DDG4/Geant4DataDump.h |  2 ++
 DDG4/src/Geant4DataDump.cpp        | 22 +++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/DDG4/include/DDG4/Geant4DataDump.h b/DDG4/include/DDG4/Geant4DataDump.h
index 352df0e5b..fb5b61bc7 100644
--- a/DDG4/include/DDG4/Geant4DataDump.h
+++ b/DDG4/include/DDG4/Geant4DataDump.h
@@ -57,6 +57,8 @@ namespace DD4hep {
 #if !(defined(G__DICTIONARY) || defined(__CLANG__) || defined(__CINT__) || defined(__MAKECINT__))
       /// Print a single particle to the output logging using the specified print level
       void print(PrintLevel level, Geant4ParticleHandle p)  const;
+      /// Print a single particle to the output logging using the specified print level
+      void print(PrintLevel level, int key, Geant4ParticleHandle p)  const;
 #endif
       /// Print the particle map to the output logging using the specified print level
       void print(PrintLevel level, const Geant4ParticleMap* parts)  const;
diff --git a/DDG4/src/Geant4DataDump.cpp b/DDG4/src/Geant4DataDump.cpp
index 54cb0eb93..1306d9c00 100644
--- a/DDG4/src/Geant4DataDump.cpp
+++ b/DDG4/src/Geant4DataDump.cpp
@@ -50,6 +50,26 @@ void Geant4DataDump::print(PrintLevel level, Geant4ParticleHandle p)  const  {
            );
 }
 
+/// Print a single particle to the output logging using the specified print level
+void Geant4DataDump::print(PrintLevel level, int id, Geant4ParticleHandle p)  const  {
+  PropertyMask mask(p->reason);
+  int parent = p->parents.empty() ? -1 : *p->parents.begin();
+  printout(level, m_tag, "   +++ TrackID: %6d [key:%d] %12d %6d %-7s %3s %5d %6s %8.3g %-4s %-7s %-7s %-3s",
+           p->id, id,
+           p->pdgID,
+           parent,
+           yes_no(mask.isSet(G4PARTICLE_PRIMARY)),
+           yes_no(mask.isSet(G4PARTICLE_HAS_SECONDARIES)),
+           int(p->daughters.size()),
+           yes_no(mask.isSet(G4PARTICLE_ABOVE_ENERGY_THRESHOLD)),
+           p.energy(),
+           yes_no(mask.isSet(G4PARTICLE_CREATED_CALORIMETER_HIT)),
+           yes_no(mask.isSet(G4PARTICLE_CREATED_TRACKER_HIT)),
+           yes_no(mask.isSet(G4PARTICLE_KEEP_PROCESS)),
+           mask.isSet(G4PARTICLE_KEEP_PARENT) ? "YES" : ""
+           );
+}
+
 /// Print the particle container to the output logging using the specified print level
 void Geant4DataDump::print(PrintLevel level, const std::string& container, const Particles* parts)  const   {
   if ( parts )    {
@@ -74,7 +94,7 @@ void Geant4DataDump::print(PrintLevel level, const Geant4ParticleMap* parts)  co
     printout(level,m_tag,"+++ # of Tracks:%6d          PDG Parent Primary Secondary Energy %-8s Calo Tracker Process/Par",
              int(pm.size()),"in [MeV]");
     for(const auto& p : pm)
-      print(low_lvl, p.second);
+      print(low_lvl, p.first, p.second);
   }
 }
 
-- 
GitLab