CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrkMETMaker.cc
Go to the documentation of this file.
4 
7 using namespace reco;
8 using namespace edm;
9 using namespace std;
10 
11 
12 double TrkMETdzPV(const LorentzVector& vtx, const LorentzVector& p4, const LorentzVector& pv){
13  return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
14 }
15 
16 
17 void TrkMETMaker::SetVars(HWW& hww, const edm::Event& iEvent, const edm::EventSetup& iSetup) {
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
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
std::pair< double, double > Point
Definition: CaloEllipse.h:18
std::vector< int > & pfcands_trkidx()
Definition: HWW.cc:729
std::vector< LorentzVector > & hyp_ll_p4()
Definition: HWW.cc:569
int iEvent
Definition: GenABIO.cc:230
T sqrt(T t)
Definition: SSEVec.h:48
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< LorentzVector > & vtxs_position()
Definition: HWW.cc:5
Definition: HWW.h:11
double TrkMETdzPV(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
Definition: TrkMETMaker.cc:12
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: analysisEnums.h:9
std::vector< LorentzVector > & hyp_lt_p4()
Definition: HWW.cc:573
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
math::PtEtaPhiELorentzVectorF LorentzVector
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: TrkMETMaker.cc:17
void Load_trk_met()
Definition: HWW.cc:1358