ATLAS Offline Software
Loading...
Searching...
No Matches
JEMJetAlgorithm.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 JEMJetAlgorithm.cxx - description
6 -------------------
7 begin : Thurs Mar 13 2014
8 email : Alan.Watson@cern.ch
9 ***************************************************************************/
10
19#include "TrigConfData/L1Menu.h"
20
21
22#include <math.h>
23
24namespace LVL1 {
25using namespace TrigConf;
26
27const int JEMJetAlgorithm::m_satLarge = 0x3FF;
28const int JEMJetAlgorithm::m_satSmall = 0x1FF;
29
30LVL1::JEMJetAlgorithm::JEMJetAlgorithm( double eta, double phi, const std::map<int, JetInput *>* jiContainer,
31 const TrigConf::L1Menu * l1menu):
32 m_l1menu(l1menu),
33 m_ET4x4(0),
34 m_ET6x6(0),
35 m_ET8x8(0),
36 m_ETLarge(0),
37 m_ETSmall(0),
38 m_EtMax(false)
39 //m_debug(false)
40{
56
57 // Offset depends on eta. Need to protect against rounding errors even here
58 JetInputKey get(phi-0.01,eta-0.01);
59 double de = get.dEta()/4.;
60
61 // Get coordinate of centre of this "reference element"
62 Coordinate refCoord = get.getCentre(phi-M_PI/64., eta-de);
63 m_refEta = refCoord.eta();
64 m_refPhi = refCoord.phi();
65
66 // Set coordinate of centre of RoI, starting from reference tower coordinate
68
69 // Get coordinate of bottom-left JetInput in this window
70 int minEtaOffset = -1;
71 Coordinate startCoord = get.lowerLeft(m_refPhi,m_refEta);
72 if (startCoord.eta() == TrigT1CaloDefs::RegionERROREtaCentre) { // already at left edge
73 startCoord = get.downPhi(m_refPhi,m_refEta);
74 minEtaOffset = 0;
75 }
76 double tempEta = startCoord.eta();
77 double startPhi = startCoord.phi();
78
95
96 std::vector<int> et6x6(4);
97 std::vector<int> cores(9);
98 for (int etaOffset=minEtaOffset; etaOffset<=2 ; etaOffset++){
99 Coordinate tempCoord(startPhi,tempEta);
100 for (int phiOffset=-1; phiOffset<=2 ; phiOffset++){
101 int tempKey = get.jeKey(tempCoord);
102 std::map<int, JetInput*>::const_iterator ji = jiContainer->find(tempKey);
103 if (ji != jiContainer->end() ){
104 // get ET once here, rather than repeat function calls
105 int ET = (ji->second)->energy();
106 // 8x8 jet is easy
107 m_ET8x8 += ET;
108 // but there are 4 possible 6x6 clusters
109 if (phiOffset > -1) {
110 if (etaOffset < 2) et6x6[1] += ET;
111 if (etaOffset > -1) et6x6[2] += ET;
112 }
113 if (phiOffset < 2) {
114 if (etaOffset < 2) et6x6[0] += ET;
115 if (etaOffset > -1) et6x6[3] += ET;
116 }
117 // Each JetInput is part of up to 4 RoI core clusters
118
119 if (etaOffset >= 0) {
120 if (phiOffset >= 0) cores[phiOffset+3*etaOffset] += ET;
121 if (phiOffset < 2) cores[phiOffset+3*etaOffset+1] += ET;
122 }
123 if (etaOffset < 2) {
124 if (phiOffset >= 0) cores[phiOffset+3*etaOffset+3] += ET;
125 if (phiOffset < 2) cores[phiOffset+3*etaOffset+4] += ET;
126 }
127 } // end of check that jetinput exists in container
128 tempCoord = get.upPhi(tempCoord); // Increment phi coordinate
129 } // end phi offset loop
130 tempCoord = get.rightEta(tempCoord); // Increment eta coordinate
131 tempEta = tempCoord.eta();
132 if (tempEta == TrigT1CaloDefs::RegionERROREtaCentre) break; // gone outside coverage
133 } // end eta offset loop
134
135 // 4x4 cluster = central RoI core
136 m_ET4x4 = cores[4];
137
138 // find most energetic 6x6 cluster
139 for (int i = 0; i < 4; i++) if (et6x6[i] > m_ET6x6) m_ET6x6 = et6x6[i];
140
141 // Check whether RoI condition is met.
142 testEtMax(cores);
143
144 // test trigger conditions
146
147}
148
151
155
156 JetInputKey keyLL(phi,eta);
157 // Get coordinate of centre of this "reference element"
158 Coordinate lowerLeft = keyLL.getCentre(phi, eta);
159
160 // Hence find lower-left corner of RoI core
161 double lowerEta = lowerLeft.eta() - ( keyLL.dEta()/2. );
162 double lowerPhi = lowerLeft.phi() - ( keyLL.dPhi()/2. );
163
164 // Get coordinate of opposite corner of RoI core:
165 Coordinate upperRight;
166 if (keyLL.isFCAL(lowerLeft.eta()) && eta > 0) {
167 // Special case: no JE to right, so get centre of element at eta, phi+1
168 upperRight = keyLL.upPhi(phi, eta);
169 }
170 else {
171 // Get centre of element at eta+1, phi+1, i.e. opposite corner of RoI core
172 upperRight = keyLL.upperRight(phi, eta);
173 }
174
175 // Now get upper-right corner of RoI core:
176 JetInputKey keyUR(upperRight);
177 double upperEta = upperRight.eta() + ( keyUR.dEta()/2. );
178 double upperPhi = upperRight.phi() + ( keyUR.dPhi()/2. );
179
180
181 // CoordinateRange object will compute centre, correcting for wrap-around
182 CoordinateRange roi(lowerPhi,upperPhi,lowerEta,upperEta);
183 m_eta = roi.eta();
184 m_phi = roi.phi();
185
186}
187
189void LVL1::JEMJetAlgorithm::testEtMax(const std::vector<int>& cores) {
190
198
199 // RoI condition test
200 m_EtMax = true;
201 for (int i = 0; i < 4; i++) if (cores[4] < cores[i]) m_EtMax = false;
202 for (int i = 5; i < 9; i++) if (cores[4] <= cores[i]) m_EtMax = false;
203
204}
205
208
209 // Belt and braces
210 m_ETLarge = 0;
211 m_ETSmall = 0;
212
213 // Don't waste time if it isn't an RoI candidate
214 if (!m_EtMax) return;
215
216 // Does this pass min TOB pT cut?
217 constexpr unsigned int sizeSmall{4}; // the size of the small jets (by default 4)
218 constexpr unsigned int sizeLarge{8}; // the size of the large jets (by default 8)
219 int threshSmall{0}; // the minimum pT of small jet objects sent to TOPO (in counts, not in GeV)
220 int threshLarge{0}; // the minimum pT of large jet objects sent to TOPO (in counts, not in GeV)
221
222
223 float scale = m_l1menu->thrExtraInfo().JET().jetScale();
224 threshSmall = m_l1menu->thrExtraInfo().JET().ptMinToTopoSmallWindowCounts()*scale;
225 threshLarge = m_l1menu->thrExtraInfo().JET().ptMinToTopoLargeWindowCounts()*scale;
226
227 int etLarge = m_ET8x8;
228 if constexpr (sizeLarge == 6) etLarge = m_ET6x6;
229 else if (sizeLarge == 4) etLarge = m_ET4x4;
230
231 const int etSmall = m_ET4x4;
232 if constexpr (sizeSmall == 6) etLarge = m_ET6x6;
233 else if (sizeSmall == 8) etLarge = m_ET8x8;
234
235 if (etLarge <= threshLarge && etSmall <= threshSmall) return;
236
237 m_ETLarge = etLarge;
238 m_ETSmall = etSmall;
239
240}
241
242// Public accessor methods follow
243
246 return m_ET4x4;
247}
248
253
258
263
268
273
276 return m_EtMax;
277}
278
281 return ( m_EtMax && (m_ETLarge > 0 || m_ETSmall > 0) );
282}
283
286 return m_eta;
287}
288
291 return ( (m_phi <= M_PI) ? m_phi : m_phi - 2.*M_PI);
292}
293
296
298
299 if (isRoI()) {
300
301 // Need to calculate hardware coordinate
303 CoordToHardware convertor;
304
305 int crate = convertor.jepCrate(coord);
306 int jem = convertor.jepModule(coord);
307 unsigned int jemCoord = convertor.jepLocalCoordinate(coord);
308 int frame = (jemCoord>>2);
309 int lc = jemCoord&3;
310
311 /*
312 JetEnergyModuleKey get();
313 Coordinate tempCoord(m_refPhi, m_refEta);
314 unsigned int quadrant = m_refPhi*2/M_PI;
315 unsigned int row = get.row(tempCoord);
316 unsigned int col = get.col(tempCoord);
317
318 unsigned int crate = quadrant&1;
319 unsigned int jem = get.jem(tempCoord);
320 unsigned int frame = ((col&2)<<1) + (row>>1);
321 unsigned int lc = (col&1) + (row&1)*2;
322 */
323 xAOD::JEMTobRoI* roi = new xAOD::JEMTobRoI();
324 roi->makePrivateStore();
325 roi->initialize(crate, jem, frame, lc, ETLarge(), ETSmall());
326 return roi;
327 }
328
329 return 0;
330
331}
332
333} // end of namespace bracket
334
335
#define M_PI
double coord
Type of coordination system.
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 jepLocalCoordinate(const Coordinate &coord)
returns the roi's local coord, in the form of a 5b word.
unsigned int jepCrate(const Coordinate &Coord)
returns ID of JEP Crate that covers this coordinate
CoordinateRange class declaration.
double phi() const
return phi
double eta() const
return eta
bool isEtMax()
Does this window pass the local ET maximum condition.
const TrigConf::L1Menu * m_l1menu
int ET4x4()
Returns 4x4 TT cluster ET.
double m_eta
Algorithm results.
int Core()
Returns RoI Core ET.
int ETSmall()
Returns Small cluster ET.
double eta()
Accessors.
static const int m_satSmall
bool isRoI()
Does this window pass the local ET maximum condition.
double phi()
Returns phi coordinate of RoI, using standard ATLAS convention.
int ETLarge()
Returns Large cluster ET.
JEMJetAlgorithm(double eta, double phi, const std::map< int, JetInput * > *jiContainer, const TrigConf::L1Menu *l1menu)
void passesTrigger()
Check trigger condition and set ET values if TOB created.
xAOD::JEMTobRoI * jemTobRoI()
Create JEMTobRoI and return pointers to it.
static const int m_satLarge
Algorithm parameters.
void setRoICoord(double eta, double phi)
Compute RoI coordinate.
void testEtMax(const std::vector< int > &cores)
Form all 2x2 clusters within window and test centre is a local ET maximum.
int ET8x8()
Returns 8x8 TT cluster ET.
int ET6x6()
Returns 6x6 TT cluster ET.
Coordinate getCentre(const double phi, const double eta)
returns the central coordinate of the JE which contains the passed coord
double dEta(const double phi, const double eta) const
return width of JE
Coordinate upperRight(const double phi, const double eta)
double dPhi(const double phi, const double eta) const
return height of JE
bool isFCAL(double eta) const
returns TRUE if this coordinate is in the FCAL
Coordinate upPhi(const double phi, const double eta)
returns coord of next JE in +ve phi dir.
The JetInputKey object provides the key for each JetElement depending on its eta,phi coords (JetEleme...
Definition JetInputKey.h:42
static const double RegionERROREtaCentre
void makePrivateStore()
Create a new (empty) private store for this object.
L1 menu configuration.
Definition L1Menu.h:28
virtual void initialize(const int crate, const int jem, const int frame, const int location, const int energyLarge, const int energySmall)
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...
JEMTobRoI_v1 JEMTobRoI
Define the latest version of the JEMTobRoI class.