CMS 3D CMS Logo

EcalPFClusterIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaRecHitIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer, hacked by Sam Harper (ie the ugly stuff is mine)
5 // Institute: IIHE-VUB, RAL
6 //=============================================================================
7 //*****************************************************************************
8 
10 
15 
17 
18 template <typename T1>
20  double drVetoBarrel,
21  double drVetoEndcap,
22  double etaStripBarrel,
23  double etaStripEndcap,
24  double energyBarrel,
25  double energyEndcap)
26  : drMax_(drMax),
27  drVetoBarrel_(drVetoBarrel),
28  drVetoEndcap_(drVetoEndcap),
29  etaStripBarrel_(etaStripBarrel),
30  etaStripEndcap_(etaStripEndcap),
31  energyBarrel_(energyBarrel),
32  energyEndcap_(energyEndcap) {}
33 
34 template <typename T1>
36 
37 template <typename T1>
39  float dR2 = deltaR2(candRef->eta(), candRef->phi(), pfclu->eta(), pfclu->phi());
40  if (dR2 > (drMax_ * drMax_))
41  return false;
42 
43  if (candRef->superCluster().isNonnull()) {
44  // Exclude clusters that are part of the candidate
45  for (reco::CaloCluster_iterator it = candRef->superCluster()->clustersBegin();
46  it != candRef->superCluster()->clustersEnd();
47  ++it) {
48  if ((*it)->seed() == pfclu->seed()) {
49  return false;
50  }
51  }
52  }
53 
54  return true;
55 }
56 
57 template <>
59  float dR2 = deltaR2(candRef->eta(), candRef->phi(), pfclu->eta(), pfclu->phi());
60  if (dR2 > (drMax_ * drMax_) || dR2 < drVeto2_)
61  return false;
62  else
63  return true;
64 }
65 
66 template <typename T1>
68  drVeto2_ = -1.;
69  float etaStrip = -1;
70 
71  if (std::abs(cand.eta()) < 1.479) {
72  drVeto2_ = drVetoBarrel_ * drVetoBarrel_;
73  etaStrip = etaStripBarrel_;
74  } else {
75  drVeto2_ = drVetoEndcap_ * drVetoEndcap_;
76  etaStrip = etaStripEndcap_;
77  }
78 
79  float etSum = 0;
80  for (size_t i = 0; i < clusterHandle->size(); i++) {
81  reco::PFClusterRef pfclu(clusterHandle, i);
82 
83  if (std::abs(cand.eta()) < 1.479) {
84  if (std::abs(pfclu->pt()) < energyBarrel_)
85  continue;
86  } else {
87  if (std::abs(pfclu->energy()) < energyEndcap_)
88  continue;
89  }
90 
91  float dEta = std::abs(cand.eta() - pfclu->eta());
92  if (dEta < etaStrip)
93  continue;
94  if (not computedRVeto(cand, pfclu))
95  continue;
96 
97  etSum += pfclu->pt();
98  }
99 
100  return etSum;
101 }
102 
103 template <typename T1>
104 double EcalPFClusterIsolation<T1>::getSum(T1Ref ref, edm::Handle<std::vector<reco::PFCluster> > clusts) {
105  return getSum(*ref, clusts);
106 }
107 
108 template <typename T1>
110  float dR2 = deltaR2(cand.eta(), cand.phi(), pfclu->eta(), pfclu->phi());
111  if (dR2 > (drMax_ * drMax_))
112  return false;
113 
114  if (cand.superCluster().isNonnull()) {
115  // Exclude clusters that are part of the candidate
116  for (reco::CaloCluster_iterator it = cand.superCluster()->clustersBegin(); it != cand.superCluster()->clustersEnd();
117  ++it) {
118  if ((*it)->seed() == pfclu->seed()) {
119  return false;
120  }
121  }
122  }
123 
124  return true;
125 }
126 
EcalPFClusterIsolation(double drMax, double drVetoBarrel, double drVetoEndcap, double etaStripBarrel, double etaStripEndcap, double energyBarrel, double energyEndcap)
double getSum(T1, edm::Handle< std::vector< reco::PFCluster > >)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu)