File indexing completed on 2024-04-06 12:18:33
0001
0002
0003
0004
0005
0006
0007
0008 #include <string>
0009 #include <vector>
0010
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017 #include "DataFormats/Common/interface/Handle.h"
0018 #include "DataFormats/Math/interface/deltaPhi.h"
0019 #include "HLTrigger/JetMET/interface/HLTJetCollectionsFilter.h"
0020 #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h"
0021
0022
0023
0024
0025 template <typename jetType>
0026 HLTJetCollectionsFilter<jetType>::HLTJetCollectionsFilter(const edm::ParameterSet& iConfig)
0027 : HLTFilter(iConfig),
0028 inputTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
0029 originalTag_(iConfig.getParameter<edm::InputTag>("originalTag")),
0030 minJetPt_(iConfig.getParameter<double>("MinJetPt")),
0031 maxAbsJetEta_(iConfig.getParameter<double>("MaxAbsJetEta")),
0032 minNJets_(iConfig.getParameter<unsigned int>("MinNJets")),
0033 triggerType_(iConfig.getParameter<int>("triggerType")) {
0034 typedef std::vector<
0035 edm::RefVector<std::vector<jetType>, jetType, edm::refhelper::FindUsingAdvance<std::vector<jetType>, jetType>>>
0036 JetCollectionVector;
0037 m_theJetToken = consumes<JetCollectionVector>(inputTag_);
0038 }
0039
0040 template <typename jetType>
0041 HLTJetCollectionsFilter<jetType>::~HLTJetCollectionsFilter() = default;
0042
0043 template <typename jetType>
0044 void HLTJetCollectionsFilter<jetType>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0045 edm::ParameterSetDescription desc;
0046 makeHLTFilterDescription(desc);
0047 desc.add<edm::InputTag>("inputTag", edm::InputTag("hltIterativeCone5CaloJets"));
0048 desc.add<edm::InputTag>("originalTag", edm::InputTag("hltIterativeCone5CaloJets"));
0049 desc.add<double>("MinJetPt", 30.0);
0050 desc.add<double>("MaxAbsJetEta", 2.6);
0051 desc.add<unsigned int>("MinNJets", 1);
0052 desc.add<int>("triggerType", trigger::TriggerJet);
0053 descriptions.add(defaultModuleLabel<HLTJetCollectionsFilter<jetType>>(), desc);
0054 }
0055
0056
0057 template <typename jetType>
0058 bool HLTJetCollectionsFilter<jetType>::hltFilter(edm::Event& iEvent,
0059 const edm::EventSetup& iSetup,
0060 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0061 using namespace std;
0062 using namespace edm;
0063 using namespace reco;
0064 using namespace trigger;
0065
0066 typedef vector<RefVector<vector<jetType>, jetType, refhelper::FindUsingAdvance<vector<jetType>, jetType>>>
0067 JetCollectionVector;
0068 typedef vector<jetType> JetCollection;
0069 typedef edm::RefVector<JetCollection> JetRefVector;
0070 typedef edm::Ref<JetCollection> JetRef;
0071
0072
0073 if (saveTags())
0074 filterproduct.addCollectionTag(originalTag_);
0075
0076 Handle<JetCollectionVector> theJetCollectionsHandle;
0077 iEvent.getByToken(m_theJetToken, theJetCollectionsHandle);
0078 const JetCollectionVector& theJetCollections = *theJetCollectionsHandle;
0079
0080
0081 bool accept(false);
0082 std::set<JetRef> goodJetRefs;
0083
0084 for (unsigned int collection = 0; collection < theJetCollections.size(); ++collection) {
0085 unsigned int numberOfGoodJets(0);
0086 const JetRefVector& refVector = theJetCollections[collection];
0087
0088 typename JetRefVector::const_iterator jet(refVector.begin());
0089 for (; jet != refVector.end(); jet++) {
0090 JetRef jetRef(*jet);
0091 if (jetRef->pt() >= minJetPt_ && std::abs(jetRef->eta()) <= maxAbsJetEta_) {
0092 numberOfGoodJets++;
0093 goodJetRefs.insert(jetRef);
0094 }
0095 }
0096
0097 if (numberOfGoodJets >= minNJets_) {
0098 accept = true;
0099
0100 }
0101 }
0102
0103
0104 for (typename std::set<JetRef>::const_iterator ref = goodJetRefs.begin(); ref != goodJetRefs.end(); ++ref) {
0105 filterproduct.addObject(triggerType_, *ref);
0106 }
0107
0108 return accept;
0109 }