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 75 of file CaloTools.cc.

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

78 {
79 
80  return calHwEtSum(iEta,iPhi,towers,localEtaMin,localEtaMax,localPhiMin,localPhiMax,kHFEnd,etMode);
81 }
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:75
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 83 of file CaloTools.cc.

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

86 {
87  int hwEtSum=0;
88  for(int etaNr=localEtaMin;etaNr<=localEtaMax;etaNr++){
89  for(int phiNr=localPhiMin;phiNr<=localPhiMax;phiNr++){
90 
91  int towerIEta = l1t::CaloStage2Nav::offsetIEta(iEta,etaNr);
92  int towerIPhi = l1t::CaloStage2Nav::offsetIPhi(iPhi,phiNr);
93  if(abs(towerIEta)<=iEtaAbsMax){
94  const l1t::CaloTower& tower = getTower(towers,towerIEta,towerIPhi);
95  if(etMode&ECAL) hwEtSum+=tower.hwEtEm();
96  if(etMode&HCAL) hwEtSum+=tower.hwEtHad();
97  }
98  }
99  }
100  return hwEtSum;
101 }
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 104 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::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

105 {
106  size_t nrTowers=0;
107  l1t::CaloStage2Nav nav(iEtaMin,iPhiMin);
108  while(nav.currIEta()<=iEtaMax){
109  while(nav.currIPhi()<=iPhiMax){
110  nav.north();
111  const l1t::CaloTower& tower = l1t::CaloTools::getTower(towers,nav.currIEta(),nav.currIPhi());
112  int towerHwEt =0;
113  if(etMode&ECAL) towerHwEt+=tower.hwEtEm();
114  if(etMode&HCAL) towerHwEt+=tower.hwEtHad();
115  if(etMode&CALO) towerHwEt+=tower.hwPt();
116  if(towerHwEt>=minHwEt && towerHwEt<=maxHwEt) nrTowers++;
117  }
118  nav.east();
119  nav.resetIPhi();
120  }
121  return nrTowers;
122 }
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 39 of file CaloTools.cc.

References funct::abs().

Referenced by getTower(), and l1t::Stage2Layer1Producer::produce().

40 {
41 
42  if(!isValidIEtaIPhi(iEta,iPhi)) return caloTowerHashMax();
43  else{
44  const int absIEta = abs(iEta);
45  if(absIEta>kHFEnd) return kNrTowers;
46  else if(absIEta<=kHBHEEnd){ //HBHE
47  int iEtaNoZero=iEta;
48  if(iEta>0) iEtaNoZero--;
49  return (iEtaNoZero+kHBHEEnd)*kHBHENrPhi+iPhi-1;
50  }else{ //HF
51  int iEtaIndex = iEta+kHFEnd; //iEta=-32 is 0
52  if(iEta>0) iEtaIndex= iEta-kHBHEEnd+(kHFEnd-kHBHEEnd)-1; //but iEta=29 is 4
53  return iEtaIndex*kHFNrPhi+iPhi/kHFPhiSeg + kNrHBHETowers;
54  }
55  }
56 }
static const int kHFPhiSeg
Definition: CaloTools.h:35
static bool isValidIEtaIPhi(int iEta, int iPhi)
Definition: CaloTools.cc:65
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:59
size_t l1t::CaloTools::caloTowerHashMax ( )
static

Definition at line 59 of file CaloTools.cc.

Referenced by l1t::Stage2Layer1Producer::produce().

60 {
61  return kNrTowers;
62 }
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 26 of file CaloTools.cc.

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

27 {
28  for(size_t clusterNr=0;clusterNr<clusters.size();clusterNr++){
29  if(clusters[clusterNr].hwEta()==iEta && clusters[clusterNr].hwPhi()==iPhi) return clusters[clusterNr];
30  }
31  return nullCluster_;
32 }
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 Stage2InputPatternWriter::analyze(), calNrTowers(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::clustering(), l1t::Stage2Layer2JetAlgorithmFirmwareImp1::create(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::filtering(), l1t::Stage2Layer2EtSumAlgorithmFirmwareImp1::processEvent(), l1t::Stage2Layer2JetAlgorithmFirmwareImp1::pusRing(), 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  return nullTower_;
24 }
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:39
static const l1t::CaloTower nullTower_
Definition: CaloTools.h:80
bool l1t::CaloTools::isValidIEtaIPhi ( int  iEta,
int  iPhi 
)
static

Definition at line 65 of file CaloTools.cc.

References funct::abs().

Referenced by l1t::Stage2Layer1Producer::produce().

66 {
67  size_t absIEta = abs(iEta);
68  if(iPhi<=0 || iPhi>kHBHENrPhi) return false;
69  if(absIEta==0 || absIEta>kHFEnd) return false;
70  if(absIEta>kHBHEEnd && iPhi%kHFPhiSeg!=1) return false;
71  return true;
72 
73 }
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 133 of file CaloTools.cc.

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

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

134 {
135  std::pair<float,float> bounds = towerEtaBounds(ieta);
136  float eta = (bounds.second+bounds.first)/2.;
137  float sign = ieta>0 ? 1. : -1.;
138  return sign*eta;
139 }
double sign(double x)
T eta() const
static std::pair< float, float > towerEtaBounds(int ieta)
Definition: CaloTools.cc:124
std::pair< float, float > l1t::CaloTools::towerEtaBounds ( int  ieta)
staticprivate

Definition at line 124 of file CaloTools.cc.

References funct::abs().

125 {
126  if(ieta==0) ieta = 1;
127  if(ieta>32) ieta = 32;
128  if(ieta<-32) ieta = -32;
129  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};
130  return std::make_pair( towerEtas[abs(ieta)-1],towerEtas[abs(ieta)] );
131 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float l1t::CaloTools::towerEtaSize ( int  ieta)
static

Definition at line 146 of file CaloTools.cc.

References findQualityFiles::size.

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

147 {
148  std::pair<float,float> bounds = towerEtaBounds(ieta);
149  float size = (bounds.second-bounds.first);
150  return size;
151 }
static std::pair< float, float > towerEtaBounds(int ieta)
Definition: CaloTools.cc:124
tuple size
Write out results.
float l1t::CaloTools::towerPhi ( int  ieta,
int  iphi 
)
static

Definition at line 141 of file CaloTools.cc.

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

142 {
143  return (float(iphi)-0.5)*towerPhiSize(ieta);
144 }
static float towerPhiSize(int ieta)
Definition: CaloTools.cc:153
float l1t::CaloTools::towerPhiSize ( int  ieta)
static

Definition at line 153 of file CaloTools.cc.

References funct::abs(), and M_PI.

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

154 {
155  if(abs(ieta)<=28) return 2.*M_PI/72.;
156  else return 2.*M_PI/18.;
157 }
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().