Warning, /eic-spack/spack_repo/eic/packages/dd4hep/pull-1702.patch is written in an unsupported language. File is not indexed.
0001 diff --git a/DDG4/src/Geant4Particle.cpp b/DDG4/src/Geant4Particle.cpp
0002 index 57321de8dcc6598fb4121e1e0468b64103a9c24a..54fdc9a3efd4e438b7763b56f4d71aaf38336482 100644
0003 --- a/DDG4/src/Geant4Particle.cpp
0004 +++ b/DDG4/src/Geant4Particle.cpp
0005 @@ -521,10 +521,8 @@ void Geant4ParticleMap::dump() const {
0006 /// Adopt particle maps
0007 void Geant4ParticleMap::adopt(ParticleMap& pm, TrackEquivalents& equiv) {
0008 clear();
0009 - particleMap = pm;
0010 - equivalentTracks = equiv;
0011 - pm.clear();
0012 - equiv.clear();
0013 + particleMap.swap(pm);
0014 + equivalentTracks.swap(equiv);
0015 //dump();
0016 }
0017
0018 diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp
0019 index 9c573cb38a7abd3285927ce39a69a5aac38ec76f..7ef38fe773aba5b2e3f2376df610e827b0219347 100644
0020 --- a/DDG4/src/Geant4ParticleHandler.cpp
0021 +++ b/DDG4/src/Geant4ParticleHandler.cpp
0022 @@ -38,6 +38,8 @@
0023 // C/C++ include files
0024 #include <set>
0025 #include <algorithm>
0026 +#include <limits>
0027 +#include <vector>
0028
0029 using namespace dd4hep::sim;
0030 using PropertyMask = dd4hep::detail::ReferenceBitMask<int>;
0031 @@ -514,7 +516,7 @@ void Geant4ParticleHandler::endEvent(const G4Event* event) {
0032 /// Rebase the simulated tracks, so that they fit to the generator particles
0033 void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0034 /// No we have to update the map of equivalent tracks and assign the 'equivalentTrack' entry
0035 - TrackEquivalents equivalents, orgParticles;
0036 + TrackEquivalents orgParticles;
0037 ParticleMap finalParticles;
0038 ParticleMap::const_iterator ipar, iend, i;
0039 int count;
0040 @@ -545,6 +547,10 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0041 }
0042 }
0043 // (2) Re-evaluate the corresponding geant4 track equivalents using the new mapping
0044 + // (collected first, as the lookups below use the old mapping)
0045 + constexpr int no_equivalent = std::numeric_limits<int>::min();
0046 + std::vector<int> new_ids;
0047 + new_ids.reserve(m_equivalentTracks.size());
0048 for(TrackEquivalents::iterator ie=m_equivalentTracks.begin(),ie_end=m_equivalentTracks.end(); ie!=ie_end; ++ie) {
0049 int g4_equiv = (*ie).first;
0050 while( (ipar=m_particleMap.find(g4_equiv)) == m_particleMap.end() ) {
0051 @@ -557,7 +563,7 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0052 TrackEquivalents::mapped_type equiv = (*ie).second;
0053 if ( ipar != m_particleMap.end() ) {
0054 Geant4ParticleHandle p = (*ipar).second;
0055 - equivalents[(*ie).first] = p->id; // requires (1) to be filled properly!
0056 + new_ids.push_back(p->id); // requires (1) to be filled properly!
0057 const G4ParticleDefinition* def = p.definition();
0058 int pdg = int(std::abs(def->GetPDGEncoding())+0.1);
0059 if ( pdg != 0 && pdg<36 && !(pdg > 10 && pdg < 17) && pdg != 22 ) {
0060 @@ -570,6 +576,16 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0061 }
0062 else {
0063 error("+++ No Equivalent particle for track:%d last known is:%d",equiv,g4_equiv);
0064 + new_ids.push_back(no_equivalent);
0065 + }
0066 + }
0067 + std::size_t idx = 0;
0068 + for(auto ie = m_equivalentTracks.begin(); ie != m_equivalentTracks.end(); ++idx) {
0069 + if ( new_ids[idx] == no_equivalent )
0070 + ie = m_equivalentTracks.erase(ie);
0071 + else {
0072 + (*ie).second = new_ids[idx];
0073 + ++ie;
0074 }
0075 }
0076
0077 @@ -584,8 +600,8 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0078 for( auto& part : finalParticles ) {
0079 auto& p = part.second;
0080 if ( p->g4Parent > 0 ) {
0081 - TrackEquivalents::iterator iequ = equivalents.find(p->g4Parent);
0082 - if ( iequ != equivalents.end() ) {
0083 + TrackEquivalents::iterator iequ = m_equivalentTracks.find(p->g4Parent);
0084 + if ( iequ != m_equivalentTracks.end() ) {
0085 equiv_id = (*iequ).second;//equivalents[p->g4Parent];
0086 if ( (ipar=finalParticles.find(equiv_id)) != finalParticles.end() ) {
0087 Particle* q = (*ipar).second;
0088 @@ -635,7 +651,6 @@ void Geant4ParticleHandler::rebaseSimulatedTracks(int ) {
0089 }
0090 }
0091 #endif
0092 - m_equivalentTracks = std::move(equivalents);
0093 m_particleMap = std::move(finalParticles);
0094 }
0095