ATLAS Offline Software
gFexJetRoI_v1.cxx
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 
7 // System include(s):
8 #include <stdexcept>
9 #include <numbers>
10 
11 // xAOD include(s):
13 
14 // Local include(s):
16 
17 namespace xAOD {
18 
20  using std::numbers::pi;
21  const float gFexJetRoI_v1::s_PhiWidth = (2*pi)/32; //In central region, gFex has 32 bins in phi
22  const float gFexJetRoI_v1::s_PhiWidthFR = (2*pi)/16; //In central region, gFex has 32 bins in phi
23  const std::vector<float> gFexJetRoI_v1::s_EtaEdge = { -4.9, -4.1, -3.5, -3.25, -3.2, -3.1,
24  -2.9, -2.7, -2.5, -2.2, -2.0, -1.8, -1.6, -1.4, -1.2, -1.0,
25  -0.8, -0.6, -0.4, -0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0,
26  1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.5, 2.7, 2.9,
27  3.1,3.25, 3.3, 3.5, 4.1, 4.9 }; //Indices 0-3 and 37-40 are niot currently used in hardware (don't receive energy info)
28 
29  const std::vector<float> gFexJetRoI_v1::s_EtaCenter = { -4.5, -3.8, -3.38, -3.18, -3.15, -3,
30  -2.8, -2.6, -2.35, -2.1, -1.9, -1.7, -1.5, -1.3, -1.1, -0.9,
31  -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9, 1.1,
32  1.3, 1.5, 1.7, 1.9, 2.1, 2.35, 2.6, 2.8, 3.0,
33  3.15, 3.18, 3.38, 3.8, 4.5};
34 
35 
36  //vector<float> gFexJetRoI_v1::s_maxEta = {};
37 
39  : SG::AuxElement() {
40 
41  }
42 
44 
45  setWord( word );
48  setTobEt( unpackEt() );
53 
54  }
55 
56  int gFexJetRoI_v1::menuEta() const {
57  return static_cast<int>(eta()*40)/4;
58  }
59 
60 
63  setWord )
65  setScale )
67  setSaturated )
68 
71 
74  setgFexType )
76  setTobEt )
78  setEta )
80  setPhi )
81 
82  uint8_t gFexJetRoI_v1::status() const {
83  static const Accessor< uint8_t > acc( "gFexJetStatus" );
84  return acc( *this );
85  }
87  static const Accessor< uint8_t > acc( "gFexJetStatus" );
88  acc( *this ) = value;
89  return;
90  }
91 
92 
93  // Methods to decode data from the TOB/RoI and return to the user
94 
95 
96  // Object disambiguation ()
98  auto tobID = (word() >> s_tobIDBit) & s_tobIDMask;
99  if (tobID == 0 ){
100  return gRho;
101  }
102  else if (tobID == 1 || tobID == 2) {
103  return gBlockLead;
104  }
105  else if (tobID == 3 || tobID == 4 ) {
106  return gBlockSub;
107  }
108  else if (tobID == 5 || tobID == 6) {
109  return gJet;
110  }
111  else return -999;
112  }
113 
115  return gFexType() == gBlockLead;
116  }
117 
119  return gFexType() == gBlockSub;
120  }
121 
122  bool gFexJetRoI_v1::isgJet() const {
123  return gFexType() == gJet;
124  }
125 
126  bool gFexJetRoI_v1::isgRho() const {
127  return gFexType() == gRho;
128  }
129 
130 
131  unsigned int gFexJetRoI_v1::unpackStatus() const{
132  return (word() >> s_statusBit) & s_statusMask;
133  }
134 
135  unsigned int gFexJetRoI_v1::unpackSaturated() const{
136  return (word() >> s_saturBit) & s_saturMask;
137  }
138 
139 
140  // Raw ET on TOB scale
142  // Data content = TOB
143  int16_t energy = (word() >> s_etBit) & s_etMask;
144  return energy;
145  }
146 
147  // Return an eta index in the range 0-49
148  unsigned int gFexJetRoI_v1::unpackEtaIndex() const {
149  return (word() >> s_etaBit) & s_etaMask;
150  }
151 
152  // Return an eta index in the range 0-32
153  unsigned int gFexJetRoI_v1::unpackPhiIndex() const {
154  return (word() >> s_phiBit) & s_phiMask;
155 
156  }
157 
158  // Methods that require combining results or applying scales
159 
160  float gFexJetRoI_v1::et() const {
161  return gFexTobEt()*tobEtScale();
162  }
163 
164 
165  // Floating point coordinates. Return the center of Eta.
166 
167  float gFexJetRoI_v1::eta() const {
168  if (gFexType() != gRho){
169  int new_iEtaFR = 0;
170  // Remapping in the extreme FR
171  if (iEta() < 4 || iEta() > 35){
172  if (iEta() == 2){
173  new_iEtaFR = (int(iPhi())%2 == 0) ? 0 : 1 ;
174  }
175  if (iEta() == 3){
176  new_iEtaFR = (int(iPhi())%2 == 0) ? 2 : 3 ;
177  }
178  if (iEta() == 36){
179  new_iEtaFR = (int(iPhi())%2 == 0) ? 37 : 36 ;
180  }
181  if (iEta() == 37){
182  new_iEtaFR = (int(iPhi())%2 == 0) ? 39 : 38 ;
183  }
184  return s_EtaCenter[new_iEtaFR];
185  }
186  //No remapping for central region |eta| < 3.0
187  else{
188  return s_EtaCenter[iEta()];
189  }
190  }
191  return 0;
192  }
193 
195  float gFexJetRoI_v1::etaMin() const {
196  if (gFexType() != gRho){
197  int new_iEtaFR = 0;
198  // Remapping in the extreme FR
199  if (iEta() < 4 || iEta() > 35){
200  if (iEta() == 2){
201  new_iEtaFR = (int(iPhi())%2 == 0) ? 0 : 1 ;
202  }
203  if (iEta() == 3){
204  new_iEtaFR = (int(iPhi())%2 == 0) ? 2 : 3 ;
205  }
206  if (iEta() == 36){
207  new_iEtaFR = (int(iPhi())%2 == 0) ? 37 : 36 ;
208  }
209  if (iEta() == 37){
210  new_iEtaFR = (int(iPhi())%2 == 0) ? 39 : 38 ;
211  }
212  return s_EtaEdge[new_iEtaFR];
213  }
214  //No remapping for central region |eta| < 3.0
215  else{
216  return s_EtaEdge[iEta()];
217  }
218  }
219  return 0;
220  }
221 
222  float gFexJetRoI_v1::etaMax() const {
223  if (gFexType() != gRho){
224  int new_iEtaFR = 0;
225  // Remapping in the extreme FR
226  if (iEta() < 4 || iEta() > 35){
227  if (iEta() == 2){
228  new_iEtaFR = (int(iPhi())%2 == 0) ? 0 : 1 ;
229  }
230  if (iEta() == 3){
231  new_iEtaFR = (int(iPhi())%2 == 0) ? 2 : 3 ;
232  }
233  if (iEta() == 36){
234  new_iEtaFR = (int(iPhi())%2 == 0) ? 37 : 36 ;
235  }
236  if (iEta() == 37){
237  new_iEtaFR = (int(iPhi())%2 == 0) ? 39 : 38 ;
238  }
239  return s_EtaEdge[new_iEtaFR + 1];
240  }
241  //No remapping for central region |eta| < 3.0
242  else{
243  return s_EtaEdge[iEta() + 1];
244  }
245  }
246  return 0;
247  }
248 
249 
250 
251  // Floating point coordinates using gFex convention [0, 2pi].
252  // Returns the centre phi coordinate.
253  // Note that for iEta = 0,1,2,3,36,37,38,39 - there are only 16 bins in phi (otherwise 32)
254  float gFexJetRoI_v1::phi_gFex() const {
255  float phi_out = 0;
256  if (gFexType() != gRho){
257  float phi_idx;
258  if (iEta() < 4 || iEta() > 35){
259  // take the even iphi() and divide by 2 to get a continuous range (0-15)
260  if (int(iPhi()%2) == 0 ){
261  phi_idx = iPhi()/2;
262  phi_out = (phi_idx * s_PhiWidthFR) + (s_PhiWidthFR/2);
263  }
264  // take the odd iphi() and get a continuous range (0,15)
265  else {
266  phi_idx = (iPhi()-1)/2;
267  phi_out = (phi_idx * s_PhiWidthFR) + (s_PhiWidthFR/2);}
268  }
269  else{
270  phi_out = (iPhi() * s_PhiWidth) + (s_PhiWidth/2);
271  }
272 
273  }
274  return phi_out;
275  }
276 
277 
278  // Floating point coordinates using gFex convention [0, 2pi].
279  // Returns the low edge of the phi bin.
281  float phi_out = 0;
282  if (gFexType() != gRho){
283  phi_out = iPhi() * s_PhiWidth;
284  }
285  return phi_out;
286  }
287 
288  // Floating point coordinates using gFex convention [0, 2pi].
289  // Returns the high edge of the phi bin.
291  float phi_out = 0;
292  if (gFexType() != gRho){
293  phi_out = iPhi() * s_PhiWidth + s_PhiWidth;
294  }
295  return phi_out;
296  }
297 
298  // Floating point coordinates using ATLAS convention [-pi, pi].
299  // Returns the centre phi coordinate.
300  float gFexJetRoI_v1::phi() const {
301  float phi_out = 0;
302  if (gFexType() != gRho){
303  if (phi_gFex() < pi) phi_out = phi_gFex();
304  else phi_out = (phi_gFex() - 2*pi);
305  }
306  return phi_out;
307  }
308 
309  // Floating point coordinates using ATLAS convention [-pi, pi].
310  // Returns the high edge of the phi bin.
311  float gFexJetRoI_v1::phiMax() const {
312  float phi_out = 0;
313  if (gFexType() != gRho){
314  if (phiMax_gFex() < pi) phi_out = phiMax_gFex();
315  else phi_out = (phiMax_gFex() - 2*pi);
316  }
317  return phi_out;
318  }
319 
320  // Floating point coordinates using ATLAS convention [-pi, pi].
321  // Returns the low edge of the phi bin.
322  float gFexJetRoI_v1::phiMin() const {
323  float phi_out = 0;
324  if (gFexType() != gRho){
325  if (phiMin_gFex() < pi) phi_out = phiMin_gFex();
326  else phi_out = (phiMin_gFex() - 2*pi);
327  }
328  return phi_out;
329  }
330 
331  // Returns phi index in the range used by L1Topo (0->127).
333  int phi_out = 0;
334  if (gFexType() != gRho){
335  if (( iEta() <= 3 ) || ( (iEta() >= 36) )){
336  phi_out = ( 8 * iPhi() ) + 4;
337  }
338  else if ( iEta() >3 && iEta() < 36 ){
339  phi_out = ( 4 * iPhi() ) + 2;
340  }
341  else return -999;
342  }
343  return phi_out;
344  }
345 
346 
347 } // namespace xAOD
xAOD::gFexJetRoI_v1::setScale
void setScale(int value)
Set the "raw" 32-bit words describing the object candidate.
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
xAOD::gFexJetRoI_v1::phi_gFex
float phi_gFex() const
retrieves the phi index from the 32-bit word
Definition: gFexJetRoI_v1.cxx:254
xAOD::gFexJetRoI_v1::isgJet
bool isgJet() const
Definition: gFexJetRoI_v1.cxx:122
xAOD::gFexJetRoI_v1::phiMax
float phiMax() const
Low value of phi corresponding to phi index (using ATLAS convention, phi in [-pi, pi]).
Definition: gFexJetRoI_v1.cxx:311
xAOD::gFexJetRoI_v1::s_phiMask
static const int s_phiMask
Definition: gFexJetRoI_v1.h:133
xAOD::gFexJetRoI_v1::setgFexType
void setgFexType(int type)
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
xAOD::gFexJetRoI_v1::setTobEt
void setTobEt(int16_t value)
getter for integer ET on TOB scale (3.2 GeV/count)
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::int
setRawEt setRawPhi int
Definition: TrigCaloCluster_v1.cxx:33
xAOD::gFexJetRoI_v1::eta
float eta() const
retrieves the Eta index from the 32-bit word
Definition: gFexJetRoI_v1.cxx:167
SG::Accessor< uint8_t >
AuxStoreAccessorMacros.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
xAOD::gFexJetRoI_v1::etaMax
float etaMax() const
Floating point.
Definition: gFexJetRoI_v1.cxx:222
xAOD::gFexJetRoI_v1::gBlockLead
@ gBlockLead
This object is a TOB (32 bit word)
Definition: gFexJetRoI_v1.h:37
xAOD::gFexJetRoI_v1::s_tobIDMask
static const int s_tobIDMask
Definition: gFexJetRoI_v1.h:138
xAOD::gFexJetRoI_v1::unpackEtaIndex
unsigned int unpackEtaIndex() const
setter for the above
Definition: gFexJetRoI_v1.cxx:148
xAOD::gFexJetRoI_v1::etaMin
float etaMin() const
Floating point.
Definition: gFexJetRoI_v1.cxx:195
xAOD::gFexJetRoI_v1::setWord
void setWord(uint32_t value)
Set the "raw" 32-bit words describing the object candidate.
xAOD::gFexJetRoI_v1::unpackSaturated
unsigned int unpackSaturated() const
Definition: gFexJetRoI_v1.cxx:135
athena.value
value
Definition: athena.py:124
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::gFexJetRoI_v1::word
uint32_t word() const
The "raw" 32-bit word describing the object candidate.
xAOD::gFexJetRoI_v1::gFexTobEt
int16_t gFexTobEt() const
TOB ET (decoded from TOB, stored for convenience)
xAOD::gFexJetRoI_v1::s_statusBit
static const int s_statusBit
Definition: gFexJetRoI_v1.h:127
xAOD::gFexJetRoI_v1::phiMin_gFex
float phiMin_gFex() const
Central value of phi corresponding to phi index (using gFex convention, phi in [0,...
Definition: gFexJetRoI_v1.cxx:280
xAOD::gFexJetRoI_v1::phiMax_gFex
float phiMax_gFex() const
Low value of phi corresponding to phi index (using gFex convention, phi in [0, 2pi]).
Definition: gFexJetRoI_v1.cxx:290
xAOD::int16_t
setScaleOne setStatusOne setSaturated int16_t
Definition: gFexGlobalRoI_v1.cxx:55
xAOD::gFexJetRoI_v1::tobEtScale
int tobEtScale() const
xAOD::gFexJetRoI_v1::iPhiTopo
int iPhiTopo() const
High value of phi corresponding to phi index (using ATLAS convention, phi in [-pi,...
Definition: gFexJetRoI_v1.cxx:332
Amg::setPhi
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Definition: EulerAnglesHelpers.h:102
setWord
void setWord(uint32_t)
pi
#define pi
Definition: TileMuonFitter.cxx:65
xAOD::gFexJetRoI_v1::setStatus
void setStatus(uint8_t value)
xAOD::gFexJetRoI_v1::unpackPhiIndex
unsigned int unpackPhiIndex() const
Setter for the above.
Definition: gFexJetRoI_v1.cxx:153
xAOD::gFexJetRoI_v1::s_etBit
static const int s_etBit
Definition: gFexJetRoI_v1.h:126
xAOD::gFexJetRoI_v1::gRho
@ gRho
Definition: gFexJetRoI_v1.h:36
xAOD::gFexJetRoI_v1::phi
float phi() const
High value of phi corresponding to phi index (using gFex convention, phi in [0, 2pi]).
Definition: gFexJetRoI_v1.cxx:300
xAOD::saturated
setScaleOne setStatusOne saturated
Definition: gFexGlobalRoI_v1.cxx:51
xAOD::gFexJetRoI_v1::s_statusMask
static const int s_statusMask
Definition: gFexJetRoI_v1.h:136
xAOD::gFexJetRoI_v1::gBlockSub
@ gBlockSub
This object is a TOB (32 bit word)
Definition: gFexJetRoI_v1.h:38
xAOD::gFexJetRoI_v1::iPhi
uint8_t iPhi() const
Floating point.
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
xAOD::gFexJetRoI_v1::setEta
void setEta(uint8_t value)
getter for integer eta index (0-63)
xAOD::gFexJetRoI_v1::s_EtaCenter
static const std::vector< float > s_EtaCenter
Definition: gFexJetRoI_v1.h:114
xAOD::gFexJetRoI_v1::unpackEt
int16_t unpackEt() const
setter for the above
Definition: gFexJetRoI_v1.cxx:141
xAOD::gFexJetRoI_v1::setPhi
void setPhi(uint8_t value)
Getter for integer phi index (0-32) --> check numbers for gFEX.
xAOD::gFexJetRoI_v1
Class describing properties of a LVL1 gFEX jet Trigger Object (TOB) in the xAOD format.
Definition: gFexJetRoI_v1.h:25
xAOD::gFexJetRoI_v1::gFexType
int gFexType() const
retrieves the Saturated info from the 32-bit word
xAOD::gFexJetRoI_v1::isgBlockSub
bool isgBlockSub() const
Definition: gFexJetRoI_v1.cxx:118
xAOD::gFexJetRoI_v1::s_etaBit
static const int s_etaBit
Definition: gFexJetRoI_v1.h:125
xAOD::gFexJetRoI_v1::s_etaMask
static const int s_etaMask
Definition: gFexJetRoI_v1.h:134
xAOD::gFexJetRoI_v1::iEta
uint8_t iEta() const
floating point value (GeV, TOB scale)
xAOD::gFexJetRoI_v1::et
float et() const
retrieves the Et index from the 32-bit word
Definition: gFexJetRoI_v1.cxx:160
xAOD::gFexJetRoI_v1::s_PhiWidthFR
static const float s_PhiWidthFR
Definition: gFexJetRoI_v1.h:112
xAOD::gFexJetRoI_v1::s_etMask
static const int s_etMask
Definition: gFexJetRoI_v1.h:135
xAOD::gFexJetRoI_v1::menuEta
int menuEta() const
the eta index to use for looking up thresholds in the menu
Definition: gFexJetRoI_v1.cxx:56
xAOD::gFexJetRoI_v1::s_saturMask
static const int s_saturMask
Definition: gFexJetRoI_v1.h:132
xAOD::gFexJetRoI_v1::unpackStatus
unsigned int unpackStatus() const
Definition: gFexJetRoI_v1.cxx:131
gFexJetRoI_v1.h
xAOD::gFexType
setScale gFexType
Definition: gFexJetRoI_v1.cxx:73
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
xAOD::gFexJetRoI_v1::s_EtaEdge
static const std::vector< float > s_EtaEdge
Definition: gFexJetRoI_v1.h:113
xAOD::gFexJetRoI_v1::gJet
@ gJet
This object is a TOB (32 bit word)
Definition: gFexJetRoI_v1.h:39
xAOD::gFexJetRoI_v1::phiMin
float phiMin() const
Central value of phi corresponding to phi index (using ATLAS convention, phi in [-pi,...
Definition: gFexJetRoI_v1.cxx:322
xAOD::gFexJetRoI_v1::gFexJetRoI_v1
gFexJetRoI_v1()
Default constructor.
Definition: gFexJetRoI_v1.cxx:38
xAOD::tobEtScale
tobEtScale
Definition: gFexJetRoI_v1.cxx:64
xAOD::gFexJetRoI_v1::s_phiBit
static const int s_phiBit
Definition: gFexJetRoI_v1.h:124
xAOD::gFexJetRoI_v1::initialize
void initialize(uint32_t word, int tobEtScale)
Initialise the object with its most important properties: only the word for gFEX.
Definition: gFexJetRoI_v1.cxx:43
xAOD::gFexJetRoI_v1::setSaturated
void setSaturated(uint8_t value)
merge.status
status
Definition: merge.py:17
xAOD::gFexJetRoI_v1::unpackType
int unpackType() const
Definition: gFexJetRoI_v1.cxx:97
xAOD::gFexJetRoI_v1::isgRho
bool isgRho() const
Definition: gFexJetRoI_v1.cxx:126
xAOD::gFexJetRoI_v1::isgBlockLead
bool isgBlockLead() const
Identification of object type with flags.
Definition: gFexJetRoI_v1.cxx:114
xAOD::gFexJetRoI_v1::s_saturBit
static const int s_saturBit
Constants used in decoding TOB words For TOB word format changes these can be replaced by arrays in t...
Definition: gFexJetRoI_v1.h:123
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:77
xAOD::gFexJetRoI_v1::s_tobIDBit
static const int s_tobIDBit
Definition: gFexJetRoI_v1.h:129
xAOD::gFexJetRoI_v1::s_PhiWidth
static const float s_PhiWidth
Constants used in converting to ATLAS units.
Definition: gFexJetRoI_v1.h:111