ATLAS Offline Software
Loading...
Searching...
No Matches
LVL1::TriggerTowerKey Class Reference

The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords. More...

#include <TriggerTowerKey.h>

Inheritance diagram for LVL1::TriggerTowerKey:
Collaboration diagram for LVL1::TriggerTowerKey:

Public Types

enum  TriggerTowerRegion {
  TTBarrel =0 , TTEndCap1 =1 , TTEndCap2 =2 , TTFCAL =3 ,
  TTRegionError =999
}

Public Member Functions

 TriggerTowerKey (double m_phi, double m_eta)
 takes phi and eta and constructs a TriggerTowerKey object which can return the key for this coord *todo This method must be phased out - it will not work when this class simulates the hardware completely
 TriggerTowerKey ()
 constructs a TriggerTowerKey object
virtual ~TriggerTowerKey ()
virtual unsigned int ttKey (const TriggerTower &tower)
 returns the key of the passed tower
unsigned int ttKey (const CaloCell &calocell)
 returns the key of the passed calo cell
unsigned int ttKey (const double phi, const double eta)
 returns trigger tower key of passed coords
TriggerTowerRegion region (const Coordinate &coord) const
 returns the TT region that the coordinate corresponds to.
double dEta (const Coordinate &coord) const
 returns eta width of trigger tower at coordinate coord
double dPhi (const Coordinate &coord) const
 returns phi height of trigger tower at coordinate coord
virtual double eta () const
 returns the centre of the TT at eta_coord:
virtual double phi () const
 returns phi coordinate of centre of relevant trigger tower.
unsigned int key (double phi, double eta)
 calculates a map key from passed phi, eta coordinates
unsigned int key (const Coordinate &coord)
 returns the key of the passed Coordinate
Coordinate coord () const
 return central coords of current key value.

Protected Member Functions

ICoordinateconvertCoordsToIntegers (double phi, double eta)
 converts the coordinates and corrects for overflows etc.
virtual int sign (int temp) const
 returns -1 if temp is -ve and +1 if it is +ve.
virtual int sign (double temp) const
 returns -1 if temp is -ve and +1 if it is +ve.
int round (double a) const
 rounds number to nearest whole number
int sharpRound (double a) const
 rounds number as follows (-1.0 to 0.0) -> -1, (0.0 to 1.0) -> 0, (1.0 to 2.0)->1 etc.
int sharpRound2 (int a, int b) const
 divides a/b and returns a number as follows (where +b means +ve b): if 0
void setupThisKeyValues ()

Protected Attributes

int m_iphi
 integer phi coord
int m_ieta
 integer eta coord
double m_eta
 eta coordinate of key
double m_phi
 phi coordinate of key
int m_phiBin
 phi bin
int m_etaBin
 eta bin
double m_centralPhi
 this is the coordinate of the centre of the relevant trigger tower.
double m_centralEta
 this is the coordinate of the centre of the relevant trigger tower.
bool m_debug
 turns DEBUG code on and off

Private Member Functions

BinAndCoordcalculateTriggerBin (ICoordinate *iCoord)
 converts integer phi, eta coordinates to phi, eta trigger bins.

Detailed Description

The TriggerTowerKey object provides the key for each trigger tower depending on its eta-phi coords.

The key is an integer number that uniquely identifies each tower, and is needed by the STL map container: the map holds trigger towers and we retrieve them using their keys.

Author
Edward Moyse

Definition at line 51 of file TriggerTowerKey.h.

Member Enumeration Documentation

◆ TriggerTowerRegion

Enumerator
TTBarrel 
TTEndCap1 
TTEndCap2 
TTFCAL 
TTRegionError 

Definition at line 54 of file TriggerTowerKey.h.

Constructor & Destructor Documentation

◆ TriggerTowerKey() [1/2]

LVL1::TriggerTowerKey::TriggerTowerKey ( double m_phi,
double m_eta )

takes phi and eta and constructs a TriggerTowerKey object which can return the key for this coord *todo This method must be phased out - it will not work when this class simulates the hardware completely

Definition at line 31 of file TriggerTowerKey.cxx.

31 {
32 m_phi=phi;
33 m_eta=eta;
34 m_debug=false;
35 if (m_debug) { std::cout << "TriggerTowerKey: m_debug output turned on...."<<std::endl; }
37 //std::cout << "m_ieta : "<<m_ieta<<std::endl;
38}
virtual double eta() const
returns the centre of the TT at eta_coord:
virtual double phi() const
returns phi coordinate of centre of relevant trigger tower.
bool m_debug
turns DEBUG code on and off
double m_phi
phi coordinate of key
double m_eta
eta coordinate of key

◆ TriggerTowerKey() [2/2]

LVL1::TriggerTowerKey::TriggerTowerKey ( )

constructs a TriggerTowerKey object

Definition at line 42 of file TriggerTowerKey.cxx.

42 {
43 m_phi=0.0;
44 m_eta=0.0;
45 m_debug=false;
46 if (m_debug) { std::cout << "TriggerTowerKey: m_debug output turned on...."<<std::endl; }
48 //std::cout << "m_ieta : "<<m_ieta<<std::endl;
49}

◆ ~TriggerTowerKey()

LVL1::TriggerTowerKey::~TriggerTowerKey ( )
virtual

Definition at line 51 of file TriggerTowerKey.cxx.

51 {
52}

Member Function Documentation

◆ calculateTriggerBin()

BinAndCoord * LVL1::TriggerTowerKey::calculateTriggerBin ( ICoordinate * iCoord)
privatevirtual

converts integer phi, eta coordinates to phi, eta trigger bins.

Implements LVL1::KeyUtilities.

Definition at line 56 of file TriggerTowerKey.cxx.

56 {
57
58 double phiBinWidth=((2*M_PI)/64.0);
59 int iphi=iCoord->phi();
60 int ieta=iCoord->eta();
61 double centralPhi=0.0;
62 double centralEta=0.0;
63 int phiBin=0; int etaBin=0;
64 int abs_ieta=abs(ieta);
65 int sign=ieta/abs_ieta;
66
67 if (m_debug){
68 std::cout << "TriggerTowerKey: start calcTrigBin"<<std::endl;
69 std::cout << "phi, eta : ("<<iCoord->phi()<<", "<<iCoord->eta()<<")"<<std::endl;
70 std::cout << "iphi, ieta : ("<<iphi<<", "<<ieta<<")"<<std::endl;
71 std::cout << "abs_ieta : ("<<abs_ieta<<" and sign : "<<sign<<std::endl;
72 }
73
74 if ( abs_ieta<=25 ){
75 /* in 0.1x0.1 barrel region
76 This extends from -2.4 to +2.4 in eta, and has divisions of 0.1 in eta.
77 ieta extends from -24 to +24, and the centres of ieta=+/-1,2,3 are at
78 centralEta=+/-0.05, 0.15, 0.25 etc.*/
79 phiBin=iphi;
80 etaBin=ieta;
81 centralEta=( (static_cast<double>(abs_ieta)*0.1)-0.05)*sign;
82 centralPhi=(iphi*phiBinWidth)+(phiBinWidth/2);
83 if (m_debug) std::cout << "central : ("<<centralPhi<<", "<<centralEta<<")"<<std::endl;
84 // std::cout<<etaBin<<std::endl;
85 }else{
86 if (abs_ieta>25 && abs_ieta<=32){
87 //std::cout <<"0.2x0.2 :";
88 /* in 0.2 x 0.2 region.
89 Here we have three 0.2 cells from eta=+-2.5-3.2 (etaBin=26,27,28),
90 then a final 0.1 cell from +-3.1 to 3.2 (etaBin=-32).*/
91 etaBin=( ( (abs_ieta-24) /2 )+25)*sign;
92 // this ^ perhaps seems slightly counter-intuitive ...
93 // The point is we have cells like |'|''|''|''|
94 // (where the edge of the first cell is ieta=-32) - i.e. the first
95 // cell is 0.1x0.2 instead of 0.2x0.2.
96 // so if we did (ieta-33)/2+29 as you might expect
97 // our algorithm will (wrongly) behave as if the cells are
98 // |''|''|''|'| instead.
99 phiBin=iphi/2;
100 centralPhi=(static_cast<double>(phiBin)*2.0+1.0)*phiBinWidth;
101 // it's a bit harder for the centralEta case though so:
102 if (abs_ieta<32){
103 centralEta=((static_cast<double>(static_cast<int>((abs_ieta-26)/2))*0.2)+2.6)*sign;
104 }else{
105 //in weird 0.1x0.2 region
106 centralEta=3.15*sign;
107 }
108 }else{
109 // in FCAL
110 // there's a complication here, namely that the eta bins aren't multiples
111 // of 0.1.We therefore must work in doubles ...
112
113 double fcalEtaSize=0.425; //=(4.9-3.2)/4
114
115 double abs_eta = iCoord->dEta()*sign;
116 double temp=static_cast<double>(abs_eta-3.2);
117 temp = (temp/ fcalEtaSize );
118 int iTemp=static_cast<int>(temp);
119 etaBin=(iTemp+32)*sign;
120
121 phiBin=iphi/4;
122
123 centralEta=((static_cast<double>(iTemp)*fcalEtaSize)+3.2+(fcalEtaSize/2))*sign;
124//std::cout<<"eb: "<<etaBin<<" iTemp"<<iTemp<<std::endl;
125 centralPhi=(static_cast<double>(phiBin)*phiBinWidth*4)+(phiBinWidth*2);
126 }// end else: in .4x.4
127 }// end of not in 0.1x0.1
128 if (m_debug) std::cout << "central : /t("<<centralPhi<<", "<<centralEta<<")"<<std::endl;
129 Coordinate* centralCoords = new Coordinate(centralPhi, centralEta);
130 BinAndCoord* bandc = new BinAndCoord(phiBin,etaBin,centralCoords);
131 return bandc;
132}
#define M_PI
virtual int sign(int temp) const
returns -1 if temp is -ve and +1 if it is +ve.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin

◆ convertCoordsToIntegers()

ICoordinate * LVL1::KeyUtilities::convertCoordsToIntegers ( double phi,
double eta )
protectedinherited

converts the coordinates and corrects for overflows etc.

For instance, if phi is negative this routine converts to the equivalent positive position.

For instance, if phi is negative this routine converts to the equivalent positive position. *todo tidy up a bit.

Definition at line 105 of file KeyUtilities.cxx.

105 {
106
107 double phiBinWidth=((2*M_PI)/64.0);
108 // there are a maximum of 64 cells in the phi direction
109 // stretching from 0 to ~2*PI.
110 if (m_debug) std::cout << "KU : (phi, eta) ("<<phi<<","<<eta<<")"<<std::endl;
111 int iphi=sharpRound(phi/phiBinWidth);
112 int ieta=0;
113
114 // Now check that m_iphi is between 0 and 64.
115 iphi = iphi%64;
116 if (iphi<0) iphi = 64+iphi;
117
118 // Make m_ieta symmetrical:
119 // o no cell at m_ieta=0
120 // o first cells at +-1
121 // o last cells at about +- 50
122 // this gives us a more useful numerical symmetry.
123
124 // So to get integer value we do:
125 int temp_sign=sign(eta);
126 double temp_abs=eta*temp_sign;
127
128 double temp_double=(temp_abs*10.0+1.0)*temp_sign;
129 if (m_debug) std::cout << "KU : temp_abs, temp_sign, temp_double : "<<temp_abs<<","<<temp_sign<<","<<temp_double<<std::endl;
130// if (m_eta>=0.0){
131// temp_double=m_eta*10.0+1.0;
132// }else{
133// temp_double=m_eta*10.0-1.0;
134// }
135
136 ieta=static_cast<int>(temp_double);
137 if (m_debug) std::cout << "KU : (iphi, ieta) ("<<iphi<<","<<ieta<<")"<<std::endl;
138 ICoordinate* iCoord=new ICoordinate(iphi, ieta, eta);
139 return iCoord;
140}
int sharpRound(double a) const
rounds number as follows (-1.0 to 0.0) -> -1, (0.0 to 1.0) -> 0, (1.0 to 2.0)->1 etc.

◆ coord()

LVL1::Coordinate LVL1::KeyUtilities::coord ( ) const
inherited

return central coords of current key value.

Definition at line 199 of file KeyUtilities.cxx.

199 {
200 return Coordinate(m_centralPhi,m_centralEta);
201}
double m_centralEta
this is the coordinate of the centre of the relevant trigger tower.
double m_centralPhi
this is the coordinate of the centre of the relevant trigger tower.

◆ dEta()

double LVL1::TriggerTowerKey::dEta ( const Coordinate & coord) const
virtual

returns eta width of trigger tower at coordinate coord

Implements LVL1::KeyUtilities.

Definition at line 171 of file TriggerTowerKey.cxx.

171 {
173 if (reg==TTBarrel) return 0.1;
174 if (reg==TTEndCap1) return 0.2;
175 if (reg==TTEndCap2) return 0.1;
176 if (reg==TTFCAL) return 0.425;
177 return 0;
178}
Coordinate coord() const
return central coords of current key value.
TriggerTowerRegion region(const Coordinate &coord) const
returns the TT region that the coordinate corresponds to.

◆ dPhi()

double LVL1::TriggerTowerKey::dPhi ( const Coordinate & coord) const
virtual

returns phi height of trigger tower at coordinate coord

Implements LVL1::KeyUtilities.

Definition at line 181 of file TriggerTowerKey.cxx.

181 {
183 if (reg==TTBarrel) return M_PI/32;//0.0981748;//PI/32
184 if (reg==TTEndCap1) return M_PI/16;//0.19635;//PI/16
185 if (reg==TTEndCap2) return M_PI/16;//0.19635;
186 if (reg==TTFCAL) return M_PI/8;//0.392699;//PI/8
187 return TTRegionError;
188}

◆ eta()

double LVL1::KeyUtilities::eta ( ) const
virtualinherited

returns the centre of the TT at eta_coord:

returns the eta coord of the centre of the relevent trigger tower

Definition at line 145 of file KeyUtilities.cxx.

145 {
146 return m_centralEta;
147}

◆ key() [1/2]

unsigned int LVL1::KeyUtilities::key ( const Coordinate & coord)
inherited

returns the key of the passed Coordinate

returns trigger tower key of passed Coordinate

Definition at line 96 of file KeyUtilities.cxx.

96 {
97 return key(coord.phi(), coord.eta());
98}
unsigned int key(double phi, double eta)
calculates a map key from passed phi, eta coordinates

◆ key() [2/2]

unsigned int LVL1::KeyUtilities::key ( double phi,
double eta )
inherited

calculates a map key from passed phi, eta coordinates

returns key

calculates a map key from passed phi, eta coordinates

Definition at line 77 of file KeyUtilities.cxx.

77 {
78 m_eta=eta;
79 m_phi=phi;
80 ICoordinate* iCoord = convertCoordsToIntegers(m_phi, m_eta);
81 BinAndCoord* bandc = calculateTriggerBin(iCoord);
82 if (m_debug) std::cout << "KU : key: got bandc "<<std::endl;
83 m_phiBin=bandc->phiBin();
84 m_etaBin=bandc->etaBin();
85 m_centralPhi=bandc->coords()->phi();
86 m_centralEta=bandc->coords()->eta();
87 delete bandc;
88 delete iCoord;
89 int temp=((m_etaBin+50)<<6) + m_phiBin;
90
91 if (m_debug) std::cout << "KU : key: returning - "<<temp<<std::endl;
92 return static_cast<unsigned int>(temp);
93}
virtual BinAndCoord * calculateTriggerBin(ICoordinate *iCoord)=0
converts integer phi, eta coordinates to phi, eta trigger bins.
ICoordinate * convertCoordsToIntegers(double phi, double eta)
converts the coordinates and corrects for overflows etc.

◆ phi()

double LVL1::KeyUtilities::phi ( ) const
virtualinherited

returns phi coordinate of centre of relevant trigger tower.

returns phi coordinate of the centre of the relevent trigger tower.

Definition at line 154 of file KeyUtilities.cxx.

154 {
155 return m_centralPhi;
156}

◆ region()

LVL1::TriggerTowerKey::TriggerTowerRegion LVL1::TriggerTowerKey::region ( const Coordinate & coord) const

returns the TT region that the coordinate corresponds to.

Definition at line 158 of file TriggerTowerKey.cxx.

158 {
159 double absEta=fabs(coord.eta());
160 if (absEta<2.5) return TTBarrel;
161 if ((absEta>=2.5)&&(absEta<3.1)) return TTEndCap1;
162 if ((absEta>=3.1)&&(absEta<3.2)) return TTEndCap2;
163 if ((absEta>=3.2)&&(absEta<=4.9)) return TTFCAL;
164 std::cerr <<"TriggerTowerKey::region UNKNOWN REGION"
165 << "Coordinate is ("<<coord.phi()<<", "<<coord.eta()<<")"
166 <<std::endl;
167 return TTRegionError;
168}
bool absEta(const xAOD::TauJet &tau, float &out)

◆ round()

int LVL1::KeyUtilities::round ( double a) const
protectedinherited

rounds number to nearest whole number

Definition at line 180 of file KeyUtilities.cxx.

180 {
181 return static_cast<int>(a<0.0?ceil(a-0.5):a>0.0?floor(a+0.5):0.0);
182}
static Double_t a

◆ setupThisKeyValues()

void LVL1::KeyUtilities::setupThisKeyValues ( )
protectedinherited

Definition at line 168 of file KeyUtilities.cxx.

168 {
169 ICoordinate* iCoord = convertCoordsToIntegers(m_phi, m_eta);
170 BinAndCoord* bandc = calculateTriggerBin(iCoord);
171 m_phiBin=bandc->phiBin();
172 m_etaBin=bandc->etaBin();
173 m_centralPhi=bandc->coords()->phi();
174 m_centralEta=bandc->coords()->eta();
175 delete bandc;
176 delete iCoord;
177}

◆ sharpRound()

int LVL1::KeyUtilities::sharpRound ( double a) const
protectedinherited

rounds number as follows (-1.0 to 0.0) -> -1, (0.0 to 1.0) -> 0, (1.0 to 2.0)->1 etc.

Definition at line 185 of file KeyUtilities.cxx.

185 {
186 return static_cast<int>(a<0.0?(a-1.0):a>0.0?(a):0.0);
187}

◆ sharpRound2()

int LVL1::KeyUtilities::sharpRound2 ( int a,
int b ) const
protectedinherited

divides a/b and returns a number as follows (where +b means +ve b): if 0

Definition at line 189 of file KeyUtilities.cxx.

189 {
190 int temp=(abs(a)-1)/b+1;
191 return temp*sign(a);
192}

◆ sign() [1/2]

int LVL1::KeyUtilities::sign ( double temp) const
protectedvirtualinherited

returns -1 if temp is -ve and +1 if it is +ve.

returns 0 if temp =0

Definition at line 164 of file KeyUtilities.cxx.

164 {
165 return ((temp >= 0.0) ? 1 : -1);
166}

◆ sign() [2/2]

int LVL1::KeyUtilities::sign ( int temp) const
protectedvirtualinherited

returns -1 if temp is -ve and +1 if it is +ve.

returns 0 if temp =0

Definition at line 159 of file KeyUtilities.cxx.

159 {
160 return ((temp >= 0) ? 1 : -1);
161}

◆ ttKey() [1/3]

unsigned int LVL1::TriggerTowerKey::ttKey ( const CaloCell & calocell)

returns the key of the passed calo cell

Definition at line 143 of file TriggerTowerKey.cxx.

143 {
144 return key(calocell.phi(), calocell.eta());
145}
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382

◆ ttKey() [2/3]

unsigned int LVL1::TriggerTowerKey::ttKey ( const double phi,
const double eta )

returns trigger tower key of passed coords

Definition at line 149 of file TriggerTowerKey.cxx.

149 {
150 if (m_debug) std::cout << "TTK: returning key for coords ("<<phi<<","<<eta<<")"<<std::endl;
151 return key(phi, eta);
152}

◆ ttKey() [3/3]

unsigned int LVL1::TriggerTowerKey::ttKey ( const TriggerTower & tower)
virtual

returns the key of the passed tower

Definition at line 138 of file TriggerTowerKey.cxx.

138 {
139 return key(tower.phi(), tower.eta());
140}

Member Data Documentation

◆ m_centralEta

double LVL1::KeyUtilities::m_centralEta
protectedinherited

this is the coordinate of the centre of the relevant trigger tower.

Definition at line 112 of file KeyUtilities.h.

◆ m_centralPhi

double LVL1::KeyUtilities::m_centralPhi
protectedinherited

this is the coordinate of the centre of the relevant trigger tower.

Definition at line 109 of file KeyUtilities.h.

◆ m_debug

bool LVL1::KeyUtilities::m_debug
protectedinherited

turns DEBUG code on and off

Definition at line 114 of file KeyUtilities.h.

◆ m_eta

double LVL1::KeyUtilities::m_eta
protectedinherited

eta coordinate of key

Definition at line 100 of file KeyUtilities.h.

◆ m_etaBin

int LVL1::KeyUtilities::m_etaBin
protectedinherited

eta bin

Definition at line 106 of file KeyUtilities.h.

◆ m_ieta

int LVL1::KeyUtilities::m_ieta
protectedinherited

integer eta coord

Definition at line 98 of file KeyUtilities.h.

◆ m_iphi

int LVL1::KeyUtilities::m_iphi
protectedinherited

integer phi coord

Definition at line 96 of file KeyUtilities.h.

◆ m_phi

double LVL1::KeyUtilities::m_phi
protectedinherited

phi coordinate of key

Definition at line 102 of file KeyUtilities.h.

◆ m_phiBin

int LVL1::KeyUtilities::m_phiBin
protectedinherited

phi bin

Definition at line 104 of file KeyUtilities.h.


The documentation for this class was generated from the following files: