|
2 | 2 | #include <fstream>
|
3 | 3 | #include <cmath>
|
4 | 4 | #include <string>
|
| 5 | +#include <algorithm> |
5 | 6 | #include "CalibCalorimetry/HcalTPGAlgos/interface/HcaluLUTTPGCoder.h"
|
6 | 7 | #include "CalibFormats/HcalObjects/interface/HcalCoderDb.h"
|
7 | 8 | #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
|
|
29 | 30 | #include "CalibCalorimetry/HcalTPGAlgos/interface/LutXml.h"
|
30 | 31 |
|
31 | 32 | const float HcaluLUTTPGCoder::lsb_ = 1. / 16;
|
32 |
| -const float HcaluLUTTPGCoder::zdc_lsb_ = 50.; |
33 | 33 |
|
34 | 34 | const int HcaluLUTTPGCoder::QIE8_LUT_BITMASK;
|
35 | 35 | const int HcaluLUTTPGCoder::QIE10_LUT_BITMASK;
|
@@ -275,10 +275,10 @@ void HcaluLUTTPGCoder::update(const char* filename, bool appendMSB) {
|
275 | 275 | } else
|
276 | 276 | inputLUT_[lutId][adc] = lutFromFile[i][adc];
|
277 | 277 | } // for adc
|
278 |
| - } // for depth |
279 |
| - } // for iphi |
280 |
| - } // for ieta |
281 |
| - } // for nCol |
| 278 | + } // for depth |
| 279 | + } // for iphi |
| 280 | + } // for ieta |
| 281 | + } // for nCol |
282 | 282 | }
|
283 | 283 |
|
284 | 284 | void HcaluLUTTPGCoder::updateXML(const char* filename) {
|
@@ -595,10 +595,21 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
|
595 | 595 | const HcalLutMetadatum* meta = metadata->getValues(cell);
|
596 | 596 |
|
597 | 597 | auto tpParam = conditions.getHcalTPChannelParameter(cell, false);
|
598 |
| - int weight = tpParam->getauxi1(); |
| 598 | + const int weight = tpParam->getauxi1(); |
| 599 | + int factorGeVPerCount = tpParam->getauxi2(); |
| 600 | + if (factorGeVPerCount == 0) { |
| 601 | + edm::LogWarning("HcaluLUTTPGCoder") |
| 602 | + << "WARNING: ZDC trigger spacing factor, taken from auxi2 field of HCALTPChannelParameters for the cell " |
| 603 | + "with (zside, section, channel) = (" |
| 604 | + << cell.zside() << " , " << cell.section() << " , " << cell.channel() |
| 605 | + << ") is set to the " |
| 606 | + "default value of 0, which is an incompatible value for a spacing factor. Setting the value to 50 and " |
| 607 | + "continuing."; |
| 608 | + factorGeVPerCount = 50; |
| 609 | + } |
599 | 610 |
|
600 |
| - int lutId = getLUTId(cell); |
601 |
| - int lutId_ootpu = lutId + sizeZDC_; |
| 611 | + const int lutId = getLUTId(cell); |
| 612 | + const int lutId_ootpu = lutId + sizeZDC_; |
602 | 613 | Lut& lut = inputLUT_[lutId];
|
603 | 614 | Lut& lut_ootpu = inputLUT_[lutId_ootpu];
|
604 | 615 | float ped = 0;
|
@@ -656,9 +667,9 @@ void HcaluLUTTPGCoder::update(const HcalDbService& conditions) {
|
656 | 667 | lut[adc] = 0;
|
657 | 668 | lut_ootpu[adc] = 0;
|
658 | 669 | } else {
|
659 |
| - lut[adc] = std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib / zdc_lsb_)), MASK); |
660 |
| - lut_ootpu[adc] = |
661 |
| - std::min(std::max(0, int((adc2fC(adc) - ped) * gain * rcalib * weight / (zdc_lsb_ * 256))), MASK); |
| 670 | + auto lut_term = (adc2fC(adc) - ped) * gain * rcalib / factorGeVPerCount; |
| 671 | + lut[adc] = std::clamp(int(lut_term), 0, MASK); |
| 672 | + lut_ootpu[adc] = std::clamp(int(lut_term * weight / 256), 0, MASK); |
662 | 673 | }
|
663 | 674 | }
|
664 | 675 | }
|
|
0 commit comments