CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PfBlockBasedIsolation.cc
Go to the documentation of this file.
2 #include <cmath>
4 
5 
6 
18 
19 
20 //--------------------------------------------------------------------------------------------------
21 
23  // Default Constructor.
24 }
25 
26 
27 
28 
29 //--------------------------------------------------------------------------------------------------
31 {
32 
33 }
34 
35 
37 
38  coneSize_ = conf.getParameter<double>("coneSize");
39 
40 }
41 
42 
43 std::vector<reco::PFCandidateRef> PfBlockBasedIsolation::calculate(math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle<reco::PFCandidateCollection> pfCandidateHandle) {
44 
45  std::vector<reco::PFCandidateRef> myVec;
46 
47  math::XYZVector candidateMomentum(p4.px(),p4.py(),p4.pz());
48  math::XYZVector candidateDirection=candidateMomentum.Unit();
49 
50  const reco::PFCandidate::ElementsInBlocks& theElementsInpfEGcand = (*pfEGCand).elementsInBlocks();
51  reco::PFCandidate::ElementsInBlocks::const_iterator ieg = theElementsInpfEGcand.begin();
52  const reco::PFBlockRef egblock = ieg->first;
53 
54 
55  unsigned nObj = pfCandidateHandle->size();
56  for(unsigned int lCand=0; lCand < nObj; lCand++) {
57 
58  reco::PFCandidateRef pfCandRef(reco::PFCandidateRef(pfCandidateHandle,lCand));
59 
60  float dR = 0.0;
61  if( coneSize_ < 10.0 ) {
62  dR = deltaR(candidateDirection.Eta(), candidateDirection.Phi(), pfCandRef->eta(), pfCandRef->phi());
63  if ( dR> coneSize_ ) continue;
64  }
65 
66  const reco::PFCandidate::ElementsInBlocks& theElementsInPFcand = pfCandRef->elementsInBlocks();
67 
68  bool elementFound=false;
69  for (reco::PFCandidate::ElementsInBlocks::const_iterator ipf = theElementsInPFcand.begin(); ipf<theElementsInPFcand.end(); ++ipf) {
70 
71  if ( ipf->first == egblock && !elementFound ) {
72 
73  for (ieg = theElementsInpfEGcand.begin(); ieg<theElementsInpfEGcand.end(); ++ieg) {
74  if ( ipf->second == ieg->second && !elementFound ) {
75  elementFound=true;
76  myVec.push_back(pfCandRef);
77 
78  }
79  }
80 
81 
82 
83  }
84  }
85 
86 
87 
88  }
89 
90 
91 
92  return myVec;
93 
94 
95 
96  }
97 
98 
99 
100 
T getParameter(std::string const &) const
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
void setup(const edm::ParameterSet &conf)
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:381
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< reco::PFCandidateRef > calculate(math::XYZTLorentzVectorD p4, const reco::PFCandidateRef pfEGCand, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle)
tuple conf
Definition: dbtoconf.py:185
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30