Skip to content

Commit

Permalink
Merge pull request #18997 from albertdow/FinalCrossCleaningModule
Browse files Browse the repository at this point in the history
adding a PFJets-Tau overlap removal module for HLT
  • Loading branch information
cmsbuild committed Jun 8, 2017
2 parents 76d3430 + 74b124e commit 3187cf6
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
33 changes: 33 additions & 0 deletions RecoTauTag/HLTProducers/interface/PFJetsTauOverlapRemoval.h
@@ -0,0 +1,33 @@
#ifndef RecoTauTag_HLTProducers_PFJetsTauOverlapRemoval_H
#define RecoTauTag_HLTProducers_PFJetsTauOverlapRemoval_H

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/TauReco/interface/PFTauFwd.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "DataFormats/HLTReco/interface/TriggerObject.h"
#include "DataFormats/HLTReco/interface/TriggerEvent.h"

class PFJetsTauOverlapRemoval: public edm::global::EDProducer<> {

private:
const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> tauSrc_;
const edm::EDGetTokenT<reco::PFJetCollection> pfJetSrc_;
const double matchingR2_;

public:
explicit PFJetsTauOverlapRemoval(const edm::ParameterSet&);
~PFJetsTauOverlapRemoval();
virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
};
#endif
58 changes: 58 additions & 0 deletions RecoTauTag/HLTProducers/src/PFJetsTauOverlapRemoval.cc
@@ -0,0 +1,58 @@
#include "RecoTauTag/HLTProducers/interface/PFJetsTauOverlapRemoval.h"
#include "Math/GenVector/VectorUtil.h"
#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "DataFormats/TauReco/interface/PFTau.h"
#include "DataFormats/Math/interface/deltaR.h"

//
// class declaration
//
PFJetsTauOverlapRemoval::PFJetsTauOverlapRemoval(const edm::ParameterSet& iConfig):
tauSrc_ ( consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<edm::InputTag>("TauSrc" ) ) ),
pfJetSrc_ ( consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("PFJetSrc") ) ),
matchingR2_ ( iConfig.getParameter<double>("Min_dR")*iConfig.getParameter<double>("Min_dR") )
{
produces<reco::PFJetCollection>();
}
PFJetsTauOverlapRemoval::~PFJetsTauOverlapRemoval(){ }

void PFJetsTauOverlapRemoval::produce(edm::StreamID iSId, edm::Event& iEvent, const edm::EventSetup& iES) const
{
std::unique_ptr<reco::PFJetCollection> cleanedPFJets(new reco::PFJetCollection);

edm::Handle<trigger::TriggerFilterObjectWithRefs> tauJets;
iEvent.getByToken(tauSrc_, tauJets);

edm::Handle<reco::PFJetCollection> PFJets;
iEvent.getByToken(pfJetSrc_,PFJets);

trigger::VRpftau taus;
tauJets->getObjects(trigger::TriggerTau,taus);

if(PFJets->size() > 1){
for(unsigned int iJet = 0; iJet < 2; iJet++){
bool isMatched = false;
const reco::PFJet & myPFJet = (*PFJets)[iJet];
for(unsigned int iTau = 0; iTau < taus.size(); iTau++){
if(reco::deltaR2(taus[iTau]->p4(), myPFJet.p4()) < matchingR2_){
isMatched = true;
break;
}
}
if(isMatched == false) cleanedPFJets->push_back(myPFJet);
}
if(PFJets->size() > 2) cleanedPFJets->push_back((*PFJets)[2]);
}
iEvent.put(std::move(cleanedPFJets));
}

void PFJetsTauOverlapRemoval::fillDescriptions(edm::ConfigurationDescriptions& descriptions)
{
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("PFJetSrc", edm::InputTag("hltAK4PFJetsCorrected"))->setComment("Input collection of PFJets" );
desc.add<edm::InputTag>("TauSrc", edm::InputTag("hltSinglePFTau20TrackPt1LooseChargedIsolationReg"))->setComment("Input collection of PFTaus that have passed ID and isolation requirements");
desc.add<double> ("Min_dR",0.5)->setComment("Minimum dR outside of which PFJets will be saved");
descriptions.setComment("This module produces a collection of PFJets that are cross-cleaned with respect to PFTaus passing a HLT filter.");
descriptions.add ("PFJetsTauOverlapRemoval",desc);
}
3 changes: 2 additions & 1 deletion RecoTauTag/HLTProducers/src/SealModule.cc
Expand Up @@ -19,6 +19,7 @@
//#include "RecoTauTag/HLTProducers/interface/L2TauPixelTrackMatch.h"
#include "HLTPFTauPairLeadTrackDzMatchFilter.h"
#include "RecoTauTag/HLTProducers/interface/L2TauPixelIsoTagProducer.h"
#include "RecoTauTag/HLTProducers/interface/PFJetsTauOverlapRemoval.h"

DEFINE_EDM_PLUGIN(TrackingRegionProducerFactory, TauRegionalPixelSeedGenerator, "TauRegionalPixelSeedGenerator");
DEFINE_EDM_PLUGIN(TrackingRegionProducerFactory, TrackingRegionsFromBeamSpotAndL2Tau, "TrackingRegionsFromBeamSpotAndL2Tau");
Expand All @@ -45,4 +46,4 @@ DEFINE_FWK_MODULE(VertexFromTrackProducer);
//DEFINE_FWK_MODULE(L2TauPixelTrackMatch);
DEFINE_FWK_MODULE(HLTPFTauPairLeadTrackDzMatchFilter);
DEFINE_FWK_MODULE(L2TauPixelIsoTagProducer);

DEFINE_FWK_MODULE(PFJetsTauOverlapRemoval);

0 comments on commit 3187cf6

Please sign in to comment.