ATLAS Offline Software
JEMJetAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 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 
24 namespace LVL1 {
25 using namespace TrigConf;
26 
27 const int JEMJetAlgorithm::m_satLarge = 0x3FF;
28 const int JEMJetAlgorithm::m_satSmall = 0x1FF;
29 
30 LVL1::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 {
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
67  setRoICoord(m_refEta, m_refPhi);
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 
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
145  passesTrigger();
146 
147 }
148 
150 }
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 
189 void LVL1::JEMJetAlgorithm::testEtMax(const std::vector<int>& cores) {
190 
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  unsigned int sizeSmall{4}; // the size of the small jets (by default 4)
218  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  sizeSmall = 4; // not part of the new menu
223  sizeLarge = 8; // not part of the new menu
224  float scale = m_l1menu->thrExtraInfo().JET().jetScale();
225  threshSmall = m_l1menu->thrExtraInfo().JET().ptMinToTopoSmallWindowCounts()*scale;
226  threshLarge = m_l1menu->thrExtraInfo().JET().ptMinToTopoLargeWindowCounts()*scale;
227 
228  int etLarge = m_ET8x8;
229  if (sizeLarge == 6) etLarge = m_ET6x6;
230  else if (sizeLarge == 4) etLarge = m_ET4x4;
231 
232  int etSmall = m_ET4x4;
233  if (sizeSmall == 6) etLarge = m_ET6x6;
234  else if (sizeSmall == 8) etLarge = m_ET8x8;
235 
236  if (etLarge <= threshLarge && etSmall <= threshSmall) return;
237 
238  m_ETLarge = etLarge;
239  m_ETSmall = etSmall;
240 
241 }
242 
243 // Public accessor methods follow
244 
247  return m_ET4x4;
248 }
249 
252  return ( (m_ET4x4 < m_satLarge) ? m_ET4x4 : m_satLarge );
253 }
254 
257  return ( (m_ET6x6 < m_satLarge) ? m_ET6x6 : m_satLarge );
258 }
259 
262  return ( (m_ET8x8 < m_satLarge) ? m_ET8x8 : m_satLarge );
263 }
264 
267  return ( (m_ETLarge < m_satLarge) ? m_ETLarge : m_satLarge );
268 }
269 
272  return ( (m_ETSmall < m_satSmall) ? m_ETSmall : m_satSmall );
273 }
274 
277  return m_EtMax;
278 }
279 
282  return ( m_EtMax && (m_ETLarge > 0 || m_ETSmall > 0) );
283 }
284 
287  return m_eta;
288 }
289 
292  return ( (m_phi <= M_PI) ? m_phi : m_phi - 2.*M_PI);
293 }
294 
299 
300  if (isRoI()) {
301 
302  // Need to calculate hardware coordinate
303  Coordinate coord(m_refPhi, m_refEta);
304  CoordToHardware convertor;
305 
306  int crate = convertor.jepCrate(coord);
307  int jem = convertor.jepModule(coord);
308  unsigned int jemCoord = convertor.jepLocalCoordinate(coord);
309  int frame = (jemCoord>>2);
310  int lc = jemCoord&3;
311 
312  /*
313  JetEnergyModuleKey get();
314  Coordinate tempCoord(m_refPhi, m_refEta);
315  unsigned int quadrant = m_refPhi*2/M_PI;
316  unsigned int row = get.row(tempCoord);
317  unsigned int col = get.col(tempCoord);
318 
319  unsigned int crate = quadrant&1;
320  unsigned int jem = get.jem(tempCoord);
321  unsigned int frame = ((col&2)<<1) + (row>>1);
322  unsigned int lc = (col&1) + (row&1)*2;
323  */
324  xAOD::JEMTobRoI* roi = new xAOD::JEMTobRoI();
325  roi->makePrivateStore();
326  roi->initialize(crate, jem, frame, lc, ETLarge(), ETSmall());
327  return roi;
328  }
329 
330  return 0;
331 
332 }
333 
334 } // end of namespace bracket
335 
336 
LVL1::JetElementKeyBase::isFCAL
bool isFCAL(double eta) const
returns TRUE if this coordinate is in the FCAL
Definition: JetElementKeyBase.cxx:430
LVL1::JEMJetAlgorithm::passesTrigger
void passesTrigger()
Check trigger condition and set ET values if TOB created.
Definition: JEMJetAlgorithm.cxx:212
LVL1::Coordinate::phi
double phi() const
return phi
Definition: Coordinate.cxx:50
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
LVL1::JEMJetAlgorithm::ET6x6
int ET6x6()
Returns 6x6 TT cluster ET.
Definition: JEMJetAlgorithm.cxx:261
xAOD::JEMTobRoI
JEMTobRoI_v1 JEMTobRoI
Define the latest version of the JEMTobRoI class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JEMTobRoI.h:17
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
LVL1::JEMJetAlgorithm::eta
double eta()
Accessors.
Definition: JEMJetAlgorithm.cxx:291
M_PI
#define M_PI
Definition: ActiveFraction.h:11
LVL1::JEMJetAlgorithm::ET4x4
int ET4x4()
Returns 4x4 TT cluster ET.
Definition: JEMJetAlgorithm.cxx:256
LVL1::JEMJetAlgorithm::m_satSmall
static const int m_satSmall
Definition: JEMJetAlgorithm.h:94
LVL1::JEMJetAlgorithm::isRoI
bool isRoI()
Does this window pass the local ET maximum condition.
Definition: JEMJetAlgorithm.cxx:286
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
LVL1::JetElementKeyBase::upperRight
Coordinate upperRight(const double phi, const double eta)
Definition: JetElementKeyBase.cxx:323
CoordToHardware.h
python.LumiCalcHtml.lc
lc
Definition: LumiCalcHtml.py:579
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::JEMJetAlgorithm::ETSmall
int ETSmall()
Returns Small cluster ET.
Definition: JEMJetAlgorithm.cxx:276
LVL1::JEMJetAlgorithm::setRoICoord
void setRoICoord(double eta, double phi)
Compute RoI coordinate.
Definition: JEMJetAlgorithm.cxx:159
ThresholdConfig.h
LVL1::JEMJetAlgorithm::isEtMax
bool isEtMax()
Does this window pass the local ET maximum condition.
Definition: JEMJetAlgorithm.cxx:281
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
LVL1::JetElementKeyBase::upPhi
Coordinate upPhi(const double phi, const double eta)
returns coord of next JE in +ve phi dir.
Definition: JetElementKeyBase.cxx:263
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
LVL1::Coordinate
Coordinate class declaration.
Definition: TrigT1/TrigT1Interfaces/TrigT1Interfaces/Coordinate.h:50
lumiFormat.i
int i
Definition: lumiFormat.py:92
LVL1::JEMJetAlgorithm::Core
int Core()
Returns RoI Core ET.
Definition: JEMJetAlgorithm.cxx:251
CaloInfo.h
LVL1::JetInputKey
The JetInputKey object provides the key for each JetElement depending on its eta,phi coords (JetEleme...
Definition: JetInputKey.h:47
LVL1::JetElementKeyBase::dPhi
double dPhi(const double phi, const double eta) const
return height of JE
Definition: JetElementKeyBase.cxx:362
LVL1::JEMJetAlgorithm::JEMJetAlgorithm
JEMJetAlgorithm(double eta, double phi, const std::map< int, JetInput * > *jiContainer, const TrigConf::L1Menu *l1menu)
Definition: JEMJetAlgorithm.cxx:35
LVL1::CoordToHardware
returns the trigger hardware components associated with a given Coordinate
Definition: CoordToHardware.h:42
LVL1::CoordToHardware::jepModule
unsigned int jepModule(const Coordinate &coord)
returns ID of JEP module (i.e.
Definition: CoordToHardware.cxx:67
JetInputKey.h
LVL1::TrigT1CaloDefs::RegionERROREtaCentre
static const double RegionERROREtaCentre
Definition: TrigT1CaloDefs.h:102
LVL1::JEMJetAlgorithm::testEtMax
void testEtMax(const std::vector< int > &cores)
Form all 2x2 clusters within window and test centre is a local ET maximum.
Definition: JEMJetAlgorithm.cxx:194
LVL1::JEMJetAlgorithm::ET8x8
int ET8x8()
Returns 8x8 TT cluster ET.
Definition: JEMJetAlgorithm.cxx:266
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
TrigT1CaloDefs.h
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
LVL1::Coordinate::eta
double eta() const
return eta
Definition: Coordinate.cxx:45
L1DataDef.h
LVL1::JEMJetAlgorithm::~JEMJetAlgorithm
~JEMJetAlgorithm()
Definition: JEMJetAlgorithm.cxx:154
LVL1::CoordToHardware::jepLocalCoordinate
unsigned int jepLocalCoordinate(const Coordinate &coord)
returns the roi's local coord, in the form of a 5b word.
Definition: CoordToHardware.cxx:195
xAOD::JEMTobRoI_v1
Description of JEMTobRoI_v1.
Definition: JEMTobRoI_v1.h:25
CoordinateRange.h
JEMJetAlgorithm.h
LVL1::JEMJetAlgorithm::phi
double phi()
Returns phi coordinate of RoI, using standard ATLAS convention.
Definition: JEMJetAlgorithm.cxx:296
LVL1::CoordToHardware::jepCrate
unsigned int jepCrate(const Coordinate &Coord)
returns ID of JEP Crate that covers this coordinate
Definition: CoordToHardware.cxx:32
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
xAOD::JEMTobRoI_v1::initialize
virtual void initialize(const int crate, const int jem, const int frame, const int location, const int energyLarge, const int energySmall)
Definition: JEMTobRoI_v1.cxx:23
LVL1::JetElementKeyBase::getCentre
Coordinate getCentre(const double phi, const double eta)
returns the central coordinate of the JE which contains the passed coord
Definition: JetElementKeyBase.cxx:489
LVL1::JEMJetAlgorithm::m_satLarge
static const int m_satLarge
Algorithm parameters.
Definition: JEMJetAlgorithm.h:93
LVL1::JEMJetAlgorithm::jemTobRoI
xAOD::JEMTobRoI * jemTobRoI()
Create JEMTobRoI and return pointers to it.
Definition: JEMJetAlgorithm.cxx:303
LVL1::JEMJetAlgorithm::ETLarge
int ETLarge()
Returns Large cluster ET.
Definition: JEMJetAlgorithm.cxx:271
L1Menu.h
LVL1::JetElementKeyBase::dEta
double dEta(const double phi, const double eta) const
return width of JE
Definition: JetElementKeyBase.cxx:380