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 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)
 

Private Member Functions

 CaloTools ()
 
 ~CaloTools ()
 

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

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

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

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

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

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

References funct::abs().

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

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

Definition at line 57 of file CaloTools.cc.

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

58 {
59  return kNrTowers;
60 }
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 24 of file CaloTools.cc.

Referenced by l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::clustering(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::filtering(), l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::refining(), and l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::sharing().

25 {
26  for(size_t clusterNr=0;clusterNr<clusters.size();clusterNr++){
27  if(clusters[clusterNr].hwEta()==iEta && clusters[clusterNr].hwPhi()==iPhi) return clusters[clusterNr];
28  }
29  return nullCluster_;
30 }
static const l1t::CaloCluster nullCluster_
Definition: CaloTools.h:73
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::Stage2Layer2JetAlgorithmFirmwareImp1::pusRing(), and l1t::Stage2Layer2ClusterAlgorithmFirmwareImp1::refining().

12 {
13  size_t towerIndex = CaloTools::caloTowerHash(iEta, iPhi);
14  if(towerIndex<towers.size()){
15  if(towers[towerIndex].hwEta()!=iEta || towers[towerIndex].hwPhi()!=iPhi){
16  for(size_t towerNr=0;towerNr<towers.size();towerNr++){
17  if(towers[towerNr].hwEta()==iEta && towers[towerNr].hwPhi()==iPhi) return towers[towerNr];
18  }
19  }else return towers[towerIndex];
20  }
21  return nullTower_;
22 }
static size_t caloTowerHash(int iEta, int iPhi)
Definition: CaloTools.cc:37
static const l1t::CaloTower nullTower_
Definition: CaloTools.h:72
bool l1t::CaloTools::isValidIEtaIPhi ( int  iEta,
int  iPhi 
)
static

Definition at line 63 of file CaloTools.cc.

References funct::abs().

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

64 {
65  size_t absIEta = abs(iEta);
66  if(iPhi<=0 || iPhi>kHBHENrPhi) return false;
67  if(absIEta==0 || absIEta>kHFEnd) return false;
68  if(absIEta>kHBHEEnd && iPhi%kHFPhiSeg!=1) return false;
69  return true;
70 
71 }
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

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 73 of file CaloTools.h.

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

Definition at line 72 of file CaloTools.h.

Referenced by getTower().