CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes
l1t::CaloTools Class Reference

#include <CaloTools.h>

Public Types

enum  SubDet { ECAL =0x1, HCAL =0x2, CALO =0x3 }
 

Static Public Member Functions

static int calHwEtSum (int iEta, int iPhi, const std::vector< l1t::CaloTower > &towers, int localEtaMin, int localEtaMax, int localPhiMin, int localPhiMax, SubDet etMode=CALO)
 
static int calHwEtSum (int iEta, int iPhi, const std::vector< l1t::CaloTower > &towers, int localEtaMin, int localEtaMax, int localPhiMin, int localPhiMax, int iEtaAbsMax, SubDet etMode=CALO)
 
static size_t calNrTowers (int iEtaMin, int iEtaMax, int iPhiMin, int iPhiMax, const std::vector< l1t::CaloTower > &towers, int minHwEt, int maxHwEt, SubDet etMode=CALO)
 
static size_t caloTowerHash (int iEta, int iPhi)
 
static size_t caloTowerHashMax ()
 
static const l1t::CaloClustergetCluster (const std::vector< l1t::CaloCluster > &clusters, int iEta, int iPhi)
 
static const l1t::CaloTowergetTower (const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
 
static bool isValidIEtaIPhi (int iEta, int iPhi)
 
static float towerEta (int ieta)
 
static float towerEtaSize (int ieta)
 
static float towerPhi (int ieta, int iphi)
 
static float towerPhiSize (int ieta)
 

Private Member Functions

 CaloTools ()
 
 ~CaloTools ()
 

Static Private Member Functions

static std::pair< float, float > towerEtaBounds (int ieta)
 

Static Private Attributes

static const int kHBHEEnd =28
 
static const int kHBHENrPhi =72
 
static const int kHFBegin =29
 
static const int kHFEnd =32
 
static const int kHFNrPhi =72/kHFPhiSeg
 
static const int kHFPhiSeg =4
 
static const int kNrHBHETowers = kHBHEEnd*kHBHENrPhi*2
 
static const int kNrTowers = ((kHFEnd-kHFBegin+1)*kHFNrPhi + kHBHEEnd*kHBHENrPhi )*2
 
static const l1t::CaloCluster nullCluster_
 
static const l1t::CaloTower nullTower_
 

Detailed Description

Description: A collection of useful functions for the Calorimeter that are of generic interest

Implementation: currently implimented as a static class rather than a namespace, open to re-writing it as namespace

Author
: Sam Harper - RAL

Definition at line 22 of file CaloTools.h.

Member Enumeration Documentation

Enumerator
ECAL 
HCAL 
CALO 

Definition at line 42 of file CaloTools.h.

42 {ECAL=0x1,HCAL=0x2,CALO=0x3}; //CALO is a short cut for ECAL|HCAL

Constructor & Destructor Documentation

l1t::CaloTools::CaloTools ( )
inlineprivate

Definition at line 26 of file CaloTools.h.

26 {}
l1t::CaloTools::~CaloTools ( )
inlineprivate

Definition at line 27 of file CaloTools.h.

27 {}

Member Function Documentation

int l1t::CaloTools::calHwEtSum ( int  iEta,
int  iPhi,
const std::vector< l1t::CaloTower > &  towers,
int  localEtaMin,
int  localEtaMax,
int  localPhiMin,
int  localPhiMax,
SubDet  etMode = CALO 
)
static

Definition at line 81 of file CaloTools.cc.

Referenced by l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::isoCalEgHwFootPrint(), l1t::Stage2Layer2TauAlgorithmFirmwareImp1::isoCalTauHwFootPrint(), l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

84 {
85 
86  return calHwEtSum(iEta,iPhi,towers,localEtaMin,localEtaMax,localPhiMin,localPhiMax,kHFEnd,etMode);
87 }
static int calHwEtSum(int iEta, int iPhi, const std::vector< l1t::CaloTower > &towers, int localEtaMin, int localEtaMax, int localPhiMin, int localPhiMax, SubDet etMode=CALO)
Definition: CaloTools.cc:81
static const int kHFEnd
Definition: CaloTools.h:34
int l1t::CaloTools::calHwEtSum ( int  iEta,
int  iPhi,
const std::vector< l1t::CaloTower > &  towers,
int  localEtaMin,
int  localEtaMax,
int  localPhiMin,
int  localPhiMax,
int  iEtaAbsMax,
SubDet  etMode = CALO 
)
static

Definition at line 89 of file CaloTools.cc.

References funct::abs(), ECAL, HCAL, l1t::CaloTower::hwEtEm(), l1t::CaloTower::hwEtHad(), l1t::CaloStage2Nav::offsetIEta(), and l1t::CaloStage2Nav::offsetIPhi().

92 {
93  int hwEtSum=0;
94  for(int etaNr=localEtaMin;etaNr<=localEtaMax;etaNr++){
95  for(int phiNr=localPhiMin;phiNr<=localPhiMax;phiNr++){
96 
97  int towerIEta = l1t::CaloStage2Nav::offsetIEta(iEta,etaNr);
98  int towerIPhi = l1t::CaloStage2Nav::offsetIPhi(iPhi,phiNr);
99  if(abs(towerIEta)<=iEtaAbsMax){
100  const l1t::CaloTower& tower = getTower(towers,towerIEta,towerIPhi);
101  if(etMode&ECAL) hwEtSum+=tower.hwEtEm();
102  if(etMode&HCAL) hwEtSum+=tower.hwEtHad();
103  }
104  }
105  }
106  return hwEtSum;
107 }
static int offsetIEta(int iEta, int offset)
Definition: CaloStage2Nav.h:43
int hwEtEm() const
Definition: CaloTower.cc:64
static int offsetIPhi(int iPhi, int offset)
Definition: CaloStage2Nav.h:32
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:11
int hwEtHad() const
Definition: CaloTower.cc:69
size_t l1t::CaloTools::calNrTowers ( int  iEtaMin,
int  iEtaMax,
int  iPhiMin,
int  iPhiMax,
const std::vector< l1t::CaloTower > &  towers,
int  minHwEt,
int  maxHwEt,
SubDet  etMode = CALO 
)
static

Definition at line 110 of file CaloTools.cc.

References l1t::CaloStage2Nav::currIEta(), l1t::CaloStage2Nav::currIPhi(), l1t::CaloStage2Nav::east(), ECAL, getTower(), HCAL, l1t::CaloTower::hwEtEm(), l1t::CaloTower::hwEtHad(), l1t::L1Candidate::hwPt(), l1t::CaloStage2Nav::north(), and l1t::CaloStage2Nav::resetIPhi().

Referenced by l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

111 {
112  size_t nrTowers=0;
113  l1t::CaloStage2Nav nav(iEtaMin,iPhiMin);
114  while(nav.currIEta()<=iEtaMax){
115  bool finishPhi = false;
116  while(!finishPhi){
117  const l1t::CaloTower& tower = l1t::CaloTools::getTower(towers,nav.currIEta(),nav.currIPhi());
118  int towerHwEt =0;
119  if(etMode&ECAL) towerHwEt+=tower.hwEtEm();
120  if(etMode&HCAL) towerHwEt+=tower.hwEtHad();
121  if(etMode&CALO) towerHwEt+=tower.hwPt();
122  if(towerHwEt>=minHwEt && towerHwEt<=maxHwEt) nrTowers++;
123  finishPhi = (nav.currIPhi() == iPhiMax);
124  nav.north();
125  }
126  nav.east();
127  nav.resetIPhi();
128  }
129  return nrTowers;
130 }
int hwEtEm() const
Definition: CaloTower.cc:64
int hwPt() const
Definition: L1Candidate.cc:69
static const l1t::CaloTower & getTower(const std::vector< l1t::CaloTower > &towers, int iEta, int iPhi)
Definition: CaloTools.cc:11
int hwEtHad() const
Definition: CaloTower.cc:69
size_t l1t::CaloTools::caloTowerHash ( int  iEta,
int  iPhi 
)
static

Definition at line 45 of file CaloTools.cc.

References funct::abs().

Referenced by getTower(), and l1t::stage2::CaloTowerPacker::pack().

46 {
47 
48  if(!isValidIEtaIPhi(iEta,iPhi)) return caloTowerHashMax();
49  else{
50  const int absIEta = abs(iEta);
51  if(absIEta>kHFEnd) return kNrTowers;
52  else if(absIEta<=kHBHEEnd){ //HBHE
53  int iEtaNoZero=iEta;
54  if(iEta>0) iEtaNoZero--;
55  return (iEtaNoZero+kHBHEEnd)*kHBHENrPhi+iPhi-1;
56  }else{ //HF
57  int iEtaIndex = iEta+kHFEnd; //iEta=-32 is 0
58  if(iEta>0) iEtaIndex= iEta-kHBHEEnd+(kHFEnd-kHBHEEnd)-1; //but iEta=29 is 4
59  return iEtaIndex*kHFNrPhi+iPhi/kHFPhiSeg + kNrHBHETowers;
60  }
61  }
62 }
static const int kHFPhiSeg
Definition: CaloTools.h:35
static bool isValidIEtaIPhi(int iEta, int iPhi)
Definition: CaloTools.cc:71
static const int kHBHEEnd
Definition: CaloTools.h:32
static const int kNrHBHETowers
Definition: CaloTools.h:39
static const int kHFNrPhi
Definition: CaloTools.h:36
static const int kHFEnd
Definition: CaloTools.h:34
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kNrTowers
Definition: CaloTools.h:38
static const int kHBHENrPhi
Definition: CaloTools.h:37
static size_t caloTowerHashMax()
Definition: CaloTools.cc:65
size_t l1t::CaloTools::caloTowerHashMax ( )
static

Definition at line 65 of file CaloTools.cc.

66 {
67  return kNrTowers;
68 }
static const int kNrTowers
Definition: CaloTools.h:38
const l1t::CaloCluster & l1t::CaloTools::getCluster ( const std::vector< l1t::CaloCluster > &  clusters,
int  iEta,
int  iPhi 
)
static

Definition at line 32 of file CaloTools.cc.

Referenced by l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::filtering(), l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::sharing().

33 {
34  for(size_t clusterNr=0;clusterNr<clusters.size();clusterNr++){
35  if(clusters[clusterNr].hwEta()==iEta && clusters[clusterNr].hwPhi()==iPhi) return clusters[clusterNr];
36  }
37  return nullCluster_;
38 }
static const l1t::CaloCluster nullCluster_
Definition: CaloTools.h:81
const l1t::CaloTower & l1t::CaloTools::getTower ( const std::vector< l1t::CaloTower > &  towers,
int  iEta,
int  iPhi 
)
static

Definition at line 11 of file CaloTools.cc.

References caloTowerHash(), and nullTower_.

Referenced by L1TStage2InputPatternWriter::analyze(), calNrTowers(), l1t::Stage2Layer2JetAlgorithmFirmwareImp1::chunkyDonutPUEstimate(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::clustering(), l1t::Stage2Layer2JetAlgorithmFirmwareImp1::create(), l1t::Stage2Layer2JetAlgorithmFirmwareImp1::donutPUEstimate(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::filtering(), l1t::Stage2Layer2EtSumAlgorithmFirmwareImp1::processEvent(), l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::refining(), and l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::sharing().

12 {
13  size_t towerIndex = CaloTools::caloTowerHash(iEta, iPhi);
14  if(towerIndex<towers.size()){
15  if(towers[towerIndex].hwEta()!=iEta || towers[towerIndex].hwPhi()!=iPhi){ //it failed, this is bad, but we will not log the error due to policy and silently attempt to do a brute force search instead
16  // std::cout <<"error, tower "<<towers[towerIndex].hwEta()<<" "<<towers[towerIndex].hwPhi()<<" does not match "<<iEta<<" "<<iPhi<<" index "<<towerIndex<<" nr towrs "<<towers.size()<<std::endl;
17  for(size_t towerNr=0;towerNr<towers.size();towerNr++){
18  if(towers[towerNr].hwEta()==iEta && towers[towerNr].hwPhi()==iPhi) return towers[towerNr];
19  }
20  }else return towers[towerIndex];
21 
22  }
23  else{// in case the vector of towers do not contain all the towers (towerIndex can be > towers.size())
24  for(size_t towerNr=0;towerNr<towers.size();towerNr++){
25  if(towers[towerNr].hwEta()==iEta && towers[towerNr].hwPhi()==iPhi) return towers[towerNr];
26  }
27  }
28 
29  return nullTower_;
30 }
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:45
static const l1t::CaloTower nullTower_
Definition: CaloTools.h:80
bool l1t::CaloTools::isValidIEtaIPhi ( int  iEta,
int  iPhi 
)
static

Definition at line 71 of file CaloTools.cc.

References funct::abs().

72 {
73  size_t absIEta = abs(iEta);
74  if(iPhi<=0 || iPhi>kHBHENrPhi) return false;
75  if(absIEta==0 || absIEta>kHFEnd) return false;
76  if(absIEta>kHBHEEnd && iPhi%kHFPhiSeg!=1) return false;
77  return true;
78 
79 }
static const int kHFPhiSeg
Definition: CaloTools.h:35
static const int kHBHEEnd
Definition: CaloTools.h:32
static const int kHFEnd
Definition: CaloTools.h:34
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int kHBHENrPhi
Definition: CaloTools.h:37
float l1t::CaloTools::towerEta ( int  ieta)
static

Definition at line 141 of file CaloTools.cc.

References eta(), and jetcorrextractor::sign().

Referenced by l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

142 {
143  std::pair<float,float> bounds = towerEtaBounds(ieta);
144  float eta = (bounds.second+bounds.first)/2.;
145  float sign = ieta>0 ? 1. : -1.;
146  return sign*eta;
147 }
double sign(double x)
T eta() const
static std::pair< float, float > towerEtaBounds(int ieta)
Definition: CaloTools.cc:132
std::pair< float, float > l1t::CaloTools::towerEtaBounds ( int  ieta)
staticprivate

Definition at line 132 of file CaloTools.cc.

References funct::abs().

133 {
134  if(ieta==0) ieta = 1;
135  if(ieta>32) ieta = 32;
136  if(ieta<-32) ieta = -32;
137  const float towerEtas[33] = {0,0.087,0.174,0.261,0.348,0.435,0.522,0.609,0.696,0.783,0.870,0.957,1.044,1.131,1.218,1.305,1.392,1.479,1.566,1.653,1.740,1.830,1.930,2.043,2.172,2.322,2.5,2.650,3.000,3.5,4.0,4.5,5.0};
138  return std::make_pair( towerEtas[abs(ieta)-1],towerEtas[abs(ieta)] );
139 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float l1t::CaloTools::towerEtaSize ( int  ieta)
static

Definition at line 154 of file CaloTools.cc.

References findQualityFiles::size.

Referenced by l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

155 {
156  std::pair<float,float> bounds = towerEtaBounds(ieta);
157  float size = (bounds.second-bounds.first);
158  return size;
159 }
static std::pair< float, float > towerEtaBounds(int ieta)
Definition: CaloTools.cc:132
tuple size
Write out results.
float l1t::CaloTools::towerPhi ( int  ieta,
int  iphi 
)
static

Definition at line 149 of file CaloTools.cc.

Referenced by l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

150 {
151  return (float(iphi)-0.5)*towerPhiSize(ieta);
152 }
static float towerPhiSize(int ieta)
Definition: CaloTools.cc:161
float l1t::CaloTools::towerPhiSize ( int  ieta)
static

Definition at line 161 of file CaloTools.cc.

References funct::abs(), and M_PI.

Referenced by l1t::Stage2Layer2TauAlgorithmFirmwareImp1::merging(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

162 {
163  if(abs(ieta)<=28) return 2.*M_PI/72.;
164  else return 2.*M_PI/18.;
165 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define M_PI

Member Data Documentation

const int l1t::CaloTools::kHBHEEnd =28
staticprivate

Definition at line 32 of file CaloTools.h.

const int l1t::CaloTools::kHBHENrPhi =72
staticprivate

Definition at line 37 of file CaloTools.h.

const int l1t::CaloTools::kHFBegin =29
staticprivate

Definition at line 33 of file CaloTools.h.

const int l1t::CaloTools::kHFEnd =32
staticprivate

Definition at line 34 of file CaloTools.h.

const int l1t::CaloTools::kHFNrPhi =72/kHFPhiSeg
staticprivate

Definition at line 36 of file CaloTools.h.

const int l1t::CaloTools::kHFPhiSeg =4
staticprivate

Definition at line 35 of file CaloTools.h.

const int l1t::CaloTools::kNrHBHETowers = kHBHEEnd*kHBHENrPhi*2
staticprivate

Definition at line 39 of file CaloTools.h.

const int l1t::CaloTools::kNrTowers = ((kHFEnd-kHFBegin+1)*kHFNrPhi + kHBHEEnd*kHBHENrPhi )*2
staticprivate

Definition at line 38 of file CaloTools.h.

const l1t::CaloCluster l1t::CaloTools::nullCluster_
staticprivate

Definition at line 81 of file CaloTools.h.

const l1t::CaloTower l1t::CaloTools::nullTower_
staticprivate

Definition at line 80 of file CaloTools.h.

Referenced by getTower().