CMS 3D CMS Logo

Classes | Public Member Functions | Public Attributes | Static Public Attributes

EgammaTowerIsolationNew< NC > Class Template Reference

#include <EgammaTowerIsolation.h>

List of all members.

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 (float extRadius[NC], float intRadius[NC], CaloTowerCollection const &towers)
 EgammaTowerIsolationNew ()
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 39 of file EgammaTowerIsolation.h.


Constructor & Destructor Documentation

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

Definition at line 56 of file EgammaTowerIsolation.h.

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

Definition at line 117 of file EgammaTowerIsolation.h.

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

                                                                                         :
  maxEta(*std::max_element(extRadius,extRadius+NC)),
  nt(towers.size()) {
  if (nt==0) return;
  initSoa();

  etiStat::Count::count.create++;

  
  for (std::size_t i=0; i!=NCuts; ++i) {
    extRadius2_[i]=extRadius[i]*extRadius[i];
    intRadius2_[i]=intRadius[i]*intRadius[i];
  }
  
  // sort in eta  (kd-tree anoverkill,does not vectorize...)
  uint32_t index[nt];
  float e[nt];
  for (std::size_t k=0; k!=nt; ++k) {
    e[k]=towers[k].eta();
    index[k]=k;
    std::push_heap(index,index+k+1,[&e](uint32_t i, uint32_t j){ return e[i]<e[j];});
  }
  std::sort_heap(index,index+nt,[&e](uint32_t i, uint32_t j){ return e[i]<e[j];});
  
  
  for (std::size_t i=0;i!=nt; ++i) {
    auto j = index[i];
    eta[i]=towers[j].eta();
    phi[i]=towers[j].phi();
    id[i]=towers[j].id();
    st[i] =  1.f/std::cosh(eta[i]); // std::sin(towers[j].theta());   //;
    he[i] = towers[j].hadEnergy();
    h2[i] = towers[j].hadEnergyHeOuterLayer();
  }
}
template<unsigned int NC>
EgammaTowerIsolationNew< NC >::~EgammaTowerIsolationNew ( ) [inline]

Definition at line 62 of file EgammaTowerIsolation.h.

{ 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 64 of file EgammaTowerIsolation.h.

Referenced by EgammaTowerIsolationNew< 1 >::compute(), and EgammaTowerIsolation::getSum().

                                                                                                                                {
    reco::SuperCluster const & sc =  *cand.get<reco::SuperClusterRef>().get();
    return compute(et,sum,sc,first,last);
  }
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 159 of file EgammaTowerIsolation.h.

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

                                                                                                                                                      {
  if (nt==0) return;

  etiStat::Count::count.comp++;

  float candEta = sc.eta();
  float candPhi = sc.phi();

  
  auto lb = std::lower_bound(eta,eta+nt,candEta-maxEta);
  auto ub = std::upper_bound(lb,eta+nt,candEta+maxEta);
  uint32_t il = lb-eta;
  uint32_t iu = std::min(nt,uint32_t(ub-eta+1));
  
  etiStat::Count::count.span += (iu-il);

  bool ok[iu-il];
  for (std::size_t i=il;i!=iu; ++i)
    ok[i-il] = (std::find(first,last,id[i])==last);
  


  // should be restricted in eta....
  for (std::size_t i=il;i!=iu; ++i) {
    float dr2 = reco::deltaR2(candEta,candPhi,eta[i], phi[i]);
    float tt = et ? st[i] : 1.f;
    for (std::size_t j=0; j!=NCuts; ++j) {
      if (dr2<extRadius2_[j]) {
        if (dr2>=intRadius2_[j]) {
          sum.he[j] +=he[i]*tt;
          sum.h2[j] +=h2[i]*tt;
        }
        if(ok[i-il]) {
          sum.heBC[j] +=he[i]*tt;
          sum.h2BC[j] +=h2[i]*tt;
        }
      }
    }
  }
}
template<unsigned int NC>
void EgammaTowerIsolationNew< NC >::initSoa ( ) [inline]

Definition at line 93 of file EgammaTowerIsolation.h.

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

                 {
    mem = new uint32_t[nt*6];
    eta = (float*)(mem); phi = eta+nt; he = phi+nt; h2 = he+nt; st = h2+nt;
    id = (uint32_t*)(st) + nt;
 }
template<unsigned int NC>
void EgammaTowerIsolationNew< NC >::setRadius ( float const  extRadius[NC],
float const  intRadius[NC] 
) [inline]

Definition at line 70 of file EgammaTowerIsolation.h.

Referenced by EgammaTowerIsolation::getSum().

                                                                      {
    for (std::size_t i=0; i!=NCuts; ++i) {
      extRadius2_[i]=extRadius[i]*extRadius[i];
      intRadius2_[i]=intRadius[i]*intRadius[i];
    }
    maxEta = *std::max_element(extRadius,extRadius+NC);
  }

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 91 of file EgammaTowerIsolation.h.

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

Definition at line 83 of file EgammaTowerIsolation.h.

Referenced by EgammaTowerIsolationNew< 1 >::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