File indexing completed on 2024-04-06 12:19:53
0001 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetLeafCard.h"
0002
0003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0004
0005 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctJetFinderBase.h"
0006 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctTdrJetFinder.h"
0007 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctHardwareJetFinder.h"
0008 #include "L1Trigger/GlobalCaloTrigger/interface/L1GctNullJetFinder.h"
0009
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011
0012
0013 const int L1GctJetLeafCard::MAX_JET_FINDERS = 3;
0014
0015 L1GctJetLeafCard::L1GctJetLeafCard(int id, int iphi, jetFinderType jfType)
0016 : L1GctProcessor(),
0017 m_id(id),
0018 m_whichJetFinder(jfType),
0019 phiPosition(iphi),
0020 m_exSum(0),
0021 m_eySum(0),
0022 m_hxSum(0),
0023 m_hySum(0),
0024 m_etSum(0),
0025 m_htSum(0),
0026 m_hfSums(),
0027 m_exSumPipe(),
0028 m_eySumPipe(),
0029 m_hxSumPipe(),
0030 m_hySumPipe(),
0031 m_etSumPipe(),
0032 m_htSumPipe(),
0033 m_hfSumsPipe(),
0034 m_ctorInputOk(true) {
0035
0036 if (m_id < 0 || m_id > 5) {
0037 m_ctorInputOk = false;
0038 if (m_verbose) {
0039 edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
0040 << " has been incorrectly constructed!\n"
0041 << "ID number should be between the range of 0 to 5\n";
0042 }
0043 }
0044
0045
0046 if (phiPosition != m_id % 3) {
0047 m_ctorInputOk = false;
0048 if (m_verbose) {
0049 edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
0050 << " has been incorrectly constructed!\n"
0051 << "Argument iphi is " << phiPosition << ", should be " << (m_id % 3)
0052 << " for this ID value \n";
0053 }
0054 }
0055
0056 switch (m_whichJetFinder) {
0057 case tdrJetFinder:
0058 m_jetFinderA = new L1GctTdrJetFinder(3 * id);
0059 m_jetFinderB = new L1GctTdrJetFinder(3 * id + 1);
0060 m_jetFinderC = new L1GctTdrJetFinder(3 * id + 2);
0061 break;
0062
0063 case hardwareJetFinder:
0064 m_jetFinderA = new L1GctHardwareJetFinder(3 * id);
0065 m_jetFinderB = new L1GctHardwareJetFinder(3 * id + 1);
0066 m_jetFinderC = new L1GctHardwareJetFinder(3 * id + 2);
0067 break;
0068
0069 case nullJetFinder:
0070 m_jetFinderA = new L1GctNullJetFinder(3 * id);
0071 m_jetFinderB = new L1GctNullJetFinder(3 * id + 1);
0072 m_jetFinderC = new L1GctNullJetFinder(3 * id + 2);
0073 break;
0074
0075 default:
0076
0077 m_ctorInputOk = false;
0078 if (m_verbose) {
0079 edm::LogWarning("L1GctSetupError")
0080 << "L1GctJetLeafCard::L1GctJetLeafCard() : Jet Leaf Card ID " << m_id
0081 << " has been incorrectly constructed!\n"
0082 << "Unrecognised jetFinder type " << m_whichJetFinder << ", cannot setup jetFinders\n";
0083 }
0084 }
0085
0086 if (!m_ctorInputOk && m_verbose) {
0087 edm::LogError("L1GctSetupError") << "Jet Leaf Card ID " << m_id << " has been incorrectly constructed";
0088 }
0089 }
0090
0091 L1GctJetLeafCard::~L1GctJetLeafCard() {
0092 delete m_jetFinderA;
0093 delete m_jetFinderB;
0094 delete m_jetFinderC;
0095 }
0096
0097
0098 void L1GctJetLeafCard::setNeighbourLeafCards(const std::vector<L1GctJetLeafCard*>& neighbours) {
0099 std::vector<L1GctJetFinderBase*> jfNeighbours(2);
0100
0101 if (neighbours.size() == 2) {
0102 jfNeighbours.at(0) = neighbours.at(0)->getJetFinderC();
0103 jfNeighbours.at(1) = m_jetFinderB;
0104 m_jetFinderA->setNeighbourJetFinders(jfNeighbours);
0105
0106 jfNeighbours.at(0) = m_jetFinderA;
0107 jfNeighbours.at(1) = m_jetFinderC;
0108 m_jetFinderB->setNeighbourJetFinders(jfNeighbours);
0109
0110 jfNeighbours.at(0) = m_jetFinderB;
0111 jfNeighbours.at(1) = neighbours.at(1)->getJetFinderA();
0112 m_jetFinderC->setNeighbourJetFinders(jfNeighbours);
0113
0114 } else {
0115 m_ctorInputOk = false;
0116 if (m_verbose) {
0117 edm::LogWarning("L1GctSetupError") << "L1GctJetLeafCard::setNeighbourLeafCards() : In Jet Leaf Card ID " << m_id
0118 << " size of input vector should be 2, but is in fact " << neighbours.size()
0119 << "\n";
0120 }
0121 }
0122 }
0123
0124 std::ostream& operator<<(std::ostream& s, const L1GctJetLeafCard& card) {
0125 using std::endl;
0126
0127 s << "===L1GctJetLeafCard===" << endl;
0128 s << "ID = " << card.m_id << endl;
0129 s << "i_phi = " << card.phiPosition << endl;
0130 ;
0131 s << "Ex " << card.m_exSum << endl;
0132 s << "Ey " << card.m_eySum << endl;
0133 s << "Hx " << card.m_hxSum << endl;
0134 s << "Hy " << card.m_hySum << endl;
0135 s << "Et " << card.m_etSum << endl;
0136 s << "Ht " << card.m_htSum << endl;
0137 s << "JetFinder A : " << endl << (*card.m_jetFinderA);
0138 s << "JetFinder B : " << endl << (*card.m_jetFinderB);
0139 s << "JetFinder C : " << endl << (*card.m_jetFinderC);
0140 s << endl;
0141
0142 return s;
0143 }
0144
0145
0146 void L1GctJetLeafCard::reset() {
0147 L1GctProcessor::reset();
0148 m_jetFinderA->reset();
0149 m_jetFinderB->reset();
0150 m_jetFinderC->reset();
0151 }
0152
0153
0154 void L1GctJetLeafCard::setBxRange(const int firstBx, const int numberOfBx) {
0155 L1GctProcessor::setBxRange(firstBx, numberOfBx);
0156 m_jetFinderA->setBxRange(firstBx, numberOfBx);
0157 m_jetFinderB->setBxRange(firstBx, numberOfBx);
0158 m_jetFinderC->setBxRange(firstBx, numberOfBx);
0159 }
0160
0161 void L1GctJetLeafCard::setNextBx(const int bx) {
0162 L1GctProcessor::setNextBx(bx);
0163 m_jetFinderA->setNextBx(bx);
0164 m_jetFinderB->setNextBx(bx);
0165 m_jetFinderC->setNextBx(bx);
0166 }
0167
0168 void L1GctJetLeafCard::resetProcessor() {
0169 m_exSum.reset();
0170 m_eySum.reset();
0171 m_hxSum.reset();
0172 m_hySum.reset();
0173 m_etSum.reset();
0174 m_htSum.reset();
0175 m_hfSums.reset();
0176 }
0177
0178 void L1GctJetLeafCard::resetPipelines() {
0179 m_exSumPipe.reset(numOfBx());
0180 m_eySumPipe.reset(numOfBx());
0181 m_hxSumPipe.reset(numOfBx());
0182 m_hySumPipe.reset(numOfBx());
0183 m_etSumPipe.reset(numOfBx());
0184 m_htSumPipe.reset(numOfBx());
0185 m_hfSumsPipe.reset(numOfBx());
0186 }
0187
0188 void L1GctJetLeafCard::fetchInput() {
0189 m_jetFinderA->fetchInput();
0190 m_jetFinderB->fetchInput();
0191 m_jetFinderC->fetchInput();
0192 }
0193
0194 void L1GctJetLeafCard::process() {
0195
0196 if (setupOk()) {
0197
0198 m_jetFinderA->process();
0199 m_jetFinderB->process();
0200 m_jetFinderC->process();
0201
0202
0203
0204 m_etSum = m_jetFinderA->getEtSum() + m_jetFinderB->getEtSum() + m_jetFinderC->getEtSum();
0205 if (m_etSum.overFlow())
0206 m_etSum.setValue(etTotalMaxValue);
0207 m_exSum = ((etComponentType)m_jetFinderA->getExSum()) + ((etComponentType)m_jetFinderB->getExSum()) +
0208 ((etComponentType)m_jetFinderC->getExSum());
0209 m_eySum = ((etComponentType)m_jetFinderA->getEySum()) + ((etComponentType)m_jetFinderB->getEySum()) +
0210 ((etComponentType)m_jetFinderC->getEySum());
0211
0212
0213 m_htSum = m_jetFinderA->getHtSum() + m_jetFinderB->getHtSum() + m_jetFinderC->getHtSum();
0214 if (m_htSum.overFlow())
0215 m_htSum.setValue(htTotalMaxValue);
0216 m_hxSum = ((htComponentType)m_jetFinderA->getHxSum()) + ((htComponentType)m_jetFinderB->getHxSum()) +
0217 ((htComponentType)m_jetFinderC->getHxSum());
0218 m_hySum = ((htComponentType)m_jetFinderA->getHySum()) + ((htComponentType)m_jetFinderB->getHySum()) +
0219 ((htComponentType)m_jetFinderC->getHySum());
0220
0221
0222 m_hfSums = m_jetFinderA->getHfSums() + m_jetFinderB->getHfSums() + m_jetFinderC->getHfSums();
0223
0224
0225 m_exSumPipe.store(m_exSum, bxRel());
0226 m_eySumPipe.store(m_eySum, bxRel());
0227 m_hxSumPipe.store(m_hxSum, bxRel());
0228 m_hySumPipe.store(m_hySum, bxRel());
0229 m_etSumPipe.store(m_etSum, bxRel());
0230 m_htSumPipe.store(m_htSum, bxRel());
0231 m_hfSumsPipe.store(m_hfSums, bxRel());
0232 }
0233 }
0234
0235 bool L1GctJetLeafCard::setupOk() const {
0236 return (m_ctorInputOk && m_jetFinderA->setupOk() && m_jetFinderB->setupOk() && m_jetFinderC->setupOk());
0237 }
0238
0239
0240 L1GctJetFinderBase::JetVector L1GctJetLeafCard::getOutputJetsA() const {
0241 return m_jetFinderA->getJets();
0242 }
0243 L1GctJetFinderBase::JetVector L1GctJetLeafCard::getOutputJetsB() const {
0244 return m_jetFinderB->getJets();
0245 }
0246 L1GctJetFinderBase::JetVector L1GctJetLeafCard::getOutputJetsC() const {
0247 return m_jetFinderC->getJets();
0248 }
0249
0250
0251 std::vector<L1GctInternEtSum> L1GctJetLeafCard::getInternalEtSums() const {
0252 std::vector<L1GctInternEtSum> result;
0253 for (int bx = 0; bx < numOfBx(); bx++) {
0254 result.push_back(L1GctInternEtSum::fromEmulatorJetTotEt(m_etSumPipe.contents.at(bx).value(),
0255 m_etSumPipe.contents.at(bx).overFlow(),
0256 static_cast<int16_t>(bx - bxMin())));
0257 result.push_back(L1GctInternEtSum::fromEmulatorJetMissEt(m_exSumPipe.contents.at(bx).value(),
0258 m_exSumPipe.contents.at(bx).overFlow(),
0259 static_cast<int16_t>(bx - bxMin())));
0260 result.push_back(L1GctInternEtSum::fromEmulatorJetMissEt(m_eySumPipe.contents.at(bx).value(),
0261 m_eySumPipe.contents.at(bx).overFlow(),
0262 static_cast<int16_t>(bx - bxMin())));
0263 result.push_back(L1GctInternEtSum::fromEmulatorJetTotHt(m_htSumPipe.contents.at(bx).value(),
0264 m_htSumPipe.contents.at(bx).overFlow(),
0265 static_cast<int16_t>(bx - bxMin())));
0266 }
0267 return result;
0268 }
0269
0270 std::vector<L1GctInternHtMiss> L1GctJetLeafCard::getInternalHtMiss() const {
0271 std::vector<L1GctInternHtMiss> result;
0272 result.reserve(numOfBx());
0273 for (int bx = 0; bx < numOfBx(); bx++) {
0274 result.push_back(L1GctInternHtMiss::emulatorMissHtxHty(m_hxSumPipe.contents.at(bx).value(),
0275 m_hySumPipe.contents.at(bx).value(),
0276 m_hxSumPipe.contents.at(bx).overFlow(),
0277 static_cast<int16_t>(bx - bxMin())));
0278 }
0279 return result;
0280 }