Skip to content

Commit

Permalink
Merge pull request #39851 from missirol/fixGlobalBoardForFractPS_125X
Browse files Browse the repository at this point in the history
update of `L1TGlobalProducer` to handle fractional prescales [`12_5_X`]
  • Loading branch information
cmsbuild authored Oct 26, 2022
2 parents d90168a + 844f35a commit 9d0926f
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 159 deletions.
67 changes: 47 additions & 20 deletions L1Trigger/L1TGlobal/interface/GlobalBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
#include <bitset>
#include <cassert>
#include <vector>
#include <cmath>
#include <memory>

// user include files
#include "FWCore/Utilities/interface/typedefs.h"
#include "FWCore/Utilities/interface/Exception.h"

#include "DataFormats/L1TGlobal/interface/GlobalObjectMapRecord.h"

#include "L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h"
Expand All @@ -37,8 +41,6 @@
#include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/EventSetup.h"

// forward declarations
Expand All @@ -61,7 +63,7 @@ namespace l1t {

public:
/// receive data from Global Muon Trigger
void receiveCaloObjectData(edm::Event&,
void receiveCaloObjectData(const edm::Event&,
const edm::EDGetTokenT<BXVector<l1t::EGamma>>&,
const edm::EDGetTokenT<BXVector<l1t::Tau>>&,
const edm::EDGetTokenT<BXVector<l1t::Jet>>&,
Expand All @@ -74,17 +76,17 @@ namespace l1t {
const int nrL1Jet,
const bool receiveEtSums);

void receiveMuonObjectData(edm::Event&,
void receiveMuonObjectData(const edm::Event&,
const edm::EDGetTokenT<BXVector<l1t::Muon>>&,
const bool receiveMu,
const int nrL1Mu);

void receiveMuonShowerObjectData(edm::Event&,
void receiveMuonShowerObjectData(const edm::Event&,
const edm::EDGetTokenT<BXVector<l1t::MuonShower>>&,
const bool receiveMuShower,
const int nrL1MuShower);

void receiveExternalData(edm::Event&, const edm::EDGetTokenT<BXVector<GlobalExtBlk>>&, const bool receiveExt);
void receiveExternalData(const edm::Event&, const edm::EDGetTokenT<BXVector<GlobalExtBlk>>&, const bool receiveExt);

/// initialize the class (mainly reserve)
void init(const int numberPhysTriggers,
Expand All @@ -97,7 +99,7 @@ namespace l1t {
int bxLast);

/// run the uGT GTL (Conditions and Algorithms)
void runGTL(edm::Event& iEvent,
void runGTL(const edm::Event& iEvent,
const edm::EventSetup& evSetup,
const TriggerMenu* m_l1GtMenu,
const bool produceL1GtObjectMapRecord,
Expand All @@ -111,7 +113,7 @@ namespace l1t {
const int nrL1Jet);

/// run the uGT FDL (Apply Prescales and Veto)
void runFDL(edm::Event& iEvent,
void runFDL(const edm::Event& iEvent,
const int iBxInEvent,
const int totalBxInEvent,
const unsigned int numberPhysTriggers,
Expand Down Expand Up @@ -165,10 +167,6 @@ namespace l1t {
/// pointer to Tau data list
inline const BXVector<const GlobalExtBlk*>* getCandL1External() const { return m_candL1External; }

//initializer prescale counter using a semi-random value between [1, prescale value]
static const std::vector<double> semirandomNumber(const edm::Event& iEvent,
const std::vector<double>& prescaleFactorsAlgoTrig);

/* Drop individual EtSums for Now
/// pointer to ETM data list
inline const l1t::EtSum* getCandL1ETM() const
Expand Down Expand Up @@ -243,15 +241,10 @@ namespace l1t {

GlobalAlgBlk m_uGtAlgBlk;

// cache of maps
// cache of maps
std::vector<AlgorithmEvaluation::ConditionEvaluationMap> m_conditionResultMaps;

/// prescale counters: NumberPhysTriggers counters per bunch cross in event
std::vector<std::vector<double>> m_prescaleCounterAlgoTrig;

bool m_firstEv;
bool m_firstEvLumiSegment;
uint m_currentLumi;
unsigned int m_currentLumi;

private:
/// verbosity level
Expand All @@ -277,7 +270,41 @@ namespace l1t {

// start the PS counter from a random value between [1,PS] instead of PS
bool m_semiRandomInitialPSCounters = false;

// step-size in prescale counter corresponding to 10^p,
// where p is the precision allowed for non-integer prescales;
// since the introduction of L1T fractional prescales, p == 2
static constexpr size_t m_singlestep = 100;

// struct to increment the prescale according to fractional prescale logic in firmware
struct PrescaleCounter {
size_t const prescale_count;
size_t trigger_counter;

PrescaleCounter(double prescale, size_t const initial_counter = 0)
: prescale_count(std::lround(prescale * m_singlestep)), trigger_counter(initial_counter) {
if (prescale_count != 0 and (prescale_count < m_singlestep or prescale < 0)) {
throw cms::Exception("PrescaleCounterConstructor")
<< "invalid initialisation of PrescaleCounter: prescale = " << prescale
<< ", prescale_count = " << prescale_count << " (< " << m_singlestep << " = m_singlestep)";
}
}

// function to increment the prescale counter and return the decision
bool accept();
};

// prescale counters: NumberPhysTriggers counters per bunch cross in event
std::vector<std::vector<PrescaleCounter>> m_prescaleCounterAlgoTrig;

// create prescale counters, initialising trigger_counter to zero
static std::vector<PrescaleCounter> prescaleCounters(std::vector<double> const& prescaleFactorsAlgoTrig);

// create prescale counters, initialising trigger_counter to a semirandom number between 0 and prescale_count - 1 inclusive
static std::vector<PrescaleCounter> prescaleCountersWithSemirandomInitialCounter(
std::vector<double> const& prescaleFactorsAlgoTrig, edm::Event const& iEvent);
};

} // namespace l1t
#endif

#endif
Loading

0 comments on commit 9d0926f

Please sign in to comment.