File indexing completed on 2023-03-17 11:09:34
0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002 #include "HLTrigger/JetMET/interface/HLTHemiDPhiFilter.h"
0003
0004 #include "DataFormats/Common/interface/Handle.h"
0005
0006 #include "DataFormats/Common/interface/Ref.h"
0007 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0008 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0009
0010 #include "DataFormats/JetReco/interface/CaloJet.h"
0011 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0012
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015
0016 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0018 #include "FWCore/Utilities/interface/InputTag.h"
0019
0020
0021
0022
0023 HLTHemiDPhiFilter::HLTHemiDPhiFilter(const edm::ParameterSet& iConfig)
0024 : HLTFilter(iConfig),
0025 inputTag_(iConfig.getParameter<edm::InputTag>("inputTag")),
0026 min_dphi_(iConfig.getParameter<double>("minDPhi")),
0027 accept_NJ_(iConfig.getParameter<bool>("acceptNJ"))
0028
0029 {
0030 m_theHemiToken = consumes<std::vector<math::XYZTLorentzVector>>(inputTag_);
0031 LogDebug("") << "Inputs/minDphi/acceptNJ : " << inputTag_.encode() << " " << min_dphi_ << " " << accept_NJ_ << ".";
0032 }
0033
0034 HLTHemiDPhiFilter::~HLTHemiDPhiFilter() = default;
0035
0036 void HLTHemiDPhiFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0037 edm::ParameterSetDescription desc;
0038 makeHLTFilterDescription(desc);
0039 desc.add<edm::InputTag>("inputTag", edm::InputTag("hltRHemisphere"));
0040 desc.add<double>("minDPhi", 2.9415);
0041 desc.add<bool>("acceptNJ", true);
0042 descriptions.add("hltHemiDPhiFilter", desc);
0043 }
0044
0045
0046
0047
0048
0049
0050 bool HLTHemiDPhiFilter::hltFilter(edm::Event& iEvent,
0051 const edm::EventSetup& iSetup,
0052 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0053 using namespace std;
0054 using namespace edm;
0055 using namespace reco;
0056 using namespace trigger;
0057
0058
0059 Handle<vector<math::XYZTLorentzVector>> hemispheres;
0060 iEvent.getByToken(m_theHemiToken, hemispheres);
0061
0062
0063 if (not hemispheres.isValid())
0064 return false;
0065
0066 if (hemispheres
0067 ->empty()) {
0068 return accept_NJ_;
0069 }
0070
0071
0072
0073
0074 TLorentzVector j1R(hemispheres->at(0).x(), hemispheres->at(0).y(), hemispheres->at(0).z(), hemispheres->at(0).t());
0075 TLorentzVector j2R(hemispheres->at(1).x(), hemispheres->at(1).y(), hemispheres->at(1).z(), hemispheres->at(1).t());
0076
0077
0078 double dphi = 50.;
0079 dphi = deltaPhi(j1R.Phi(), j2R.Phi());
0080
0081
0082
0083 if (dphi <= min_dphi_)
0084 return true;
0085
0086
0087 return false;
0088 }
0089
0090 double HLTHemiDPhiFilter::deltaPhi(double v1, double v2) {
0091
0092
0093 double diff = std::abs(v2 - v1);
0094 return (diff < M_PI) ? diff : 2 * M_PI - diff;
0095 }