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