File indexing completed on 2024-07-16 02:43:00
0001 #ifndef GtBoard_h
0002 #define GtBoard_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <bitset>
0017 #include <cassert>
0018 #include <vector>
0019 #include <cmath>
0020 #include <memory>
0021
0022
0023 #include "FWCore/Utilities/interface/typedefs.h"
0024 #include "FWCore/Utilities/interface/Exception.h"
0025
0026 #include "DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h"
0027
0028 #include "L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h"
0029
0030
0031 #include "DataFormats/L1Trigger/interface/EGamma.h"
0032 #include "DataFormats/L1Trigger/interface/Muon.h"
0033 #include "DataFormats/L1Trigger/interface/MuonShower.h"
0034 #include "DataFormats/L1Trigger/interface/Tau.h"
0035 #include "DataFormats/L1Trigger/interface/Jet.h"
0036 #include "DataFormats/L1Trigger/interface/EtSum.h"
0037 #include "L1Trigger/L1TGlobal/interface/GlobalScales.h"
0038
0039
0040 #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
0041 #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
0042 #include "DataFormats/L1TGlobal/interface/AXOL1TLScore.h"
0043
0044 #include "FWCore/Framework/interface/Event.h"
0045 #include "FWCore/Framework/interface/EventSetup.h"
0046
0047
0048 class TriggerMenu;
0049 class L1CaloGeometry;
0050 class L1MuTriggerScales;
0051
0052
0053
0054
0055 namespace l1t {
0056
0057 class GlobalBoard {
0058 public:
0059
0060 GlobalBoard();
0061
0062
0063 virtual ~GlobalBoard();
0064
0065 public:
0066
0067 void receiveCaloObjectData(const edm::Event&,
0068 const edm::EDGetTokenT<BXVector<l1t::EGamma>>&,
0069 const edm::EDGetTokenT<BXVector<l1t::Tau>>&,
0070 const edm::EDGetTokenT<BXVector<l1t::Jet>>&,
0071 const edm::EDGetTokenT<BXVector<l1t::EtSum>>&,
0072 const edm::EDGetTokenT<BXVector<l1t::EtSum>>&,
0073 const edm::EDGetTokenT<BXVector<float>>&,
0074 const bool receiveEG,
0075 const int nrL1EG,
0076 const bool receiveTau,
0077 const int nrL1Tau,
0078 const bool receiveJet,
0079 const int nrL1Jet,
0080 const bool receiveEtSums,
0081 const bool receiveEtSumsZdc,
0082 const bool receiveCICADA);
0083
0084 void receiveMuonObjectData(const edm::Event&,
0085 const edm::EDGetTokenT<BXVector<l1t::Muon>>&,
0086 const bool receiveMu,
0087 const int nrL1Mu);
0088
0089 void receiveMuonShowerObjectData(const edm::Event&,
0090 const edm::EDGetTokenT<BXVector<l1t::MuonShower>>&,
0091 const bool receiveMuShower,
0092 const int nrL1MuShower);
0093
0094 void receiveExternalData(const edm::Event&, const edm::EDGetTokenT<BXVector<GlobalExtBlk>>&, const bool receiveExt);
0095
0096 void fillAXOScore(int iBxInEvent, std::unique_ptr<AXOL1TLScoreBxCollection>& AxoScoreRecord);
0097
0098
0099 void init(const int numberPhysTriggers,
0100 const int nrL1Mu,
0101 const int nrL1MuShower,
0102 const int nrL1EG,
0103 const int nrL1Tau,
0104 const int nrL1Jet,
0105 int bxFirst,
0106 int bxLast);
0107
0108
0109 void runGTL(const edm::Event& iEvent,
0110 const edm::EventSetup& evSetup,
0111 const TriggerMenu* m_l1GtMenu,
0112 const bool produceL1GtObjectMapRecord,
0113 const int iBxInEvent,
0114 std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
0115 const unsigned int numberPhysTriggers,
0116 const int nrL1Mu,
0117 const int nrL1MuShower,
0118 const int nrL1EG,
0119 const int nrL1Tau,
0120 const int nrL1Jet);
0121
0122
0123 void runFDL(const edm::Event& iEvent,
0124 const int iBxInEvent,
0125 const int totalBxInEvent,
0126 const unsigned int numberPhysTriggers,
0127 const std::vector<double>& prescaleFactorsAlgoTrig,
0128 const std::vector<unsigned int>& triggerMaskAlgoTrig,
0129 const std::vector<int>& triggerMaskVetoAlgoTrig,
0130 const bool algorithmTriggersUnprescaled,
0131 const bool algorithmTriggersUnmasked);
0132
0133
0134 void fillAlgRecord(int iBxInEvent,
0135 std::unique_ptr<GlobalAlgBlkBxCollection>& uGtAlgRecord,
0136 int prescaleSet,
0137 int menuUUID,
0138 int firmwareUUID);
0139
0140
0141 void reset();
0142 void resetMu();
0143 void resetMuonShower();
0144 void resetCalo();
0145 void resetExternal();
0146
0147
0148 void printGmtData(const int iBxInEvent) const;
0149
0150
0151 inline const std::bitset<GlobalAlgBlk::maxPhysicsTriggers>& getDecisionWord() const { return m_gtlDecisionWord; }
0152
0153
0154 inline const std::bitset<GlobalAlgBlk::maxPhysicsTriggers>& getAlgorithmOR() const { return m_gtlAlgorithmOR; }
0155
0156
0157 inline const BXVector<const l1t::Muon*>* getCandL1Mu() const { return m_candL1Mu; }
0158
0159
0160 inline const BXVector<std::shared_ptr<l1t::MuonShower>>* getCandL1MuShower() const { return m_candL1MuShower; }
0161
0162
0163 inline const BXVector<const l1t::L1Candidate*>* getCandL1EG() const { return m_candL1EG; }
0164
0165
0166 inline const BXVector<const l1t::L1Candidate*>* getCandL1Jet() const { return m_candL1Jet; }
0167
0168
0169 inline const BXVector<const l1t::L1Candidate*>* getCandL1Tau() const { return m_candL1Tau; }
0170
0171
0172 inline const BXVector<const l1t::EtSum*>* getCandL1EtSum() const { return m_candL1EtSum; }
0173
0174
0175 inline const BXVector<const l1t::EtSum*>* getCandL1EtSumZdc() const { return m_candL1EtSumZdc; }
0176
0177
0178 inline const BXVector<const GlobalExtBlk*>* getCandL1External() const { return m_candL1External; }
0179
0180 inline const float getCICADAScore() const { return m_cicadaScore; }
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208 void setBxFirst(int bx);
0209 void setBxLast(int bx);
0210
0211 void setResetPSCountersEachLumiSec(bool val) { m_resetPSCountersEachLumiSec = val; }
0212 void setSemiRandomInitialPSCounters(bool val) { m_semiRandomInitialPSCounters = val; }
0213
0214 void setCICADAScore(float val) { m_cicadaScore = val; }
0215
0216 public:
0217 inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }
0218
0219 inline void enableAXOScoreSaving(bool savescore) { m_saveAXOScore = savescore; }
0220
0221 private:
0222
0223
0224
0225 const TriggerMenu* m_l1GtMenu;
0226 unsigned long long m_l1GtMenuCacheID;
0227
0228
0229 const L1CaloGeometry* m_l1CaloGeometry;
0230 unsigned long long m_l1CaloGeometryCacheID;
0231
0232 const L1MuTriggerScales* m_l1MuTriggerScales;
0233 unsigned long long m_l1MuTriggerScalesCacheID;
0234
0235
0236
0237
0238 private:
0239 BXVector<const l1t::Muon*>* m_candL1Mu;
0240 BXVector<std::shared_ptr<l1t::MuonShower>>* m_candL1MuShower;
0241 BXVector<const l1t::L1Candidate*>* m_candL1EG;
0242 BXVector<const l1t::L1Candidate*>* m_candL1Tau;
0243 BXVector<const l1t::L1Candidate*>* m_candL1Jet;
0244 BXVector<const l1t::EtSum*>* m_candL1EtSum;
0245 BXVector<const l1t::EtSum*>* m_candL1EtSumZdc;
0246 BXVector<const GlobalExtBlk*>* m_candL1External;
0247
0248
0249
0250
0251
0252
0253 int m_bxFirst_;
0254 int m_bxLast_;
0255
0256 float m_cicadaScore = 0.0;
0257
0258 std::bitset<GlobalAlgBlk::maxPhysicsTriggers> m_gtlAlgorithmOR;
0259 std::bitset<GlobalAlgBlk::maxPhysicsTriggers> m_gtlDecisionWord;
0260
0261 GlobalAlgBlk m_uGtAlgBlk;
0262
0263
0264 AXOL1TLScore m_uGtAXOScore;
0265 float m_storedAXOScore = -999.0;
0266 bool m_saveAXOScore = false;
0267
0268
0269 std::vector<AlgorithmEvaluation::ConditionEvaluationMap> m_conditionResultMaps;
0270
0271 unsigned int m_currentLumi;
0272
0273 private:
0274
0275 int m_verbosity;
0276 bool m_isDebugEnabled;
0277
0278
0279 bool m_algInitialOr;
0280 bool m_algIntermOr;
0281 bool m_algPrescaledOr;
0282 bool m_algFinalOr;
0283 bool m_algFinalOrVeto;
0284
0285
0286 unsigned int m_boardEventCount;
0287
0288
0289 int m_uGtBoardNumber;
0290 bool m_uGtFinalBoard;
0291
0292
0293 bool m_resetPSCountersEachLumiSec = false;
0294
0295
0296 bool m_semiRandomInitialPSCounters = false;
0297
0298
0299
0300
0301 static constexpr size_t m_singlestep = 100;
0302
0303
0304 struct PrescaleCounter {
0305 size_t const prescale_count;
0306 size_t trigger_counter;
0307
0308 PrescaleCounter(double prescale, size_t const initial_counter = 0)
0309 : prescale_count(std::lround(prescale * m_singlestep)), trigger_counter(initial_counter) {
0310 if (prescale_count != 0 and (prescale_count < m_singlestep or prescale < 0)) {
0311 throw cms::Exception("PrescaleCounterConstructor")
0312 << "invalid initialisation of PrescaleCounter: prescale = " << prescale
0313 << ", prescale_count = " << prescale_count << " (< " << m_singlestep << " = m_singlestep)";
0314 }
0315 }
0316
0317
0318 bool accept();
0319 };
0320
0321
0322 std::vector<std::vector<PrescaleCounter>> m_prescaleCounterAlgoTrig;
0323
0324
0325 static std::vector<PrescaleCounter> prescaleCounters(std::vector<double> const& prescaleFactorsAlgoTrig);
0326
0327
0328 static std::vector<PrescaleCounter> prescaleCountersWithSemirandomInitialCounter(
0329 std::vector<double> const& prescaleFactorsAlgoTrig, edm::Event const& iEvent);
0330 };
0331
0332 }
0333
0334 #endif