Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update of L1TGlobalProducer to handle fractional prescales [12_5_X] #39851

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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