CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoEgamma/EgammaHLTAlgos/src/EgammaHLTHcalIsolation.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     EgammaHLTAlgos
00004 // Class  :     EgammaHLTHcalIsolation
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Monica Vazquez Acosta - CERN
00010 //         Created:  Tue Jun 13 12:16:41 CEST 2006
00011 // $Id: EgammaHLTHcalIsolation.cc,v 1.4 2010/08/12 15:25:02 sharper Exp $
00012 //
00013 
00014 // include files
00015 
00016 #include "RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTHcalIsolation.h"
00017 
00018 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00019 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00020 
00021 #include "DataFormats/Math/interface/deltaR.h"
00022 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00023 
00024 //first is the sum E, second is the sum Et
00025 std::pair<float,float> EgammaHLTHcalIsolation::getSum(const float candEta,const float candPhi, const HBHERecHitCollection* hbhe, const CaloGeometry* geometry,const HcalSeverityLevelComputer* hcalSevLvlAlgo,const HcalChannelQuality* dbHcalChStatus)const //note last two pointers can be NULL
00026 {
00027   float sumE=0.;
00028   float sumEt=0.;
00029   
00030   for(HBHERecHitCollection::const_iterator hbheItr = hbhe->begin(); hbheItr != hbhe->end(); ++hbheItr){
00031     if(passCleaning_(&(*hbheItr),hcalSevLvlAlgo,dbHcalChStatus)){
00032       //      if(hbheItr->id().ietaAbs()==29) continue;
00033 
00034       HcalDetId id = hbheItr->id();
00035       if(!(id.ietaAbs()==28 && id.depth()==3)){ //default normal case
00036         float energy = hbheItr->energy();
00037         const GlobalPoint& pos = geometry->getPosition(id);
00038         if(acceptHit_(id,pos,energy,candEta,candPhi)){
00039           sumE+=energy;
00040           sumEt+=energy*sin(pos.theta());
00041         }
00042       }else{
00043         //the special case, tower 28 depth 3 is split between tower 28 and 29 when using calo towers so we have to emulate it. To do this we need to divide energy by 2 and then check seperately if 28 and 29 are accepted
00044         float energy = hbheItr->energy()/2.;
00045         HcalDetId tower28Id(id.subdet(),28*id.zside(),id.iphi(),2);
00046         const GlobalPoint& tower28Pos = geometry->getPosition(tower28Id);
00047         if(acceptHit_(id,tower28Pos,energy,candEta,candPhi)){
00048           sumE+=energy;
00049           sumEt+=energy*sin(tower28Pos.theta());
00050         }
00051         HcalDetId tower29Id(id.subdet(),29*id.zside(),id.iphi(),2);
00052         const GlobalPoint& tower29Pos = geometry->getPosition(tower29Id);
00053         if(acceptHit_(id,tower29Pos,energy,candEta,candPhi)){
00054           sumE+=energy;
00055           sumEt+=energy*sin(tower29Pos.theta());
00056         }
00057       }//end of the special case for tower 28 depth 3
00058     }//end cleaning check
00059   }//end of loop over all rec hits
00060   return std::make_pair(sumE,sumEt);
00061   
00062 }
00063 
00064 
00065 //true if the hit passes Et, E, dR and depth requirements
00066 bool EgammaHLTHcalIsolation::acceptHit_(const HcalDetId id,const GlobalPoint& pos,const float hitEnergy,const float candEta,const float candPhi)const
00067 {
00068   if(passMinE_(hitEnergy,id) && passDepth_(id)){ //doing the energy and depth cuts first will avoid potentially slow eta calc
00069     float innerConeSq = innerCone_*innerCone_; 
00070     float outerConeSq = outerCone_*outerCone_;
00071 
00072     float hitEta = pos.eta();
00073     float hitPhi = pos.phi();
00074     
00075     float dR2 = reco::deltaR2(candEta,candPhi,hitEta,hitPhi);
00076     
00077     if(dR2>=innerConeSq && dR2<outerConeSq) { //pass inner and outer cone cuts
00078       float hitEt = hitEnergy*sin(2*atan(exp(-hitEta)));
00079       if(passMinEt_(hitEt,id)) return true; //and we've passed the last requirement
00080     }//end dR check
00081   }//end min energy + depth check
00082   
00083   return false;
00084 }
00085 
00086 bool EgammaHLTHcalIsolation::passMinE_(float energy,const HcalDetId id)const
00087 {
00088   if(id.subdet()==HcalBarrel && energy>=eMinHB_) return true;
00089   else if(id.subdet()==HcalEndcap && energy>=eMinHE_) return true;
00090   else return false;
00091 }
00092 
00093 bool EgammaHLTHcalIsolation::passMinEt_(float et,const HcalDetId id)const
00094 {
00095   if(id.subdet()==HcalBarrel && et>=etMinHB_) return true;
00096   else if(id.subdet()==HcalEndcap && et>=etMinHE_) return true;
00097   else return false;
00098 
00099 }
00100 
00101 bool EgammaHLTHcalIsolation::passDepth_(const HcalDetId id)const
00102 {
00103   if(depth_==-1) return true; //I wish we had chosen 0 as all depths but EgammaTowerIsolation chose -1 and 0 as invalid
00104   else if(getEffectiveDepth(id)==depth_) return true;
00105   else return false;
00106     
00107 }
00108 
00109 //inspired from CaloTowersCreationAlgo::hcalChanStatusForCaloTower, we dont distingush from good from recovered and prob channels
00110 bool EgammaHLTHcalIsolation::passCleaning_(const CaloRecHit* hit,const HcalSeverityLevelComputer* hcalSevLvlComp,
00111                                            const HcalChannelQuality* hcalChanStatus)const
00112 {
00113   if(hcalSevLvlComp==NULL || hcalChanStatus==NULL) return true; //return true if we dont have valid pointers
00114 
00115   const DetId id = hit->detid();
00116   
00117   const uint32_t recHitFlag = hit->flags();
00118   const uint32_t dbStatusFlag = hcalChanStatus->getValues(id)->getValue();
00119   
00120   int severityLevel = hcalSevLvlComp->getSeverityLevel(id,recHitFlag,dbStatusFlag);
00121   bool isRecovered = hcalSevLvlComp->recoveredRecHit(id,recHitFlag);
00122   
00123   if(severityLevel == 0) return true;
00124   else if(isRecovered) return useRecoveredHcalHits_;
00125   else if(severityLevel <= hcalAcceptSeverityLevel_) return true;
00126   else return false;
00127 }
00128 
00129 
00130 
00131 //this is the effective depth of the rec-hit, basically converts 3 depth towers to 2 depths and all barrel to depth 1
00132 int EgammaHLTHcalIsolation::getEffectiveDepth(const HcalDetId id)
00133 {
00134   int iEtaAbs = id.ietaAbs();
00135   int depth = id.depth();
00136   if(iEtaAbs<=17 ||
00137      (iEtaAbs<=29 && depth==1) ||
00138      (iEtaAbs>=27 && iEtaAbs<=29 && depth==2)){   
00139     return 1;
00140   }else return 2;
00141   
00142 }