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
New HLT jet ptave filter allowing to specify eta ranges for tagging/probeing jet #5527
Merged
ktf
merged 7 commits into
cms-sw:CMSSW_7_3_X
from
fruboes:HLTPFJetAveFilterWithEtaRanges
Sep 25, 2014
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a786461
New HLTDiJetAveEtaFilter filter
fruboes 6c0770d
Fixes after testing
fruboes 53d5146
Clean out couts
fruboes 11aa587
Rewrite in more efficienct way
fruboes 2db75f5
Add missing pt and eta checks for probe jet
fruboes e1f57a1
Fix inner loop
fruboes 9e90a07
Switch tag/probe loops
fruboes File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef HLTDiJetAveEtaFilter_h | ||
#define HLTDiJetAveEtaFilter_h | ||
|
||
/** \class HLTDiJetAveEtaFilter | ||
* | ||
* \author Tomasz Fruboes | ||
* based on HLTDiJetAveFilter | ||
*/ | ||
|
||
#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h" | ||
#include "HLTrigger/HLTcore/interface/HLTFilter.h" | ||
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h" | ||
|
||
namespace edm { | ||
class ConfigurationDescriptions; | ||
} | ||
|
||
// | ||
// class declaration | ||
// | ||
|
||
template<typename T> | ||
class HLTDiJetAveEtaFilter : public HLTFilter { | ||
|
||
public: | ||
explicit HLTDiJetAveEtaFilter(const edm::ParameterSet&); | ||
~HLTDiJetAveEtaFilter(); | ||
static void fillDescriptions(edm::ConfigurationDescriptions & descriptions); | ||
virtual bool hltFilter(edm::Event&, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override; | ||
|
||
private: | ||
edm::EDGetTokenT<std::vector<T>> m_theJetToken; | ||
edm::InputTag inputJetTag_; // input tag identifying jets | ||
double minPtJet_; | ||
double minPtAve_; | ||
//double minPtJet3_; | ||
double minDphi_; | ||
double tagEtaMin_; | ||
double tagEtaMax_; | ||
double probeEtaMin_; | ||
double probeEtaMax_; | ||
int triggerType_; | ||
}; | ||
|
||
#endif //HLTDiJetAveEtaFilter_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/** \class HLTDiJetAveEtaFilter | ||
* | ||
* | ||
* \author Tomasz Fruboes | ||
* based on HLTDiJetAveFilter | ||
*/ | ||
|
||
#include "HLTrigger/JetMET/interface/HLTDiJetAveEtaFilter.h" | ||
|
||
#include "DataFormats/Common/interface/Ref.h" | ||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/Math/interface/deltaPhi.h" | ||
|
||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
|
||
#include<typeinfo> | ||
|
||
// | ||
// constructors and destructor | ||
// | ||
template<typename T> | ||
HLTDiJetAveEtaFilter<T>::HLTDiJetAveEtaFilter(const edm::ParameterSet& iConfig) : HLTFilter(iConfig), | ||
inputJetTag_ (iConfig.template getParameter< edm::InputTag > ("inputJetTag")), | ||
minPtJet_ (iConfig.template getParameter<double> ("minPtJet")), | ||
minPtAve_ (iConfig.template getParameter<double> ("minPtAve")), | ||
//minPtJet3_ (iConfig.template getParameter<double> ("minPtJet3")), | ||
minDphi_ (iConfig.template getParameter<double> ("minDphi")), | ||
tagEtaMin_ (iConfig.template getParameter<double> ("minTagEta")), | ||
tagEtaMax_ (iConfig.template getParameter<double> ("maxTagEta")), | ||
probeEtaMin_ (iConfig.template getParameter<double> ("minProbeEta")), | ||
probeEtaMax_ (iConfig.template getParameter<double> ("maxProbeEta")), | ||
triggerType_ (iConfig.template getParameter<int> ("triggerType")) | ||
{ | ||
m_theJetToken = consumes<std::vector<T>>(inputJetTag_); | ||
LogDebug("") << "HLTDiJetAveEtaFilter: Input/minPtAve/minDphi/triggerType : " | ||
<< inputJetTag_.encode() << " " | ||
<< minPtAve_ << " " | ||
//<< minPtJet3_ << " " | ||
<< minDphi_ << " " | ||
<< triggerType_; | ||
} | ||
|
||
template<typename T> | ||
HLTDiJetAveEtaFilter<T>::~HLTDiJetAveEtaFilter(){} | ||
|
||
template<typename T> | ||
void | ||
HLTDiJetAveEtaFilter<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
makeHLTFilterDescription(desc); | ||
desc.add<edm::InputTag>("inputJetTag",edm::InputTag("hltIterativeCone5CaloJets")); | ||
desc.add<double>("minPtAve",100.0); | ||
desc.add<double>("minPtJet",50.0); | ||
//desc.add<double>("minPtJet3",99999.0); | ||
desc.add<double>("minDphi",-1.0); | ||
desc.add<double>("minTagEta", -1.); | ||
desc.add<double>("maxTagEta", 1.4); | ||
desc.add<double>("minProbeEta", 2.7); | ||
desc.add<double>("maxProbeEta", 5.5); | ||
desc.add<int>("triggerType",trigger::TriggerJet); | ||
descriptions.add(std::string("hlt")+std::string(typeid(HLTDiJetAveEtaFilter<T>).name()),desc); | ||
} | ||
|
||
// ------------ method called to produce the data ------------ | ||
template<typename T> | ||
bool | ||
HLTDiJetAveEtaFilter<T>::hltFilter(edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs & filterproduct) const | ||
{ | ||
using namespace std; | ||
using namespace edm; | ||
using namespace reco; | ||
using namespace trigger; | ||
|
||
typedef vector<T> TCollection; | ||
typedef Ref<TCollection> TRef; | ||
|
||
// The filter object | ||
if (saveTags()) filterproduct.addCollectionTag(inputJetTag_); | ||
|
||
// get hold of collection of objects | ||
Handle<TCollection> objects; | ||
iEvent.getByToken (m_theJetToken,objects); | ||
|
||
// look at all candidates, check cuts and add to filter object | ||
int n(0); | ||
|
||
//std::cout << "--- " << minPtJet_ << std::endl; | ||
if(objects->size() > 1){ // events with two or more jets | ||
std::map<int, TRef > tags; // since eta ranges can overlap | ||
std::map<int, TRef > probes; | ||
typename TCollection::const_iterator i ( objects->begin() ); | ||
typename TCollection::const_iterator iEnd ( objects->end() ); | ||
int cnt = 0; | ||
for (; i!=iEnd; ++i) { | ||
++cnt; | ||
|
||
if (i->pt() < minPtJet_) continue; | ||
float eta = std::abs(i->eta()); | ||
bool isGood = false; | ||
if ( eta > tagEtaMin_ && eta < tagEtaMax_ ){ | ||
//std::cout << "Tag: " << cnt << " " << eta << " " << i->pt() << " " << i->phi() << std::endl; | ||
tags[cnt] = TRef(objects,distance(objects->begin(),i)); | ||
isGood = true; | ||
} | ||
if ( eta > probeEtaMin_ && eta < probeEtaMax_ ){ | ||
//std::cout << "Probe: " << cnt << " " << eta << " " << i->pt() << " " << i->phi() << std::endl; | ||
probes[cnt] = TRef(objects,distance(objects->begin(),i)); | ||
isGood = true; | ||
} | ||
if (isGood){ // for easier efficiency evaluation | ||
filterproduct.addObject(triggerType_, TRef(objects,distance(objects->begin(),i))); | ||
} | ||
} | ||
if (probes.size() == 0) return false; | ||
|
||
typename std::map<int, TRef >::const_iterator iTag = tags.begin(); | ||
typename std::map<int, TRef >::const_iterator iTagE = tags.end(); | ||
typename std::map<int, TRef >::const_iterator iProbe = probes.begin(); | ||
typename std::map<int, TRef >::const_iterator iProbeE = probes.end(); | ||
//std::cout <<"Tags: " << tags.size() << std::endl; | ||
//std::cout <<"Probes: " << probes.size() << std::endl; | ||
for(;iTag != iTagE; ++iTag){ | ||
iProbe = probes.begin(); | ||
//std::cout << "With tag " << iTag -> first << std::endl; | ||
for(;iProbe != iProbeE; ++iProbe){ | ||
//std::cout << "C " << iTag->first << " " << iProbe->first << std::endl; | ||
|
||
if (iTag->first == iProbe->first) { | ||
//std::cout << "Skip same\n" ; | ||
continue; // not the same jet | ||
} | ||
double dphi = std::abs(deltaPhi(iTag->second->phi(),iProbe->second->phi() )); | ||
if (dphi<minDphi_) { | ||
//std::cout << "skip dphi " << dphi << " < " << minDphi_ << std::endl; | ||
continue; | ||
} | ||
double ptAve = (iTag->second->pt() + iProbe->second->pt())/2; | ||
if (ptAve<minPtAve_ ) { | ||
//std::cout << "skip ave " << ptAve << " < " << minPtAve_ << std::endl; | ||
continue; | ||
} | ||
//std::cout << "Good: " << ptAve << " " << dphi << std::endl; | ||
//std::cout << " Tag: " << iTag->second->eta() << " " << iTag->second->pt() << std::endl; | ||
//std::cout << " Probe: " << iProbe->second->eta() << " " << iProbe->second->pt() << std::endl; | ||
//filterproduct.addObject(triggerType_, iTag->second); | ||
//filterproduct.addObject(triggerType_, iProbe->second); | ||
++n; | ||
} | ||
} | ||
} // events with two or more jets | ||
// filter decision | ||
bool accept(n>=1); | ||
//std::cout << "ACC: " << accept << std::endl; | ||
return accept; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that you want to comment out this line, and the following one?
May I suggest you to remove completely the other lines commented out with "cout" statements, clearly included for your debug while coding? They are so many in this code that they make difficult to read and follow the flow of the code (and one can then also comment out lines unwillingly, then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that you want to comment out this line, and the following one?
May I suggest you to remove completely the other lines commented out with "cout" statements, clearly included for your debug while coding? They are so many in this code that they make difficult to read and follow the flow of the code (and one can then also comment out lines unwillingly, then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the couts and updated the branch (BTW what is the procedure now - should I somehow update the pull request?).
When it comes to saving into filterproduct - it is present in the first loop (line 117, or 114 after cout cleaning), the idea here is to make the trigger efficiency (as a function of jet pt and eta) evaluation easier. Is this acceptable?