Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SimDataFormats/Track/interface/SimTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SimTrack : public CoreSimTrack {

void setIsPrimary() { trackInfo_ |= (1 << 1); }
void setGenParticleID(const int idx) { igenpart = idx; }
int getPrimaryID() const { return igenpart; }
int getPrimaryOrLastStoredID() const { return igenpart; }
uint8_t getTrackInfo() const { return trackInfo_; }

private:
Expand Down
6 changes: 4 additions & 2 deletions SimG4CMS/Calo/src/CaloSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ unsigned int CaloSD::findBoundaryCrossingParent(const G4Track* track, bool markA
#endif
boundaryCrossingParentMap_[id] = id;
trkInfo->setStoreTrack();
trkInfo->setIdLastStoredAncestor(id);
if (trkInfo->idLastStoredAncestor() == track->GetParentID())
trkInfo->setIdLastStoredAncestor(id);
return id;
}
// Else, traverse the history of the track
Expand Down Expand Up @@ -683,7 +684,8 @@ CaloG4Hit* CaloSD::createNewHit(const G4Step* aStep, const G4Track* theTrack, in
#endif
if (etrack >= energyCut || forceSave) {
trkInfo->setStoreTrack();
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
}
} else {
TrackWithHistory* trkh = tkMap[currentID[k].trackID()];
Expand Down
3 changes: 2 additions & 1 deletion SimG4CMS/Forward/src/TimingSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ void TimingSD::getStepInfo(const G4Step* aStep) {
if (incidentEnergy > energyCut) {
info = cmsTrackInformation(theTrack);
info->setStoreTrack();
info->setIdLastStoredAncestor(theTrack->GetTrackID());
if (info->idLastStoredAncestor() == theTrack->GetParentID())
info->setIdLastStoredAncestor(theTrack->GetTrackID());
}
if (incidentEnergy > energyHistoryCut) {
if (nullptr == info) {
Expand Down
3 changes: 2 additions & 1 deletion SimG4CMS/Muon/src/MuonSensitiveDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ void MuonSensitiveDetector::createHit(const G4Step* aStep) {
if (thePabs > ePersistentCutGeV_ || (thePID == 13 && allMuonsPersistent_)) {
TrackInformation* info = cmsTrackInformation(theTrack);
info->setStoreTrack();
info->setIdLastStoredAncestor(theTrack->GetTrackID());
if (info->idLastStoredAncestor() == theTrack->GetParentID())
info->setIdLastStoredAncestor(theTrack->GetTrackID());
}

#ifdef EDM_ML_DEBUG
Expand Down
3 changes: 2 additions & 1 deletion SimG4CMS/Tracker/src/TkAccumulatingSensitiveDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void TkAccumulatingSensitiveDetector::update(const BeginOfTrack* bot) {
if (gTrack->GetKineticEnergy() > energyCut) {
info = cmsTrackInformation(gTrack);
info->setStoreTrack();
info->setIdLastStoredAncestor(gTrack->GetTrackID());
if (info->idLastStoredAncestor() == gTrack->GetParentID())
info->setIdLastStoredAncestor(gTrack->GetTrackID());
}
//
// Save History?
Expand Down
2 changes: 1 addition & 1 deletion SimG4Core/Application/plugins/OscarMTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void OscarMTProducer::produce(edm::Event& e, const edm::EventSetup& es) {
edm::LogVerbatim("Track") << " " << i << ". " << (*p1)[i].trackId() << ", " << (*p1)[i] << ", "
<< (*p1)[i].crossedBoundary() << "-> " << (*p1)[i].getIDAtBoundary() << ", "
<< (*p1)[i].isFromBackScattering() << ", " << (*p1)[i].isPrimary() << "-> "
<< (*p1)[i].getPrimaryID();
<< (*p1)[i].getPrimaryOrLastStoredID();
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions SimG4Core/CustomPhysics/plugins/DBremWatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ void DBremWatcher::update(const BeginOfTrack* trk) {
if (std::find(pdgs_.begin(), pdgs_.end(), pdg) != pdgs_.end()) {
//Found an A'
trkInfo->setStoreTrack();
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
VertexPos = Vpos;
aPrimeTraj = theTrack->GetMomentum();
LogDebug("DBremWatcher") << "Save SimTrack the Track " << theTrack->GetTrackID() << " Type "
Expand Down Expand Up @@ -137,7 +138,8 @@ void DBremWatcher::update(const EndOfTrack* trk) {
if (std::find(pdgs_.begin(), pdgs_.end(), pdg) == pdgs_.end() &&
(theTrack->GetCreatorProcess()->GetProcessName()) == "muDBrem") {
trkInfo->setStoreTrack();
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
if (trkInfo->idLastStoredAncestor() == theTrack->GetParentID())
trkInfo->setIdLastStoredAncestor(theTrack->GetTrackID());
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions SimG4Core/Notification/src/SimTrackManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void SimTrackManager::addTrack(TrackWithHistory* iTrack, const G4Track* track, b
auto info = static_cast<const TrackInformation*>(track->GetUserInformation());
if (info->isInTrkFromBackscattering())
iTrack->setFromBackScattering();
// set there for the *non-primary* tracks the genParticle ID associated with the G4Track
// for the primaries this is done in the TrackWithHistory constructor.
// set there for the *non-primary* tracks the G4Track ID of the last stored ancestor
// for the primaries the genparticle id is saved in the TrackWithHistory constructor.
// In the constructor of TrackWithHistory the info isPrimary is saved and used
// to give -1 if the track is not a primary.
if (not iTrack->isPrimary())
iTrack->setGenParticleID(info->mcTruthID());
iTrack->setGenParticleID(info->idLastStoredAncestor());
m_trackContainer.push_back(iTrack);
const auto& v = track->GetStep()->GetPostStepPoint()->GetPosition();
std::pair<int, math::XYZVectorD> p(iTrack->trackID(),
Expand Down
11 changes: 6 additions & 5 deletions SimGeneral/Debugging/plugins/CaloParticleDebugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void CaloParticleDebugger::analyze(const edm::Event& iEvent, const edm::EventSet
LogVerbatim("CaloParticleDebuggerSimTracks")
<< i << "\t" << t.trackId() << "\t" << t << " Crossed Boundary: " << t.crossedBoundary()
<< " Vtx: " << t.vertIndex() << " isFromBackScattering: " << t.isFromBackScattering()
<< " isPrimary: " << t.isPrimary() << " ParentID: " << t.getPrimaryID()
<< " isPrimary: " << t.isPrimary() << " ParentID: " << t.getPrimaryOrLastStoredID()
<< " Position Boundary: " << t.getPositionAtBoundary() << " Momentum Boundary: " << t.getMomentumAtBoundary()
<< " Momemtum Origin: " << t.momentum();
trackid_to_track_index[t.trackId()] = i;
Expand Down Expand Up @@ -232,10 +232,11 @@ void CaloParticleDebugger::analyze(const edm::Event& iEvent, const edm::EventSet
<< "\n\n"
<< i << "\tType: " << simcl.pdgId() << "\tEnergy: " << simcl.energy() << "\tKey: " << i; // << simcl ;
auto const& simtrack = simcl.g4Tracks()[0];
LogVerbatim("CaloParticleDebuggerSimClusters") << "\n Primary GenParticleID: " << simtrack.getPrimaryID()
<< "\n Crossed Boundary: " << simtrack.crossedBoundary()
<< "\n Position Boundary: " << simtrack.getPositionAtBoundary()
<< "\n Momentum Boundary: " << simtrack.getMomentumAtBoundary();
LogVerbatim("CaloParticleDebuggerSimClusters")
<< "\n GenParticleID/ancestor: " << simtrack.getPrimaryOrLastStoredID()
<< "\n Crossed Boundary: " << simtrack.crossedBoundary()
<< "\n Position Boundary: " << simtrack.getPositionAtBoundary()
<< "\n Momentum Boundary: " << simtrack.getMomentumAtBoundary();
if (simClusters_in_CaloParticles.find(simcl.g4Tracks()[0].trackId()) == simClusters_in_CaloParticles.end()) {
LogVerbatim("CaloParticleDebuggerSimClusters") << " Orphan SimCluster: " << simtrack.trackId();
}
Expand Down