ATLAS Offline Software
Loading...
Searching...
No Matches
JetEnergyModuleKey.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 JetEnergyModuleKey.cpp - description
6 -------------------
7 begin : Tue Sep 26 2000
8 email : e.moyse@qmw.ac.uk
9 ***************************************************************************/
10
11#ifndef TRIGGERSPACE
12// running in Athena
15// #include "TrigT1CaloUtils/ICoordinate.h"
17
19
20#else
22#include "JetEnergyModuleKey.h"
23#include "TrigT1CaloDefs.h"
24#include "ICoordinate.h"
25#include "JetElementKey.h"
26#include "CoordToHardware.h"
27
28//
29#endif
30
31#include <math.h>
32
33namespace LVL1 {
34
37 if (m_debugModuleKey) std::cout << "JetEnergyModuleKey: m_debugModuleKey output turned on...."<<std::endl;
38}
39
42
44unsigned int JetEnergyModuleKey::jemKey(const xAOD::JetElement* jetElement) {
45 return key(jetElement->phi(), jetElement->eta());
46}
47
48
49
51unsigned int JetEnergyModuleKey::jemKey(unsigned int crate, unsigned int module) {
52 double eta = ((module%8)+0.5)*TrigT1CaloDefs::jemEtaSize - 3.2;
53 int quadrant = crate + ((module>7) ? 2 : 0);
54 double phi = (quadrant+0.5)*TrigT1CaloDefs::jemPhiSize;
55 return key(phi, eta);
56}
57
59std::vector<unsigned int> JetEnergyModuleKey::jeKeys(unsigned int crate, unsigned int module) {
60 std::vector<unsigned int> keys;
61
62 // Protection
63 if (crate > 1 || module > 15) return keys;
64
65 // First get coordinates
66 std::vector<Coordinate> coords = jeCoords(crate, module);
67
68 // Then calculate keys
69 JetElementKey get(0.,0.);
70 for (const Coordinate& c : coords) {
71 keys.push_back(get.jeKey(c));
72 }
73
74 return keys;
75}
76
77
79std::vector<Coordinate> JetEnergyModuleKey::jeCoords(unsigned int crate, unsigned int module) {
80 std::vector<Coordinate> coords;
81
82 // Protection
83 if (crate > 1 || module > 15) return coords;
84
90
91 int top = ( module < 8 ? 0 : 1 );
92 double phiStart = crate*TrigT1CaloDefs::jemPhiSize
95 double etaStart;
96 // Central JEMs are easy
97 if ( (module%8) > 0) {
98 etaStart = (module%8)*TrigT1CaloDefs::jemEtaSize - 3.1;
99 }
100 // -ive eta end
101 else {
103 }
104
105 // First coordinate for this JEM
106 Coordinate startCol(phiStart, etaStart);
107 // Nested incrementation of eta and phi
108 CoordToHardware cth;
109 JetElementKey get(0.,0.);
110 while (cth.jepModule( startCol ) == module) {
111 Coordinate next = get.getCentre(startCol);
112 while (cth.jepCrate( next ) == crate) {
113 coords.push_back(next);
114 next = get.upPhi(next);
115 }
116 startCol = get.rightEta(startCol);
117 if (startCol.eta() == TrigT1CaloDefs::RegionERROREtaCentre) break;
118 }
119
120 return coords;
121}
122
125 double phi=coord.phi();
126 double rowHeight=TrigT1CaloDefs::jemPhiSize/8.0;
127
128 unsigned int rowsPerJEM = 8u;
129 int rowNum=static_cast<int>(phi/rowHeight);
130 rowNum=rowNum%rowsPerJEM;
131 return rowNum;
132}
133
137 Coordinate coord(JE->phi(), JE->eta());
138 return row( coord );
139}
140
141
143double LVL1::JetEnergyModuleKey::rowPhiCoord(unsigned int rowNum, const Coordinate& jemCoord){
144 //not sure how to do this.
145 //should really reuse code, but above is tied to KU stuff. Probably way to go though.
146
147 ICoordinate iCoord = convertCoordsToIntegers(jemCoord.phi(), jemCoord.eta());
148 int etaBin=0; unsigned int phiBin=0;
149 setBins(iCoord,phiBin,etaBin);
150 // now work out row coord.
151
152 if (rowNum>7){
153 std::cerr << "ERROR!!! JetEnergyModuleKey::rowPhiCoord exceeds allowed range. Row, "<<rowNum
154 <<" will be set to zero"<<std::endl;
155 rowNum=0;
156 }
157 double phi =( (static_cast<double>(phiBin))*TrigT1CaloDefs::jemPhiSize ); //bot of JEM
158 phi+= static_cast<double>( rowNum )*0.2+0.1; //mid of row
159 if (m_debugModuleKey){
160 if ( (phi<(jemCoord.phi()-0.8))||(phi>(jemCoord.phi()+0.8) ) ){
161 std::cerr << "ERROR!!! JetEnergyModuleKey::rowPhiCoord phi of row is "<<phi
162 <<" in a JEM at ("<<jemCoord.phi()<<", "<<jemCoord.eta()<<")"<<std::endl;
163 }//endif phi sensible
164 }//endif debug
165 return phi;
166}
167
169double JetEnergyModuleKey::dPhi(const Coordinate& /*coord*/) const{
170 return M_PI/2;// one quadrant
171}
172
175 if (region(coord) == MidJEM) return 0.8;
177 return 2.5;//end JEMs cover 2.4-4.9
178 return 0.0;
179}
180
181} //end of ns
182
183
187 double absEta=fabs(coord.eta());
188 if (absEta<=2.4) return MidJEM;
189 if ((coord.eta()>2.4)&&(coord.eta()<=4.9))return RightEndJEM;
190 if ((coord.eta()>=-4.9)&&(coord.eta()<-2.4))return LeftEndJEM;
191 std::cerr << "JetEnergyModuleKey::region ... Unknown region!"<<std::endl
192 << "Coordinate is ("<<coord.phi()<<", "<<coord.eta()<<")"
193 <<std::endl;
194 return JEMRegionERROR;
195}
196
197
198
200void LVL1::JetEnergyModuleKey::setBins(const ICoordinate& iCoord, unsigned int& phiBin, int& etaBin){
201 unsigned int iPhiSize=16 ; // =PI/2 * 10
202 phiBin=( iCoord.phi() )/(iPhiSize);
203 int iEtaSize=8;// JEMs are 0.8 in eta, i.e ietaSize=8
204 etaBin=sharpRound2(iCoord.eta(),iEtaSize);
205 // the above calculation fails since end JEMs are larger, so ....
206 etaBin=(etaBin < -4 ? -4 : etaBin); // etaBin=-5
207 etaBin=(etaBin > 4 ? 4 : etaBin); // belongs to the JEM in etaBin=-4
208
209 return;
210}
211
214 switch (region(coord)){
215 case MidJEM :
216 return midJEMEtaCol(coord);
217 case LeftEndJEM :
218 return leftEndJEMEtaCol(coord);
219 case RightEndJEM :
220 return rightEndJEMEtaCol(coord);
221 default:
222 std::cerr << "JetEnergyModuleKey::etaColumn UNKNOWN REGION"<<std::endl;
223 }
224 return static_cast<unsigned int>(JEMRegionERROR);
225}
226
228unsigned int LVL1::JetEnergyModuleKey::jem(const Coordinate & coord) const {
229 double min=3.2; double jemEtaWidth=0.8;
230 unsigned int crateModifier=(phiQuadrant(coord.phi())/2);
231 //=0 for quad 0&1, =1 for quad 2&3
232
233 double temp = (coord.eta()+min)/jemEtaWidth;
234 int jem = static_cast<int>(temp);
235 jem=(jem < 0 ? 0 : jem);
236 jem=(jem > 7 ? 7 : jem);
237
238 jem+=(8*crateModifier);
239 return static_cast<unsigned int>(jem);
240}
241
246// double phiBinWidth=((2*M_PI)/64.0);
247 int abs_ieta=abs(iCoord.eta() );
248 int sign=( iCoord.eta() )/abs_ieta;
249
250 int etaBin=0; unsigned int phiBin=0;
251 setBins(iCoord,phiBin,etaBin);
252
253 double centralPhi=( (static_cast<double>(phiBin))*TrigT1CaloDefs::jemPhiSize )
255 double centralEta=0.0;
256 if ((etaBin>-4)&&(etaBin<4)){
257 centralEta=(static_cast<double>(etaBin)*(TrigT1CaloDefs::jemEtaSize) )
259 }else{
260 centralEta=3.65*sign;//centre of end JEMs
261 }
262 if (m_debugModuleKey){
263 std::cout << "JetEnergyModuleKey: start calcTrigBin"<<std::endl;
264 std::cout << "phi, eta : ("<<m_phi<<", "<<m_eta<<")"<<std::endl;
265 std::cout << "iphi, ieta : ("<<( iCoord.phi() )<<", "<<( iCoord.eta() )<<")"<<std::endl;
266 std::cout << "abs_ieta : ("<<abs_ieta<<" and sign : "<<sign<<std::endl;
267 std::cout << "central : ("<<centralPhi<<", "<<centralEta<<")"
268 << "bin : ("<<phiBin<<","<<etaBin<<")"<<std::endl;
269 }
270
271 Coordinate centralCoords(centralPhi, centralEta);
272 if (m_debugModuleKey) std::cout <<" JetEnergyModuleKey : created coord "<<centralCoords<<std::endl;
273 return BinAndCoord(phiBin,etaBin,centralCoords);
274}
275
278 double etaWidth=0.2;//only true for middle JEMS
279 double JEMEtaSize=0.8;
280// unsigned int columnsPerJEM= 4;
281 int etaBin=( jem(coord)%8)-4;//bins range from -4 to +3
282 double etaMin=(etaBin*JEMEtaSize);
283
284 double temp =(coord.eta()-etaMin)/etaWidth;
285 int colNum=sharpRound(temp);
286
287 colNum=(colNum < 0 ? 0 : colNum);//sorts out any rounding errors
288 colNum=(colNum > 3 ? 3 : colNum);
289
290 return colNum;
291}
292
294 // left hand end first
296 switch (get.jeRegion( coord )){
298 return 3;
299 break;
301 return 2;
302 break;
304 return 1;
305 break;
307 return 0;
308 break;
310 // here to stop compiler warnings
311 break;
313 // here to stop compiler warnings
314 break;
315 }
316 return static_cast<unsigned int>(JEMRegionERROR);
317}
318
321 // left hand end first
323 switch (get.jeRegion( coord )){
325 return 0;
326 break;
328 return 1;
329 break;
331 return 2;
332 break;
334 return 3;
335 break;
337 // here to stop compiler warnings
338 break;
340 // here to stop compiler warnings
341 break;
342 }
343 return static_cast<unsigned int>(JEMRegionERROR);
344}
345
346
347
353unsigned int LVL1::JetEnergyModuleKey::phiQuadrant(const double phi) const {
354 double temp = phi/(M_PI/2);
355 unsigned int quad = static_cast<unsigned int>(temp);
356 quad=(quad > 3 ? 0 : quad);
357
358 return static_cast<unsigned int>(quad);
359}
#define M_PI
double coord
Type of coordination system.
@ top
#define min(a, b)
Definition cfImp.cxx:40
Used to pass data between the methods of the Key Classes: Returns the Eta and Phi bins,...
Definition BinAndCoord.h:35
returns the trigger hardware components associated with a given Coordinate
unsigned int jepModule(const Coordinate &coord)
returns ID of JEP module (i.e.
unsigned int jepCrate(const Coordinate &Coord)
returns ID of JEP Crate that covers this coordinate
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
The JetElementKey object provides the key for each JetElement depending on its eta,...
unsigned int col(const Coordinate &coord)
return row of passed coordinate
virtual double dPhi(const Coordinate &coord) const override
height
unsigned int phiQuadrant(const double phi) const
returns the quadrant number associated with the phi coordinate, 0 - 90 = 0 90 - 180 = 1 180-270 = 2 2...
std::vector< unsigned int > jeKeys(unsigned int crate, unsigned int module)
calculates keys of all JetElements in given crate and module
void setBins(const ICoordinate &iCoord, unsigned int &phiBin, int &etaBin)
sets the eta and phi bins
virtual BinAndCoord calculateTriggerBin(const ICoordinate &iCoord) override
converts integer phi, eta coordinates to phi, eta trigger bins, and central coords
unsigned int jemKey(const xAOD::JetElement *jetElement)
returns the key of the passed Coordinate
unsigned int midJEMEtaCol(const Coordinate &coord) const
No descriptions.
unsigned int jem(const Coordinate &coord) const
returns ID of JEP module (i.e.
virtual double dEta(const Coordinate &coord) const override
width
unsigned int leftEndJEMEtaCol(const Coordinate &coord) const
returns eta row of JEMs 0, or 8
JetEnergyModuleKey()
constructs a JetEnergyModuleKey object
std::vector< Coordinate > jeCoords(unsigned int crate, unsigned int module)
returns coordinates of all JetElements in given crate and module
bool m_debugModuleKey
set to true to turn debugging info on
unsigned int row(const Coordinate &coord) const
returns the phi row of a coord within the JEM that contains it.
double rowPhiCoord(unsigned int row, const Coordinate &jemCoord)
returns the phi coord of the row of the JEM at the coordinates passed
unsigned int rightEndJEMEtaCol(const Coordinate &coord) const
returns eta row of JEMs 7 or 15
JEMRegion region(const Coordinate &coord) const
region
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.
int sharpRound2(int a, int b) const
divides a/b and returns a number as follows (where +b means +ve b): if 0
virtual double phi() const
returns phi coordinate of centre of relevant trigger tower.
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.
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 Region5EtaCentre
static const double RegionERROREtaCentre
static const double jemPhiSize
static const double jemEtaSize
static const double Region0Height
float phi() const
get phi (note that for L1Calo phi runs from 0 to 2pi)
float eta() const
get eta
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
JetElement_v2 JetElement
Define the latest version of the JetElement class.