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  private:
31  double ptThreshold_;
34  bool userawPt_;
35  };
36 }
37 
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 {
46 
47  produces<std::vector<pat::Jet>>("good");
48  produces<std::vector<pat::Jet>>("bad");
49 
50 }
51 
53 
55 
56  auto goodJets = std::make_unique<std::vector<pat::Jet>>();
57  auto badJets = std::make_unique<std::vector<pat::Jet>>();
58 
59  edm::Handle<edm::View<pat::Jet> > jetcandidates;
60  iEvent.getByToken(jetsrc_, jetcandidates);
61 
62  int njets = jetcandidates->size();
63 
64  // find the bad jets
65  for (int jetindex = 0; jetindex < njets; ++jetindex){
66  edm::Ptr<pat::Jet> candjet = jetcandidates->ptrAt(jetindex);
67 
68  // Corrected Pt or Uncorrected Pt (It is defined from cfi file)
69  double ptJet = userawPt_ ? candjet->correctedJet("Uncorrected").pt() : candjet->pt();
70  double absEtaJet = std::abs(candjet->eta());
71 
72  if ( ptJet > ptThreshold_ || absEtaJet < minEtaThreshold_ || absEtaJet > maxEtaThreshold_) {
73  // save good jets
74  goodJets->emplace_back(candjet);
75  }
76  else {
77  // save bad jets
78  badJets->emplace_back(candjet);
79  }
80 
81  }
82  iEvent.put(std::move(goodJets),"good");
83  iEvent.put(std::move(badJets),"bad");
84 
85 }
86 
89  desc.add<edm::InputTag>("jetsrc",edm::InputTag("slimmedJets"));
90  desc.add<bool>("userawPt",true);
91  desc.add<double>("ptThreshold",50.0);
92  desc.add<double>("minEtaThreshold",2.65);
93  desc.add<double>("maxEtaThreshold",3.139);
94 
95  descriptions.add("BadPFCandidateJetsEEnoiseProducer",desc);
96 }
97 
99 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
double pt() const final
transverse momentum
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: Jet.py:1
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::View< pat::Jet > > jetsrc_