22 #ifndef RecoTauTag_HLTProducers_L1TJetsMatching_h 23 #define RecoTauTag_HLTProducers_L1TJetsMatching_h 38 #include "Math/GenVector/VectorUtil.h" 58 std::pair<std::vector<T>, std::vector<T>>
categorise(
59 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const;
61 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const;
79 const std::vector<T>& pfMatchedJets,
double pt1,
double pt2,
double pt3,
double Mjj)
const {
80 std::pair<std::vector<T>, std::vector<T>>
output;
84 if (pfMatchedJets.size() > 1) {
85 for (
unsigned int i = 0;
i < pfMatchedJets.size() - 1;
i++) {
86 const T& myJet1 = (pfMatchedJets)[
i];
88 for (
unsigned int j =
i + 1;
j < pfMatchedJets.size();
j++) {
89 const T& myJet2 = (pfMatchedJets)[
j];
91 const double mjj_test = (myJet1.p4() + myJet2.p4()).M();
101 const T& myJet1 = (pfMatchedJets)[
i1];
102 const T& myJet2 = (pfMatchedJets)[
i2];
104 if ((mjj > Mjj) && (myJet1.pt() >=
pt1) && (myJet2.pt() >
pt2)) {
105 output.first.push_back(myJet1);
106 output.first.push_back(myJet2);
109 if ((mjj > Mjj) && (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 mjj_test = (myJet1.p4() + myJet2.p4()).M();
138 if (mjj_test > mjj) {
146 const T& myJet1 = (pfMatchedJets)[
i1];
147 const T& myJet2 = (pfMatchedJets)[
i2];
149 std::vector<T> vec4jets;
151 std::vector<T> vec5jets;
153 std::vector<T> vec6jets;
155 if (pfMatchedJets.size() > 3) {
156 if ((mjj > Mjj) && (myJet1.pt() >= pt3) && (myJet2.pt() >
pt2)) {
157 vec4jets.push_back(myJet1);
158 vec4jets.push_back(myJet2);
160 for (
unsigned int i = 0;
i < pfMatchedJets.size();
i++) {
161 if (vec4jets.size() > 3)
165 vec4jets.push_back(pfMatchedJets[
i]);
169 if ((mjj > Mjj) && (myJet1.pt() <
pt1) && (myJet1.pt() < pt3) && (myJet1.pt() >
pt2) &&
170 (myJet2.pt() >
pt2)) {
172 std::vector<unsigned int> idx_jets;
173 idx_jets.reserve(pfMatchedJets.size() - 2);
175 for (
unsigned int i = 0;
i < pfMatchedJets.size();
i++) {
178 if (pfMatchedJets[
i].
pt() >
pt2) {
179 idx_jets.push_back(
i);
182 if (idx_jets.size() == 3) {
183 vec5jets.push_back(myJet1);
184 vec5jets.push_back(myJet2);
185 vec5jets.push_back(pfMatchedJets[idx_jets[0]]);
186 vec5jets.push_back(pfMatchedJets[idx_jets[1]]);
187 vec5jets.push_back(pfMatchedJets[idx_jets[2]]);
189 }
else if (idx_jets.size() > 3) {
190 vec6jets.push_back(myJet1);
191 vec6jets.push_back(myJet2);
192 vec6jets.push_back(pfMatchedJets[idx_jets[0]]);
193 vec6jets.push_back(pfMatchedJets[idx_jets[1]]);
194 vec6jets.push_back(pfMatchedJets[idx_jets[2]]);
195 vec6jets.push_back(pfMatchedJets[idx_jets[3]]);
200 output = std::make_tuple(vec4jets, vec5jets, vec6jets);
206 template <
typename T>
209 jetTrigger_(consumes<
trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<
edm::
InputTag>(
"L1JetTrigger"))),
210 matchingMode_(iConfig.getParameter<
std::
string>(
"matchingMode")),
211 pt1Min_(iConfig.getParameter<double>(
"pt1Min")),
212 pt2Min_(iConfig.getParameter<double>(
"pt2Min")),
213 pt3Min_(iConfig.getParameter<double>(
"pt3Min")),
214 mjjMin_(iConfig.getParameter<double>(
"mjjMin")),
215 matchingR_(iConfig.getParameter<double>(
"matchingR")),
216 matchingR2_(matchingR_ * 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\")";
229 template <
typename T>
232 template <
typename T>
234 unique_ptr<std::vector<T>> pfMatchedJets(
new std::vector<T>);
241 iEvent.getByToken(jetTrigger_, l1TriggeredJets);
250 for (
unsigned int iJet = 0; iJet <
pfJets->size(); iJet++) {
251 const T& myJet = (*pfJets)[iJet];
252 for (
unsigned int iL1Jet = 0; iL1Jet < jetCandRefVec.size(); iL1Jet++) {
255 if ((
reco::deltaR2(myJet.p4(), jetCandRefVec[iL1Jet]->p4()) < matchingR2_) && (myJet.pt() > pt2Min_)) {
256 pfMatchedJets->push_back(myJet);
262 std::sort(pfMatchedJets->begin(), pfMatchedJets->end(), [](
const T& j1,
const T& j2) {
return j1.pt() > j2.pt(); });
264 if (matchingMode_ ==
"VBF") {
265 std::pair<std::vector<T>, std::vector<T>>
output = categorise(*pfMatchedJets, pt1Min_, pt2Min_, pt3Min_, mjjMin_);
266 auto output1 = std::make_unique<std::vector<T>>(
output.first);
267 auto output2 = std::make_unique<std::vector<T>>(
output.second);
272 }
else if (matchingMode_ ==
"VBFPlus2CentralJets") {
273 std::tuple<std::vector<T>, std::vector<T>, std::vector<T>>
output =
274 categoriseVBFPlus2CentralJets(*pfMatchedJets, pt1Min_, pt2Min_, pt3Min_, mjjMin_);
275 auto output1 = std::make_unique<std::vector<T>>(std::get<0>(
output));
276 auto output2 = std::make_unique<std::vector<T>>(std::get<1>(
output));
277 auto output3 = std::make_unique<std::vector<T>>(std::get<2>(
output));
285 template <
typename T>
290 ->setComment(
"Input collection of PFJets");
292 ->setComment(
"Switch from Di/tri-jet (VBF) to Multi-jet (VBFPlus2CentralJets) matching");
293 desc.add<
double>(
"pt1Min", 110.0)->setComment(
"Minimal pT1 of PFJets to match");
294 desc.add<
double>(
"pt2Min", 35.0)->setComment(
"Minimal pT2 of PFJets to match");
295 desc.add<
double>(
"pt3Min", 110.0)->setComment(
"Minimum pT3 of PFJets to match");
296 desc.add<
double>(
"mjjMin", 650.0)->setComment(
"Minimal mjj of matched PFjets");
297 desc.add<
double>(
"matchingR", 0.5)->setComment(
"dR value used for matching");
299 "This module produces collection of PFJets matched to L1 Taus / Jets passing a HLT filter (Only p4 and vertex " 300 "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
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_