File indexing completed on 2023-03-17 11:12:14
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 SingleCombInCond 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 int 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 gtTowerCount:
0151 type = l1t::EtSum::EtSumType::kTowerCount;
0152 MissingEnergy = false;
0153 break;
0154 case gtMinBiasHFP0:
0155 type = l1t::EtSum::EtSumType::kMinBiasHFP0;
0156 MissingEnergy = false;
0157 break;
0158 case gtMinBiasHFM0:
0159 type = l1t::EtSum::EtSumType::kMinBiasHFM0;
0160 MissingEnergy = false;
0161 break;
0162 case gtMinBiasHFP1:
0163 type = l1t::EtSum::EtSumType::kMinBiasHFP1;
0164 MissingEnergy = false;
0165 break;
0166 case gtMinBiasHFM1:
0167 type = l1t::EtSum::EtSumType::kMinBiasHFM1;
0168 MissingEnergy = false;
0169 break;
0170 case gtAsymmetryEt:
0171 type = l1t::EtSum::EtSumType::kAsymEt;
0172 MissingEnergy = false;
0173 break;
0174 case gtAsymmetryHt:
0175 type = l1t::EtSum::EtSumType::kAsymHt;
0176 MissingEnergy = false;
0177 break;
0178 case gtAsymmetryEtHF:
0179 type = l1t::EtSum::EtSumType::kAsymEtHF;
0180 MissingEnergy = false;
0181 break;
0182 case gtAsymmetryHtHF:
0183 type = l1t::EtSum::EtSumType::kAsymHtHF;
0184 MissingEnergy = false;
0185 break;
0186 case gtCentrality0:
0187 centbit = 0;
0188 type = l1t::EtSum::EtSumType::kCentrality;
0189 MissingEnergy = false;
0190 break;
0191 case gtCentrality1:
0192 centbit = 1;
0193 type = l1t::EtSum::EtSumType::kCentrality;
0194 MissingEnergy = false;
0195 break;
0196 case gtCentrality2:
0197 centbit = 2;
0198 type = l1t::EtSum::EtSumType::kCentrality;
0199 MissingEnergy = false;
0200 break;
0201 case gtCentrality3:
0202 centbit = 3;
0203 type = l1t::EtSum::EtSumType::kCentrality;
0204 MissingEnergy = false;
0205 break;
0206 case gtCentrality4:
0207 centbit = 4;
0208 type = l1t::EtSum::EtSumType::kCentrality;
0209 MissingEnergy = false;
0210 break;
0211 case gtCentrality5:
0212 centbit = 5;
0213 type = l1t::EtSum::EtSumType::kCentrality;
0214 MissingEnergy = false;
0215 break;
0216 case gtCentrality6:
0217 centbit = 6;
0218 type = l1t::EtSum::EtSumType::kCentrality;
0219 MissingEnergy = false;
0220 break;
0221 case gtCentrality7:
0222 centbit = 7;
0223 type = l1t::EtSum::EtSumType::kCentrality;
0224 MissingEnergy = false;
0225 break;
0226 default:
0227 edm::LogError("L1TGlobal")
0228 << "\n Error: "
0229 << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
0230 << (m_gtEnergySumTemplate->objectType())[0] << std::endl;
0231 type = l1t::EtSum::EtSumType::kTotalEt;
0232 break;
0233 }
0234
0235
0236 unsigned int candEt = 0;
0237 unsigned int candPhi = 0;
0238 bool candOverflow = false;
0239 for (int iEtSum = 0; iEtSum < numberObjects; ++iEtSum) {
0240 l1t::EtSum cand = *(candVec->at(useBx, iEtSum));
0241 if (cand.getType() != type)
0242 continue;
0243 candEt = cand.hwPt();
0244 candPhi = cand.hwPhi();
0245 }
0246
0247 const EnergySumTemplate::ObjectParameter objPar = (*(m_gtEnergySumTemplate->objectParameter()))[iCondition];
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259 bool condGEqVal = m_gtEnergySumTemplate->condGEq();
0260
0261 if (type == l1t::EtSum::EtSumType::kCentrality) {
0262 bool myres = checkBit(candEt, centbit);
0263
0264 if (!myres) {
0265 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed Centrality bit" << std::endl;
0266 return false;
0267 }
0268 } else {
0269
0270 if (!checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal)) {
0271 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
0272 return false;
0273 }
0274
0275 if (!condGEqVal && candOverflow)
0276 return false;
0277
0278
0279
0280 if (MissingEnergy) {
0281
0282 if (!checkRangePhi(
0283 candPhi, objPar.phiWindow1Lower, objPar.phiWindow1Upper, objPar.phiWindow2Lower, objPar.phiWindow2Upper)) {
0284 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
0285 return false;
0286 }
0287 }
0288 }
0289
0290
0291 int indexObj = 0;
0292
0293 objectsInComb.push_back(indexObj);
0294 (combinationsInCond()).push_back(objectsInComb);
0295
0296
0297
0298
0299 condResult = true;
0300 return condResult;
0301 }
0302
0303 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
0304 m_gtEnergySumTemplate->print(myCout);
0305 ConditionEvaluation::print(myCout);
0306 }