ATLAS Offline Software
Loading...
Searching...
No Matches
JetElementKeyBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 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 Coordinate* centralCoords = new Coordinate(centralPhi, centralEta);
142 BinAndCoord* bandc = new BinAndCoord(phiBin,etaBin,centralCoords);
143 return bandc;
144}
145
146#ifndef TRIGGERSPACE
147// these methods are only applicable if running in Athena
148
150unsigned int JetElementKeyBase::jeKey( const xAOD::TriggerTower& tower) {
151 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<tower.phi()<<","<<tower.eta()<<")"<<std::endl;
152 return key(tower.phi(), tower.eta());
153}
154
156unsigned int JetElementKeyBase::jeKey( const xAOD::JetElement& jetElement){
157 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<jetElement.phi()<<","<<jetElement.eta()<<")"<<std::endl;
158 return key(jetElement.phi(), jetElement.eta());
159}
160
161#endif
162
163
165unsigned int JetElementKeyBase::jeKey(const double phi, const double eta){
166 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for coords ("<<phi<<","<<eta<<")"<<std::endl;
167 return key(phi, eta);
168}
169
172 if (m_debugKeyBase) std::cout << "JetElementKeyBase: returning key for Coord: ("<<coord.phi()<<","<<coord.eta()<<")"<<std::endl;
173 return key(coord.phi(), coord.eta());
174}
175
176
177
179Coordinate JetElementKeyBase::leftEta(const double phi, const double eta){
180 Coordinate centre=getCentre(phi,eta);
181 double temp_eta=centre.eta();
182
183 // look in method for definition of regions
184 unsigned int reg=region(temp_eta);
185 // suppress leftEta in -ve region 5
186 unsigned int maxRegion=5+((temp_eta>0.0)? 0:-1);
187 if ( reg==0 ){
188 temp_eta-=m_regionWidth[0];
189 }else{
190 if ((reg==TrigT1CaloDefs::RegionError)||(reg>maxRegion)) {
192 }else{
193 int sign = ((temp_eta>0.0)? 1:-1);
194 temp_eta= sign*m_regionEtaCentre[reg-sign]; }
195 }
196 // there's a complication here ... moving left can move us
197 // into a JE with a different phi height, and so phi can change.
198 // However we want to keep eta at 8.0, so reset eta afterwards.
199 Coordinate coord( getCentre(phi,temp_eta) );
200 coord.setCoords(coord.phi(), temp_eta) ;
201// analCoordChecking(coord);
202 return coord;
203}
204
209
211unsigned int JetElementKeyBase::leftEtaKey(const double phi, const double eta){
213 return jeKey(coord.phi(),coord.eta());
214}
215
217unsigned int JetElementKeyBase::rightEtaKey(const double phi, const double eta){
219 return jeKey(coord.phi(),coord.eta());
220}
221
224 Coordinate centre=getCentre(phi,eta);
225 double temp_eta=centre.eta();
226
227 unsigned int reg=region(temp_eta);
228 // supress rightEta in +ve region 5
229 unsigned int maxRegion=5+((temp_eta>0.0)? -1:0);
230 if ( reg==0 ){
231 temp_eta+=m_regionWidth[0];
232 }else{
233 if ((reg==TrigT1CaloDefs::RegionError)||(reg>maxRegion)) {
235 }else{
236 int sign = ((temp_eta>0.0)? 1:-1);
237 temp_eta= sign*m_regionEtaCentre[reg+sign];
238 }
239 }
240 // there's a complication here ... moving right can move us
241 // into a JE with a different phi height, and so phi can change.
242 // However we want to keep eta at 8.0, so reset eta afterwards.
243 Coordinate coord( getCentre(phi,temp_eta) );
244 coord.setCoords(coord.phi(), temp_eta) ;
245// analCoordChecking(coord);
246 return coord;
247}
248
253
254
256Coordinate JetElementKeyBase::upPhi(const double phi, const double eta){
257 Coordinate centre=getCentre(phi,eta);
258 double temp_phi=centre.phi();
259 unsigned int reg=region(centre.eta());
261// std::cout << "Out of bounds error in JetElementKeyBase::upPhi"<<std::endl;
262 temp_phi=0.0;
263 }else{
264 temp_phi+= m_regionHeight[reg];
265 }
266 centre.setCoords(temp_phi,centre.eta());
267 analCoordChecking(centre);
268 return centre;
269}
270
273 return upPhi(coord.phi(), coord.eta());
274}
275
277unsigned int JetElementKeyBase::upPhiKey(const double phi, const double eta){
279 return jeKey(coord.phi(),coord.eta());
280}
281
283Coordinate JetElementKeyBase::downPhi(const double phi, const double eta){
284 Coordinate centre=getCentre(phi,eta);
285 double temp_phi=centre.phi();
286 unsigned int reg=region(centre.eta());
288// std::cout << "Out of bounds error in JetElementKeyBase::downPhi"<<std::endl;
289 temp_phi=0.0;
290 }else{
291 temp_phi-= m_regionHeight[reg];
292 }
293 centre.setCoords(temp_phi,centre.eta());
294 analCoordChecking(centre);
295 return centre;
296}
297
302
303
305unsigned int JetElementKeyBase::downPhiKey(const double phi, const double eta){
307 return jeKey(coord.phi(),coord.eta());
308}
309
312 coord=leftEta(coord.phi(),coord.eta());
313 return coord;
314}
315
318 coord=rightEta(coord.phi(),coord.eta());
319 return coord;
320}
321
324 coord=leftEta(coord.phi(),coord.eta());
325 return coord;
326}
327
330 coord=rightEta(coord.phi(),coord.eta());
331 return coord;
332}
333
335 Coordinate newCoord=upperLeft(coord.phi(),coord.eta());
336 return newCoord;
337}
338
340 Coordinate newCoord=upperRight(coord.phi(),coord.eta());
341 return newCoord;
342}
343
345 Coordinate newCoord=lowerLeft(coord.phi(),coord.eta());
346 return newCoord;
347}
348
350 Coordinate newCoord=lowerRight(coord.phi(),coord.eta());
351 return newCoord;
352}
353
355double JetElementKeyBase::dPhi(const double /*phi*/, const double eta) const {
356 unsigned int reg=region(eta);
357
358 if (reg==TrigT1CaloDefs::RegionError) return 0.0;
359 return m_regionHeight[reg];
360}
361
364 return dPhi(m_phi,m_eta);
365}
366
369 return dPhi(coord.phi(), coord.eta() );
370}
371
373double JetElementKeyBase::dEta(const double /*phi*/, const double eta) const{
374 unsigned int reg=region(eta);
375 if (reg==TrigT1CaloDefs::RegionError) return 0.0;
376
377 return m_regionWidth[reg];
378}
379
382 return dEta(m_phi,m_eta);
383}
384
387 return dEta(coord.phi(), coord.eta() );
388}
389
390unsigned int JetElementKeyBase::region(double eta) const{
391 unsigned int reg=TrigT1CaloDefs::RegionError;
392 int sign=((eta>0.0) ? 1:-1);
393 if (eta==0.0) sign=1;
394 double abs_eta=eta*sign;
395 if (abs_eta<2.2){
396 // barrel
397 reg=0;
398 }else{
399 if((abs_eta>2.2)&&(abs_eta<=2.4)) reg=1;
400 if((abs_eta>2.4)&&(abs_eta<=2.7)) reg=2;
401 if((abs_eta>2.7)&&(abs_eta<=2.9)) reg=3;
402 if((abs_eta>2.9)&&(abs_eta<=3.2)) reg=4;
403 if((abs_eta>3.2)&&(abs_eta<=4.9)) reg=5;
404 }//end if
405 return reg;
406}
407
409 // really unhappy about this. It'll go horribly wrong if anyone alters the enum.
410 // Ideally I'd like region(eta) to return an enum, and have a
411 // separate numRegion(eta) which returns ints.
412 // That will require a lot of re-writing though....
413 unsigned int reg=region(coord.eta());
414 if (reg==5) return FCAL;
415 if (reg==4) return EndCap3;
416 if (reg==3) return EndCap2;
417 if (reg==2) return EndCap1;
418 if (reg==1) return EndBarrel;
419 return Barrel;
420
421}
422
424 return (region(eta)==5);
425}
426
453
480
482Coordinate JetElementKeyBase::getCentre(const double phi, const double eta){
484 BinAndCoord* bandc = calculateTriggerBin(iCoord);
485 Coordinate yuck=*(bandc->coords() ); // this is horrible, but easier than changing other stuff
486 delete iCoord; delete bandc ;
487 return yuck;
488}
489
492 Coordinate centre = getCentre( coord.phi(), coord.eta() );
493 return centre;
494}
495
496} // end LVL1 namespace
497
503 Coordinate centre( getCentre( coord.phi(), coord.eta() ) );
504 double allowedSpread=0.0002;// I don't mind a bit of a rounding error....
505 if ( (coord.phi()<(centre.phi()-allowedSpread))||(coord.phi()>(centre.phi()+allowedSpread) ) )
506 std::cout << "PHI ERROR: "<< coord.phi() <<"!="<<centre.phi()<<std::endl;
507 if ( (coord.eta()<(centre.eta()-allowedSpread))||(coord.eta()>(centre.eta()+allowedSpread) ) )
508 std::cout << "ETA ERROR: "<< coord.eta() <<"!="<<centre.eta()<<std::endl;
509 return;
510}
511
512
513
#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:
BinAndCoord * calculateTriggerBin(ICoordinate *iCoord)
converts integer phi, eta coordinates to phi, eta trigger bins.
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
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.
virtual double phi() const
returns phi coordinate of centre of relevant trigger tower.
ICoordinate * convertCoordsToIntegers(double phi, double eta)
converts the coordinates and corrects for overflows etc.
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.