CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoEgamma/EgammaIsolationAlgos/src/EgammaTowerIsolation.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaTowerIsolation.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 //CMSSW includes
00010 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
00011 #include<cassert>
00012 
00013 
00014 // #include<iostream>
00015 namespace etiStat {
00016   Count::~Count() { 
00017     //    std::cout << "\nEgammaTowerIsolationNew " << create << "/" << comp << "/" << float(span)/float(comp)  
00018     //        << std::endl<< std::endl;
00019     }
00020 
00021   Count Count::count;
00022 }
00023 
00024 
00025 
00026 EgammaTowerIsolationNew<1> *EgammaTowerIsolation::newAlgo=nullptr;
00027 const CaloTowerCollection* EgammaTowerIsolation::oldTowers=nullptr;
00028 uint32_t EgammaTowerIsolation::id15=0;
00029 
00030 EgammaTowerIsolation::EgammaTowerIsolation (float extRadiusI,
00031                                             float intRadiusI,
00032                                             float etLow,
00033                                             signed int depth,
00034                                             const CaloTowerCollection* towers ) :  
00035   depth_(depth), 
00036   extRadius(extRadiusI),
00037   intRadius(intRadiusI)
00038 {
00039   assert(0==etLow);
00040 
00041   // cheating  (test of performance)
00042   if (newAlgo==nullptr ||  towers!=oldTowers || towers->size()!=newAlgo->nt || (towers->size()>15 && (*towers)[15].id()!=id15)) {
00043     delete newAlgo;
00044     newAlgo = new EgammaTowerIsolationNew<1>(&extRadius,&intRadius,*towers);
00045     oldTowers=towers;
00046     id15 = (*towers)[15].id();
00047   }
00048 }
00049 
00050 
00051 double  EgammaTowerIsolation::getSum (bool et, reco::SuperCluster const & sc, const std::vector<CaloTowerDetId> * detIdToExclude) const{
00052 
00053   if (0!=detIdToExclude) assert(0==intRadius);
00054 
00055   // hack
00056   newAlgo->setRadius(&extRadius,&intRadius);
00057 
00058   EgammaTowerIsolationNew<1>::Sum sum;
00059   newAlgo->compute(et, sum, sc, 
00060                   (detIdToExclude==0) ? nullptr : &((*detIdToExclude).front()),
00061                   (detIdToExclude==0) ? nullptr : (&(*detIdToExclude).back())+1
00062                   );
00063   
00064   switch(depth_){
00065   case AllDepths: return detIdToExclude==0 ? sum.he[0] : sum.heBC[0]; 
00066   case Depth1: return detIdToExclude==0 ? sum.he[0]-sum.h2[0] : sum.heBC[0]-sum.h2BC[0]; 
00067   case Depth2:return detIdToExclude==0 ? sum.h2[0] : sum.h2BC[0]; 
00068   default: return 0;
00069   }
00070   return 0;
00071 }
00072