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 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
CompositeCandidate.h
sistrip::View
View
Definition: ConstantsForView.h:26
PFCandidate.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
pat::BadPFCandidateJetsEEnoiseProducer::ptThreshold_
double ptThreshold_
Definition: BadPFCandidateJetsEEnoiseProducer.cc:32
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
pat::BadPFCandidateJetsEEnoiseProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: BadPFCandidateJetsEEnoiseProducer.cc:51
LeafCandidate.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
pat::BadPFCandidateJetsEEnoiseProducer::BadPFCandidateJetsEEnoiseProducer
BadPFCandidateJetsEEnoiseProducer(const edm::ParameterSet &)
Definition: BadPFCandidateJetsEEnoiseProducer.cc:39
pat::BadPFCandidateJetsEEnoiseProducer
Definition: BadPFCandidateJetsEEnoiseProducer.cc:23
Event.h
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
iEvent
int iEvent
Definition: GenABIO.cc:224
RefToPtr.h
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
pat::BadPFCandidateJetsEEnoiseProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: BadPFCandidateJetsEEnoiseProducer.cc:82
Jet.h
edm::Ptr< pat::Jet >
ShallowCloneCandidate.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
pat::BadPFCandidateJetsEEnoiseProducer::~BadPFCandidateJetsEEnoiseProducer
~BadPFCandidateJetsEEnoiseProducer() override
Definition: BadPFCandidateJetsEEnoiseProducer.cc:49
BTaggingMonitoring_cff.njets
njets
Definition: BTaggingMonitoring_cff.py:10
Frameworkfwd.h
pat::BadPFCandidateJetsEEnoiseProducer::userawPt_
bool userawPt_
Definition: BadPFCandidateJetsEEnoiseProducer.cc:35
pat::BadPFCandidateJetsEEnoiseProducer::jetsrc_
edm::EDGetTokenT< edm::View< pat::Jet > > jetsrc_
Definition: BadPFCandidateJetsEEnoiseProducer.cc:31
Point3D.h
pat::Jet::correctedJet
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
pat::BadPFCandidateJetsEEnoiseProducer::maxEtaThreshold_
double maxEtaThreshold_
Definition: BadPFCandidateJetsEEnoiseProducer.cc:34
topObjectSelection_cff.goodJets
goodJets
Definition: topObjectSelection_cff.py:58
Candidate.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
pat::BadPFCandidateJetsEEnoiseProducer::minEtaThreshold_
double minEtaThreshold_
Definition: BadPFCandidateJetsEEnoiseProducer.cc:33
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
PFCandidateFwd.h