File indexing completed on 2025-01-14 23:17:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "L1Trigger/L1TGlobal/interface/EnergySumZdcCondition.h"
0017
0018
0019 #include <iostream>
0020 #include <iomanip>
0021
0022 #include <string>
0023 #include <vector>
0024 #include <algorithm>
0025
0026
0027
0028 #include "L1Trigger/L1TGlobal/interface/EnergySumZdcTemplate.h"
0029 #include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
0030 #include "DataFormats/L1Trigger/interface/L1Candidate.h"
0031 #include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
0032
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0035
0036
0037
0038 l1t::EnergySumZdcCondition::EnergySumZdcCondition() : ConditionEvaluation() {
0039
0040 }
0041
0042
0043 l1t::EnergySumZdcCondition::EnergySumZdcCondition(const GlobalCondition* eSumTemplate, const GlobalBoard* ptrGTB)
0044 : ConditionEvaluation(),
0045 m_gtEnergySumZdcTemplate(static_cast<const EnergySumZdcTemplate*>(eSumTemplate)),
0046 m_uGtB(ptrGTB)
0047
0048 {
0049
0050
0051
0052 m_condMaxNumberObjects = 1;
0053 }
0054
0055
0056 void l1t::EnergySumZdcCondition::copy(const l1t::EnergySumZdcCondition& cp) {
0057 m_gtEnergySumZdcTemplate = cp.gtEnergySumZdcTemplate();
0058 m_uGtB = cp.getuGtB();
0059
0060 m_condMaxNumberObjects = cp.condMaxNumberObjects();
0061 m_condLastResult = cp.condLastResult();
0062 m_combinationsInCond = cp.getCombinationsInCond();
0063
0064 m_verbosity = cp.m_verbosity;
0065 }
0066
0067 l1t::EnergySumZdcCondition::EnergySumZdcCondition(const l1t::EnergySumZdcCondition& cp) : ConditionEvaluation() {
0068 copy(cp);
0069 }
0070
0071
0072 l1t::EnergySumZdcCondition::~EnergySumZdcCondition() = default;
0073
0074
0075 l1t::EnergySumZdcCondition& l1t::EnergySumZdcCondition::operator=(const l1t::EnergySumZdcCondition& cp) {
0076 copy(cp);
0077 return *this;
0078 }
0079
0080
0081 void l1t::EnergySumZdcCondition::setGtEnergySumZdcTemplate(const EnergySumZdcTemplate* eSumTempl) {
0082 m_gtEnergySumZdcTemplate = eSumTempl;
0083 }
0084
0085
0086 void l1t::EnergySumZdcCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
0087
0088
0089 const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const {
0090
0091 int iCondition = 0;
0092
0093
0094
0095 bool condResult = false;
0096
0097
0098
0099 SingleCombWithBxInCond objectsInComb;
0100
0101
0102 (combinationsInCond()).clear();
0103
0104
0105 objectsInComb.clear();
0106
0107 const BXVector<const l1t::EtSum*>* candVecZdc = m_uGtB->getCandL1EtSumZdc();
0108
0109
0110 L1TObjBxIndexType const useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx();
0111
0112
0113 if ((useBx < candVecZdc->getFirstBX()) || (useBx > candVecZdc->getLastBX())) {
0114 return false;
0115 }
0116
0117
0118 int numberObjectsZdc = candVecZdc->size(useBx);
0119 if (numberObjectsZdc < 1) {
0120 return false;
0121 }
0122
0123 const EnergySumZdcTemplate::ObjectParameter objPar = (*(m_gtEnergySumZdcTemplate->objectParameter()))[iCondition];
0124 l1t::EtSum::EtSumType type;
0125 switch ((m_gtEnergySumZdcTemplate->objectType())[0]) {
0126 case gtZDCP:
0127 type = l1t::EtSum::EtSumType::kZDCP;
0128 break;
0129 case gtZDCM:
0130 type = l1t::EtSum::EtSumType::kZDCM;
0131 break;
0132 default:
0133 edm::LogError("L1TGlobal")
0134 << "\n Error: "
0135 << "Unmatched object type from template to EtSumZdcType, (m_gtEnergySumZdcTemplate->objectType())[0] = "
0136 << (m_gtEnergySumZdcTemplate->objectType())[0] << std::endl;
0137 type = l1t::EtSum::EtSumType::kZDCP;
0138 break;
0139 }
0140
0141
0142
0143 bool condGEqVal = m_gtEnergySumZdcTemplate->condGEq();
0144
0145 l1t::EtSum candZdcPlus;
0146 l1t::EtSum candZdcMinus;
0147 unsigned int candZDCPEsum = 0;
0148 unsigned int candZDCMEsum = 0;
0149 bool myres = false;
0150
0151 for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) {
0152 auto const& candZdc = *(candVecZdc->at(useBx, iEtSum));
0153
0154 if (candZdc.getType() != type)
0155 continue;
0156
0157 if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) {
0158 candZdcPlus = *(candVecZdc->at(useBx, iEtSum));
0159 candZDCPEsum = candZdcPlus.hwPt();
0160 myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal);
0161 } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) {
0162 candZdcMinus = *(candVecZdc->at(useBx, iEtSum));
0163 candZDCMEsum = candZdcMinus.hwPt();
0164 myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal);
0165 } else {
0166 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl;
0167 return false;
0168 }
0169
0170 LogDebug("L1TGlobal") << "CANDZdc: " << candZdc.hwPt() << ", " << useBx << ", " << candZdc.getType();
0171
0172 LogDebug("L1TGlobal")
0173 << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate"
0174 << "\n objPar.etLowThreshold = " << objPar.etLowThreshold
0175 << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum
0176 << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres
0177 << std::endl;
0178 }
0179
0180 if (not myres)
0181 return false;
0182
0183
0184 objectsInComb.emplace_back(useBx, 0);
0185 (combinationsInCond()).push_back(objectsInComb);
0186
0187
0188
0189 condResult = true;
0190 return condResult;
0191 }
0192
0193 void l1t::EnergySumZdcCondition::print(std::ostream& myCout) const {
0194 m_gtEnergySumZdcTemplate->print(myCout);
0195 ConditionEvaluation::print(myCout);
0196 }