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

Updated vbf filter v2 #20394

Merged
merged 5 commits into from Sep 12, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions GeneratorInterface/GenFilters/BuildFile.xml
Expand Up @@ -25,4 +25,5 @@
<use name="DataFormats/HepMCCandidate"/>
<use name="DataFormats/JetReco"/>
<use name="DataFormats/EgammaReco"/>
<use name="DataFormats/Math"/>
<flags EDM_PLUGIN="1"/>
12 changes: 9 additions & 3 deletions GeneratorInterface/GenFilters/interface/VBFGenJetFilter.h
Expand Up @@ -12,6 +12,7 @@
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

// ROOT includes
#include "TFile.h"
Expand All @@ -28,9 +29,9 @@
class VBFGenJetFilter : public edm::EDFilter {
public:
explicit VBFGenJetFilter(const edm::ParameterSet&);
~VBFGenJetFilter();
~VBFGenJetFilter() override;

virtual bool filter(edm::Event&, const edm::EventSetup&);
bool filter(edm::Event&, const edm::EventSetup&) override;
private:

// ----------memeber function----------------------
Expand All @@ -42,7 +43,7 @@ class VBFGenJetFilter : public edm::EDFilter {
double nuMET(std::vector<HepMC::GenParticle*> vNu);

std::vector<const reco::GenJet*> filterGenJets(const std::vector<reco::GenJet>* jets);
// std::vector<const reco::GenJet*> filterGenJets(const std::vector<reco::GenJet>* jets);
std::vector<const reco::GenParticle*> filterGenLeptons(const std::vector<reco::GenParticle>* particles);

//**************************
// Private Member data *****
Expand All @@ -52,6 +53,7 @@ class VBFGenJetFilter : public edm::EDFilter {

// Dijet cut
bool oppositeHemisphere;
bool leadJetsNoLepMass;
double ptMin;
double etaMin;
double etaMax;
Expand All @@ -61,9 +63,13 @@ class VBFGenJetFilter : public edm::EDFilter {
double maxDeltaPhi;
double minDeltaEta;
double maxDeltaEta;
double minLeadingJetsInvMass;
double maxLeadingJetsInvMass;
double deltaRJetLep;

// Input tags
edm::EDGetTokenT< reco::GenJetCollection > m_inputTag_GenJetCollection;
edm::EDGetTokenT< reco::GenParticleCollection > m_inputTag_GenParticleCollection;


};
Expand Down
13 changes: 12 additions & 1 deletion GeneratorInterface/GenFilters/python/VBFGenJetFilter_cfi.py
Expand Up @@ -49,4 +49,15 @@
minDeltaEta = cms.untracked.double( 3.0), # Minimum dijet delta eta
maxDeltaEta = cms.untracked.double(99999.) # Maximum dijet delta eta

)
)

vbfGenJetFilterD = cms.EDFilter("VBFGenJetFilter",

inputTag_GenJetCollection = cms.untracked.InputTag('ak4GenJetsNoNu'),

leadJetsNoLepMass = cms.untracked.bool ( True), # Require the cut on the mass of the leading jets
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probably be False

Copy link
Contributor

Choose a reason for hiding this comment

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

not true, should be True...
Does it work if leadJetsNoLepMass and the other parameters are not specified?

Copy link
Author

Choose a reason for hiding this comment

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

If leadJetsNoLepMass is true but no other parameters are specified the code works.
In that case, the events pass the selection whenever there are at least two jets with DR > 0.3 from all the charged hard leptons.

Copy link
Author

Choose a reason for hiding this comment

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

If leadJetsNoLepMass is not specified, it is set as false

minLeadingJetsInvMass = cms.untracked.double( 0.0), # Minimum dijet invariant mass
maxLeadingJetsInvMass = cms.untracked.double(99999.), # Maximum dijet invariant mass
deltaRNoLep = cms.untracked.double( 0.3), # Maximum dijet invariant mass

)
64 changes: 63 additions & 1 deletion GeneratorInterface/GenFilters/src/VBFGenJetFilter.cc
@@ -1,6 +1,7 @@
#include "GeneratorInterface/GenFilters/interface/VBFGenJetFilter.h"

#include "DataFormats/Math/interface/deltaPhi.h"
#include "DataFormats/Math/interface/deltaR.h"

#include <HepMC/GenVertex.h>

Expand All @@ -16,6 +17,7 @@ using namespace std;

VBFGenJetFilter::VBFGenJetFilter(const edm::ParameterSet& iConfig) :
oppositeHemisphere(iConfig.getUntrackedParameter<bool> ("oppositeHemisphere",false)),
leadJetsNoLepMass (iConfig.getUntrackedParameter<bool> ("leadJetsNoLepMass", false)),
ptMin (iConfig.getUntrackedParameter<double>("minPt", 20)),
etaMin (iConfig.getUntrackedParameter<double>("minEta", -5.0)),
etaMax (iConfig.getUntrackedParameter<double>("maxEta", 5.0)),
Expand All @@ -24,17 +26,42 @@ maxInvMass (iConfig.getUntrackedParameter<double>("maxInvMass", 9999
minDeltaPhi (iConfig.getUntrackedParameter<double>("minDeltaPhi", -1.0)),
maxDeltaPhi (iConfig.getUntrackedParameter<double>("maxDeltaPhi", 99999.0)),
minDeltaEta (iConfig.getUntrackedParameter<double>("minDeltaEta", -1.0)),
maxDeltaEta (iConfig.getUntrackedParameter<double>("maxDeltaEta", 99999.0))
maxDeltaEta (iConfig.getUntrackedParameter<double>("maxDeltaEta", 99999.0)),
minLeadingJetsInvMass (iConfig.getUntrackedParameter<double>("minLeadingJetsInvMass", 0.0)),
maxLeadingJetsInvMass (iConfig.getUntrackedParameter<double>("maxLeadingJetsInvMass", 99999.0)),
deltaRJetLep (iConfig.getUntrackedParameter<double>("deltaRJetLep", 0.3))
{

m_inputTag_GenJetCollection = consumes<reco::GenJetCollection>(iConfig.getUntrackedParameter<edm::InputTag>("inputTag_GenJetCollection",edm::InputTag("ak5GenJetsNoNu")));
if (leadJetsNoLepMass) m_inputTag_GenParticleCollection = consumes<reco::GenParticleCollection>(iConfig.getUntrackedParameter<edm::InputTag>("genParticles",edm::InputTag("genParticles")));

}

VBFGenJetFilter::~VBFGenJetFilter(){

}


vector<const reco::GenParticle*> VBFGenJetFilter::filterGenLeptons(const vector<reco::GenParticle>* particles){
vector<const reco::GenParticle*> out;



for(const auto & p : *particles){

int absPdgId = std::abs(p.pdgId());

if(((absPdgId == 11) || (absPdgId == 13) || (absPdgId == 15)) && p.isHardProcess()) {
out.push_back(&p);
}


}
return out;
}



vector<const reco::GenJet*> VBFGenJetFilter::filterGenJets(const vector<reco::GenJet>* jets){

vector<const reco::GenJet*> out;
Expand Down Expand Up @@ -68,6 +95,41 @@ bool VBFGenJetFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
// If we do not find at least 2 jets veto the event
if(filGenJets.size()<2){return false;}


// Testing dijet mass
if(leadJetsNoLepMass) {

Handle<reco::GenParticleCollection> genParticelesCollection;
iEvent.getByToken(m_inputTag_GenParticleCollection, genParticelesCollection);
const vector<reco::GenParticle>* genParticles = genParticelesCollection.product();

// Getting filtered generator muons
vector<const reco::GenParticle*> filGenLep = filterGenLeptons(genParticles);

// Getting p4 of jet with no lepton
vector<math::XYZTLorentzVector> genJetsWithoutLeptonsP4;
unsigned int jetIdx = 0;

while(genJetsWithoutLeptonsP4.size()<2 && jetIdx < filGenJets.size()) {
bool jetWhitoutLep = true;

const math::XYZTLorentzVector & p4J= (filGenJets[jetIdx])->p4();
for(unsigned int i = 0; i < filGenLep.size() && jetWhitoutLep; ++i) {
if(reco::deltaR2((filGenLep[i])->p4(), p4J) < deltaRJetLep*deltaRJetLep)
jetWhitoutLep = false;
}
if (jetWhitoutLep) genJetsWithoutLeptonsP4.push_back(p4J);
++jetIdx;
}

// Checking the invariant mass of the leading jets
if (genJetsWithoutLeptonsP4.size() < 2) return false;
float invMassLeadingJet = (genJetsWithoutLeptonsP4[0] + genJetsWithoutLeptonsP4[1]).M();
if ( invMassLeadingJet > minLeadingJetsInvMass && invMassLeadingJet < maxLeadingJetsInvMass) return true;
else return false;
}


for(unsigned a=0; a<filGenJets.size(); a++){
for(unsigned b=a+1; b<filGenJets.size(); b++){

Expand Down