test
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 namespace {
27  struct TLS {
28  EgammaTowerIsolationNew<1> * newAlgo=nullptr;;
29  const CaloTowerCollection* oldTowers=nullptr;;
30  uint32_t id15=0;
31  };
32  thread_local static TLS tls;
33 }
34 
36  float intRadiusI,
37  float etLow,
38  signed int depth,
39  const CaloTowerCollection* towers ) :
40  depth_(depth),
41  extRadius(extRadiusI),
42  intRadius(intRadiusI)
43 {
44  assert(0==etLow);
45 
46  // extremely poor in quality (test of performance)
47  if (tls.newAlgo==nullptr || towers!=tls.oldTowers || towers->size()!=tls.newAlgo->nt || (towers->size()>15 && (*towers)[15].id()!=tls.id15)) {
48  delete tls.newAlgo;
50  tls.oldTowers=towers;
51  tls.id15 = towers->size()>15 ? (*towers)[15].id() : 0;
52  }
53 }
54 
55 
56 double EgammaTowerIsolation::getSum (bool et, reco::SuperCluster const & sc, const std::vector<CaloTowerDetId> * detIdToExclude) const{
57 
58  if (0!=detIdToExclude) assert(0==intRadius);
59 
60  // hack
61  tls.newAlgo->setRadius(&extRadius,&intRadius);
62 
64  tls.newAlgo->compute(et, sum, sc,
65  (detIdToExclude==0) ? nullptr : &((*detIdToExclude).front()),
66  (detIdToExclude==0) ? nullptr : (&(*detIdToExclude).back())+1
67  );
68 
69  switch(depth_){
70  case AllDepths: return detIdToExclude==0 ? sum.he[0] : sum.heBC[0];
71  case Depth1: return detIdToExclude==0 ? sum.he[0]-sum.h2[0] : sum.heBC[0]-sum.h2BC[0];
72  case Depth2:return detIdToExclude==0 ? sum.h2[0] : sum.h2BC[0];
73  default: return 0;
74  }
75  return 0;
76 }
77 
double getSum(bool et, reco::SuperCluster const &sc, const std::vector< CaloTowerDetId > *detIdToExclude) const
assert(m_qm.get())
size_type size() const
EgammaTowerIsolation(float extRadiusI, float intRadiusI, float etLow, signed int depth, const CaloTowerCollection *towers)