1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
/**
* Author: Sridhara Dasu
* Created: 04 July 2007
* $Id: L1RCTParameters.cc,v 1.24 2010/05/24 11:54:35 efron Exp $
**/
#include <iostream>
#include <fstream>
#include <cmath>
#include "CondFormats/L1TObjects/interface/L1RCTParameters.h"
#include <iomanip>
#include "FWCore/MessageLogger/interface/MessageLogger.h"
using namespace std;
L1RCTParameters::L1RCTParameters(double eGammaLSB,
double jetMETLSB,
double eMinForFGCut,
double eMaxForFGCut,
double hOeCut,
double eMinForHoECut,
double eMaxForHoECut,
double hMinForHoECut,
double eActivityCut,
double hActivityCut,
unsigned eicIsolationThreshold,
unsigned jscQuietThresholdBarrel,
unsigned jscQuietThresholdEndcap,
bool noiseVetoHB,
bool noiseVetoHEplus,
bool noiseVetoHEminus,
bool useCorrections,
const std::vector<double>& eGammaECalScaleFactors,
const std::vector<double>& eGammaHCalScaleFactors,
const std::vector<double>& jetMETECalScaleFactors,
const std::vector<double>& jetMETHCalScaleFactors,
const std::vector<double>& ecal_calib,
const std::vector<double>& hcal_calib,
const std::vector<double>& hcal_high_calib,
const std::vector<double>& cross_terms,
const std::vector<double>& lowHoverE_smear,
const std::vector<double>& highHoverE_smear)
: eGammaLSB_(eGammaLSB),
jetMETLSB_(jetMETLSB),
eMinForFGCut_(eMinForFGCut),
eMaxForFGCut_(eMaxForFGCut),
hOeCut_(hOeCut),
eMinForHoECut_(eMinForHoECut),
eMaxForHoECut_(eMaxForHoECut),
hMinForHoECut_(hMinForHoECut),
eActivityCut_(eActivityCut),
hActivityCut_(hActivityCut),
eicIsolationThreshold_(eicIsolationThreshold),
jscQuietThresholdBarrel_(jscQuietThresholdBarrel),
jscQuietThresholdEndcap_(jscQuietThresholdEndcap),
noiseVetoHB_(noiseVetoHB),
noiseVetoHEplus_(noiseVetoHEplus),
noiseVetoHEminus_(noiseVetoHEminus),
useCorrections_(useCorrections),
eGammaECalScaleFactors_(eGammaECalScaleFactors),
eGammaHCalScaleFactors_(eGammaHCalScaleFactors),
jetMETECalScaleFactors_(jetMETECalScaleFactors),
jetMETHCalScaleFactors_(jetMETHCalScaleFactors),
HoverE_smear_low_(lowHoverE_smear),
HoverE_smear_high_(highHoverE_smear) {
ecal_calib_.resize(28);
hcal_calib_.resize(28);
hcal_high_calib_.resize(28);
cross_terms_.resize(28);
for (unsigned i = 0; i < ecal_calib.size(); ++i)
ecal_calib_[i / 3].push_back(ecal_calib[i]);
for (unsigned i = 0; i < hcal_calib.size(); ++i)
hcal_calib_[i / 3].push_back(hcal_calib[i]);
for (unsigned i = 0; i < hcal_high_calib.size(); ++i)
hcal_high_calib_[i / 3].push_back(hcal_high_calib[i]);
for (unsigned i = 0; i < cross_terms.size(); ++i)
cross_terms_[i / 6].push_back(cross_terms[i]);
}
// maps rct iphi, ieta of tower to crate
unsigned short L1RCTParameters::calcCrate(unsigned short rct_iphi, short ieta) const {
unsigned short crate = rct_iphi / 8;
if (abs(ieta) > 28)
crate = rct_iphi / 2;
if (ieta > 0) {
crate = crate + 9;
}
return crate;
}
//map digi rct iphi, ieta to card
unsigned short L1RCTParameters::calcCard(unsigned short rct_iphi, unsigned short absIeta) const {
unsigned short card = 999;
// Note absIeta counts from 1-32 (not 0-31)
if (absIeta <= 24) {
card = ((absIeta - 1) / 8) * 2 + (rct_iphi % 8) / 4;
}
// 25 <= absIeta <= 28 (card 6)
else if ((absIeta >= 25) && (absIeta <= 28)) {
card = 6;
} else {
}
return card;
}
//map digi rct iphi, ieta to tower
unsigned short L1RCTParameters::calcTower(unsigned short rct_iphi, unsigned short absIeta) const {
unsigned short tower = 999;
unsigned short iphi = rct_iphi;
unsigned short regionPhi = (iphi % 8) / 4;
// Note absIeta counts from 1-32 (not 0-31)
if (absIeta <= 24) {
// assume iphi between 0 and 71; makes towers from 0-31, mod. 7Nov07
tower = ((absIeta - 1) % 8) * 4 + (iphi % 4); // REMOVED +1
}
// 25 <= absIeta <= 28 (card 6)
else if ((absIeta >= 25) && (absIeta <= 28)) {
if (regionPhi == 0) {
// towers from 0-31, modified 7Nov07 Jessica Leonard
tower = (absIeta - 25) * 4 + (iphi % 4); // REMOVED +1
} else {
tower = 28 + iphi % 4 + (25 - absIeta) * 4; // mod. 7Nov07 JLL
}
}
// absIeta >= 29 (HF regions)
else if ((absIeta >= 29) && (absIeta <= 32)) {
// SPECIAL DEFINITION OF REGIONPHI FOR HF SINCE HF IPHI IS 0-17
// Sept. 19 J. Leonard
regionPhi = iphi % 2;
// HF MAPPING, just regions now, don't need to worry about towers
// just calling it "tower" for convenience
tower = (regionPhi) * 4 + absIeta - 29;
}
return tower;
}
// iCrate 0-17, iCard 0-6, NEW iTower 0-31
short L1RCTParameters::calcIEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const {
unsigned short absIEta = calcIAbsEta(iCrate, iCard, iTower);
short iEta;
if (iCrate < 9)
iEta = -absIEta;
else
iEta = absIEta;
return iEta;
}
// iCrate 0-17, iCard 0-6, NEW iTower 0-31
unsigned short L1RCTParameters::calcIPhi(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const {
short iPhi;
if (iCard < 6)
iPhi = (iCrate % 9) * 8 + (iCard % 2) * 4 + (iTower % 4); // rm -1 7Nov07
else if (iCard == 6) {
// region 0
if (iTower < 16) // 17->16
iPhi = (iCrate % 9) * 8 + (iTower % 4); // rm -1
// region 1
else
iPhi = (iCrate % 9) * 8 + ((iTower - 16) % 4) + 4; // 17 -> 16
}
// HF regions
else
iPhi = (iCrate % 9) * 2 + iTower / 4;
return iPhi;
}
// iCrate 0-17, iCard 0-6, NEW iTower 0-31
unsigned short L1RCTParameters::calcIAbsEta(unsigned short iCrate, unsigned short iCard, unsigned short iTower) const {
unsigned short absIEta;
if (iCard < 6)
absIEta = (iCard / 2) * 8 + (iTower / 4) + 1; // rm -1 JLL 7Nov07
else if (iCard == 6) {
// card 6, region 0
if (iTower < 16) // 17->16
absIEta = 25 + iTower / 4; // rm -1
// card 6, region 1
else
absIEta = 28 - ((iTower - 16) / 4); // 17->16
}
// HF regions
else
absIEta = 29 + iTower % 4;
return absIEta;
}
float L1RCTParameters::JetMETTPGSum(const float& ecal, const float& hcal, const unsigned& iAbsEta) const {
// We never deal with HF in this function (see note below)
if (iAbsEta < 1 || iAbsEta > 28)
throw cms::Exception("L1RCTParameters invalid function call") << "Eta out of range in MET TPGSum: " << iAbsEta;
float ecal_c = ecal * jetMETECalScaleFactors_.at(iAbsEta - 1);
float hcal_c = hcal * jetMETHCalScaleFactors_.at(iAbsEta - 1);
// scale factors will either be length 28 for legacy, or 28*(# et bins + 1) where the first set is an average over the et bins
// The first set provides a legacy fallthrough option
// Currently, # et bins is 9
if (jetMETECalScaleFactors_.size() == 28 * 10) {
int et_bin = ((int)floor(ecal) / 5);
// lowest bin (1) is 0-10GeV
if (et_bin < 1)
et_bin = 1;
// highest bin (9) is 45GeV and up
if (et_bin > 9)
et_bin = 9;
ecal_c = ecal * jetMETECalScaleFactors_.at(et_bin * 28 + iAbsEta - 1);
}
// We may be interested in HF jets, in which case, there are four more scale factors
// for the 4 HF regions. HOWEVER, we will never expect to see them accessed from
// this function. HF scaling is done in L1Trigger/RegionalCaloTrigger/src/L1RCTLookupTables
if (jetMETHCalScaleFactors_.size() == 32 * 10) {
int ht_bin = ((int)floor(hcal) / 5);
// lowest bin (1) is 0-10GeV
if (ht_bin < 1)
ht_bin = 1;
// highest bin (9) is 45GeV and up
if (ht_bin > 9)
ht_bin = 9;
hcal_c = hcal * jetMETHCalScaleFactors_.at(ht_bin * 32 + iAbsEta - 1);
}
float result = ecal_c + hcal_c;
// defunct section (polynomial-parameterized corrections)
if (useCorrections_) {
if (jetMETHCalScaleFactors_.at(iAbsEta - 1) != 0)
hcal_c = hcal;
if (jetMETECalScaleFactors_.at(iAbsEta - 1) != 0)
ecal_c = ecal * eGammaECalScaleFactors_.at(iAbsEta - 1); // Use eGamma Corrections
result = correctedTPGSum(ecal_c, hcal_c, iAbsEta - 1);
}
return result;
}
float L1RCTParameters::EGammaTPGSum(const float& ecal, const float& hcal, const unsigned& iAbsEta) const {
// We never deal with HF in this function (EG objects don't use hcal at all, really)
if (iAbsEta < 1 || iAbsEta > 28)
throw cms::Exception("L1RCTParameters invalid function call") << "Eta out of range in MET TPGSum: " << iAbsEta;
float ecal_c = ecal * eGammaECalScaleFactors_.at(iAbsEta - 1);
float hcal_c = hcal * eGammaHCalScaleFactors_.at(iAbsEta - 1);
// scale factors will either be length 28 for legacy, or 28*(# et bins + 1) where the first set of 28 is an average over the et bins
// The first set of 28 provides a legacy fallthrough option
// Currently, # et bins is 9
if (eGammaECalScaleFactors_.size() == 28 * 10) {
int et_bin = ((int)floor(ecal) / 5);
// lowest bin (1) is 0-10GeV
if (et_bin < 1)
et_bin = 1;
// highest bin (9) is 45GeV and up
if (et_bin > 9)
et_bin = 9;
ecal_c = ecal * eGammaECalScaleFactors_.at(et_bin * 28 + iAbsEta - 1);
}
if (eGammaHCalScaleFactors_.size() == 28 * 10) {
int ht_bin = ((int)floor(hcal) / 5);
// lowest bin (1) is 0-10GeV
if (ht_bin < 1)
ht_bin = 1;
// highest bin (9) is 45GeV and up
if (ht_bin > 9)
ht_bin = 9;
hcal_c = hcal * eGammaHCalScaleFactors_.at(ht_bin * 28 + iAbsEta - 1);
}
float result = ecal_c + hcal_c;
// defunct section (polynomial-parameterized corrections)
if (useCorrections_) {
if (eGammaHCalScaleFactors_.at(iAbsEta - 1) != 0)
hcal_c = hcal;
result = correctedTPGSum(ecal_c, hcal_c, iAbsEta - 1);
}
return result;
}
// index = iAbsEta - 1... make sure you call the function like so: "correctedTPGSum(ecal,hcal, iAbsEta - 1)"
float L1RCTParameters::correctedTPGSum(const float& ecal, const float& hcal, const unsigned& index) const {
if (index >= 28 && ecal > 120 && hcal > 120)
return (ecal + hcal); // return plain sum if outside of calibration range or index is too high
// let's make sure we're asking for items that are there.
if (ecal_calib_.at(index).size() != 3 || hcal_calib_.at(index).size() != 3 ||
hcal_high_calib_.at(index).size() != 3 || cross_terms_.at(index).size() != 6 ||
HoverE_smear_high_.size() <= index || HoverE_smear_low_.size() <= index)
return (ecal + hcal);
double e = ecal, h = hcal;
double ec = 0.0, hc = 0.0, c = 0.0;
ec = (ecal_calib_.at(index).at(0) * std::pow(e, 3.) + ecal_calib_.at(index).at(1) * std::pow(e, 2.) +
ecal_calib_.at(index).at(2) * e);
if (e + h < 23) {
hc = (hcal_calib_.at(index).at(0) * std::pow(h, 3.) + hcal_calib_.at(index).at(1) * std::pow(h, 2.) +
hcal_calib_.at(index).at(2) * h);
c = (cross_terms_.at(index).at(0) * std::pow(e, 2.) * h + cross_terms_.at(index).at(1) * std::pow(h, 2.) * e +
cross_terms_.at(index).at(2) * e * h + cross_terms_.at(index).at(3) * std::pow(e, 3.) * h +
cross_terms_.at(index).at(4) * std::pow(h, 3.) * e +
cross_terms_.at(index).at(5) * std::pow(h, 2.) * std::pow(e, 2.));
} else {
hc = (hcal_high_calib_.at(index).at(0) * std::pow(h, 3.) + hcal_high_calib_.at(index).at(1) * std::pow(h, 2.) +
hcal_high_calib_.at(index).at(2) * h);
}
if (h / (e + h) >= 0.05) {
ec *= HoverE_smear_high_.at(index);
hc *= HoverE_smear_high_.at(index);
c *= HoverE_smear_high_.at(index);
} else {
ec *= HoverE_smear_low_.at(index);
}
return ec + hc + c;
}
void L1RCTParameters::print(std::ostream& s) const {
s << "\nPrinting record L1RCTParametersRcd" << endl;
s << "\n\"Parameter description\" \n \"Parameter name\" \"Value\" " << endl;
s << "\ne/gamma least significant bit energy transmitted from receiver cards to EIC cards. \n "
<< "eGammaLSB = " << eGammaLSB_ << endl;
s << "\nLSB of region Et scale from RCT to GCT (GeV) \n "
<< "jetMETLSB = " << jetMETLSB_ << endl;
s << "\nminimum ECAL Et for which fine-grain veto is applied (GeV) \n "
<< " eMinForFGCut = " << eMinForFGCut_ << endl;
s << "\nmaximum ECAL Et for which fine-grain veto is applied (GeV) \n "
<< "eMaxForFGCut = " << eMaxForFGCut_ << endl;
s << "\nmaximum value of (HCAL Et / ECAL Et) \n "
<< "hOeCut = " << hOeCut_ << endl;
s << "\nminimum ECAL Et for which H/E veto is applied (GeV) \n "
<< "eMinForHoECut = " << eMinForHoECut_ << endl;
s << "\nmaximum ECAL Et for which H/E veto is applied (GeV) \n "
<< "eMaxForHoECut = " << eMaxForHoECut_ << endl;
s << "\nminimum HCAL Et for which H/E veto is applied (GeV) \n "
<< "hMinForHoECut = " << hMinForHoECut_ << endl;
s << "\nECAL Et threshold above which tau activity bit is set (GeV) \n "
<< "eActivityCut = " << eActivityCut_ << endl;
s << "\nHCAL Et threshold above which tau activity bit is set (GeV) \n "
<< "hActivityCut = " << hActivityCut_ << endl;
s << "\nNeighboring trigger tower energy minimum threshold that marks candidate as non-isolated. (LSB bits) \n "
<< "eicIsolationThreshold = " << eicIsolationThreshold_ << endl;
s << "\nIf jetMet energy in RCT Barrel Region is below this value, a quiet bit is set. (LSB bits)\n "
<< "jscQuietThreshBarrel = " << jscQuietThresholdBarrel_ << endl;
s << "\nIf jetMet energy in RCT Endcap Region is below this value, a quiet bit is set. (LSB bits) \n "
<< "jscQuietThreshEndcap = " << jscQuietThresholdEndcap_ << endl;
s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT "
"Barrel \n "
<< "noiseVetoHB = " << noiseVetoHB_ << endl;
s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT "
"Encap+ \n "
<< "noiseVetoHEplus = " << noiseVetoHEplus_ << endl;
s << "\nWhen set to TRUE, HCAL energy is ignored if no ECAL energy is present in corresponding trigger tower for RCT "
"Endcap- \n "
<< "noiseVetoHEminus = " << noiseVetoHEminus_ << endl;
auto printScalefactors = [&s](const std::vector<double>& sf) {
if (sf.size() == 10 * 28) {
s << "et bin ieta ScaleFactor" << endl;
for (unsigned i = 0; i < sf.size(); i++)
s << setw(6) << i / 28 << " " << setw(4) << i % 28 + 1 << " " << sf.at(i) << endl;
} else if (sf.size() == 10 * 32) // jet HCAL (HF regions are 29-32)
{
s << "et bin ieta ScaleFactor" << endl;
for (unsigned i = 0; i < sf.size(); i++)
s << setw(6) << i / 32 << " " << setw(4) << i % 32 + 1 << " " << sf.at(i) << endl;
} else {
s << "ieta ScaleFactor" << endl;
for (unsigned i = 0; i < sf.size(); i++)
s << setw(4) << i + 1 << " " << sf.at(i) << endl;
}
};
s << "\n\neta-dependent multiplicative factors for ECAL Et before summation \n "
<< "eGammaECal Scale Factors " << endl;
printScalefactors(eGammaECalScaleFactors_);
s << "\n\neta-dependent multiplicative factors for HCAL Et before summation \n "
<< "eGammaHCal Scale Factors " << endl;
printScalefactors(eGammaHCalScaleFactors_);
s << "\n\neta-dependent multiplicative factors for ECAL Et before summation \n "
<< "jetMETECal Scale Factors " << endl;
printScalefactors(jetMETECalScaleFactors_);
s << "\n\neta-dependent multiplicative factors for HCAL Et before summation \n"
<< "jetMETHCal Scale Factors " << endl;
printScalefactors(jetMETHCalScaleFactors_);
if (useCorrections_) {
s << "\n\nUSING calibration variables " << endl;
s << "\n\nH over E smear low Correction Factors " << endl;
s << "ieta Correction Factor" << endl;
for (int i = 0; i < 28; i++)
s << setw(4) << i + 1 << " " << HoverE_smear_low_.at(i) << endl;
s << "\n\nH over E smear high Correction Factors " << endl;
s << "ieta Correction Factor" << endl;
for (int i = 0; i < 28; i++)
s << setw(4) << i + 1 << " " << HoverE_smear_high_.at(i) << endl;
s << "\n\necal calibrations " << endl;
s << "ieta CorrFactor1 CorrFactor2 CorrFactor3" << endl;
int end = ecal_calib_[0].size();
for (int i = 0; i < 28; i++) {
s << setw(4) << i;
for (int j = 0; j < end; j++)
s << setw(11) << setprecision(8) << ecal_calib_[i][j];
s << endl;
}
s << "\n\nhcal calibrations " << endl;
s << "ieta CorrFactor1 CorrFactor2 CorrFactor3" << endl;
end = hcal_calib_[0].size();
for (int i = 0; i < 28; i++) {
s << setw(4) << i;
for (int j = 0; j < end; j++)
s << setw(11) << setprecision(8) << hcal_calib_[i][j];
s << endl;
}
s << "\n\nhcal_high calibrations " << endl;
s << "ieta CorrFactor1 CorrFactor2 CorrFactor3" << endl;
end = hcal_high_calib_[0].size();
for (int i = 0; i < 28; i++) {
s << setw(4) << i;
for (int j = 0; j < end; j++)
s << setw(11) << setprecision(8) << hcal_high_calib_[i][j];
s << endl;
}
end = cross_terms_[0].size();
s << "\n\ncross terms calibrations " << endl;
s << "ieta CorrFactor1 CorrFactor2 CorrFactor3 CorrFactor4 CorrFactor5 CorrFactor6" << endl;
for (int i = 0; i < 28; i++) {
s << setw(4) << i;
for (int j = 0; j < end; j++)
s << setw(11) << setprecision(8) << cross_terms_[i][j];
s << endl;
}
} else
s << "\n\nNOT USING calibration variables " << endl;
s << "\n\n" << endl;
}
|