CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Analysis-level calorimeter jet class.
Definition: Jet.h:77
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::View< pat::Jet > > jetsrc_