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