Skip to content

Commit 6c25e34

Browse files
committed
overwrite lastStoredAncestor only when parent is in history
1 parent 05248a5 commit 6c25e34

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

SimG4CMS/Calo/src/CaloSD.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,8 @@ unsigned int CaloSD::findBoundaryCrossingParent(const G4Track* track, bool markA
574574
#endif
575575
boundaryCrossingParentMap_[id] = id;
576576
trkInfo->setStoreTrack();
577-
trkInfo->setIdLastStoredAncestor(id);
577+
if (trkInfo->idLastStoredAncestor() == track->GetParentID())
578+
trkInfo->setIdLastStoredAncestor(id);
578579
return id;
579580
}
580581
// Else, traverse the history of the track
@@ -683,7 +684,8 @@ CaloG4Hit* CaloSD::createNewHit(const G4Step* aStep, const G4Track* theTrack, in
683684
#endif
684685
if (etrack >= energyCut || forceSave) {
685686
trkInfo->setStoreTrack();
686-
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
687+
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
688+
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
687689
}
688690
} else {
689691
TrackWithHistory* trkh = tkMap[currentID[k].trackID()];

SimG4CMS/Forward/src/TimingSD.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ void TimingSD::getStepInfo(const G4Step* aStep) {
163163
if (incidentEnergy > energyCut) {
164164
info = cmsTrackInformation(theTrack);
165165
info->setStoreTrack();
166-
info->setIdLastStoredAncestor(theTrack->GetTrackID());
166+
if (info->idLastStoredAncestor() == theTrack->GetParentID())
167+
info->setIdLastStoredAncestor(theTrack->GetTrackID());
167168
}
168169
if (incidentEnergy > energyHistoryCut) {
169170
if (nullptr == info) {

SimG4CMS/Muon/src/MuonSensitiveDetector.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ void MuonSensitiveDetector::createHit(const G4Step* aStep) {
249249
if (thePabs > ePersistentCutGeV_ || (thePID == 13 && allMuonsPersistent_)) {
250250
TrackInformation* info = cmsTrackInformation(theTrack);
251251
info->setStoreTrack();
252-
info->setIdLastStoredAncestor(theTrack->GetTrackID());
252+
if (info->idLastStoredAncestor() == theTrack->GetParentID())
253+
info->setIdLastStoredAncestor(theTrack->GetTrackID());
253254
}
254255

255256
#ifdef EDM_ML_DEBUG

SimG4CMS/Tracker/src/TkAccumulatingSensitiveDetector.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ void TkAccumulatingSensitiveDetector::update(const BeginOfTrack* bot) {
153153
if (gTrack->GetKineticEnergy() > energyCut) {
154154
info = cmsTrackInformation(gTrack);
155155
info->setStoreTrack();
156-
info->setIdLastStoredAncestor(gTrack->GetTrackID());
156+
if (info->idLastStoredAncestor() == gTrack->GetParentID())
157+
info->setIdLastStoredAncestor(gTrack->GetTrackID());
157158
}
158159
//
159160
// Save History?

SimG4Core/CustomPhysics/plugins/DBremWatcher.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ void DBremWatcher::update(const BeginOfTrack* trk) {
105105
if (std::find(pdgs_.begin(), pdgs_.end(), pdg) != pdgs_.end()) {
106106
//Found an A'
107107
trkInfo->setStoreTrack();
108-
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
108+
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
109+
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
109110
VertexPos = Vpos;
110111
aPrimeTraj = theTrack->GetMomentum();
111112
LogDebug("DBremWatcher") << "Save SimTrack the Track " << theTrack->GetTrackID() << " Type "
@@ -137,7 +138,8 @@ void DBremWatcher::update(const EndOfTrack* trk) {
137138
if (std::find(pdgs_.begin(), pdgs_.end(), pdg) == pdgs_.end() &&
138139
(theTrack->GetCreatorProcess()->GetProcessName()) == "muDBrem") {
139140
trkInfo->setStoreTrack();
140-
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
141+
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
142+
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
141143
}
142144
}
143145
}

0 commit comments

Comments
 (0)