Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DY option to Embedding HepMC filter #38829

Merged
merged 3 commits into from
Aug 16, 2022
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
3 changes: 3 additions & 0 deletions GeneratorInterface/Core/interface/EmbeddingHepMCFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "GeneratorInterface/Core/interface/BaseHepMCFilter.h"
#include "PhysicsTools/HepMCCandAlgos/interface/MCTruthHelper.h"
#include "DataFormats/Candidate/interface/Candidate.h"

class EmbeddingHepMCFilter : public BaseHepMCFilter {
Expand All @@ -15,6 +16,8 @@ class EmbeddingHepMCFilter : public BaseHepMCFilter {
const int electron_neutrino_PDGID_ = 12;
const int electronPDGID_ = 11;
int ZPDGID_ = 23;
bool includeDY_ = false;
MCTruthHelper<HepMC::GenParticle> mcTruthHelper_;

enum class TauDecayMode : int { Unfilled = -1, Muon = 0, Electron = 1, Hadronic = 2 };

Expand Down
32 changes: 21 additions & 11 deletions GeneratorInterface/Core/src/EmbeddingHepMCFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "boost/algorithm/string/trim_all.hpp"

EmbeddingHepMCFilter::EmbeddingHepMCFilter(const edm::ParameterSet &iConfig)
: ZPDGID_(iConfig.getParameter<int>("BosonPDGID")) {
: ZPDGID_(iConfig.getParameter<int>("BosonPDGID")), includeDY_(iConfig.getParameter<bool>("IncludeDY")) {
// Defining standard decay channels
ee.fill(TauDecayMode::Electron);
ee.fill(TauDecayMode::Electron);
Expand Down Expand Up @@ -63,25 +63,35 @@ bool EmbeddingHepMCFilter::filter(const HepMC::GenEvent *evt) {
// One can stop the loop after the second tau is reached and processed.
for (HepMC::GenEvent::particle_const_iterator particle = evt->particles_begin(); particle != evt->particles_end();
++particle) {
int mom_id = 0; // No particle available with PDG ID 0
if ((*particle)->production_vertex() != nullptr) { // search for the mom via the production_vertex
if ((*particle)->production_vertex()->particles_in_const_begin() !=
(*particle)->production_vertex()->particles_in_const_end()) {
mom_id = (*(*particle)->production_vertex()->particles_in_const_begin())->pdg_id(); // mom was found
int mom_id = 0; // no particle available with PDG ID 0
bool isHardProc = false; // mother is ZPDGID_, or is lepton from hard process (DY process qq -> ll)
int pdg_id = std::abs((*particle)->pdg_id());
HepMC::GenVertex *vertex = (*particle)->production_vertex();
if (vertex != nullptr) { // search for the mom via the production_vertex
HepMC::GenVertex::particles_in_const_iterator mom = vertex->particles_in_const_begin();
if (mom != vertex->particles_in_const_end()) {
mom_id = std::abs((*mom)->pdg_id()); // mom was found
}
if (mom_id == ZPDGID_) {
isHardProc = true; // intermediate boson
} else if (includeDY_ && 11 <= pdg_id && pdg_id <= 16 && mcTruthHelper_.isFirstCopy(**particle) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 <= pdg_id && pdg_id <= 16: instead of doing this, do you want to select the pdg_ids explicitly. Do you care about Z $\rightarrow \nu \nu$?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle this filter only targets the charged leptons, but this is done a few lines below and selecting 11, 13 and 15 explicitly should make no significant difference in performance.

I can change it if you really want?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Saptaparna, are you fine with leaving it as it is now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry. It is fine. Just signed PR.

mcTruthHelper_.fromHardProcess(**particle)) {
edm::LogInfo("EmbeddingHepMCFilter") << (*particle)->pdg_id() << " with mother " << (*mom)->pdg_id();
isHardProc = true; // assume Drell-Yan qq -> ll without intermediate boson
}
}

if (std::abs((*particle)->pdg_id()) == tauonPDGID_ && mom_id == ZPDGID_) {
if (!isHardProc) {
continue;
} else if (pdg_id == tauonPDGID_) {
reco::Candidate::LorentzVector p4Vis;
decay_and_sump4Vis((*particle), p4Vis); // recursive access to final states.
p4VisPair_.push_back(p4Vis);
} else if (std::abs((*particle)->pdg_id()) == muonPDGID_ &&
mom_id == ZPDGID_) { // Also handle the option when Z-> mumu
} else if (pdg_id == muonPDGID_) { // Also handle the option when Z-> mumu
reco::Candidate::LorentzVector p4Vis = (reco::Candidate::LorentzVector)(*particle)->momentum();
DecayChannel_.fill(TauDecayMode::Muon); // take the muon cuts
p4VisPair_.push_back(p4Vis);
} else if (std::abs((*particle)->pdg_id()) == electronPDGID_ &&
mom_id == ZPDGID_) { // Also handle the option when Z-> ee
} else if (pdg_id == electronPDGID_) { // Also handle the option when Z-> ee
reco::Candidate::LorentzVector p4Vis = (reco::Candidate::LorentzVector)(*particle)->momentum();
DecayChannel_.fill(TauDecayMode::Electron); // take the electron cuts
p4VisPair_.push_back(p4Vis);
Expand Down