CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Type1PFMET.cc
Go to the documentation of this file.
1 
2 // user include files
4 
8 
9 //using namespace std;
10 
11 using namespace reco;
12 
13 // PRODUCER CONSTRUCTORS ------------------------------------------
15 {
16  inputUncorMetLabel = iConfig.getParameter<std::string>("inputUncorMetLabel");
17  inputUncorJetsTag = iConfig.getParameter<edm::InputTag>("inputUncorJetsTag");
18  correctorLabel = iConfig.getParameter<std::string>("corrector");
19  jetPTthreshold = iConfig.getParameter<double>("jetPTthreshold");
20  jetEMfracLimit = iConfig.getParameter<double>("jetEMfracLimit");
21  jetMufracLimit = iConfig.getParameter<double>("jetMufracLimit");
22  produces<METCollection>();
23 }
25 
26 // PRODUCER DESTRUCTORS -------------------------------------------
28 
29 // PRODUCER METHODS -----------------------------------------------
31 {
32  using namespace edm;
33  Handle<PFJetCollection> inputUncorJets;
34  iEvent.getByLabel( inputUncorJetsTag, inputUncorJets );
35  const JetCorrector* corrector = JetCorrector::getJetCorrector (correctorLabel, iSetup);
36  Handle<METCollection> inputUncorMet; //Define Inputs
37  iEvent.getByLabel( inputUncorMetLabel, inputUncorMet ); //Get Inputs
38  std::auto_ptr<METCollection> output( new METCollection() ); //Create empty output
39  run( *(inputUncorMet.product()), *corrector, *(inputUncorJets.product()),
40  jetPTthreshold, jetEMfracLimit, jetMufracLimit,
41  &*output ); //Invoke the algorithm
42  iEvent.put( output ); //Put output into Event
43 }
44 
45 void Type1PFMET::run(const METCollection& uncorMET,
46  const JetCorrector& corrector,
47  const PFJetCollection& uncorJet,
48  double jetPTthreshold,
49  double jetEMfracLimit,
50  double jetMufracLimit,
51  METCollection* corMET)
52 {
53  if (!corMET) {
54  std::cerr << "Type1METAlgo_run-> undefined output MET collection. Stop. " << std::endl;
55  return;
56  }
57 
58  double DeltaPx = 0.0;
59  double DeltaPy = 0.0;
60  double DeltaSumET = 0.0;
61  // ---------------- Calculate jet corrections, but only for those uncorrected jets
62  // ---------------- which are above the given threshold. This requires that the
63  // ---------------- uncorrected jets be matched with the corrected jets.
64  for( PFJetCollection::const_iterator jet = uncorJet.begin(); jet != uncorJet.end(); ++jet) {
65  if( jet->pt() > jetPTthreshold ) {
66  double emEFrac =
67  jet->chargedEmEnergyFraction() + jet->neutralEmEnergyFraction();
68  double muEFrac = jet->chargedMuEnergyFraction();
69  if( emEFrac < jetEMfracLimit
70  && muEFrac < jetMufracLimit ) {
71  double corr = corrector.correction (*jet) - 1.; // correction itself
72  DeltaPx += jet->px() * corr;
73  DeltaPy += jet->py() * corr;
74  DeltaSumET += jet->et() * corr;
75  }
76  }
77  }
78  //----------------- Calculate and set deltas for new MET correction
80  delta.mex = - DeltaPx; //correction to MET (from Jets) is negative,
81  delta.mey = - DeltaPy; //since MET points in direction opposite of jets
82  delta.sumet = DeltaSumET;
83  //----------------- Fill holder with corrected MET (= uncorrected + delta) values
84  const MET* u = &(uncorMET.front());
85  double corrMetPx = u->px()+delta.mex;
86  double corrMetPy = u->py()+delta.mey;
87  MET::LorentzVector correctedMET4vector( corrMetPx, corrMetPy, 0.,
88  sqrt (corrMetPx*corrMetPx + corrMetPy*corrMetPy)
89  );
90  //----------------- get previous corrections and push into new corrections
91  std::vector<CorrMETData> corrections = u->mEtCorr();
92  corrections.push_back( delta );
93  //----------------- Push onto MET Collection
94  MET result = MET(u->sumEt()+delta.sumet,
95  corrections,
96  correctedMET4vector,
97  u->vertex() );
98  corMET->push_back(result);
99 
100  return;
101 }
102 
103 // DEFINE_FWK_MODULE(Type1PFMET); //define this as a plug-in
104 
105 
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
virtual const Point & vertex() const
vertex position
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
int iEvent
Definition: GenABIO.cc:243
double sumEt() const
Definition: MET.h:48
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
Definition: MET.h:32
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
Collection of MET.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double sumet
Definition: CorrMETData.h:20
JetCorrectorParameters corr
Definition: classes.h:9
std::vector< CorrMETData > mEtCorr() const
Definition: MET.h:63
virtual ~Type1PFMET()
Definition: Type1PFMET.cc:27
virtual double px() const
x coordinate of momentum vector
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:51
a MET correction term
Definition: CorrMETData.h:14
std::vector< PFJet > PFJetCollection
collection of PFJet objects
virtual void produce(edm::Event &, const edm::EventSetup &)
Definition: Type1PFMET.cc:30
void run(const reco::METCollection &uncorMET, const JetCorrector &corrector, const reco::PFJetCollection &uncorJet, double jetPTthreshold, double jetEMfracLimit, double jetMufracLimit, reco::METCollection *corMET)
Definition: Type1PFMET.cc:45
double mey
Definition: CorrMETData.h:18
double mex
Definition: CorrMETData.h:17
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:25
virtual double py() const
y coordinate of momentum vector