CMS 3D CMS Logo

BadPFCandidateJetsEEnoiseProducer.cc
Go to the documentation of this file.
1 #include <string>
2 #include <memory>
3 
9 
14 
21 
22 namespace pat {
24  public:
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
29 
30  private:
32  double ptThreshold_;
35  bool userawPt_;
36  };
37 } // namespace pat
38 
40  : jetsrc_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("jetsrc"))),
41  ptThreshold_(iConfig.getParameter<double>("ptThreshold")),
42  minEtaThreshold_(iConfig.getParameter<double>("minEtaThreshold")),
43  maxEtaThreshold_(iConfig.getParameter<double>("maxEtaThreshold")),
44  userawPt_(iConfig.getParameter<bool>("userawPt")) {
45  produces<std::vector<pat::Jet>>("good");
46  produces<std::vector<pat::Jet>>("bad");
47 }
48 
50 
53  const edm::EventSetup& iSetup) const {
54  auto goodJets = std::make_unique<std::vector<pat::Jet>>();
55  auto badJets = std::make_unique<std::vector<pat::Jet>>();
56 
57  edm::Handle<edm::View<pat::Jet>> jetcandidates;
58  iEvent.getByToken(jetsrc_, jetcandidates);
59 
60  int njets = jetcandidates->size();
61 
62  // find the bad jets
63  for (int jetindex = 0; jetindex < njets; ++jetindex) {
64  edm::Ptr<pat::Jet> candjet = jetcandidates->ptrAt(jetindex);
65 
66  // Corrected Pt or Uncorrected Pt (It is defined from cfi file)
67  double ptJet = userawPt_ ? candjet->correctedJet("Uncorrected").pt() : candjet->pt();
68  double absEtaJet = std::abs(candjet->eta());
69 
70  if (ptJet > ptThreshold_ || absEtaJet < minEtaThreshold_ || absEtaJet > maxEtaThreshold_) {
71  // save good jets
72  goodJets->emplace_back(candjet);
73  } else {
74  // save bad jets
75  badJets->emplace_back(candjet);
76  }
77  }
78  iEvent.put(std::move(goodJets), "good");
79  iEvent.put(std::move(badJets), "bad");
80 }
81 
84  desc.add<edm::InputTag>("jetsrc", edm::InputTag("slimmedJets"));
85  desc.add<bool>("userawPt", true);
86  desc.add<double>("ptThreshold", 50.0);
87  desc.add<double>("minEtaThreshold", 2.65);
88  desc.add<double>("maxEtaThreshold", 3.139);
89 
90  descriptions.add("BadPFCandidateJetsEEnoiseProducer", desc);
91 }
92 
94 
double pt() const final
transverse momentum
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
Definition: Jet.py:1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::View< pat::Jet > > jetsrc_
double eta() const final
momentum pseudorapidity