ATLAS Offline Software
Loading...
Searching...
No Matches
CoordToHardware.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4/***************************************************************************
5 CoordToHardware.cxx - description
6 -------------------
7 begin : Fri Apr 19 2002
8 email : moyse@ph.qmw.ac.uk
9 ***************************************************************************/
10
11#ifndef TRIGGERSPACE
13#else
14#include "CoordToHardware.h"
15#endif
16
17#include <cmath>
18#include <iostream>
19
26
29
33 unsigned int quad=phiQuadrant( Coord.phi() );
34 return (quad%2);
35}
36
40
41 return ( phiQuadrant(coord.phi()) );
42}
43
44
48 return ( phiQuadrant(coord.phi()) );
49}
50
53 if ( cpCoordIsValid(coord) ) {
54 // CPM1 is at -2.6 to -2.4 (here set it to -2.8)
55 // CPM8 is at 0.0 to 0.4
56 double eta=coord.eta();
57 unsigned int cpm = static_cast<unsigned int>( (eta+m_cpmEtaMax)/m_cpmEtaWidth )+1;
58 return cpm;
59 }
60 return m_error;
61}
62
68 JetEnergyModuleKey jemKey;
69 return static_cast<unsigned int>(jemKey.jem(coord));
70}
71
75 if ( cpCoordIsValid(coord) ) {
76 double phi=coord.phi();
77 // should be 32 FPGAs in 2*PI
78 double temp = phi/m_cpFPGAPhiWidth;
79 // so temp mod 8 returns FPGA #
80 return ( (static_cast<unsigned int>(temp))%8);
81 }
82 // not a valid coord
83 return m_error;
84}
85
92
93 m_roiLocalMap[0][0]=0;
94 m_roiLocalMap[0][1]=1;
95 m_roiLocalMap[0][2]=4;
96 m_roiLocalMap[0][3]=5;
97 m_roiLocalMap[1][0]=2;
98 m_roiLocalMap[1][1]=3;
99 m_roiLocalMap[1][2]=6;
100 m_roiLocalMap[1][3]=7;
101}
102
105 if ( cpCoordIsValid(coord) ) {
106 double phi=coord.phi();
107 double eta=coord.eta();
108 // should be 32 FPGAs in 2*PI, and there are 2 local RoI locations in phi per FPGA
109 // so "temp" ranges from 0-63
110 unsigned int temp = static_cast<unsigned int>( (phi/m_cpFPGAPhiWidth)*2);
111 // so this (below) gives us the integer phi coordinate WITHIN the FPGA
112 unsigned int iLocalPhi= temp%2;
113 // There are 14 CPMs, each with 8 FPGAs that each span it completely in eta
114 // (i.e. one eta position for FPGAs in CPM) and there are 4 local RoI
115 // locations in eta per FPGA
116
117 temp=static_cast<unsigned int>( (eta+2.8)/0.1 );
118
119 //temp = static_cast<unsigned int>( (eta+(m_cpmEtaMax+m_cpmEtaWidth)/m_cpmEtaWidth ) * 4);
120 unsigned int iLocalEta = temp%4;
121 return m_roiLocalMap[iLocalPhi][iLocalEta];
122 }
123 // invalid coord
124 return m_error;
125}
126
129 double eta= coord.eta();
130 if ( (eta>=-m_cpEtaMax) && (eta <=m_cpEtaMax) ) return true;
131 std::cerr << "CoordToHardware::cpCoordIsValid: Coordinate outside permitted range of eta = "
132 <<-m_cpEtaMax<<" to "<<m_cpEtaMax<<std::endl;
133 return false;
134}
135
141 unsigned int crate =jepCrate(coord);
142 unsigned int jem=jepModule(coord);
143 unsigned int PJ=jepLocalCoordinate(coord);
144
145 unsigned int word=0;
146 if ((crate==m_error)||(jem==m_error)||(PJ==m_error)){
147 std::cerr << "CPCoordinateWord ERROR: "<< std::endl;
148 }else{
149 word = crate; // put 1 bit crate number
150 word = (word<<4) + jem; // followed by 4 bit JEM number
151 word = (word<<5) + PJ; // JP
152 }
153 if (m_debug) std::cout << " Coords set to ("<<coord.phi()<<", "<<coord.eta()<<") giving : "<<word
154 << " from crate "<<crate
155 << " JEM "<<jem<<" PJ : "<<PJ<< std::endl;
156 return word;
157}
158
164unsigned int LVL1::CoordToHardware::phiQuadrant(const double phi) const {
165 double temp = phi/(M_PI/2);
166 return static_cast<unsigned int>(temp);
167}
168
175 unsigned int crate =cpCrate(coord);
176 unsigned int cpm=cpModule(coord);
177 unsigned int fpga=cpModuleFPGA(coord);
178 unsigned int lc=cpModuleLocalRoI(coord);
179
180 unsigned int word=0;
181 if ((crate==m_error)||(cpm==m_error)||(fpga==m_error)||(lc==m_error)){
182 std::cerr << "CPCoordinateWord ERROR: "<< std::endl;
183 }else{
184 word= crate; // put 2 bit crate number
185 word = (word<<4) + cpm; // followed by 4 bit CPM number
186 word = (word<<3) + fpga; // 3 bit FPGA number
187 word = (word<<3) + lc; //2 bit local coord
188 }
189 if (m_debug) std::cout << " Coords set to ("<<coord.phi()<<", "<<coord.eta()<<") giving : "<<word
190 << " from crate "<<crate
191 << " CPM "<<cpm<<" fpga : "<<fpga<<" LC : "<<lc<< std::endl;
192 return word;
193}
194
196 JetEnergyModuleKey jemKey;
197 unsigned int row=jemKey.row(coord);
198 unsigned int col=jemKey.col(coord);
199 unsigned int frame = 4*(col>>1) + (row>>1);
200 unsigned int rl = 2*(row%2) + (col%2);
201 return (frame<<2)+rl;
202}
203
206
207 const double phi = cpPhiOverlap(coord);
208 return (phi == coord.phi()) ? m_error
209 : cpCrate(Coordinate(phi, coord.eta()));
210}
211
214
215 const double phi = cpPhiOverlap(coord);
216 return (phi == coord.phi()) ? m_error
217 : cpModule(Coordinate(phi, coord.eta()));
218}
219
222
223 const double phi = jepPhiOverlap(coord);
224 return (phi == coord.phi()) ? m_error
225 : jepCrate(Coordinate(phi, coord.eta()));
226}
227
230
231 const double phi = jepPhiOverlap(coord);
232 return (phi == coord.phi()) ? m_error
233 : jepModule(Coordinate(phi, coord.eta()));
234}
235
238
239 double phi = coord.phi();
240 const double twoPi = 2.*M_PI;
241 const double piByTwo = M_PI/2.;
242 const double twoPhiBins = M_PI/16.;
243 const double phiLoc = std::fmod(phi, piByTwo);
244 if (phiLoc < twoPhiBins) {
245 phi -= twoPhiBins;
246 if (phi < 0.) phi += twoPi;
247 } else if (phiLoc > piByTwo - twoPhiBins) {
248 phi += twoPhiBins;
249 if (phi >= twoPi) phi -= twoPi;
250 }
251 return phi;
252}
253
256
257 double phi = coord.phi();
258 const double eta = coord.eta();
259 const bool fcal = eta < -3.2 || eta > 3.2;
260 const double twoPi = 2.*M_PI;
261 const double piByTwo = M_PI/2.;
262 const double twoPhiBins = M_PI/8.;
263 const double onePhiBin = (fcal) ? twoPhiBins : twoPhiBins/2.;
264 const double phiLoc = std::fmod(phi, piByTwo);
265 if (phiLoc < twoPhiBins) {
266 phi -= twoPhiBins;
267 if (phi < 0.) phi += twoPi;
268 } else if (phiLoc > piByTwo - onePhiBin) {
269 phi += onePhiBin;
270 if (phi >= twoPi) phi -= twoPi;
271 }
272 return phi;
273}
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
double coord
Type of coordination system.
unsigned int cpModuleOverlap(const Coordinate &coord)
return ID of CP module for overlap coord
double m_cpmEtaWidth
eta width of CP modules (CPMs)
void fillRoILocalMap()
No descriptions.
unsigned int jepModule(const Coordinate &coord)
returns ID of JEP module (i.e.
double m_cpEtaMax
contains the maximum permissable eta for CP system.
unsigned int phiQuadrant(const double phi) const
returns the quadrant number associated with the phi coordinate,
double jepPhiOverlap(const Coordinate &coord) const
returns a phi in core area for overlap jet elements
unsigned int cpRoIROD(const Coordinate &coord)
returns Module ID of CP RoI ROD
unsigned int jepCoordinateWord(const Coordinate &coord)
return JEP (Jet Energy Processing) hardware coordinate word for this coordinate.
unsigned int jepLocalCoordinate(const Coordinate &coord)
returns the roi's local coord, in the form of a 5b word.
unsigned int cpModuleFPGA(const Coordinate &coord)
returns ID [0-7] of the CP FPGA.
unsigned int cpModule(const Coordinate &coord)
return ID of CP module.
unsigned int cpModuleLocalRoI(const Coordinate &coord)
returns local RoI coordinate within FPGA
double cpPhiOverlap(const Coordinate &coord) const
returns a phi in core area for overlap CPM towers
bool cpCoordIsValid(const Coordinate &coord) const
returns false if Coord is outside permitted region
unsigned int jepCrate(const Coordinate &Coord)
returns ID of JEP Crate that covers this coordinate
double m_cpFPGAPhiWidth
phi width of CP FPGAs
unsigned int cpCoordinateWord(const Coordinate &coord)
return CP (Cluster Processing) hardware coordinate word for this coordinate.
unsigned int m_roiLocalMap[2][4]
width of JEMs
double m_cpmEtaMax
extreme value of eta, covered by CPMs.
unsigned int cpCrateOverlap(const Coordinate &coord)
returns crate ID covering that overlap coord.
unsigned int jepCrateOverlap(const Coordinate &coord)
returns ID of JEP Crate that covers this overlap coordinate
static const unsigned int m_error
returned value in the case of an invalid Coordinate error
unsigned int cpCrate(const Coordinate &coord)
returns crate ID covering that coord.
unsigned int jepModuleOverlap(const Coordinate &coord)
returns ID of JEP module (i.e.
double phi() const
return phi
The JetEnergyModuleKey object provides the key for each trigger tower depending on its eta-phi coords...
unsigned int col(const Coordinate &coord)
return row of passed coordinate
unsigned int jem(const Coordinate &coord) const
returns ID of JEP module (i.e.
unsigned int row(const Coordinate &coord) const
returns the phi row of a coord within the JEM that contains it.