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 }
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
PFJetsMaxInvMassModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFJetsMaxInvMassModule.cc:54
edm
HLT enums.
Definition: AlignableModifier.h:19
PFJetsMaxInvMassModule::maxInvMassPairOnly_
bool maxInvMassPairOnly_
Definition: PFJetsMaxInvMassModule.h:23
PFJetsMaxInvMassModule::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PFJetsMaxInvMassModule.cc:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TriggerTypeDefs.h
PtComparator.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle< reco::PFJetCollection >
PFJetsMaxInvMassModule.h
EDMException.h
test
Definition: SmallWORMDict.h:13
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
PFJetsMaxInvMassModule::removeMaxInvMassPair_
bool removeMaxInvMassPair_
Definition: PFJetsMaxInvMassModule.h:24
edm::ParameterSet
Definition: ParameterSet.h:47
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
PFJetsMaxInvMassModule::PFJetsMaxInvMassModule
PFJetsMaxInvMassModule(const edm::ParameterSet &)
Definition: PFJetsMaxInvMassModule.cc:10
PFJetsMaxInvMassModule::pfJetSrc_
const edm::EDGetTokenT< reco::PFJetCollection > pfJetSrc_
Definition: PFJetsMaxInvMassModule.h:22
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PFJetsMaxInvMassModule::~PFJetsMaxInvMassModule
~PFJetsMaxInvMassModule() override
Definition: PFJetsMaxInvMassModule.cc:16
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15