File indexing completed on 2023-03-17 10:54:06
0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002
0003 #include "DataFormats/Common/interface/Handle.h"
0004
0005 #include "DataFormats/JetReco/interface/CaloJet.h"
0006 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
0007
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010
0011 #include "FWCore/Utilities/interface/InputTag.h"
0012
0013 #include "DQM/DataScouting/interface/DiJetVarProducer.h"
0014
0015 #include "TLorentzVector.h"
0016 #include "TVector3.h"
0017
0018 #include <memory>
0019 #include <vector>
0020
0021
0022
0023
0024 DiJetVarProducer::DiJetVarProducer(const edm::ParameterSet &iConfig)
0025 : inputJetTag_(iConfig.getParameter<edm::InputTag>("inputJetTag")),
0026 wideJetDeltaR_(iConfig.getParameter<double>("wideJetDeltaR")) {
0027
0028
0029 produces<std::vector<math::PtEtaPhiMLorentzVector>>("widejets");
0030
0031
0032 inputJetTagToken_ = consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("inputJetTag"));
0033
0034 LogDebug("") << "Input Jet Tag: " << inputJetTag_.encode() << " ";
0035 LogDebug("") << "Radius Parameter Wide Jet: " << wideJetDeltaR_ << ".";
0036 }
0037
0038
0039 void DiJetVarProducer::produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
0040 using namespace std;
0041 using namespace edm;
0042 using namespace reco;
0043
0044
0045
0046
0047 std::unique_ptr<std::vector<math::PtEtaPhiMLorentzVector>> widejets(new std::vector<math::PtEtaPhiMLorentzVector>);
0048
0049
0050 edm::Handle<reco::CaloJetCollection> calojets_handle;
0051 iEvent.getByToken(inputJetTagToken_, calojets_handle);
0052
0053
0054
0055
0056 if (calojets_handle->size() >= 2) {
0057 TLorentzVector wj1_tmp;
0058 TLorentzVector wj2_tmp;
0059 TLorentzVector wj1;
0060 TLorentzVector wj2;
0061 TLorentzVector wdijet;
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 TLorentzVector jet1, jet2;
0073
0074 reco::CaloJetCollection::const_iterator j1 = calojets_handle->begin();
0075 reco::CaloJetCollection::const_iterator j2 = j1;
0076 ++j2;
0077
0078 jet1.SetPtEtaPhiM(j1->pt(), j1->eta(), j1->phi(), j1->mass());
0079 jet2.SetPtEtaPhiM(j2->pt(), j2->eta(), j2->phi(), j2->mass());
0080
0081
0082
0083
0084
0085
0086 for (reco::CaloJetCollection::const_iterator it = calojets_handle->begin(); it != calojets_handle->end(); ++it) {
0087 TLorentzVector currentJet;
0088 currentJet.SetPtEtaPhiM(it->pt(), it->eta(), it->phi(), it->mass());
0089
0090 double DeltaR1 = currentJet.DeltaR(jet1);
0091 double DeltaR2 = currentJet.DeltaR(jet2);
0092
0093 if (DeltaR1 < DeltaR2 && DeltaR1 < wideJetDeltaR_) {
0094 wj1_tmp += currentJet;
0095 } else if (DeltaR2 < wideJetDeltaR_) {
0096 wj2_tmp += currentJet;
0097 }
0098 }
0099
0100
0101 if (wj1_tmp.Pt() > wj2_tmp.Pt()) {
0102 wj1 = wj1_tmp;
0103 wj2 = wj2_tmp;
0104 } else {
0105 wj1 = wj2_tmp;
0106 wj2 = wj1_tmp;
0107 }
0108
0109
0110 wdijet = wj1 + wj2;
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 math::PtEtaPhiMLorentzVector wj1math(wj1.Pt(), wj1.Eta(), wj1.Phi(), wj1.M());
0127 math::PtEtaPhiMLorentzVector wj2math(wj2.Pt(), wj2.Eta(), wj2.Phi(), wj2.M());
0128 widejets->push_back(wj1math);
0129 widejets->push_back(wj2math);
0130 }
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 iEvent.put(std::move(widejets), "widejets");
0142 }
0143
0144 DEFINE_FWK_MODULE(DiJetVarProducer);