ATLAS Offline Software
Loading...
Searching...
No Matches
jFEXFormTOBs.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5//***************************************************************************
6// jFEXFormTOBs.cxx
7// -------------------
8// begin : 11 08 2022
9// email : sergi.rodriguez@cern.ch
10// ***************************************************************************/
11
12#include "jFEXFormTOBs.h"
14
15namespace LVL1 {
16
17// default constructor for persistency
18
19jFEXFormTOBs::jFEXFormTOBs(const std::string& type, const std::string& name, const IInterface* parent):
20 AthAlgTool(type, name, parent)
21{
22 declareInterface<IjFEXFormTOBs>(this);
23}
24
27
29{
30 return StatusCode::SUCCESS;
31}
32
33
34uint32_t jFEXFormTOBs::formTauTOB(int jFEX, int iPhi, int iEta, int EtClus, int IsoRing, bool satTau, int Resolution, int ptMinToTopo )
35{
36 uint32_t tobWord = 0;
37
38 int eta = iEta-8; // needed to substract 8 to be in the FPGA core area
39 int phi = iPhi-8; // needed to substract 8 to be in the FPGA core area
40 bool sat = satTau;
41
42 // correcting C-side. mirror symmetry
43 if(jFEX == 1 || jFEX == 2){
44 eta = 15 - iEta;
45 }
46 else if(jFEX == 0){
47 eta = 16 - iEta ;
48 }
49
50 unsigned int et = EtClus/Resolution;
51 if (et > 0x7ff) { //0x7ff is 11 bits
52 ATH_MSG_DEBUG("Et saturated: " << et );
53 et = 0x7ff;
54 }
55
56 unsigned int iso = IsoRing/Resolution;
57 if (iso > 0x7ff) iso = 0x7ff; //0x7ff is 11 bits
58
59 //create basic tobword with 32 bits
61
62 ATH_MSG_DEBUG("tobword tau with iso, et, eta and phi: " << std::bitset<32>(tobWord) );
63
64
65 unsigned int minEtThreshold = ptMinToTopo/Resolution;
66
67 if (et <= minEtThreshold) return 0;
68 else return tobWord;
69
70}
71
72int jFEXFormTOBs::Get_calibrated_SRj_ET(int Energy, int res, const std::vector<int>& calibFactors){
73 // This is for data taken before the end of 2023
74 // ET binned calibration factors (in practice all set to the same value)
75 int Et_edge[8] = {20,30,40,50,65,80,110,150};
76 int et_range = -1;
77
78 //checking upper threshold for SRjet energy
79 for(int i=0;i<8; i++){
80 if(Energy < Et_edge[i] * 1e3){
81 et_range = i;
82 break;
83 }
84 }
85
86 //the last threshold is inf therefore, if non of the other thresholds is satisfied, the calibration parameter is set to the maximum
87 if(et_range<0){
88 et_range = 8;
89 }
90
91 int calib = calibFactors[et_range];
92
93 //Converting into 200MeV scale
94 int et_200Mev = std::floor(1.0*Energy/res);
95
96 //Applying the calibration
97 int et = std::floor( (1.0*et_200Mev*calib)/(1<<7) );
98
99 return et;
100}
101
102int jFEXFormTOBs::Get_eta_calibrated_SRj_ET(int Energy, int jfex, unsigned int coreEta, int res, const std::vector<int>& calibFactors){
103 // This is for data taken starting from 2024
104 // eta binned calibration factors for improved calibration w.r.t. offline jets
105
106 //checking upper threshold for SRjet energy
107 if (jfex != 0 && jfex != 5) {
108 coreEta = std::min(coreEta,7u); // 8 core eta bins for central modules
109 } else {
110 coreEta = std::min(coreEta,24u); // 25 core eta bins for forward modules
111 }
112
113 int calib = calibFactors[coreEta];
114
115 //Converting into 200MeV scale
116 int et_200Mev = std::floor(1.0*Energy/res);
117
118 //Applying the calibration
119 int et = std::floor( (1.0*et_200Mev*calib)/(1<<7) );
120
121 return et;
122}
123
124
125uint32_t jFEXFormTOBs::formSRJetTOB(int jFEX, int iPhi, int iEta, int EtClus, bool sat, int Resolution, int ptMinToTopo, const std::pair<unsigned int, const std::vector<int>&>& calibParameters ) {
126 uint32_t tobWord = 0;
127 unsigned int eta = 0;
128 unsigned int phi = 0;
129 unsigned int jFEXSmallRJetTOBEt = 0;
130 int Res = 0; // 11 bits reserved
131 int Sat = sat;
132
133 if(jFEX == 1 || jFEX == 2) {
134
135 eta = 15 - iEta;
136 phi = iPhi - 8;
137 }
138 if(jFEX == 3 || jFEX == 4) {
139
140 eta = iEta - 8;
141 phi = iPhi - 8;
142 }
143 else if(jFEX == 5) {
144
145 eta = iEta - 8;
146 if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_A_EMIE_eta) { // ieta lower than EMIE stats -> belong to EMB
147 phi = iPhi - 8;
148 }
149 else if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_A_FCAL_start_eta) { // ieta lower than FCAL stats -> belong to EMIE
150 phi = iPhi - 4;
151 }
152 else { // rest ieta belongs to FCAL
153 phi = iPhi - 2;
154 }
155 }
156 else if(jFEX == 0) {
157
158 eta = 36 - iEta;
159 if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_C_FCAL_end_eta) { // ieta lower than FCal ends -> FCAL
160 phi = iPhi -2 ;
161 }
162 else if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_C_EMIE_end_eta) {// ieta lower than EMIE ends -> EMIE
163 phi = iPhi -4 ;
164 }
165 else {// rest of ieta -> EMB
166 phi = iPhi -8 ;
167 }
168 }
169
170 // Appliying jet calibration
171 if (calibParameters.first > m_jetEtaCalibrationBeginTimestamp || m_isMC) {
172 jFEXSmallRJetTOBEt = Get_eta_calibrated_SRj_ET(EtClus, jFEX, eta, Resolution, calibParameters.second);
173 } else {
174 jFEXSmallRJetTOBEt = Get_calibrated_SRj_ET(EtClus, Resolution, calibParameters.second);
175 }
176
177 if(jFEXSmallRJetTOBEt > 0x7ff) {
178 jFEXSmallRJetTOBEt = 0x7ff;
179 }
180 //create basic tobword with 32 bits
181 tobWord = tobWord + (Res << FEXAlgoSpaceDefs::jJ_resBit) + (jFEXSmallRJetTOBEt << FEXAlgoSpaceDefs::jJ_etBit) + (eta << FEXAlgoSpaceDefs::jJ_etaBit) + (phi << FEXAlgoSpaceDefs::jJ_phiBit) + (Sat);
182 ATH_MSG_DEBUG("tobword smallRJet with res, et, eta and phi: " << std::bitset<32>(tobWord) );
183
184 // retrieving the threshold for the TOB Et
185 unsigned int minEtThreshold = ptMinToTopo/Resolution;
186
187 if (jFEXSmallRJetTOBEt <= minEtThreshold) return 0;
188 else return tobWord;
189}
190
191
192
193uint32_t jFEXFormTOBs::formLRJetTOB(int jFEX, int iPhi, int iEta, int EtClus, bool sat, int Resolution, int ptMinToTopo ) {
194
195 uint32_t tobWord = 0;
196 unsigned int eta = 0;
197 unsigned int phi = 0;
198 unsigned int jFEXLargeRJetTOBEt = 0;
199 int Res = 0; // 9 bits reserved
200 int Sat = sat;
201
202 if(jFEX == 1 || jFEX == 2) {
203
204 eta = 15 - iEta;
205 phi = iPhi - 8;
206 }
207 if(jFEX == 3 || jFEX == 4) {
208
209 eta = iEta - 8;
210 phi = iPhi - 8;
211 }
212 else if(jFEX == 5) {
213 eta = iEta -8;
214
215 if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_A_EMIE_eta) { // iEta lower than EMIE stats -> belong to EMB
216 phi = iPhi-8;
217 }
218 else if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_A_FCAL_start_eta) { // iEta lower than FCAL stats -> belong to EMIE
219 phi = iPhi -4;
220 }
221 else { // rest iEta belongs to FCAL
222 phi = iPhi -2;
223 }
224 }
225 else if(jFEX == 0) {
226 eta = 36 - iEta;
227
228 if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_C_FCAL_end_eta) { // iEta lower than FCal ends -> FCAL
229 phi = iPhi -2 ;
230 }
231 else if(iEta < FEXAlgoSpaceDefs::jFEX_algoSpace_C_EMIE_end_eta) {// iEta lower than EMIE ends -> EMIE
232 phi = iPhi -4 ;
233 }
234 else {// rest of iEta -> EMB
235 phi = iPhi -8 ;
236 }
237 }
238
239 jFEXLargeRJetTOBEt = EtClus/Resolution;
240 if (jFEXLargeRJetTOBEt > 0x1fff) {
241 jFEXLargeRJetTOBEt = 0x1fff; //0x1fff is 13 bits
242 }
243 //create basic tobword with 32 bits
244 tobWord = tobWord + (Res << FEXAlgoSpaceDefs::jLJ_resBit) + (jFEXLargeRJetTOBEt << FEXAlgoSpaceDefs::jLJ_etBit) + (eta << FEXAlgoSpaceDefs::jLJ_etaBit) + (phi << FEXAlgoSpaceDefs::jLJ_phiBit) + (Sat);
245 ATH_MSG_DEBUG("tobword largeRJet with res, et, eta, phi: " << std::bitset<32>(tobWord) );
246
247
248 unsigned int minEtThreshold = ptMinToTopo/Resolution;
249
250 if (jFEXLargeRJetTOBEt <= minEtThreshold) return 0;
251 else return tobWord;
252}
253
254
255uint32_t jFEXFormTOBs::formSumETTOB(std::tuple<int,bool> & ETlow, std::tuple<int,bool> & EThigh, int Resolution )
256{
257 uint32_t tobWord = 0;
258
259 bool satlow = std::get<1>(ETlow);
260 bool sathigh = std::get<1>(EThigh);
261
262 unsigned int etlow = std::get<0>(ETlow)/Resolution;
263 if (etlow > 0x7fff) { //0x7fff is 15 bits
264 ATH_MSG_DEBUG("sumEtlow saturated: " << etlow );
265 etlow = 0x7fff;
266 }
267
268 unsigned int ethigh = std::get<0>(EThigh)/Resolution;
269 if (ethigh > 0x7fff) { //0x7fff is 15 bits
270 ATH_MSG_DEBUG("sumEthigh saturated: " << ethigh );
271 ethigh = 0x7fff;
272 }
273
274 //create basic tobword with 32 bits
276 ATH_MSG_DEBUG("tobword SumET with Sathigh, EThigh, ETlow and Satlow : " << std::bitset<32>(tobWord) );
277
278 return tobWord;
279
280}
281
282
283uint32_t jFEXFormTOBs::formMetTOB(int METX, int METY, bool sat, int Resolution ) {
284 uint32_t tobWord = 0;
285
286 bool Sat = sat;
287 unsigned int res = 0;
288
289 int metX = std::floor(1.0*METX/Resolution);
290 int metY = std::floor(1.0*METY/Resolution);
291
292 //0x7fff is 15 bits (decimal value 32767), however as MET is a signed value (can be negative) only 14 bits are allowed (16383) the MSB is the sign
293 if (std::abs(metX) > 0x3fff) {
294 ATH_MSG_DEBUG("sumEtlow saturated: " << metX );
295 if (metX < 0) {
296 metX = 0x4000; //most negative value for 15b signed two's complement
297 } else {
298 metX = 0x3fff;
299 }
300 }
301
302
303 if (std::abs(metY) > 0x3fff) { //0x7fff is 15 bits (decimal value 32767), however as MET is a signed value (can be negative) only 14 bits are allowed (16383)
304 ATH_MSG_DEBUG("sumEthigh saturated: " << metY );
305 if (metY < 0) {
306 metY = 0x4000; //most negative value for 15b signed two's complement
307 } else {
308 metY = 0x3fff;
309 }
310 }
311
312 //create basic tobword with 32 bits
313 //note that the bit-wise and with the 15bit mask (0x7fff) inherently accounts for the conversion of negative values from 32b signed (int) to 15b signed
314 tobWord = tobWord + (res << FEXAlgoSpaceDefs::jXE_ResBit) + ((metY & 0x7fff) << FEXAlgoSpaceDefs::jXE_Ey_Bit) + ((metX & 0x7fff) << FEXAlgoSpaceDefs::jXE_Ex_Bit) + (Sat << FEXAlgoSpaceDefs::jXE_SatBit) ;
315 ATH_MSG_DEBUG("tobword MET with Res, MET_Y, MET_X, Sat: " << std::bitset<32>(tobWord) );
316
317 return tobWord;
318
319}
320
321
322
323} // end of namespace bracket
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_DEBUG(x)
std::vector< double > Energy
std::pair< std::vector< unsigned int >, bool > res
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
static constexpr int jTE_Et_upperBit
static constexpr int jTE_Sat_upperBit
static constexpr int jFEX_algoSpace_C_FCAL_end_eta
static constexpr int jJ_phiBit
static constexpr int jLJ_phiBit
static constexpr int jFEX_algoSpace_A_FCAL_start_eta
static constexpr int jTE_Et_lowerBit
static constexpr int jFEX_algoSpace_A_EMIE_eta
static constexpr int jLJ_etaBit
static constexpr int jTau_phiBit
static constexpr int jLJ_etBit
static constexpr int jXE_ResBit
static constexpr int jJ_etBit
static constexpr int jXE_SatBit
static constexpr int jLJ_resBit
static constexpr int jJ_resBit
static constexpr int jTE_Sat_lowerBit
static constexpr int jJ_etaBit
static constexpr int jTau_etaBit
static constexpr int jXE_Ey_Bit
static constexpr int jTau_etBit
static constexpr int jTau_isoBit
static constexpr int jXE_Ex_Bit
static constexpr int jFEX_algoSpace_C_EMIE_end_eta
virtual StatusCode initialize() override
standard Athena-Algorithm method
jFEXFormTOBs(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Gaudi::Property< bool > m_isMC
Internal data.
int Get_calibrated_SRj_ET(int, int, const std::vector< int > &)
int Get_eta_calibrated_SRj_ET(int, int, unsigned int, int, const std::vector< int > &)
virtual uint32_t formSumETTOB(std::tuple< int, bool > &, std::tuple< int, bool > &, int) override
virtual uint32_t formTauTOB(int, int, int, int, int, bool, int, int) override
virtual uint32_t formMetTOB(int, int, bool, int) override
virtual uint32_t formSRJetTOB(int, int, int, int, bool, int, int, const std::pair< unsigned int, const std::vector< int > & > &) override
virtual uint32_t formLRJetTOB(int, int, int, int, bool, int, int) override
virtual ~jFEXFormTOBs()
Destructor.
UnsignedIntegerProperty m_jetEtaCalibrationBeginTimestamp
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Extra patterns decribing particle interation process.