CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTHcalIsolation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EgammaHLTAlgos
4 // Class : EgammaHLTHcalIsolation
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Monica Vazquez Acosta - CERN
10 // Created: Tue Jun 13 12:16:41 CEST 2006
11 // $Id: EgammaHLTHcalIsolation.cc,v 1.4 2010/08/12 15:25:02 sharper Exp $
12 //
13 
14 // include files
15 
17 
20 
23 
24 //first is the sum E, second is the sum Et
25 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
26 {
27  float sumE=0.;
28  float sumEt=0.;
29 
30  for(HBHERecHitCollection::const_iterator hbheItr = hbhe->begin(); hbheItr != hbhe->end(); ++hbheItr){
31  if(passCleaning_(&(*hbheItr),hcalSevLvlAlgo,dbHcalChStatus)){
32  // if(hbheItr->id().ietaAbs()==29) continue;
33 
34  HcalDetId id = hbheItr->id();
35  if(!(id.ietaAbs()==28 && id.depth()==3)){ //default normal case
36  float energy = hbheItr->energy();
37  const GlobalPoint& pos = geometry->getPosition(id);
38  if(acceptHit_(id,pos,energy,candEta,candPhi)){
39  sumE+=energy;
40  sumEt+=energy*sin(pos.theta());
41  }
42  }else{
43  //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
44  float energy = hbheItr->energy()/2.;
45  HcalDetId tower28Id(id.subdet(),28*id.zside(),id.iphi(),2);
46  const GlobalPoint& tower28Pos = geometry->getPosition(tower28Id);
47  if(acceptHit_(id,tower28Pos,energy,candEta,candPhi)){
48  sumE+=energy;
49  sumEt+=energy*sin(tower28Pos.theta());
50  }
51  HcalDetId tower29Id(id.subdet(),29*id.zside(),id.iphi(),2);
52  const GlobalPoint& tower29Pos = geometry->getPosition(tower29Id);
53  if(acceptHit_(id,tower29Pos,energy,candEta,candPhi)){
54  sumE+=energy;
55  sumEt+=energy*sin(tower29Pos.theta());
56  }
57  }//end of the special case for tower 28 depth 3
58  }//end cleaning check
59  }//end of loop over all rec hits
60  return std::make_pair(sumE,sumEt);
61 
62 }
63 
64 
65 //true if the hit passes Et, E, dR and depth requirements
66 bool EgammaHLTHcalIsolation::acceptHit_(const HcalDetId id,const GlobalPoint& pos,const float hitEnergy,const float candEta,const float candPhi)const
67 {
68  if(passMinE_(hitEnergy,id) && passDepth_(id)){ //doing the energy and depth cuts first will avoid potentially slow eta calc
69  float innerConeSq = innerCone_*innerCone_;
70  float outerConeSq = outerCone_*outerCone_;
71 
72  float hitEta = pos.eta();
73  float hitPhi = pos.phi();
74 
75  float dR2 = reco::deltaR2(candEta,candPhi,hitEta,hitPhi);
76 
77  if(dR2>=innerConeSq && dR2<outerConeSq) { //pass inner and outer cone cuts
78  float hitEt = hitEnergy*sin(2*atan(exp(-hitEta)));
79  if(passMinEt_(hitEt,id)) return true; //and we've passed the last requirement
80  }//end dR check
81  }//end min energy + depth check
82 
83  return false;
84 }
85 
87 {
88  if(id.subdet()==HcalBarrel && energy>=eMinHB_) return true;
89  else if(id.subdet()==HcalEndcap && energy>=eMinHE_) return true;
90  else return false;
91 }
92 
93 bool EgammaHLTHcalIsolation::passMinEt_(float et,const HcalDetId id)const
94 {
95  if(id.subdet()==HcalBarrel && et>=etMinHB_) return true;
96  else if(id.subdet()==HcalEndcap && et>=etMinHE_) return true;
97  else return false;
98 
99 }
100 
102 {
103  if(depth_==-1) return true; //I wish we had chosen 0 as all depths but EgammaTowerIsolation chose -1 and 0 as invalid
104  else if(getEffectiveDepth(id)==depth_) return true;
105  else return false;
106 
107 }
108 
109 //inspired from CaloTowersCreationAlgo::hcalChanStatusForCaloTower, we dont distingush from good from recovered and prob channels
111  const HcalChannelQuality* hcalChanStatus)const
112 {
113  if(hcalSevLvlComp==NULL || hcalChanStatus==NULL) return true; //return true if we dont have valid pointers
114 
115  const DetId id = hit->detid();
116 
117  const uint32_t recHitFlag = hit->flags();
118  const uint32_t dbStatusFlag = hcalChanStatus->getValues(id)->getValue();
119 
120  int severityLevel = hcalSevLvlComp->getSeverityLevel(id,recHitFlag,dbStatusFlag);
121  bool isRecovered = hcalSevLvlComp->recoveredRecHit(id,recHitFlag);
122 
123  if(severityLevel == 0) return true;
124  else if(isRecovered) return useRecoveredHcalHits_;
125  else if(severityLevel <= hcalAcceptSeverityLevel_) return true;
126  else return false;
127 }
128 
129 
130 
131 //this is the effective depth of the rec-hit, basically converts 3 depth towers to 2 depths and all barrel to depth 1
133 {
134  int iEtaAbs = id.ietaAbs();
135  int depth = id.depth();
136  if(iEtaAbs<=17 ||
137  (iEtaAbs<=29 && depth==1) ||
138  (iEtaAbs>=27 && iEtaAbs<=29 && depth==2)){
139  return 1;
140  }else return 2;
141 
142 }
bool passDepth_(const HcalDetId id) const
std::pair< float, float > getSum(float candEta, float candPhi, const HBHERecHitCollection *hbhe, const CaloGeometry *geometry, const HcalSeverityLevelComputer *hcalSevLvlAlgo=NULL, const HcalChannelQuality *dbHcalChStatus=NULL) const
const DetId & detid() const
Definition: CaloRecHit.h:22
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool passCleaning_(const CaloRecHit *hit, const HcalSeverityLevelComputer *hcalSevLvlComp, const HcalChannelQuality *hcalChanStatus) const
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< T >::const_iterator const_iterator
#define NULL
Definition: scimark2.h:8
const Item * getValues(DetId fId, bool throwOnFail=true) const
bool passMinEt_(float et, const HcalDetId id) const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
bool recoveredRecHit(const DetId &myid, const uint32_t &myflag) const
uint32_t flags() const
Definition: CaloRecHit.h:23
Definition: DetId.h:20
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
static int getEffectiveDepth(const HcalDetId id)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:58
T eta() const
Definition: PV3DBase.h:76
ESHandle< TrackerGeometry > geometry
bool acceptHit_(const HcalDetId id, const GlobalPoint &pos, const float hitEnergy, const float candEta, const float candPhi) const
uint32_t getValue() const
bool passMinE_(float energy, const HcalDetId id) const