File indexing completed on 2025-01-14 23:17:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "L1Trigger/L1TGlobal/interface/EnergySumCondition.h"
0015
0016
0017 #include <iostream>
0018 #include <iomanip>
0019
0020 #include <string>
0021 #include <vector>
0022 #include <algorithm>
0023
0024
0025
0026 #include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h"
0027 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0028 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0029 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0030
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0033
0034
0035
0036 l1t::EnergySumCondition::EnergySumCondition() : ConditionEvaluation() {
0037
0038 }
0039
0040
0041 l1t::EnergySumCondition::EnergySumCondition(const GlobalCondition* eSumTemplate, const GlobalBoard* ptrGTB)
0042 : ConditionEvaluation(),
0043 m_gtEnergySumTemplate(static_cast<const EnergySumTemplate*>(eSumTemplate)),
0044 m_uGtB(ptrGTB)
0045
0046 {
0047
0048
0049
0050 m_condMaxNumberObjects = 1;
0051 }
0052
0053
0054 void l1t::EnergySumCondition::copy(const l1t::EnergySumCondition& cp) {
0055 m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
0056 m_uGtB = cp.getuGtB();
0057
0058 m_condMaxNumberObjects = cp.condMaxNumberObjects();
0059 m_condLastResult = cp.condLastResult();
0060 m_combinationsInCond = cp.getCombinationsInCond();
0061
0062 m_verbosity = cp.m_verbosity;
0063 }
0064
0065 l1t::EnergySumCondition::EnergySumCondition(const l1t::EnergySumCondition& cp) : ConditionEvaluation() { copy(cp); }
0066
0067
0068 l1t::EnergySumCondition::~EnergySumCondition() {
0069
0070 }
0071
0072
0073 l1t::EnergySumCondition& l1t::EnergySumCondition::operator=(const l1t::EnergySumCondition& cp) {
0074 copy(cp);
0075 return *this;
0076 }
0077
0078
0079 void l1t::EnergySumCondition::setGtEnergySumTemplate(const EnergySumTemplate* eSumTempl) {
0080 m_gtEnergySumTemplate = eSumTempl;
0081 }
0082
0083
0084 void l1t::EnergySumCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
0085
0086
0087 const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const {
0088
0089
0090 int iCondition = 0;
0091
0092
0093
0094 bool condResult = false;
0095
0096
0097
0098 SingleCombWithBxInCond objectsInComb;
0099
0100
0101 (combinationsInCond()).clear();
0102
0103
0104 objectsInComb.clear();
0105
0106 const BXVector<const l1t::EtSum*>* candVec = m_uGtB->getCandL1EtSum();
0107
0108
0109 L1TObjBxIndexType const useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx();
0110
0111
0112 if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
0113 return false;
0114 }
0115
0116
0117 int numberObjects = candVec->size(useBx);
0118 if (numberObjects < 1) {
0119 return false;
0120 }
0121
0122 l1t::EtSum::EtSumType type;
0123 bool MissingEnergy = false;
0124 int centbit = 0;
0125 switch ((m_gtEnergySumTemplate->objectType())[0]) {
0126 case gtETM:
0127 type = l1t::EtSum::EtSumType::kMissingEt;
0128 MissingEnergy = true;
0129 break;
0130 case gtETT:
0131 type = l1t::EtSum::EtSumType::kTotalEt;
0132 MissingEnergy = false;
0133 break;
0134 case gtETTem:
0135 type = l1t::EtSum::EtSumType::kTotalEtEm;
0136 MissingEnergy = false;
0137 break;
0138 case gtHTM:
0139 type = l1t::EtSum::EtSumType::kMissingHt;
0140 MissingEnergy = true;
0141 break;
0142 case gtHTT:
0143 type = l1t::EtSum::EtSumType::kTotalHt;
0144 MissingEnergy = false;
0145 break;
0146 case gtETMHF:
0147 type = l1t::EtSum::EtSumType::kMissingEtHF;
0148 MissingEnergy = true;
0149 break;
0150 case gtHTMHF:
0151 type = l1t::EtSum::EtSumType::kMissingHtHF;
0152 MissingEnergy = true;
0153 break;
0154 case gtTowerCount:
0155 type = l1t::EtSum::EtSumType::kTowerCount;
0156 MissingEnergy = false;
0157 break;
0158 case gtMinBiasHFP0:
0159 type = l1t::EtSum::EtSumType::kMinBiasHFP0;
0160 MissingEnergy = false;
0161 break;
0162 case gtMinBiasHFM0:
0163 type = l1t::EtSum::EtSumType::kMinBiasHFM0;
0164 MissingEnergy = false;
0165 break;
0166 case gtMinBiasHFP1:
0167 type = l1t::EtSum::EtSumType::kMinBiasHFP1;
0168 MissingEnergy = false;
0169 break;
0170 case gtMinBiasHFM1:
0171 type = l1t::EtSum::EtSumType::kMinBiasHFM1;
0172 MissingEnergy = false;
0173 break;
0174 case gtAsymmetryEt:
0175 type = l1t::EtSum::EtSumType::kAsymEt;
0176 MissingEnergy = false;
0177 break;
0178 case gtAsymmetryHt:
0179 type = l1t::EtSum::EtSumType::kAsymHt;
0180 MissingEnergy = false;
0181 break;
0182 case gtAsymmetryEtHF:
0183 type = l1t::EtSum::EtSumType::kAsymEtHF;
0184 MissingEnergy = false;
0185 break;
0186 case gtAsymmetryHtHF:
0187 type = l1t::EtSum::EtSumType::kAsymHtHF;
0188 MissingEnergy = false;
0189 break;
0190 case gtCentrality0:
0191 centbit = 0;
0192 type = l1t::EtSum::EtSumType::kCentrality;
0193 MissingEnergy = false;
0194 break;
0195 case gtCentrality1:
0196 centbit = 1;
0197 type = l1t::EtSum::EtSumType::kCentrality;
0198 MissingEnergy = false;
0199 break;
0200 case gtCentrality2:
0201 centbit = 2;
0202 type = l1t::EtSum::EtSumType::kCentrality;
0203 MissingEnergy = false;
0204 break;
0205 case gtCentrality3:
0206 centbit = 3;
0207 type = l1t::EtSum::EtSumType::kCentrality;
0208 MissingEnergy = false;
0209 break;
0210 case gtCentrality4:
0211 centbit = 4;
0212 type = l1t::EtSum::EtSumType::kCentrality;
0213 MissingEnergy = false;
0214 break;
0215 case gtCentrality5:
0216 centbit = 5;
0217 type = l1t::EtSum::EtSumType::kCentrality;
0218 MissingEnergy = false;
0219 break;
0220 case gtCentrality6:
0221 centbit = 6;
0222 type = l1t::EtSum::EtSumType::kCentrality;
0223 MissingEnergy = false;
0224 break;
0225 case gtCentrality7:
0226 centbit = 7;
0227 type = l1t::EtSum::EtSumType::kCentrality;
0228 MissingEnergy = false;
0229 break;
0230 case gtZDCP:
0231 type = l1t::EtSum::EtSumType::kZDCP;
0232 MissingEnergy = false;
0233 break;
0234 case gtZDCM:
0235 type = l1t::EtSum::EtSumType::kZDCM;
0236 MissingEnergy = false;
0237 break;
0238 default:
0239 edm::LogError("L1TGlobal")
0240 << "\n Error: "
0241 << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
0242 << (m_gtEnergySumTemplate->objectType())[0] << std::endl;
0243 type = l1t::EtSum::EtSumType::kTotalEt;
0244 break;
0245 }
0246
0247
0248 unsigned int candEt = 0;
0249 unsigned int candPhi = 0;
0250
0251 bool candOverflow = false;
0252 for (int iEtSum = 0; iEtSum < numberObjects; ++iEtSum) {
0253 auto const& cand = *(candVec->at(useBx, iEtSum));
0254 if (cand.getType() != type)
0255 continue;
0256 candEt = cand.hwPt();
0257 candPhi = cand.hwPhi();
0258 }
0259
0260 const EnergySumTemplate::ObjectParameter objPar = (*(m_gtEnergySumTemplate->objectParameter()))[iCondition];
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272 bool condGEqVal = m_gtEnergySumTemplate->condGEq();
0273
0274 if (type == l1t::EtSum::EtSumType::kCentrality) {
0275 bool myres = checkBit(candEt, centbit);
0276
0277 if (!myres) {
0278 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed Centrality bit" << std::endl;
0279 return false;
0280 }
0281 } else if (type == l1t::EtSum::EtSumType::kZDCP || type == l1t::EtSum::EtSumType::kZDCM) {
0282 return false;
0283 } else {
0284
0285 if (!checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal)) {
0286 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
0287 return false;
0288 }
0289
0290 if (!condGEqVal && candOverflow)
0291 return false;
0292
0293
0294
0295 if (MissingEnergy) {
0296
0297 if (!checkRangePhi(
0298 candPhi, objPar.phiWindow1Lower, objPar.phiWindow1Upper, objPar.phiWindow2Lower, objPar.phiWindow2Upper)) {
0299 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
0300 return false;
0301 }
0302 }
0303 }
0304
0305
0306 objectsInComb.emplace_back(useBx, 0);
0307 (combinationsInCond()).push_back(objectsInComb);
0308
0309
0310
0311
0312 condResult = true;
0313 return condResult;
0314 }
0315
0316 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
0317 m_gtEnergySumTemplate->print(myCout);
0318 ConditionEvaluation::print(myCout);
0319 }