CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SmearedPATJetProducer.cc
Go to the documentation of this file.
2 
4 
9 
11 
12 namespace SmearedJetProducer_namespace
13 {
14  template <>
15  class GenJetMatcherT<pat::Jet>
16  {
17  public:
18 
21  {
22  TString dRmaxGenJetMatch_formula = cfg.getParameter<std::string>("dRmaxGenJetMatch").data();
23  dRmaxGenJetMatch_formula.ReplaceAll("genJetPt", "x");
24  dRmaxGenJetMatch_ = new TFormula("dRmaxGenJetMatch", dRmaxGenJetMatch_formula.Data());
25  }
27  {
28  delete dRmaxGenJetMatch_;
29  }
30 
31  const reco::GenJet* operator()(const pat::Jet& jet, edm::Event* evt = 0) const
32  {
33  const reco::GenJet* retVal = 0;
34 
35  // CV: apply matching criterion which is tighter than PAT default,
36  // in order to avoid "accidental" matches for which the difference between genJetPt and recJetPt is large
37  // (the large effect of such bad matches on the MEt smearing is "unphysical",
38  // because the large difference between genJetPt and recJetPt results from the matching
39  // and not from the particle/jet reconstruction)
40  //retVal = jet.genJet();
41  if ( jet.genJet() ) {
42  const reco::GenJet* genJet = jet.genJet();
43  double dR = deltaR(jet.p4(), genJet->p4());
44  if ( dR < dRmaxGenJetMatch_->Eval(genJet->pt()) ) retVal = genJet;
45  }
46 
47  return retVal;
48  }
49 
50  private:
51 
52  TFormula* dRmaxGenJetMatch_;
53  };
54 
55  template <>
57  {
58  public:
59 
61  : jetResolutions_(cfg)
62  {}
64 
65  double operator()(const pat::Jet& jet) const
66  {
67  if ( jet.isPFJet() ) {
68  reco::PFJet pfJet(jet.p4(), jet.vertex(), jet.pfSpecific(), jet.getJetConstituents());
69  metsig::SigInputObj pfJetResolution = jetResolutions_.evalPFJet(&pfJet);
70  if ( pfJetResolution.get_energy() > 0. ) {
71  return jet.energy()*(pfJetResolution.get_sigma_e()/pfJetResolution.get_energy());
72  } else {
73  return 0.;
74  }
75  } else {
76  throw cms::Exception("SmearedJetProducer::produce")
77  << " Jets of type other than PF not supported yet !!\n";
78  }
79  }
80 
82  };
83 }
84 
86 
88 
T getParameter(std::string const &) const
tuple cfg
Definition: looper.py:259
const PFSpecific & pfSpecific() const
retrieve the pf specific part of the jet
Definition: Jet.h:265
virtual const Point & vertex() const
vertex position (overwritten by PF...)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual Constituents getJetConstituents() const
list of constituents
GenJetMatcherT(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
Jets made from PFObjects.
Definition: PFJet.h:21
virtual double pt() const
transverse momentum
virtual double energy() const
energy
Jets made from MC generator particles.
Definition: GenJet.h:24
bool isPFJet() const
check to see if the jet is a reco::PFJet
Definition: Jet.h:251
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
const reco::GenJet * operator()(const pat::Jet &jet, edm::Event *evt=0) const
Analysis-level calorimeter jet class.
Definition: Jet.h:77
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const reco::GenJet * genJet() const
return the matched generated jet
SmearedJetProducerT< pat::Jet, PATJetCorrExtractor > SmearedPATJetProducer
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99