CMS 3D CMS Logo

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 #include <memory>
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  std::unique_ptr<EgammaTowerIsolationNew<1>> newAlgo=nullptr;;
29  const CaloTowerCollection* oldTowers=nullptr;;
30  uint32_t id15=0;
31  };
32  thread_local 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.get()==nullptr || towers!=tls.oldTowers || towers->size()!=tls.newAlgo->nt || (towers->size()>15 && (*towers)[15].id()!=tls.id15)) {
48  tls.newAlgo = std::make_unique<EgammaTowerIsolationNew<1>>(&extRadius,&intRadius,*towers);
49  tls.oldTowers=towers;
50  tls.id15 = towers->size()>15 ? (*towers)[15].id() : 0;
51  }
52 }
53 
54 
55 double EgammaTowerIsolation::getSum (bool et, reco::SuperCluster const & sc, const std::vector<CaloTowerDetId> * detIdToExclude) const{
56 
57  if (0!=detIdToExclude) assert(0==intRadius);
58 
59  // hack
60  tls.newAlgo->setRadius(&extRadius,&intRadius);
61 
63  tls.newAlgo->compute(et, sum, sc,
64  (detIdToExclude==0) ? nullptr : &((*detIdToExclude).front()),
65  (detIdToExclude==0) ? nullptr : (&(*detIdToExclude).back())+1
66  );
67 
68  switch(depth_){
69  case AllDepths: return detIdToExclude==0 ? sum.he[0] : sum.heBC[0];
70  case Depth1: return detIdToExclude==0 ? sum.he[0]-sum.h2[0] : sum.heBC[0]-sum.h2BC[0];
71  case Depth2:return detIdToExclude==0 ? sum.h2[0] : sum.h2BC[0];
72  default: return 0;
73  }
74  return 0;
75 }
76 
double getSum(bool et, reco::SuperCluster const &sc, const std::vector< CaloTowerDetId > *detIdToExclude) const
et
define resolution functions of each parameter
size_type size() const
EgammaTowerIsolation(float extRadiusI, float intRadiusI, float etLow, signed int depth, const CaloTowerCollection *towers)