CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
TrkMETMaker Class Reference

#include <TrkMETMaker.h>

Public Member Functions

void SetVars (HWW &, const edm::Event &, const edm::EventSetup &)
 
 TrkMETMaker ()
 

Detailed Description

Definition at line 7 of file TrkMETMaker.h.

Constructor & Destructor Documentation

TrkMETMaker::TrkMETMaker ( )
inline

Definition at line 11 of file TrkMETMaker.h.

11 {};

Member Function Documentation

void TrkMETMaker::SetVars ( HWW hww,
const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 17 of file TrkMETMaker.cc.

References reco::deltaR(), HWW::hyp_ll_p4(), HWW::hyp_lt_p4(), HWW::Load_trk_met(), HWW::Load_trk_metPhi(), HWW::pfcands_charge(), HWW::pfcands_p4(), HWW::pfcands_trkidx(), mathSSE::sqrt(), HWW::trk_met(), HWW::trk_metPhi(), TrkMETdzPV(), HWW::trks_trk_p4(), HWW::trks_vertex_p4(), and HWW::vtxs_position().

Referenced by HWWAnalyzer::analyze().

17  {
18 
19  hww.Load_trk_met();
20  hww.Load_trk_metPhi();
21 
22  //track p4
23  vector<LorentzVector> *trks_trk_p4 = new vector<LorentzVector>;
24  *trks_trk_p4 = hww.trks_trk_p4();
25  if(trks_trk_p4->size()<2) return;
26 
27  //track vertex position
28  vector<LorentzVector> *trks_vertex_p4 = new vector<LorentzVector>;
29  *trks_vertex_p4 = hww.trks_vertex_p4();
30 
31  //vertex position
32  vector<LorentzVector> *vertex_position = new vector<LorentzVector>;
33  *vertex_position = hww.vtxs_position();
34 
35  //pfcandidate p4
36  vector<LorentzVector> *pfcands_p4 = new vector<LorentzVector>;
37  *pfcands_p4 = hww.pfcands_p4();
38 
39  //pfcandidate charge
40  vector<int> *pfcands_charge = new vector<int>;
41  *pfcands_charge = hww.pfcands_charge();
42 
43  //pfcandidate track index
44  vector<int> *pfcands_trkidx = new vector<int>;
45  *pfcands_trkidx = hww.pfcands_trkidx();
46 
47  //hyp ll p4
48  vector<LorentzVector> *hyp_ll_p4 = new vector<LorentzVector>;
49  *hyp_ll_p4 = hww.hyp_ll_p4();
50 
51  //hyp lt p4
52  vector<LorentzVector> *hyp_lt_p4 = new vector<LorentzVector>;
53  *hyp_lt_p4 = hww.hyp_lt_p4();
54 
55 
56  const unsigned int npfcands = pfcands_p4->size();
57  const unsigned int nhyps = hyp_ll_p4->size();
58 
59  //-----------------------------------
60  // loop over hypotheses
61  //-----------------------------------
62 
63  for( unsigned int ihyp = 0 ; ihyp < nhyps ; ihyp++ ){
64 
65  float metx = 0;
66  float mety = 0;
67  float sumet = 0;
68 
69  //------------------------------
70  // correct met for hyp leptons
71  //------------------------------
72 
73  metx -= hyp_ll_p4->at(ihyp).Px();
74  metx -= hyp_lt_p4->at(ihyp).Px();
75  mety -= hyp_ll_p4->at(ihyp).Py();
76  mety -= hyp_lt_p4->at(ihyp).Py();
77 
78 
79  //-----------------------------------
80  // loop over pfcandidates
81  //-----------------------------------
82 
83  double drcut_ = 0.1;
84  double dzcut_ = 0.1;
85 
86  for( unsigned int ipf = 0 ; ipf < npfcands ; ipf++ ){
87 
88  // require charged pfcandidate
89  if( pfcands_charge->at(ipf) == 0 ) continue;
90 
91  // don't correct for pfcandidates dr-matched to hyp leptons
92  double dRll = deltaR( hyp_ll_p4->at(ihyp).eta() , hyp_ll_p4->at(ihyp).phi() , pfcands_p4->at(ipf).eta() , pfcands_p4->at(ipf).phi());
93  double dRlt = deltaR( hyp_lt_p4->at(ihyp).eta() , hyp_lt_p4->at(ihyp).phi() , pfcands_p4->at(ipf).eta() , pfcands_p4->at(ipf).phi());
94  if( dRll < drcut_ || dRlt < drcut_ ) continue;
95 
96  // now make dz requirement on track matched to pfcandidate
97  int trkidx = pfcands_trkidx->at(ipf);
98  if( trkidx < 0 ) continue;
99  double dzpv = TrkMETdzPV( trks_vertex_p4->at(trkidx) , trks_trk_p4->at(trkidx), vertex_position->at(0) );
100  if( fabs(dzpv) > dzcut_ ) continue;
101 
102 
103  // pfcandidate passes selection so correct the met
104  metx -= pfcands_p4->at(ipf).Px();
105  mety -= pfcands_p4->at(ipf).Py();
106  sumet += pfcands_p4->at(ipf).Pt();
107 
108  }//pfcandidates
109 
110  hww.trk_met().push_back ( sqrt(metx*metx+mety*mety) );
111  hww.trk_metPhi().push_back ( atan2(mety,metx) );
112 
113  }//hypotheses
114 }
void Load_trk_metPhi()
Definition: HWW.cc:1361
std::vector< float > & trk_met()
Definition: HWW.cc:761
std::vector< LorentzVector > & trks_vertex_p4()
Definition: HWW.cc:43
std::vector< int > & pfcands_charge()
Definition: HWW.cc:745
std::vector< LorentzVector > & trks_trk_p4()
Definition: HWW.cc:39
std::vector< float > & trk_metPhi()
Definition: HWW.cc:765
std::vector< LorentzVector > & pfcands_p4()
Definition: HWW.cc:725
std::vector< int > & pfcands_trkidx()
Definition: HWW.cc:729
std::vector< LorentzVector > & hyp_ll_p4()
Definition: HWW.cc:569
T sqrt(T t)
Definition: SSEVec.h:48
std::vector< LorentzVector > & vtxs_position()
Definition: HWW.cc:5
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double TrkMETdzPV(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
Definition: TrkMETMaker.cc:12
std::vector< LorentzVector > & hyp_lt_p4()
Definition: HWW.cc:573
void Load_trk_met()
Definition: HWW.cc:1358