File indexing completed on 2024-04-06 12:20:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1Trigger/GlobalTrigger/interface/L1GtEnergySumCondition.h"
0017
0018
0019 #include <iomanip>
0020 #include <iostream>
0021
0022 #include <algorithm>
0023 #include <string>
0024 #include <vector>
0025
0026
0027
0028 #include "CondFormats/L1TObjects/interface/L1GtEnergySumTemplate.h"
0029 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h"
0030
0031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0032
0033 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0034
0035 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h"
0036 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0037
0038
0039
0040 L1GtEnergySumCondition::L1GtEnergySumCondition() : L1GtConditionEvaluation() {
0041
0042 }
0043
0044
0045 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtCondition *eSumTemplate, const L1GlobalTriggerPSB *ptrPSB)
0046 : L1GtConditionEvaluation(),
0047 m_gtEnergySumTemplate(static_cast<const L1GtEnergySumTemplate *>(eSumTemplate)),
0048 m_gtPSB(ptrPSB)
0049
0050 {
0051
0052
0053
0054 m_condMaxNumberObjects = 1;
0055 }
0056
0057
0058 void L1GtEnergySumCondition::copy(const L1GtEnergySumCondition &cp) {
0059 m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
0060 m_gtPSB = cp.gtPSB();
0061
0062 m_condMaxNumberObjects = cp.condMaxNumberObjects();
0063 m_condLastResult = cp.condLastResult();
0064 m_combinationsInCond = cp.getCombinationsInCond();
0065
0066 m_verbosity = cp.m_verbosity;
0067 }
0068
0069 L1GtEnergySumCondition::L1GtEnergySumCondition(const L1GtEnergySumCondition &cp) : L1GtConditionEvaluation() {
0070 copy(cp);
0071 }
0072
0073
0074 L1GtEnergySumCondition::~L1GtEnergySumCondition() {
0075
0076 }
0077
0078
0079 L1GtEnergySumCondition &L1GtEnergySumCondition::operator=(const L1GtEnergySumCondition &cp) {
0080 copy(cp);
0081 return *this;
0082 }
0083
0084
0085 void L1GtEnergySumCondition::setGtEnergySumTemplate(const L1GtEnergySumTemplate *eSumTempl) {
0086 m_gtEnergySumTemplate = eSumTempl;
0087 }
0088
0089
0090 void L1GtEnergySumCondition::setGtPSB(const L1GlobalTriggerPSB *ptrPSB) { m_gtPSB = ptrPSB; }
0091
0092
0093 const bool L1GtEnergySumCondition::evaluateCondition() const {
0094
0095
0096 int iCondition = 0;
0097
0098
0099
0100 bool condResult = false;
0101
0102
0103
0104 SingleCombInCond objectsInComb;
0105
0106
0107 (combinationsInCond()).clear();
0108
0109
0110 objectsInComb.clear();
0111
0112
0113
0114 unsigned int candEt = 0;
0115 unsigned int candPhi = 0;
0116 bool candOverflow = false;
0117
0118 switch ((m_gtEnergySumTemplate->objectType())[0]) {
0119 case ETT: {
0120 const L1GctEtTotal *cand1 = m_gtPSB->getCandL1ETT();
0121
0122 if (cand1 == nullptr) {
0123 return false;
0124 }
0125
0126 candEt = cand1->et();
0127 candOverflow = cand1->overFlow();
0128
0129 break;
0130 }
0131 case ETM: {
0132 const L1GctEtMiss *cand2 = m_gtPSB->getCandL1ETM();
0133
0134 if (cand2 == nullptr) {
0135 return false;
0136 }
0137
0138 candEt = cand2->et();
0139 candPhi = cand2->phi();
0140 candOverflow = cand2->overFlow();
0141
0142 break;
0143 }
0144 case HTT: {
0145 const L1GctEtHad *cand3 = m_gtPSB->getCandL1HTT();
0146
0147 if (cand3 == nullptr) {
0148 return false;
0149 }
0150
0151 candEt = cand3->et();
0152 candOverflow = cand3->overFlow();
0153
0154 break;
0155 }
0156 case HTM: {
0157 const L1GctHtMiss *cand4 = m_gtPSB->getCandL1HTM();
0158
0159 if (cand4 == nullptr) {
0160 return false;
0161 }
0162
0163 candEt = cand4->et();
0164 candPhi = cand4->phi();
0165 candOverflow = cand4->overFlow();
0166
0167 break;
0168 }
0169 default: {
0170
0171 return false;
0172
0173 break;
0174 }
0175 }
0176
0177 const L1GtEnergySumTemplate::ObjectParameter objPar = (*(m_gtEnergySumTemplate->objectParameter()))[iCondition];
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189 bool condGEqVal = m_gtEnergySumTemplate->condGEq();
0190
0191 if (condGEqVal) {
0192 if (!candOverflow) {
0193 if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
0194 return false;
0195 }
0196 }
0197 } else {
0198 if (candOverflow) {
0199 return false;
0200 } else {
0201 if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
0202 return false;
0203 }
0204 }
0205 }
0206
0207
0208
0209
0210 if (!candOverflow) {
0211 if ((m_gtEnergySumTemplate->objectType())[0] == ETM) {
0212
0213 if (candPhi < 64) {
0214 if (!checkBit(objPar.phiRange0Word, candPhi)) {
0215 return false;
0216 }
0217 } else {
0218 if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
0219 return false;
0220 }
0221 }
0222
0223 } else if ((m_gtEnergySumTemplate->objectType())[0] == HTM) {
0224
0225 if (candPhi < 64) {
0226 if (!checkBit(objPar.phiRange0Word, candPhi)) {
0227 return false;
0228 }
0229 } else {
0230 if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
0231 return false;
0232 }
0233 }
0234 }
0235 }
0236
0237
0238
0239 int indexObj = 0;
0240
0241 objectsInComb.push_back(indexObj);
0242 (combinationsInCond()).push_back(objectsInComb);
0243
0244
0245
0246
0247 condResult = true;
0248 return condResult;
0249 }
0250
0251 void L1GtEnergySumCondition::print(std::ostream &myCout) const {
0252 m_gtEnergySumTemplate->print(myCout);
0253 L1GtConditionEvaluation::print(myCout);
0254 }