CMS 3D CMS Logo

PFJetsMaxInvMassModule.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
6 
7 //
8 // class declaration
9 //
11  : pfJetSrc_(consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("PFJetSrc"))),
12  maxInvMassPairOnly_(iConfig.getParameter<bool>("maxInvMassPairOnly")),
13  removeMaxInvMassPair_(iConfig.getParameter<bool>("removeMaxInvMassPair")) {
14  produces<reco::PFJetCollection>();
15 }
17 
19  std::unique_ptr<reco::PFJetCollection> addPFJets(new reco::PFJetCollection);
20 
22  iEvent.getByToken(pfJetSrc_, jets);
23 
24  unsigned iCan = 0;
25  unsigned jCan = 0;
26  double mjj_max = 0;
27 
28  if (jets->size() > 1) {
29  for (unsigned i = 0; i < jets->size(); i++) {
30  for (unsigned j = i + 1; j < jets->size(); j++) {
31  double test = ((*jets)[i].p4() + (*jets)[j].p4()).M();
32  if (test > mjj_max) {
33  mjj_max = test;
34  iCan = i;
35  jCan = j;
36  }
37  }
38  }
39 
40  if (maxInvMassPairOnly_) {
41  addPFJets->push_back((*jets)[iCan]);
42  addPFJets->push_back((*jets)[jCan]);
43  } else if (removeMaxInvMassPair_) {
44  for (unsigned i = 0; i < jets->size(); i++) {
45  if (i != iCan && i != jCan)
46  addPFJets->push_back((*jets)[i]);
47  }
48  }
49  }
50 
51  iEvent.put(std::move(addPFJets));
52 }
53 
56  desc.add<edm::InputTag>("PFJetSrc", edm::InputTag(""))->setComment("Input collection of PFJets that pass a filter");
57  desc.add<bool>("maxInvMassPairOnly", true)->setComment("Add only max mjj pair");
58  desc.add<bool>("removeMaxInvMassPair", false)->setComment("Remove max mjj pair and keep all other jets");
59  descriptions.setComment(
60  "This module produces a collection of PFJets that are cross-cleaned with respect to PFTaus passing a HLT "
61  "filter.");
62  descriptions.add("PFJetsMaxInvMassModule", desc);
63 }
int iEvent
Definition: GenABIO.cc:224
void setComment(std::string const &value)
PFJetsMaxInvMassModule(const edm::ParameterSet &)
const edm::EDGetTokenT< reco::PFJetCollection > pfJetSrc_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511