CMS 3D CMS Logo

PFIsoDepositAlgo.cc
Go to the documentation of this file.
2 
4 
6 
8 
9 using namespace std;
10 using namespace edm;
11 using namespace reco;
12 using namespace math;
13 using namespace pf2pat;
14 
15 PFIsoDepositAlgo::PFIsoDepositAlgo(const edm::ParameterSet& iConfig)
16  : verbose_(iConfig.getUntrackedParameter<bool>("verbose", false))
17 
18 {}
19 
21 
23  const ParticleCollection& forIsolation) {
24  isoDeposits_.clear();
25  isoDeposits_.reserve(toBeIsolated.size());
26 
27  for (unsigned i = 0; i < toBeIsolated.size(); i++) {
28  const reco::PFCandidate& toBeIso = toBeIsolated[i];
29 
30  if (verbose_)
31  cout << "to be isolated: " << toBeIso << endl;
32 
33  isoDeposits_.push_back(buildIsoDeposit(toBeIso, forIsolation));
34  }
35 
36  if (verbose_) {
37  cout << "PFIsoDepositAlgo " << endl;
38  }
39 
40  return isoDeposits_;
41 }
42 
43 IsoDeposit PFIsoDepositAlgo::buildIsoDeposit(const Particle& particle, const ParticleCollection& forIsolation) const {
44  reco::isodeposit::Direction pfDir(particle.eta(), particle.phi());
45  // reco::IsoDeposit::Veto veto;
46  // veto.vetoDir = pfDir;
47  // veto.dR = 0.05;
48 
49  IsoDeposit isoDep(pfDir);
50 
51  for (unsigned i = 0; i < forIsolation.size(); i++) {
52  const reco::PFCandidate& pfc = forIsolation[i];
53 
54  // need to remove "particle"!
55 
56  if (sameParticle(particle, pfc))
57  continue;
58 
59  const XYZTLorentzVector& pvi(pfc.p4());
60  reco::isodeposit::Direction dirPfc(pfc.eta(), pfc.phi());
61  double dR = pfDir.deltaR(dirPfc);
62 
63  //COLIN make a parameter
64  double maxDeltaRForIsoDep_ = 1;
65  if (dR > maxDeltaRForIsoDep_) {
66  // if( verbose_ ) cout<<"OUT OF CONE"<<endl;
67  continue;
68  }
69  // else if(verbose_) cout<<endl;
70 
71  if (verbose_)
72  cout << "\t" << pfc << endl;
73 
74  double pt = pvi.Pt();
75  isoDep.addDeposit(dirPfc, pt);
76  }
77 
78  return isoDep;
79 }
80 
81 bool PFIsoDepositAlgo::sameParticle(const Particle& particle1, const Particle& particle2) const {
82  double smallNumber = 1e-15;
83 
84  if (particle1.particleId() != particle2.particleId())
85  return false;
86  else if (fabs(particle1.energy() - particle2.energy()) > smallNumber)
87  return false;
88  else if (fabs(particle1.eta() - particle2.eta()) > smallNumber)
89  return false;
90  else if (fabs(particle1.eta() - particle2.eta()) > smallNumber)
91  return false;
92  else
93  return true;
94 }
std::vector< Particle > ParticleCollection
const LorentzVector & p4() const final
four-momentum Lorentz vector
IsoDeposits isoDeposits_
IsoDeposits computed in the produce function.
std::vector< reco::IsoDeposit > IsoDeposits
bool sameParticle(const Particle &particle1, const Particle &particle2) const
checks if the 2 particles are in fact the same
const IsoDeposits & produce(const ParticleCollection &toBeIsolated, const ParticleCollection &forIsolation)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
fixed size matrix
HLT enums.
reco::IsoDeposit buildIsoDeposit(const Particle &particle, const ParticleCollection &forIsolation) const
build the IsoDeposit for "particle"
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
double energy() const final
energy
virtual ParticleType particleId() const
Definition: PFCandidate.h:392
double eta() const final
momentum pseudorapidity