ATLAS Offline Software
Loading...
Searching...
No Matches
JetElementKeyBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 JetElementKeyBase.cpp - description
6 -------------------
7 begin : Tue Sep 26 2000
8 email : e.moyse@qmw.ac.uk
9
10 Converted to base class JetElementKeyBase by Alan Watson, 20/01/06
11 ***************************************************************************/
12
13#ifndef TRIGGERSPACE
14// running in Athena
18
19#else
20// running in TRIGGERSPACE
21#include "JetElementKeyBase.h"
22#include "TrigT1CaloDefs.h"
23#include "ICoordinate.h"
24
25#endif
26
27#include <math.h>
28
29namespace LVL1 {
30
36 m_debugKeyBase(false)
37 {
38 if (m_debugKeyBase) { std::cout << "JetElementKeyBase: m_debugKeyBase output turned on...."<<std::endl; }
39 //setupRegionData();
40 //setupThisKeyValues();
41}
42
46 m_debugKeyBase(false)
47 {
48 if (m_debugKeyBase) { std::cout << "JetElementKeyBase: m_debugKeyBase output turned on...."<<std::endl; }
49 //setupRegionData();
50 //setupThisKeyValues();
51}
52
56 m_debugKeyBase(false)
57 {
58 if (m_debugKeyBase) { std::cout << "JetElementKeyBase: m_debugKeyBase output turned on...."<<std::endl; }
59 //setupRegionData();
60 //setupThisKeyValues();
61}
62
65
66
71
72 int iphi=iCoord.phi();
73 int ieta=iCoord.eta();
74 double centralPhi=0.0;
75 double centralEta=0.0;
76 int phiBin=0; int etaBin=0;
77 int abs_ieta=abs(ieta);
78 int sign=ieta/abs_ieta;
79
80 if (m_debugKeyBase){
81 std::cout << "JetElementKeyBase: start calculateTriggerBin"<<std::endl;
82 //std::cout << "phi, eta : ("<<m_phi<<", "<<m_eta<<")"<<std::endl;
83 std::cout << "iphi, ieta : ("<<iphi<<", "<<ieta<<")"<<std::endl;
84 std::cout << "abs_ieta : ("<<abs_ieta<<") and sign : "<<sign<<std::endl;
85 }
86
88
89 // okay this JE has been deliberately labelled as a wrong 'un.
90 // so basically ignore it.
91 phiBin=0;
92 centralPhi=0.0;
93 etaBin=20*sign;
95
96 }else{
97
98 int region;
99 if ( abs_ieta<23 ) {
100 region = 0;
101 etaBin=(ieta+1)/2;
102 }
103 else if ( abs_ieta<25 ) { // can't see why this region != region 0??
104 region = 1;
105 etaBin=(ieta+1)/2;
106 }
107 else if ( abs_ieta<28 ) { // remaining regions only have 1 eta bin, varying sizes
108 region = 2;
109 etaBin=13*sign;
110 }
111 else if ( abs_ieta<30 ) {
112 region = 3;
113 etaBin=14*sign;
114 }
115 else if ( abs_ieta<=32 ) {
116 region = 4;
117 etaBin=15*sign;
118 }
119 else {
120 region = 5;
121 etaBin=16*sign;
122 }
123
124 // Get centre of JE in eta and phi
125 if (region == 0) {
126 centralEta=(static_cast<double>(etaBin)*0.2)-0.1;
127 }
128 else {
129 centralEta=m_regionEtaCentre[region]*sign;
130 }
131
132 // Phi bin size depends on region - this should take care of that
133 int nTTperJE = static_cast<int>( 0.5 + (m_regionHeight[region]/(M_PI/32)) );
134 phiBin=iphi/nTTperJE;
135 centralPhi=(static_cast<double>(phiBin)+0.5)*m_regionHeight[region];
136
137 }
138
139 if (m_debugKeyBase) std::cout << "central : ("<<centralPhi<<", "<<centralEta<<")"
140 << " bin : ("<<phiBin<<","<<etaBin<<")"<<std::endl;
141 return BinAndCoord(phiBin,etaBin,Coordinate(centralPhi, centralEta));
142}
143
144#ifndef TRIGGERSPACE
145// these methods are only applicable if running in Athena
146
148unsigned int JetElementKeyBase::jeKey( const xAOD::TriggerTower& tower) {
149 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<tower.phi()<<","<<tower.eta()<<")"<<std::endl;
150 return key(tower.phi(), tower.eta());
151}
152
154unsigned int JetElementKeyBase::jeKey( const xAOD::JetElement& jetElement){
155 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<jetElement.phi()<<","<<jetElement.eta()<<")"<<std::endl;
156 return key(jetElement.phi(), jetElement.eta());
157}
158
159#endif
160
161
163unsigned int JetElementKeyBase::jeKey(const double phi, const double eta){
164 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<phi<<","<<eta<<")"<<std::endl;
165 return key(phi, eta);
166}
167
170 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for Coord: ("<<coord.phi()<<","<<coord.eta()<<")"<<std::endl;
171 return key(coord.phi(), coord.eta());
172}
173
174
175
177Coordinate JetElementKeyBase::leftEta(const double phi, const double eta){
178 Coordinate centre=getCentre(phi,eta);
179 double temp_eta=centre.eta();
180
181 // look in method for definition of regions
182 unsigned int reg=region(temp_eta);
183 // suppress leftEta in -ve region 5
184 unsigned int maxRegion=5+((temp_eta>0.0)? 0:-1);
185 if ( reg==0 ){
186 temp_eta-=m_regionWidth[0];
187 }else{
188 if ((reg==TrigT1CaloDefs::RegionError)||(reg>maxRegion)) {
190 }else{
191 int sign = ((temp_eta>0.0)? 1:-1);
192 temp_eta= sign*m_regionEtaCentre[reg-sign]; }
193 }
194 // there's a complication here ... moving left can move us
195 // into a JE with a different phi height, and so phi can change.
196 // However we want to keep eta at 8.0, so reset eta afterwards.
197 Coordinate coord( getCentre(phi,temp_eta) );
198 coord.setCoords(coord.phi(), temp_eta) ;
199// analCoordChecking(coord);
200 return coord;
201}
202
207
209unsigned int JetElementKeyBase::leftEtaKey(const double phi, const double eta){
211 return jeKey(coord.phi(),coord.eta());
212}
213
215unsigned int JetElementKeyBase::rightEtaKey(const double phi, const double eta){
217 return jeKey(coord.phi(),coord.eta());
218}
219
222 Coordinate centre=getCentre(phi,eta);
223 double temp_eta=centre.eta();
224
225 unsigned int reg=region(temp_eta);
226 // supress rightEta in +ve region 5
227 unsigned int maxRegion=5+((temp_eta>0.0)? -1:0);
228 if ( reg==0 ){
229 temp_eta+=m_regionWidth[0];
230 }else{
231 if ((reg==TrigT1CaloDefs::RegionError)||(reg>maxRegion)) {
233 }else{
234 int sign = ((temp_eta>0.0)? 1:-1);
235 temp_eta= sign*m_regionEtaCentre[reg+sign];
236 }
237 }
238 // there's a complication here ... moving right can move us
239 // into a JE with a different phi height, and so phi can change.
240 // However we want to keep eta at 8.0, so reset eta afterwards.
241 Coordinate coord( getCentre(phi,temp_eta) );
242 coord.setCoords(coord.phi(), temp_eta) ;
243// analCoordChecking(coord);
244 return coord;
245}
246
251
252
254Coordinate JetElementKeyBase::upPhi(const double phi, const double eta){
255 Coordinate centre=getCentre(phi,eta);
256 double temp_phi=centre.phi();
257 unsigned int reg=region(centre.eta());
259// std::cout << "Out of bounds error in JetElementKeyBase::upPhi"<<std::endl;
260 temp_phi=0.0;
261 }else{
262 temp_phi+= m_regionHeight[reg];
263 }
264 centre.setCoords(temp_phi,centre.eta());
265 analCoordChecking(centre);
266 return centre;
267}
268
271 return upPhi(coord.phi(), coord.eta());
272}
273
275unsigned int JetElementKeyBase::upPhiKey(const double phi, const double eta){
277 return jeKey(coord.phi(),coord.eta());
278}
279
281Coordinate JetElementKeyBase::downPhi(const double phi, const double eta){
282 Coordinate centre=getCentre(phi,eta);
283 double temp_phi=centre.phi();
284 unsigned int reg=region(centre.eta());
286// std::cout << "Out of bounds error in JetElementKeyBase::downPhi"<<std::endl;
287 temp_phi=0.0;
288 }else{
289 temp_phi-= m_regionHeight[reg];
290 }
291 centre.setCoords(temp_phi,centre.eta());
292 analCoordChecking(centre);
293 return centre;
294}
295
300
301
303unsigned int JetElementKeyBase::downPhiKey(const double phi, const double eta){
305 return jeKey(coord.phi(),coord.eta());
306}
307
310 coord=leftEta(coord.phi(),coord.eta());
311 return coord;
312}
313
316 coord=rightEta(coord.phi(),coord.eta());
317 return coord;
318}
319
322 coord=leftEta(coord.phi(),coord.eta());
323 return coord;
324}
325
328 coord=rightEta(coord.phi(),coord.eta());
329 return coord;
330}
331
333 Coordinate newCoord=upperLeft(coord.phi(),coord.eta());
334 return newCoord;
335}
336
338 Coordinate newCoord=upperRight(coord.phi(),coord.eta());
339 return newCoord;
340}
341
343 Coordinate newCoord=lowerLeft(coord.phi(),coord.eta());
344 return newCoord;
345}
346
348 Coordinate newCoord=lowerRight(coord.phi(),coord.eta());
349 return newCoord;
350}
351
353double JetElementKeyBase::dPhi(const double /*phi*/, const double eta) const {
354 unsigned int reg=region(eta);
355
356 if (reg==TrigT1CaloDefs::RegionError) return 0.0;
357 return m_regionHeight[reg];
358}
359
362 return dPhi(m_phi,m_eta);
363}
364
367 return dPhi(coord.phi(), coord.eta() );
368}
369
371double JetElementKeyBase::dEta(const double /*phi*/, const double eta) const{
372 unsigned int reg=region(eta);
373 if (reg==TrigT1CaloDefs::RegionError) return 0.0;
374
375 return m_regionWidth[reg];
376}
377
380 return dEta(m_phi,m_eta);
381}
382
385 return dEta(coord.phi(), coord.eta() );
386}
387
388unsigned int JetElementKeyBase::region(double eta) const{
389 unsigned int reg=TrigT1CaloDefs::RegionError;
390 int sign=((eta>0.0) ? 1:-1);
391 if (eta==0.0) sign=1;
392 double abs_eta=eta*sign;
393 if (abs_eta<2.2){
394 // barrel
395 reg=0;
396 }else{
397 if((abs_eta>2.2)&&(abs_eta<=2.4)) reg=1;
398 if((abs_eta>2.4)&&(abs_eta<=2.7)) reg=2;
399 if((abs_eta>2.7)&&(abs_eta<=2.9)) reg=3;
400 if((abs_eta>2.9)&&(abs_eta<=3.2)) reg=4;
401 if((abs_eta>3.2)&&(abs_eta<=4.9)) reg=5;
402 }//end if
403 return reg;
404}
405
407 // really unhappy about this. It'll go horribly wrong if anyone alters the enum.
408 // Ideally I'd like region(eta) to return an enum, and have a
409 // separate numRegion(eta) which returns ints.
410 // That will require a lot of re-writing though....
411 unsigned int reg=region(coord.eta());
412 if (reg==5) return FCAL;
413 if (reg==4) return EndCap3;
414 if (reg==3) return EndCap2;
415 if (reg==2) return EndCap1;
416 if (reg==1) return EndBarrel;
417 return Barrel;
418
419}
420
422 return (region(eta)==5);
423}
424
451
478
480Coordinate JetElementKeyBase::getCentre(const double phi, const double eta){
482 BinAndCoord bandc = calculateTriggerBin(iCoord);
483 return bandc.coords();
484}
485
488 Coordinate centre = getCentre( coord.phi(), coord.eta() );
489 return centre;
490}
491
492} // end LVL1 namespace
493
499 Coordinate centre( getCentre( coord.phi(), coord.eta() ) );
500 double allowedSpread=0.0002;// I don't mind a bit of a rounding error....
501 if ( (coord.phi()<(centre.phi()-allowedSpread))||(coord.phi()>(centre.phi()+allowedSpread) ) )
502 std::cout << "PHI ERROR: "<< coord.phi() <<"!="<<centre.phi()<<std::endl;
503 if ( (coord.eta()<(centre.eta()-allowedSpread))||(coord.eta()>(centre.eta()+allowedSpread) ) )
504 std::cout << "ETA ERROR: "<< coord.eta() <<"!="<<centre.eta()<<std::endl;
505 return;
506}
507
508
509
#define M_PI
Used to pass data between the methods of the Key Classes: Returns the Eta and Phi bins,...
Definition BinAndCoord.h:35
const Coordinate & coords() const
Definition BinAndCoord.h:46
void setCoords(double phi, double eta)
change coords of an existing Coordinate object
double phi() const
return phi
double eta() const
return eta
Used by Key Classes, returns and integer coorginate for the bin Eta-Phi.
Definition ICoordinate.h:26
int phi() const
return phi
int eta() const
return eta
bool m_debugKeyBase
set to true to turn debugging info on
void setupJetRegionData()
Does same as setupRegionData, except in FCAL where uses phi granularity appropriate for the jet trigg...
Coordinate upperLeft(const double phi, const double eta)
std::vector< double > m_regionHeight
holds height of JEs in regions:
void analCoordChecking(const Coordinate &coord)
this is a bit over the top, but it looks to see if the calculated coordinate matches a coordinate cen...
Coordinate getCentre(const double phi, const double eta)
returns the central coordinate of the JE which contains the passed coord
unsigned int rightEtaKey(const double phi, const double eta)
returns key of JE in -ve eta dir.
double dEta() const
return width of JE
JetElementKeyBase()
constructs a JetElementKeyBase object
Coordinate rightEta(const double phi, const double eta)
Functions for finding coordinates of neighbouring JEs.
Coordinate downPhi(const double phi, const double eta)
returns coord of next JE in -ve phi dir.
unsigned int region(double eta) const
returns region number at eta, where region is:
std::vector< double > m_regionEtaCentre
holds central coords of JEs in regions: Region Eta 0 <2.2 1 2.2-2.4 2 2.4-2.7 3 2....
Coordinate leftEta(const double phi, const double eta)
returns key of JE in -ve eta dir.
void setupRegionData()
get region data from TrigT1CaloDefs and put in more useful format - vectors
JERegion jeRegion(const Coordinate &coord) const
Coordinate upperRight(const double phi, const double eta)
double dPhi() const
return height of JE
unsigned int downPhiKey(const double phi, const double eta)
returns key of next JE in -ve phi dir.
unsigned int leftEtaKey(const double phi, const double eta)
returns key of JE in +ve eta dir.
virtual unsigned int jeKey(const xAOD::TriggerTower &tower)
returns key of passed tower
virtual BinAndCoord calculateTriggerBin(const ICoordinate &iCoord) override
converts integer phi, eta coordinates to phi, eta trigger bins.
std::vector< double > m_regionWidth
holds width of JEs in regions:
Coordinate lowerLeft(const double phi, const double eta)
unsigned int upPhiKey(const double phi, const double eta)
returns key of next JE in +ve phi dir.
bool isFCAL(double eta) const
returns TRUE if this coordinate is in the FCAL
Coordinate lowerRight(const double phi, const double eta)
Coordinate upPhi(const double phi, const double eta)
returns coord of next JE in +ve phi dir.
virtual double eta() const
returns the centre of the TT at eta_coord:
virtual int sign(int temp) const
returns -1 if temp is -ve and +1 if it is +ve.
ICoordinate convertCoordsToIntegers(double phi, double eta)
converts the coordinates and corrects for overflows etc.
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
Coordinate coord() const
return central coords of current key value.
KeyUtilities()
the constructor is protected so a user can never make a KeyUtilities object
double m_phi
phi coordinate of key
double m_eta
eta coordinate of key
static const double Region5Width
static const double Region4EtaCentre
static const double Region2EtaCentre
static const unsigned int RegionError
static const double Region4Width
static const double Region2Height
static const double Region3Width
static const double Region1EtaCentre
static const double Region3Height
static const double Region5EtaCentre
static const double Region0Width
static const double RegionERROREtaCentre
static const double Region5Height
static const int RegionERROREtaBin
static const double Region0EtaCentre
static const double Region0Height
static const double Region5JetHeight
static const double Region1Height
static const double Region1Width
static const double Region3EtaCentre
static const double Region2Width
static const double Region4Height
float phi() const
get phi (note that for L1Calo phi runs from 0 to 2pi)
float eta() const
get eta
virtual double eta() const final
The pseudorapidity ( ) of the particle.
virtual double phi() const final
The azimuthal angle ( ) of the particle.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
JetElement_v2 JetElement
Define the latest version of the JetElement class.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.