CMS 3D CMS Logo

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 //
12 
13 // include files
14 
16 
19 
22 
23 //first is the sum E, second is the sum Et
24 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
25 {
26  float sumE=0.;
27  float sumEt=0.;
28 
29  for(HBHERecHitCollection::const_iterator hbheItr = hbhe->begin(); hbheItr != hbhe->end(); ++hbheItr){
30  if(passCleaning_(&(*hbheItr),hcalSevLvlAlgo,dbHcalChStatus)){
31  // if(hbheItr->id().ietaAbs()==29) continue;
32 
33  HcalDetId id = hbheItr->id();
34  if(!(id.ietaAbs()==28 && id.depth()==3)){ //default normal case
35  float energy = hbheItr->energy();
36  const GlobalPoint& pos = geometry->getPosition(id);
37  if(acceptHit_(id,pos,energy,candEta,candPhi)){
38  sumE+=energy;
39  sumEt+=energy*sin(pos.theta());
40  }
41  }else{
42  //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
43  float energy = hbheItr->energy()/2.;
44  HcalDetId tower28Id(id.subdet(),28*id.zside(),id.iphi(),2);
45  const GlobalPoint& tower28Pos = geometry->getPosition(tower28Id);
46  if(acceptHit_(id,tower28Pos,energy,candEta,candPhi)){
47  sumE+=energy;
48  sumEt+=energy*sin(tower28Pos.theta());
49  }
50  HcalDetId tower29Id(id.subdet(),29*id.zside(),id.iphi(),2);
51  const GlobalPoint& tower29Pos = geometry->getPosition(tower29Id);
52  if(acceptHit_(id,tower29Pos,energy,candEta,candPhi)){
53  sumE+=energy;
54  sumEt+=energy*sin(tower29Pos.theta());
55  }
56  }//end of the special case for tower 28 depth 3
57  }//end cleaning check
58  }//end of loop over all rec hits
59  return std::make_pair(sumE,sumEt);
60 
61 }
62 
63 
64 //true if the hit passes Et, E, dR and depth requirements
65 bool EgammaHLTHcalIsolation::acceptHit_(const HcalDetId id,const GlobalPoint& pos,const float hitEnergy,const float candEta,const float candPhi)const
66 {
67  if(passMinE_(hitEnergy,id) && passDepth_(id)){ //doing the energy and depth cuts first will avoid potentially slow eta calc
68  float innerConeSq = innerCone_*innerCone_;
69  float outerConeSq = outerCone_*outerCone_;
70 
71  float hitEta = pos.eta();
72  float hitPhi = pos.phi();
73 
74  float dR2 = reco::deltaR2(candEta,candPhi,hitEta,hitPhi);
75 
76  if(dR2>=innerConeSq && dR2<outerConeSq) { //pass inner and outer cone cuts
77  float hitEt = hitEnergy*sin(2*atan(exp(-hitEta)));
78  if(passMinEt_(hitEt,id)) return true; //and we've passed the last requirement
79  }//end dR check
80  }//end min energy + depth check
81 
82  return false;
83 }
84 
85 bool EgammaHLTHcalIsolation::passMinE_(float energy,const HcalDetId id)const
86 {
87  if(id.subdet()==HcalBarrel && energy>=eMinHB_) return true;
88  else if(id.subdet()==HcalEndcap && energy>=eMinHE_) return true;
89  else return false;
90 }
91 
93 {
94  if(id.subdet()==HcalBarrel && et>=etMinHB_) return true;
95  else if(id.subdet()==HcalEndcap && et>=etMinHE_) return true;
96  else return false;
97 
98 }
99 
101 {
102  if(depth_==-1) return true; //I wish we had chosen 0 as all depths but EgammaTowerIsolation chose -1 and 0 as invalid
103  else if(getEffectiveDepth(id)==depth_) return true;
104  else return false;
105 
106 }
107 
108 //inspired from CaloTowersCreationAlgo::hcalChanStatusForCaloTower, we dont distingush from good from recovered and prob channels
110  const HcalChannelQuality* hcalChanStatus)const
111 {
112  if(hcalSevLvlComp==nullptr || hcalChanStatus==nullptr) return true; //return true if we dont have valid pointers
113 
114  const DetId id = hit->detid();
115 
116  const uint32_t recHitFlag = hit->flags();
117  const uint32_t dbStatusFlag = hcalChanStatus->getValues(id)->getValue();
118 
119  int severityLevel = hcalSevLvlComp->getSeverityLevel(id,recHitFlag,dbStatusFlag);
120  bool isRecovered = hcalSevLvlComp->recoveredRecHit(id,recHitFlag);
121 
122  if(severityLevel == 0) return true;
123  else if(isRecovered) return useRecoveredHcalHits_;
124  else if(severityLevel <= hcalAcceptSeverityLevel_) return true;
125  else return false;
126 }
127 
128 
129 
130 //this is the effective depth of the rec-hit, basically converts 3 depth towers to 2 depths and all barrel to depth 1
132 {
133  int iEtaAbs = id.ietaAbs();
134  int depth = id.depth();
135  if(iEtaAbs<=17 ||
136  (iEtaAbs<=29 && depth==1) ||
137  (iEtaAbs>=27 && iEtaAbs<=29 && depth==2)){
138  return 1;
139  }else return 2;
140 
141 }
bool passDepth_(const HcalDetId id) const
const DetId & detid() const
Definition: CaloRecHit.h:21
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< HBHERecHit >::const_iterator const_iterator
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:22
Definition: DetId.h:18
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
et
define resolution functions of each parameter
std::pair< float, float > getSum(float candEta, float candPhi, const HBHERecHitCollection *hbhe, const CaloGeometry *geometry, const HcalSeverityLevelComputer *hcalSevLvlAlgo=0, const HcalChannelQuality *dbHcalChStatus=0) const
static int getEffectiveDepth(const HcalDetId id)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
T eta() const
Definition: PV3DBase.h:76
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