test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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

void compute (bool et, Sum &sum, reco::Candidate const &cand, CaloTowerDetId const *first, CaloTowerDetId const *last) const
 
void compute (bool et, Sum &sum, reco::SuperCluster const &sc, CaloTowerDetId const *first, CaloTowerDetId const *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 = 0
 
const uint32_t nt
 
float * phi
 
float * st
 

Static Public Attributes

static unsigned int NCuts = NC
 

Detailed Description

template<unsigned int NC>
class EgammaTowerIsolationNew< NC >

Definition at line 40 of file EgammaTowerIsolation.h.

Constructor & Destructor Documentation

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

Definition at line 57 of file EgammaTowerIsolation.h.

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

Definition at line 120 of file EgammaTowerIsolation.h.

References KineDebug3::count(), alignCSCRings::e, EgammaTowerIsolationNew< NC >::eta, EgammaTowerIsolationNew< NC >::extRadius2_, EgammaTowerIsolationNew< NC >::h2, EgammaTowerIsolationNew< NC >::he, i, cmsHarvester::index, EgammaTowerIsolationNew< NC >::initSoa(), EgammaTowerIsolationNew< NC >::intRadius2_, j, relval_2017::k, EgammaTowerIsolationNew< NC >::NCuts, EgammaTowerIsolationNew< NC >::nt, EgammaTowerIsolationNew< NC >::phi, and EgammaTowerIsolationNew< NC >::st.

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

Definition at line 63 of file EgammaTowerIsolation.h.

References EgammaTowerIsolationNew< NC >::mem.

63 { delete[] mem;}

Member Function Documentation

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

Definition at line 65 of file EgammaTowerIsolation.h.

References reco::Candidate::get().

65  {
66  reco::SuperCluster const & sc = *cand.get<reco::SuperClusterRef>().get();
67  return compute(et,sum,sc,first,last);
68  }
void compute(bool et, Sum &sum, reco::Candidate const &cand, CaloTowerDetId const *first, CaloTowerDetId const *last) const
template<unsigned int NC>
void EgammaTowerIsolationNew< NC >::compute ( bool  et,
Sum sum,
reco::SuperCluster const &  sc,
CaloTowerDetId const *  first,
CaloTowerDetId const *  last 
) const
inline

Definition at line 167 of file EgammaTowerIsolation.h.

References KineDebug3::count(), reco::deltaR2(), eta, reco::CaloCluster::eta(), spr::find(), EgammaTowerIsolationNew< NC >::Sum::h2, EgammaTowerIsolationNew< NC >::Sum::h2BC, EgammaTowerIsolationNew< NC >::Sum::he, EgammaTowerIsolationNew< NC >::Sum::heBC, i, j, plotBeamSpotDB::last, maxEta, min(), nt, convertSQLiteXML::ok, phi(), reco::CaloCluster::phi(), and groupFilesInBlocks::tt.

167  {
168  if (nt==0) return;
169 
170 #ifdef ETISTATDEBUG
171  etiStat::Count::count.comp++;
172 #endif
173 
174  float candEta = sc.eta();
175  float candPhi = sc.phi();
176 
177 
178  auto lb = std::lower_bound(eta,eta+nt,candEta-maxEta);
179  auto ub = std::upper_bound(lb,eta+nt,candEta+maxEta);
180  uint32_t il = lb-eta;
181  uint32_t iu = std::min(nt,uint32_t(ub-eta+1));
182 
183 #ifdef ETISTATDEBUG
184  etiStat::Count::count.span += (iu-il);
185 #endif
186 
187  bool ok[iu-il];
188  for (std::size_t i=il;i!=iu; ++i)
189  ok[i-il] = (std::find(first,last,id[i])==last);
190 
191 
192 
193  // should be restricted in eta....
194  for (std::size_t i=il;i!=iu; ++i) {
195  float dr2 = reco::deltaR2(candEta,candPhi,eta[i], phi[i]);
196  float tt = et ? st[i] : 1.f;
197  for (std::size_t j=0; j!=NCuts; ++j) {
198  if (dr2<extRadius2_[j]) {
199  if (dr2>=intRadius2_[j]) {
200  sum.he[j] +=he[i]*tt;
201  sum.h2[j] +=h2[i]*tt;
202  }
203  if(ok[i-il]) {
204  sum.heBC[j] +=he[i]*tt;
205  sum.h2BC[j] +=h2[i]*tt;
206  }
207  }
208  }
209  }
210 }
int i
Definition: DBlmapReader.cc:9
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
int j
Definition: DBlmapReader.cc:9
static unsigned int NCuts
T min(T a, T b)
Definition: MathUtil.h:58
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
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 71 of file EgammaTowerIsolation.h.

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

71  {
72  for (std::size_t i=0; i!=NCuts; ++i) {
73  extRadius2_[i]=extRadius[i]*extRadius[i];
74  intRadius2_[i]=intRadius[i]*intRadius[i];
75  }
76  maxEta = *std::max_element(extRadius,extRadius+NC);
77  }
int i
Definition: DBlmapReader.cc:9
static 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 92 of file EgammaTowerIsolation.h.

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

Definition at line 84 of file EgammaTowerIsolation.h.

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

template<unsigned int NC>
uint32_t* EgammaTowerIsolationNew< NC >::mem = 0
template<unsigned int NC>
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