CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaTowerIsolation.cc
Go to the documentation of this file.
1 //*****************************************************************************
2 // File: EgammaTowerIsolation.cc
3 // ----------------------------------------------------------------------------
4 // OrigAuth: Matthias Mozer
5 // Institute: IIHE-VUB
6 //=============================================================================
7 //*****************************************************************************
8 
9 //CMSSW includes
11 #include<cassert>
12 
13 
14 #ifdef ETISTATDEBUG
15 // #include<iostream>
16 namespace etiStat {
17  Count::~Count() {
18  // std::cout << "\nEgammaTowerIsolationNew " << create << "/" << comp << "/" << float(span)/float(comp)
19  // << std::endl<< std::endl;
20  }
21 
22  Count Count::count;
23 }
24 #endif
25 
26 
28 thread_local const CaloTowerCollection* EgammaTowerIsolation::oldTowers=nullptr;
29 thread_local uint32_t EgammaTowerIsolation::id15=0;
30 
32  float intRadiusI,
33  float etLow,
34  signed int depth,
35  const CaloTowerCollection* towers ) :
36  depth_(depth),
37  extRadius(extRadiusI),
38  intRadius(intRadiusI)
39 {
40  assert(0==etLow);
41 
42  // extremely poor in quality (test of performance)
43  if (newAlgo==nullptr || towers!=oldTowers || towers->size()!=newAlgo->nt || (towers->size()>15 && (*towers)[15].id()!=id15)) {
44  delete newAlgo;
46  oldTowers=towers;
47  id15 = towers->size()>15 ? (*towers)[15].id() : 0;
48  }
49 }
50 
51 
52 double EgammaTowerIsolation::getSum (bool et, reco::SuperCluster const & sc, const std::vector<CaloTowerDetId> * detIdToExclude) const{
53 
54  if (0!=detIdToExclude) assert(0==intRadius);
55 
56  // hack
58 
60  newAlgo->compute(et, sum, sc,
61  (detIdToExclude==0) ? nullptr : &((*detIdToExclude).front()),
62  (detIdToExclude==0) ? nullptr : (&(*detIdToExclude).back())+1
63  );
64 
65  switch(depth_){
66  case AllDepths: return detIdToExclude==0 ? sum.he[0] : sum.heBC[0];
67  case Depth1: return detIdToExclude==0 ? sum.he[0]-sum.h2[0] : sum.heBC[0]-sum.h2BC[0];
68  case Depth2:return detIdToExclude==0 ? sum.h2[0] : sum.h2BC[0];
69  default: return 0;
70  }
71  return 0;
72 }
73 
double getSum(bool et, reco::SuperCluster const &sc, const std::vector< CaloTowerDetId > *detIdToExclude) const
static thread_local uint32_t id15
static thread_local EgammaTowerIsolationNew< 1 > * newAlgo
static thread_local const CaloTowerCollection * oldTowers
void setRadius(float const extRadius[NC], float const intRadius[NC])
size_type size() const
EgammaTowerIsolation(float extRadiusI, float intRadiusI, float etLow, signed int depth, const CaloTowerCollection *towers)
void compute(bool et, Sum &sum, reco::Candidate const &cand, CaloTowerDetId const *first, CaloTowerDetId const *last) const