CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Public Attributes | Static Public Attributes
EgammaTowerIsolationNew< NC > Class Template Reference

#include <EgammaTowerIsolation.h>

Classes

struct  Sum
 

Public Member Functions

template<typename I >
void compute (bool et, Sum &sum, reco::Candidate const &cand, I first, I last) const
 
template<typename I >
void compute (bool et, Sum &sum, reco::SuperCluster const &sc, I first, I last) const
 
 EgammaTowerIsolationNew ()
 
 EgammaTowerIsolationNew (float extRadius[NC], float intRadius[NC], CaloTowerCollection const &towers)
 
void initSoa ()
 
void setRadius (float const extRadius[NC], float const intRadius[NC])
 
 ~EgammaTowerIsolationNew ()
 

Public Attributes

float * eta
 
float extRadius2_ [NCuts]
 
float * h2
 
float * he
 
uint32_t * id
 
float intRadius2_ [NCuts]
 
float maxEta
 
uint32_t * mem = nullptr
 
const uint32_t nt
 
float * phi
 
float * st
 

Static Public Attributes

static constexpr unsigned int NCuts = NC
 

Detailed Description

template<unsigned int NC>
class EgammaTowerIsolationNew< NC >

Definition at line 36 of file EgammaTowerIsolation.h.

Constructor & Destructor Documentation

template<unsigned int NC>
EgammaTowerIsolationNew< NC >::EgammaTowerIsolationNew ( )
inline

Definition at line 51 of file EgammaTowerIsolation.h.

51 : nt(0) {}
template<unsigned int NC>
EgammaTowerIsolationNew< NC >::EgammaTowerIsolationNew ( float  extRadius[NC],
float  intRadius[NC],
CaloTowerCollection const &  towers 
)
inline

Definition at line 113 of file EgammaTowerIsolation.h.

References submitPVResolutionJobs::count, alignCSCRings::e, EgammaTowerIsolationNew< NC >::eta, EgammaTowerIsolationNew< NC >::extRadius2_, EgammaTowerIsolationNew< NC >::h2, EgammaTowerIsolationNew< NC >::he, mps_fire::i, EgammaTowerIsolationNew< NC >::initSoa(), EgammaTowerIsolationNew< NC >::intRadius2_, dqmiolumiharvest::j, isotrackApplyRegressor::k, EgammaTowerIsolationNew< NC >::NCuts, EgammaTowerIsolationNew< NC >::nt, EgammaTowerIsolationNew< NC >::phi, and EgammaTowerIsolationNew< NC >::st.

116  : maxEta(*std::max_element(extRadius, extRadius + NC)), nt(towers.size()) {
117  if (nt == 0)
118  return;
119  initSoa();
120 
121 #ifdef ETISTATDEBUG
122  etiStat::Count::count.create++;
123 #endif
124 
125  for (std::size_t i = 0; i != NCuts; ++i) {
126  extRadius2_[i] = extRadius[i] * extRadius[i];
127  intRadius2_[i] = intRadius[i] * intRadius[i];
128  }
129 
130  // sort in eta (kd-tree anoverkill,does not vectorize...)
131  uint32_t index[nt];
132 #ifdef __clang__
133  std::vector<float> e(nt);
134 #else
135  float e[nt];
136 #endif
137  for (std::size_t k = 0; k != nt; ++k) {
138  e[k] = towers[k].eta();
139  index[k] = k;
140  std::push_heap(index, index + k + 1, [&e](uint32_t i, uint32_t j) { return e[i] < e[j]; });
141  }
142  std::sort_heap(index, index + nt, [&e](uint32_t i, uint32_t j) { return e[i] < e[j]; });
143 
144  for (std::size_t i = 0; i != nt; ++i) {
145  auto j = index[i];
146  eta[i] = towers[j].eta();
147  phi[i] = towers[j].phi();
148  id[i] = towers[j].id();
149  st[i] = 1.f / std::cosh(eta[i]); // std::sin(towers[j].theta()); //;
150  he[i] = towers[j].hadEnergy();
151  h2[i] = towers[j].hadEnergyHeOuterLayer();
152  }
153 }
static constexpr unsigned int NCuts
template<unsigned int NC>
EgammaTowerIsolationNew< NC >::~EgammaTowerIsolationNew ( )
inline

Definition at line 54 of file EgammaTowerIsolation.h.

References EgammaTowerIsolationNew< NC >::mem.

54 { delete[] mem; }

Member Function Documentation

template<unsigned int NC>
template<typename I >
void EgammaTowerIsolationNew< NC >::compute ( bool  et,
Sum sum,
reco::Candidate const &  cand,
first,
last 
) const
inline

Definition at line 57 of file EgammaTowerIsolation.h.

References reco::Candidate::get().

57  {
58  reco::SuperCluster const& sc = *cand.get<reco::SuperClusterRef>().get();
59  return compute(et, sum, sc, first, last);
60  }
tuple last
Definition: dqmdumpme.py:56
void compute(bool et, Sum &sum, reco::Candidate const &cand, I first, I last) const
template<unsigned int NC>
template<typename I >
void EgammaTowerIsolationNew< NC >::compute ( bool  et,
Sum sum,
reco::SuperCluster const &  sc,
first,
last 
) const
inline

Definition at line 157 of file EgammaTowerIsolation.h.

References submitPVResolutionJobs::count, reco::deltaR2(), PVValHelper::eta, reco::CaloCluster::eta(), spr::find(), EgammaTowerIsolationNew< NC >::Sum::h2, EgammaTowerIsolationNew< NC >::Sum::h2BC, EgammaTowerIsolationNew< NC >::Sum::he, hcalSimParameters_cfi::he, EgammaTowerIsolationNew< NC >::Sum::heBC, mps_fire::i, dqmiolumiharvest::j, cuda_std::lower_bound(), maxEta, min(), nt, PVValHelper::phi, reco::CaloCluster::phi(), groupFilesInBlocks::tt, and cuda_std::upper_bound().

158  {
159  if (nt == 0)
160  return;
161 
162 #ifdef ETISTATDEBUG
163  etiStat::Count::count.comp++;
164 #endif
165 
166  float candEta = sc.eta();
167  float candPhi = sc.phi();
168 
169  auto lb = std::lower_bound(eta, eta + nt, candEta - maxEta);
170  auto ub = std::upper_bound(lb, eta + nt, candEta + maxEta);
171  uint32_t il = lb - eta;
172  uint32_t iu = std::min(nt, uint32_t(ub - eta + 1));
173 
174 #ifdef ETISTATDEBUG
175  etiStat::Count::count.span += (iu - il);
176 #endif
177 
178  // should be restricted in eta....
179  for (std::size_t i = il; i != iu; ++i) {
180  float dr2 = reco::deltaR2(candEta, candPhi, eta[i], phi[i]);
181  float tt = et ? st[i] : 1.f;
182  for (std::size_t j = 0; j != NCuts; ++j) {
183  if (dr2 < extRadius2_[j]) {
184  if (dr2 >= intRadius2_[j]) {
185  sum.he[j] += he[i] * tt;
186  sum.h2[j] += h2[i] * tt;
187  }
188  if (std::find(first, last, id[i]) == last) {
189  sum.heBC[j] += he[i] * tt;
190  sum.h2BC[j] += h2[i] * tt;
191  }
192  }
193  }
194  }
195 }
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
static constexpr unsigned int NCuts
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
T min(T a, T b)
Definition: MathUtil.h:58
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
tuple last
Definition: dqmdumpme.py:56
template<unsigned int NC>
void EgammaTowerIsolationNew< NC >::initSoa ( )
inline
template<unsigned int NC>
void EgammaTowerIsolationNew< NC >::setRadius ( float const  extRadius[NC],
float const  intRadius[NC] 
)
inline

Definition at line 64 of file EgammaTowerIsolation.h.

References EgammaTowerIsolationNew< NC >::extRadius2_, mps_fire::i, EgammaTowerIsolationNew< NC >::intRadius2_, EgammaTowerIsolationNew< NC >::maxEta, and EgammaTowerIsolationNew< NC >::NCuts.

64  {
65  for (std::size_t i = 0; i != NCuts; ++i) {
66  extRadius2_[i] = extRadius[i] * extRadius[i];
67  intRadius2_[i] = intRadius[i] * intRadius[i];
68  }
69  maxEta = *std::max_element(extRadius, extRadius + NC);
70  }
static constexpr unsigned int NCuts

Member Data Documentation

template<unsigned int NC>
float* EgammaTowerIsolationNew< NC >::eta
template<unsigned int NC>
float EgammaTowerIsolationNew< NC >::extRadius2_[NCuts]
template<unsigned int NC>
float* EgammaTowerIsolationNew< NC >::h2
template<unsigned int NC>
float* EgammaTowerIsolationNew< NC >::he
template<unsigned int NC>
uint32_t* EgammaTowerIsolationNew< NC >::id

Definition at line 84 of file EgammaTowerIsolation.h.

template<unsigned int NC>
float EgammaTowerIsolationNew< NC >::intRadius2_[NCuts]
template<unsigned int NC>
float EgammaTowerIsolationNew< NC >::maxEta

Definition at line 76 of file EgammaTowerIsolation.h.

Referenced by EgammaTowerIsolationNew< NC >::setRadius().

template<unsigned int NC>
uint32_t* EgammaTowerIsolationNew< NC >::mem = nullptr
template<unsigned int NC>
constexpr unsigned int EgammaTowerIsolationNew< NC >::NCuts = NC
static
template<unsigned int NC>
const uint32_t EgammaTowerIsolationNew< NC >::nt
template<unsigned int NC>
float* EgammaTowerIsolationNew< NC >::phi
template<unsigned int NC>
float* EgammaTowerIsolationNew< NC >::st