File indexing completed on 2024-04-06 12:20:25
0001
0002
0003
0004
0005
0006
0007
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "L1Trigger/L1TCalorimeter/interface/Stage2TowerDecompressAlgorithmFirmware.h"
0010
0011
0012 #include "L1Trigger/L1TCalorimeter/interface/CaloParamsHelper.h"
0013
0014 l1t::Stage2TowerDecompressAlgorithmFirmwareImp1::Stage2TowerDecompressAlgorithmFirmwareImp1(
0015 CaloParamsHelper const* params)
0016 : params_(params) {}
0017
0018 l1t::Stage2TowerDecompressAlgorithmFirmwareImp1::~Stage2TowerDecompressAlgorithmFirmwareImp1() {}
0019
0020 void l1t::Stage2TowerDecompressAlgorithmFirmwareImp1::processEvent(const std::vector<l1t::CaloTower>& inTowers,
0021 std::vector<l1t::CaloTower>& outTowers) {
0022 for (auto tow = inTowers.begin(); tow != inTowers.end(); ++tow) {
0023 if (!params_->doTowerEncoding()) {
0024 outTowers.push_back(*tow);
0025
0026 }
0027
0028 else {
0029 int sum = tow->hwPt();
0030 int ratio = tow->hwEtRatio();
0031 int qual = tow->hwQual();
0032
0033 int denomCoeff = int((128. / (1. + pow(2, ratio))) + 0.5);
0034 int numCoeff = 128 - denomCoeff;
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 int em = 0;
0078 int had = 0;
0079
0080 bool denomZeroFlag = ((qual & 0x1) > 0);
0081 bool eOverHFlag = ((qual & 0x2) > 0);
0082
0083 if (denomZeroFlag && !eOverHFlag)
0084 had = sum;
0085
0086 if (denomZeroFlag && eOverHFlag)
0087 em = sum;
0088
0089 if (!denomZeroFlag && !eOverHFlag) {
0090 em = (denomCoeff * sum) >> 7;
0091 had = (numCoeff * sum) >> 7;
0092 }
0093
0094 if (!denomZeroFlag && eOverHFlag) {
0095 em = (numCoeff * sum) >> 7;
0096 had = (denomCoeff * sum) >> 7;
0097 }
0098
0099 em &= params_->towerMaskE();
0100 had &= params_->towerMaskH();
0101
0102 l1t::CaloTower newTow;
0103 newTow.setHwEta(tow->hwEta());
0104 newTow.setHwPhi(tow->hwPhi());
0105 newTow.setHwEtEm(em);
0106 newTow.setHwEtHad(had);
0107
0108 newTow.setHwPt(sum);
0109 newTow.setHwEtRatio(ratio);
0110 newTow.setHwQual(qual);
0111
0112 outTowers.push_back(newTow);
0113 }
0114 }
0115 }