From 757fdee6514b649ec71210e428ee2f7514cb8fbb Mon Sep 17 00:00:00 2001 From: alebihan Date: Mon, 11 May 2026 16:55:41 +0200 Subject: [PATCH 1/2] neded fixes to run with photos --- GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc b/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc index 1d9a21b9eaf08..29aaa54f0ebd0 100644 --- a/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc +++ b/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc @@ -84,7 +84,7 @@ bool EmbeddingHepMCFilter::filter(const HepMC::GenEvent *evt) { if (!isHardProc) { continue; - } else if (pdg_id == tauonPDGID_) { + } else if (pdg_id == tauonPDGID_ && (*particle)->status() != 746) { reco::Candidate::LorentzVector p4Vis; decay_and_sump4Vis((*particle), p4Vis); // recursive access to final states. p4VisPair_.push_back(p4Vis); @@ -119,6 +119,8 @@ bool EmbeddingHepMCFilter::filter(const HepMC::GenEvent *evt) { void EmbeddingHepMCFilter::decay_and_sump4Vis(HepMC::GenParticle *particle, reco::Candidate::LorentzVector &p4Vis) { bool decaymode_known = false; + + if (particle->end_vertex() !=0 ) { for (HepMC::GenVertex::particle_iterator daughter = particle->end_vertex()->particles_begin(HepMC::children); daughter != particle->end_vertex()->particles_end(HepMC::children); ++daughter) { @@ -149,6 +151,7 @@ void EmbeddingHepMCFilter::decay_and_sump4Vis(HepMC::GenParticle *particle, reco p4Vis += (reco::Candidate::LorentzVector)(*daughter)->momentum(); else if (!neutrino) decay_and_sump4Vis((*daughter), p4Vis); + } } } From 93f76e30919cbca0f3c94505b2bc072b4446b053 Mon Sep 17 00:00:00 2001 From: alebihan Date: Mon, 11 May 2026 17:28:18 +0200 Subject: [PATCH 2/2] moving to nullptr --- .../Core/src/EmbeddingHepMCFilter.cc | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc b/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc index 29aaa54f0ebd0..650e09a275df0 100644 --- a/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc +++ b/GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc @@ -119,39 +119,39 @@ bool EmbeddingHepMCFilter::filter(const HepMC::GenEvent *evt) { void EmbeddingHepMCFilter::decay_and_sump4Vis(HepMC::GenParticle *particle, reco::Candidate::LorentzVector &p4Vis) { bool decaymode_known = false; - - if (particle->end_vertex() !=0 ) { - for (HepMC::GenVertex::particle_iterator daughter = particle->end_vertex()->particles_begin(HepMC::children); - daughter != particle->end_vertex()->particles_end(HepMC::children); - ++daughter) { - bool neutrino = (std::abs((*daughter)->pdg_id()) == tauon_neutrino_PDGID_) || - (std::abs((*daughter)->pdg_id()) == muon_neutrino_PDGID_) || - (std::abs((*daughter)->pdg_id()) == electron_neutrino_PDGID_); - - // Determining DecayMode, if particle is tau lepton. - // Asuming, that there are only the two tauons from the Z-boson. - // This is the case for the simulated Z->tautau event constructed by EmbeddingLHEProducer. - if (std::abs(particle->pdg_id()) == tauonPDGID_ && !decaymode_known) { - // use these bools to protect againt taus that aren't the last copy (which "decay" to a tau and a gamma) - bool isGamma = std::abs((*daughter)->pdg_id()) == 22; - bool isTau = std::abs((*daughter)->pdg_id()) == 15; - if (std::abs((*daughter)->pdg_id()) == muonPDGID_) { - DecayChannel_.fill(TauDecayMode::Muon); - decaymode_known = true; - } else if (std::abs((*daughter)->pdg_id()) == electronPDGID_) { - DecayChannel_.fill(TauDecayMode::Electron); - decaymode_known = true; - } else if (!neutrino && !isGamma && !isTau) { - DecayChannel_.fill(TauDecayMode::Hadronic); - decaymode_known = true; + + if (particle->end_vertex() != nullptr) { + for (HepMC::GenVertex::particle_iterator daughter = particle->end_vertex()->particles_begin(HepMC::children); + daughter != particle->end_vertex()->particles_end(HepMC::children); + ++daughter) { + bool neutrino = (std::abs((*daughter)->pdg_id()) == tauon_neutrino_PDGID_) || + (std::abs((*daughter)->pdg_id()) == muon_neutrino_PDGID_) || + (std::abs((*daughter)->pdg_id()) == electron_neutrino_PDGID_); + + // Determining DecayMode, if particle is tau lepton. + // Asuming, that there are only the two tauons from the Z-boson. + // This is the case for the simulated Z->tautau event constructed by EmbeddingLHEProducer. + if (std::abs(particle->pdg_id()) == tauonPDGID_ && !decaymode_known) { + // use these bools to protect againt taus that aren't the last copy (which "decay" to a tau and a gamma) + bool isGamma = std::abs((*daughter)->pdg_id()) == 22; + bool isTau = std::abs((*daughter)->pdg_id()) == 15; + if (std::abs((*daughter)->pdg_id()) == muonPDGID_) { + DecayChannel_.fill(TauDecayMode::Muon); + decaymode_known = true; + } else if (std::abs((*daughter)->pdg_id()) == electronPDGID_) { + DecayChannel_.fill(TauDecayMode::Electron); + decaymode_known = true; + } else if (!neutrino && !isGamma && !isTau) { + DecayChannel_.fill(TauDecayMode::Hadronic); + decaymode_known = true; + } } + // Adding up all visible momentum in recursive way. + if ((*daughter)->status() == 1 && !neutrino) + p4Vis += (reco::Candidate::LorentzVector)(*daughter)->momentum(); + else if (!neutrino) + decay_and_sump4Vis((*daughter), p4Vis); } - // Adding up all visible momentum in recursive way. - if ((*daughter)->status() == 1 && !neutrino) - p4Vis += (reco::Candidate::LorentzVector)(*daughter)->momentum(); - else if (!neutrino) - decay_and_sump4Vis((*daughter), p4Vis); - } } }