22 #ifndef RecoTauTag_HLTProducers_L1TJetsMatching_h 23 #define RecoTauTag_HLTProducers_L1TJetsMatching_h 38 #include "Math/GenVector/VectorUtil.h" 60 std::pair<std::vector<T>, std::vector<T>>
categorise(
61 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const;
63 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const;
78 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const {
79 std::pair<std::vector<T>, std::vector<T>>
output;
83 if (pfMatchedJets.size() > 1) {
84 for (
unsigned int i = 0;
i < pfMatchedJets.size() - 1;
i++) {
85 const T& myJet1 = (pfMatchedJets)[
i];
87 for (
unsigned int j =
i + 1;
j < pfMatchedJets.size();
j++) {
88 const T& myJet2 = (pfMatchedJets)[
j];
90 const double m2jj_test = (myJet1.p4() + myJet2.p4()).M2();
92 if (m2jj_test > m2jj) {
100 const T& myJet1 = (pfMatchedJets)[
i1];
101 const T& myJet2 = (pfMatchedJets)[
i2];
102 const double M2jj = (Mjj >= 0. ? Mjj * Mjj : -1.);
104 if ((m2jj > M2jj) && (myJet1.pt() >=
pt1) && (myJet2.pt() >
pt2)) {
105 output.first.push_back(myJet1);
106 output.first.push_back(myJet2);
109 if ((m2jj > M2jj) && (myJet1.pt() < pt3) && (myJet1.pt() >
pt2) && (myJet2.pt() >
pt2)) {
110 const T& myJetTest = (pfMatchedJets)[0];
111 if (myJetTest.pt() > pt3) {
112 output.second.push_back(myJet1);
113 output.second.push_back(myJet2);
114 output.second.push_back(myJetTest);
121 template <
typename T>
123 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const {
124 std::tuple<std::vector<T>, std::vector<T>, std::vector<T>>
output;
129 if (pfMatchedJets.size() > 1) {
130 for (
unsigned int i = 0;
i < pfMatchedJets.size() - 1;
i++) {
131 const T& myJet1 = (pfMatchedJets)[
i];
133 for (
unsigned int j =
i + 1;
j < pfMatchedJets.size();
j++) {
134 const T& myJet2 = (pfMatchedJets)[
j];
136 const double m2jj_test = (myJet1.p4() + myJet2.p4()).M2();
138 if (m2jj_test > m2jj) {
146 const T& myJet1 = (pfMatchedJets)[
i1];
147 const T& myJet2 = (pfMatchedJets)[
i2];
148 const double M2jj = (Mjj >= 0. ? Mjj * Mjj : -1.);
150 std::vector<T> vec4jets;
152 std::vector<T> vec5jets;
154 std::vector<T> vec6jets;
156 if (pfMatchedJets.size() > 3) {
157 if ((m2jj > M2jj) && (myJet1.pt() >= pt3) && (myJet2.pt() >
pt2)) {
158 vec4jets.push_back(myJet1);
159 vec4jets.push_back(myJet2);
161 for (
unsigned int i = 0;
i < pfMatchedJets.size();
i++) {
162 if (vec4jets.size() > 3)
166 vec4jets.push_back(pfMatchedJets[
i]);
170 if ((m2jj > M2jj) && (myJet1.pt() <
pt1) && (myJet1.pt() < pt3) && (myJet1.pt() >
pt2) &&
171 (myJet2.pt() >
pt2)) {
173 std::vector<unsigned int> idx_jets;
174 idx_jets.reserve(pfMatchedJets.size() - 2);
176 for (
unsigned int i = 0;
i < pfMatchedJets.size();
i++) {
179 if (pfMatchedJets[
i].
pt() >
pt2) {
180 idx_jets.push_back(
i);
183 if (idx_jets.size() == 3) {
184 vec5jets.push_back(myJet1);
185 vec5jets.push_back(myJet2);
186 vec5jets.push_back(pfMatchedJets[idx_jets[0]]);
187 vec5jets.push_back(pfMatchedJets[idx_jets[1]]);
188 vec5jets.push_back(pfMatchedJets[idx_jets[2]]);
190 }
else if (idx_jets.size() > 3) {
191 vec6jets.push_back(myJet1);
192 vec6jets.push_back(myJet2);
193 vec6jets.push_back(pfMatchedJets[idx_jets[0]]);
194 vec6jets.push_back(pfMatchedJets[idx_jets[1]]);
195 vec6jets.push_back(pfMatchedJets[idx_jets[2]]);
196 vec6jets.push_back(pfMatchedJets[idx_jets[3]]);
201 output = std::make_tuple(vec4jets, vec5jets, vec6jets);
207 template <
typename T>
210 jetTrigger_(consumes<
trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<
edm::
InputTag>(
"L1JetTrigger"))),
211 matchingMode_(iConfig.getParameter<
std::
string>(
"matchingMode")),
212 pt1Min_(iConfig.getParameter<double>(
"pt1Min")),
213 pt2Min_(iConfig.getParameter<double>(
"pt2Min")),
214 pt3Min_(iConfig.getParameter<double>(
"pt3Min")),
215 mjjMin_(iConfig.getParameter<double>(
"mjjMin")),
216 matchingR2_(iConfig.getParameter<double>(
"matchingR") * iConfig.getParameter<double>(
"matchingR")) {
218 produces<std::vector<T>>(
"TwoJets");
219 produces<std::vector<T>>(
"ThreeJets");
221 produces<std::vector<T>>(
"FourJets");
222 produces<std::vector<T>>(
"FiveJets");
223 produces<std::vector<T>>(
"SixJets");
226 <<
" (valid values are \"VBF\" and \"VBFPlus2CentralJets\")";
230 template <
typename T>
232 unique_ptr<std::vector<T>> pfMatchedJets(
new std::vector<T>);
239 iEvent.getByToken(jetTrigger_, l1TriggeredJets);
248 for (
unsigned int iJet = 0; iJet <
pfJets->size(); iJet++) {
249 const T& myJet = (*pfJets)[iJet];
250 for (
unsigned int iL1Jet = 0; iL1Jet < jetCandRefVec.size(); iL1Jet++) {
253 if ((
reco::deltaR2(myJet.p4(), jetCandRefVec[iL1Jet]->p4()) < matchingR2_) && (myJet.pt() > pt2Min_)) {
254 pfMatchedJets->push_back(myJet);
260 std::sort(pfMatchedJets->begin(), pfMatchedJets->end(), [](
const T& j1,
const T& j2) {
return j1.pt() > j2.pt(); });
262 if (matchingMode_ ==
"VBF") {
263 std::pair<std::vector<T>, std::vector<T>>
output = categorise(*pfMatchedJets, pt1Min_, pt2Min_, pt3Min_, mjjMin_);
264 auto output1 = std::make_unique<std::vector<T>>(
output.first);
265 auto output2 = std::make_unique<std::vector<T>>(
output.second);
270 }
else if (matchingMode_ ==
"VBFPlus2CentralJets") {
271 std::tuple<std::vector<T>, std::vector<T>, std::vector<T>>
output =
272 categoriseVBFPlus2CentralJets(*pfMatchedJets, pt1Min_, pt2Min_, pt3Min_, mjjMin_);
273 auto output1 = std::make_unique<std::vector<T>>(std::get<0>(
output));
274 auto output2 = std::make_unique<std::vector<T>>(std::get<1>(
output));
275 auto output3 = std::make_unique<std::vector<T>>(std::get<2>(
output));
283 template <
typename T>
288 ->setComment(
"Input collection of PFJets");
290 ->setComment(
"Switch from Di/tri-jet (VBF) to Multi-jet (VBFPlus2CentralJets) matching");
291 desc.add<
double>(
"pt1Min", 110.0)->setComment(
"Minimal pT1 of PFJets to match");
292 desc.add<
double>(
"pt2Min", 35.0)->setComment(
"Minimal pT2 of PFJets to match");
293 desc.add<
double>(
"pt3Min", 110.0)->setComment(
"Minimum pT3 of PFJets to match");
294 desc.add<
double>(
"mjjMin", 650.0)->setComment(
"Minimal mjj of matched PFjets");
295 desc.add<
double>(
"matchingR", 0.5)->setComment(
"dR value used for matching");
297 "This module produces collection of PFJets matched to L1 Taus / Jets passing a HLT filter (Only p4 and vertex " 298 "of returned PFJets are set).");
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
L1TJetsMatching(const edm::ParameterSet &)
std::pair< std::vector< T >, std::vector< T > > categorise(const std::vector< T > &pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const
std::string defaultModuleLabel()
const edm::EDGetTokenT< std::vector< T > > jetSrc_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
~L1TJetsMatching() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::tuple< std::vector< T >, std::vector< T >, std::vector< T > > categoriseVBFPlus2CentralJets(const std::vector< T > &pfMatchedJets, double pt1, double pt2, double pt3, double Mjj) const
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > jetTrigger_
void setComment(std::string const &value)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
XYZPointD XYZPoint
point in space with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< JetRef > JetVectorRef
const std::string matchingMode_