CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int iEvent
Definition: GenABIO.cc:224
vector< PseudoJet > jets
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override