CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFElToElAssMaker.cc
Go to the documentation of this file.
4 
6 
7 void PFElToElAssMaker::SetVars(HWW& hww, const edm::Event& iEvent, const edm::EventSetup& iSetup) {
8 
9  using namespace edm;
10  using std::vector;
11 
12  hww.Load_pfels_elsidx();
13 
14  vector<LorentzVector> *pfels_p4_h = new vector<LorentzVector>;
15  *pfels_p4_h = hww.pfels_p4();
16 
17  vector<LorentzVector> *els_p4_h = new vector<LorentzVector>;
18  *els_p4_h = hww.els_p4();
19 
20  //loop over reco electrons and find the closest particle flow electron
21  for (vector<LorentzVector>::const_iterator pfels_it = pfels_p4_h->begin(); pfels_it != pfels_p4_h->end(); pfels_it++) {
22 
23  double pfel_eta = pfels_it->Eta();
24  double pfel_phi = pfels_it->Phi();
25 
26  double minDR = 9999.;
27  unsigned int i = 0;
28  int index = -1;
29 
30  for (vector<LorentzVector>::const_iterator els_it = els_p4_h->begin(); els_it != els_p4_h->end(); els_it++, i++) {
31 
32  double el_eta = els_it->Eta();
33  double el_phi = els_it->Phi();
34  double dR = deltaR(pfel_eta, pfel_phi, el_eta, el_phi);
35 
36  if(dR < minDR) {
37  minDR = dR;
38  index = i;
39  }
40 
41  }
42 
43  if(minDR > 0.1) {
44  minDR = -9999.;
45  index = -1;
46  }
47 
48  hww.pfels_elsidx().push_back(index);
49 
50  }
51 
52 }
int i
Definition: DBlmapReader.cc:9
std::vector< int > & pfels_elsidx()
Definition: HWW.cc:749
void Load_pfels_elsidx()
Definition: HWW.cc:1349
int iEvent
Definition: GenABIO.cc:230
std::vector< LorentzVector > & pfels_p4()
Definition: HWW.cc:753
std::vector< LorentzVector > & els_p4()
Definition: HWW.cc:101
Definition: HWW.h:11
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > XYZTLorentzVectorF
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:22
math::PtEtaPhiELorentzVectorF LorentzVector