File indexing completed on 2023-10-25 09:54:27
0001 #include "L1Trigger/GlobalCaloTrigger/test/gctTestFunctions.h"
0002
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004
0005
0006 #include "CondFormats/L1TObjects/interface/L1GctJetFinderParams.h"
0007 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
0008 #include "CondFormats/L1TObjects/interface/L1GctChannelMask.h"
0009 #include "CondFormats/DataRecord/interface/L1GctJetFinderParamsRcd.h"
0010 #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
0011 #include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h"
0012 #include "CondFormats/DataRecord/interface/L1HfRingEtScaleRcd.h"
0013 #include "CondFormats/DataRecord/interface/L1GctChannelMaskRcd.h"
0014
0015 #include "L1Trigger/GlobalCaloTrigger/test/gctTestElectrons.h"
0016 #include "L1Trigger/GlobalCaloTrigger/test/gctTestSingleEvent.h"
0017 #include "L1Trigger/GlobalCaloTrigger/test/gctTestUsingLhcData.h"
0018 #include "L1Trigger/GlobalCaloTrigger/test/gctTestEnergyAlgos.h"
0019 #include "L1Trigger/GlobalCaloTrigger/test/gctTestFirmware.h"
0020 #include "L1Trigger/GlobalCaloTrigger/test/gctTestHt.h"
0021 #include "L1Trigger/GlobalCaloTrigger/test/gctTestHfEtSums.h"
0022
0023 #include "L1Trigger/GlobalCaloTrigger/interface/L1GlobalCaloTrigger.h"
0024
0025
0026
0027
0028
0029 gctTestFunctions::gctTestFunctions()
0030 : theElectronsTester(new gctTestElectrons()),
0031 theSingleEventTester(new gctTestSingleEvent()),
0032 theEnergyAlgosTester(new gctTestEnergyAlgos()),
0033 theFirmwareTester(new gctTestFirmware()),
0034 theRealDataTester(new gctTestUsingLhcData()),
0035 theHtTester(new gctTestHt()),
0036 theHfEtSumsTester(new gctTestHfEtSums()),
0037 m_inputEmCands(),
0038 m_inputRegions(),
0039 m_bxStart(0),
0040 m_numOfBx(1) {}
0041
0042 gctTestFunctions::~gctTestFunctions() {
0043 delete theElectronsTester;
0044 delete theEnergyAlgosTester;
0045 delete theFirmwareTester;
0046 delete theRealDataTester;
0047 delete theHtTester;
0048 delete theHfEtSumsTester;
0049 }
0050
0051
0052
0053
0054 void gctTestFunctions::configure(const L1GctJetFinderParams& jfPars,
0055 const L1GctChannelMask& chanMask,
0056 const L1CaloEtScale& etScale,
0057 const L1CaloEtScale& htMissScale,
0058 const L1CaloEtScale& hfRingEtScale) {
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 theEnergyAlgosTester->configure(&chanMask);
0074 theHtTester->configure(&etScale, &htMissScale, &jfPars);
0075 theHfEtSumsTester->configure(&hfRingEtScale);
0076 }
0077
0078
0079
0080
0081 void gctTestFunctions::reset() {
0082 m_inputEmCands.clear();
0083 m_inputRegions.clear();
0084 m_inputEmCands.resize(1);
0085 m_inputRegions.resize(1);
0086 m_bxStart = 0;
0087 m_numOfBx = 1;
0088 }
0089
0090
0091
0092
0093 void gctTestFunctions::loadNextEvent(L1GlobalCaloTrigger*& gct, const bool simpleEvent, const int16_t bx) {
0094 bxRangeUpdate(bx);
0095 m_inputRegions.at(bx - m_bxStart) = theEnergyAlgosTester->loadEvent(gct, simpleEvent, bx);
0096 }
0097
0098 void gctTestFunctions::loadNextEvent(L1GlobalCaloTrigger*& gct,
0099 const std::string fileName,
0100 bool& endOfFile,
0101 const int16_t bx) {
0102 bxRangeUpdate(bx);
0103 std::vector<L1CaloRegion> temp = theEnergyAlgosTester->loadEvent(gct, fileName, endOfFile, bx);
0104 if (endOfFile) {
0105 reset();
0106 } else {
0107 m_inputRegions.at(bx - m_bxStart) = temp;
0108 }
0109 }
0110
0111 void gctTestFunctions::loadNextEvent(L1GlobalCaloTrigger*& gct, const std::string fileName, const int16_t bx) {
0112 bxRangeUpdate(bx);
0113 m_inputEmCands.at(bx - m_bxStart) = theElectronsTester->loadEvent(gct, fileName, bx);
0114 }
0115
0116 void gctTestFunctions::loadNextEvent(L1GlobalCaloTrigger*& gct, const edm::Event& iEvent, const int16_t bx) {
0117 bxRangeUpdate(bx);
0118 m_inputRegions.at(bx - m_bxStart) =
0119 theEnergyAlgosTester->loadEvent(gct, theRealDataTester->loadEvent(iEvent, bx), bx);
0120 }
0121
0122 void gctTestFunctions::loadSingleEvent(L1GlobalCaloTrigger*& gct, const std::string fileName, const int16_t bx) {
0123 bxRangeUpdate(bx);
0124 m_inputRegions.at(bx - m_bxStart) =
0125 theEnergyAlgosTester->loadEvent(gct, theSingleEventTester->loadEvent(fileName, bx), bx);
0126 }
0127
0128
0129
0130
0131
0132
0133
0134 void gctTestFunctions::bxRangeUpdate(const int16_t bx) {
0135
0136
0137 int bxRel = bx - m_bxStart;
0138
0139
0140 if (bxRel < 0) {
0141 m_numOfBx -= bxRel;
0142 m_bxStart = bx;
0143 }
0144 if (bxRel >= m_numOfBx) {
0145 m_numOfBx = bxRel + 1;
0146 }
0147
0148
0149 std::vector<L1CaloEmCand> tempEmc;
0150 std::vector<L1CaloRegion> tempRgn;
0151 for (int i = bxRel; i < 0; i++) {
0152 m_inputEmCands.insert(m_inputEmCands.begin(), tempEmc);
0153 m_inputRegions.insert(m_inputRegions.begin(), tempRgn);
0154 }
0155
0156
0157 m_inputEmCands.resize(m_numOfBx);
0158 m_inputRegions.resize(m_numOfBx);
0159
0160
0161 theEnergyAlgosTester->setBxRange(m_bxStart, m_numOfBx);
0162 theHtTester->setBxRange(m_bxStart, m_numOfBx);
0163 }
0164
0165
0166
0167
0168 void gctTestFunctions::fillElectronData(const L1GlobalCaloTrigger* gct) { theElectronsTester->fillElectronData(gct); }
0169
0170
0171
0172
0173 void gctTestFunctions::fillJetsFromFirmware(const std::string& fileName) {
0174 theFirmwareTester->fillJetsFromFirmware(fileName, m_bxStart, m_numOfBx);
0175 }
0176
0177
0178
0179
0180 void gctTestFunctions::fillRawJetData(const L1GlobalCaloTrigger* gct) { theHtTester->fillRawJetData(gct); }
0181
0182
0183
0184
0185 bool gctTestFunctions::checkElectrons(const L1GlobalCaloTrigger* gct) const {
0186 return theElectronsTester->checkElectrons(gct, m_bxStart, m_numOfBx);
0187 }
0188
0189
0190 bool gctTestFunctions::checkJetFinder(const L1GlobalCaloTrigger* gct) const {
0191 return theFirmwareTester->checkJetFinder(gct);
0192 }
0193
0194
0195 bool gctTestFunctions::checkEnergySums(const L1GlobalCaloTrigger* gct) const {
0196 return theEnergyAlgosTester->checkEnergySums(gct);
0197 }
0198
0199
0200
0201
0202 bool gctTestFunctions::checkHtSums(const L1GlobalCaloTrigger* gct) const { return theHtTester->checkHtSums(gct); }
0203
0204
0205
0206
0207 bool gctTestFunctions::checkHfEtSums(const L1GlobalCaloTrigger* gct) const {
0208 theHfEtSumsTester->reset();
0209 theHfEtSumsTester->fillExpectedHfSums(m_inputRegions);
0210 return theHfEtSumsTester->checkHfEtSums(gct, m_numOfBx);
0211 }
0212
0213
0214
0215
0216 bool gctTestFunctions::checkEnergySumsFromFirmware(const L1GlobalCaloTrigger* gct, const std::string& fileName) const {
0217 return theFirmwareTester->checkEnergySumsFromFirmware(gct, fileName, m_numOfBx);
0218 }
0219
0220
0221
0222
0223 void gctTestFunctions::checkHwResults(const L1GlobalCaloTrigger* gct, const edm::Event& iEvent) const {
0224 theRealDataTester->checkHwResults(gct, iEvent);
0225 }
0226
0227 void gctTestFunctions::checkEmResults(const L1GlobalCaloTrigger* gct, const edm::Event& iEvent) const {
0228 theRealDataTester->checkEmResults(gct, iEvent);
0229 }