File indexing completed on 2024-04-06 12:20:35
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 SingleCombInCond 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 int 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
0120 if (numberObjectsZdc < 1) {
0121 return false;
0122 }
0123
0124 const EnergySumZdcTemplate::ObjectParameter objPar = (*(m_gtEnergySumZdcTemplate->objectParameter()))[iCondition];
0125 l1t::EtSum::EtSumType type;
0126 switch ((m_gtEnergySumZdcTemplate->objectType())[0]) {
0127 case gtZDCP:
0128 type = l1t::EtSum::EtSumType::kZDCP;
0129 break;
0130 case gtZDCM:
0131 type = l1t::EtSum::EtSumType::kZDCM;
0132 break;
0133 default:
0134 edm::LogError("L1TGlobal")
0135 << "\n Error: "
0136 << "Unmatched object type from template to EtSumZdcType, (m_gtEnergySumZdcTemplate->objectType())[0] = "
0137 << (m_gtEnergySumZdcTemplate->objectType())[0] << std::endl;
0138 type = l1t::EtSum::EtSumType::kZDCP;
0139 break;
0140 }
0141
0142
0143
0144 bool condGEqVal = m_gtEnergySumZdcTemplate->condGEq();
0145
0146 l1t::EtSum candZdcPlus;
0147 l1t::EtSum candZdcMinus;
0148 unsigned int candZDCPEsum = 0;
0149 unsigned int candZDCMEsum = 0;
0150 bool myres = false;
0151
0152 for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) {
0153 l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum));
0154
0155 if (candZdc.getType() != type)
0156 continue;
0157
0158 if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) {
0159 candZdcPlus = *(candVecZdc->at(useBx, iEtSum));
0160 candZDCPEsum = candZdcPlus.hwPt();
0161 myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal);
0162 } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) {
0163 candZdcMinus = *(candVecZdc->at(useBx, iEtSum));
0164 candZDCMEsum = candZdcMinus.hwPt();
0165 myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal);
0166 } else {
0167 LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl;
0168 return false;
0169 }
0170
0171 LogDebug("L1TGlobal") << "CANDZdc: " << candZdc.hwPt() << ", " << useBx << ", " << candZdc.getType();
0172
0173 LogDebug("L1TGlobal")
0174 << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate"
0175 << "\n objPar.etLowThreshold = " << objPar.etLowThreshold
0176 << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum
0177 << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres
0178 << std::endl;
0179 }
0180
0181 if (not myres)
0182 return false;
0183
0184
0185 int indexObj = 0;
0186
0187 objectsInComb.push_back(indexObj);
0188 (combinationsInCond()).push_back(objectsInComb);
0189
0190
0191
0192 condResult = true;
0193 return condResult;
0194 }
0195
0196 void l1t::EnergySumZdcCondition::print(std::ostream& myCout) const {
0197 m_gtEnergySumZdcTemplate->print(myCout);
0198 ConditionEvaluation::print(myCout);
0199 }