9 #include <fmt/printf.h> 22 template <
typename S,
typename T,
unsigned int N>
23 std::string build_comment_from_entries(
S pre,
const Entry<T> (&entries)[
N]) {
26 for (
auto entry : entries)
29 for (
auto entry : entries)
31 comment.reserve(comment.size() + length + std::strlen(
entry.description) + 8);
35 for (
unsigned int i = 0;
i < length - std::strlen(
entry.tag); ++
i)
37 comment +=
entry.description;
42 template <
typename S1,
typename S2,
typename T,
unsigned int N>
51 constexpr
T get_enum_value(Entry<T>
const* entries,
const char*
tag) {
52 for (; entries->tag; ++entries)
53 if (std::strcmp(entries->tag,
tag) == 0)
54 return entries->value;
55 throw std::logic_error(
"invalid tag "s +
tag);
59 constexpr
T get_enum_value(Entry<T>
const* entries,
const char*
tag,
T default_value) {
60 for (; entries->tag; ++entries)
61 if (std::strcmp(entries->tag,
tag) == 0)
62 return entries->value;
103 static const constexpr Entry<Mode> s_modes[]{
104 {Mode::ApplyPrescaleValues,
"applyPrescaleValues",
"apply the given prescale values"},
105 {Mode::ApplyPrescaleRatios,
106 "applyPrescaleRatios",
107 "apply prescales equal to ratio between the given values and the ones read from the EventSetup"},
108 {Mode::ApplyColumnValues,
110 "apply the prescale values from the EventSetup corresponding to the given column index"},
111 {Mode::ApplyColumnRatios,
113 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read " 114 "from the EventSetup"},
115 {Mode::ForcePrescaleValues,
116 "forcePrescaleValues",
117 "apply the given prescale values, ignoring the prescales and masks already applied"},
118 {Mode::ForceColumnValues,
120 "apply the prescale values from the EventSetup corresponding to the given column index, ignoring the prescales " 121 "and masks already applied"},
128 std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers>
m_counters;
137 : m_mode(get_enum_value(s_modes,
config.getParameter<
std::
string>(
"mode").c_str(),
Mode::Invalid)),
139 m_l1tPrescales(m_mode ==
Mode::ApplyPrescaleValues
or m_mode ==
Mode::ApplyPrescaleRatios
or 140 m_mode ==
Mode::ForcePrescaleValues
143 m_l1tPrescaleColumn(m_mode == Mode::ApplyColumnValues
or m_mode == Mode::ApplyColumnRatios
or 144 m_mode == Mode::ForceColumnValues
145 ?
config.getParameter<uint32_t>(
"l1tPrescaleColumn")
170 produces<GlobalAlgBlkBxCollection>();
197 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
210 <<
"Request to enable the trigger " <<
i <<
" which was originally disabled\nIt will be kept disabled.";
215 <<
"Request to prescale the trigger " <<
i 216 <<
" less than it was originally prescaled\nNo further prescale will be applied.";
236 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
259 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
264 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
288 bool finalOr =
false;
297 }
else if (decision[
i]) {
323 result->push_back(0, algoBlock);
332 l1tResults.setComment(
"Collection with the original uGT results");
336 mode.setComment(build_comment_from_entries(
"Define how to apply the prescale values:",
s_modes));
342 "Target prescale values (for modes \"applyPrescaleValues\", \"applyPrescaleRatios\" or \"forcePrescaleValues\")");
347 "Target prescale column (for modes \"applyColumnValues\", \"applyColumnRatios\" or \"forceColumnValues\")");
356 "applyPrescaleValues" >> l1tPrescales
or "applyPrescaleRatios" >> l1tPrescales
or 357 "forcePrescaleValues" >> l1tPrescales
or 359 "applyColumnValues" >> l1tPrescaleColumn
or "applyColumnRatios" >> l1tPrescaleColumn
or 360 "forceColumnValues" >> l1tPrescaleColumn);
361 descriptions.
add(
"l1tGlobalPrescaler",
desc);
370 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones " 371 "read from the EventSetup");
372 desc.addNode(l1tPrescaleColumn);
373 descriptions.
add(
"l1tGlobalPrescalerTargetColumn",
desc);
static const constexpr Entry< Mode > s_modes[]
void setComment(std::string const &value)
edm::ESGetToken< L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd > m_l1tGtPrescalesVetosToken
void setFinalORPreVeto(bool fOR)
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_l1tPrescales
std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
std::vector< bool > const & getAlgoDecisionFinal() const
Entry(const ALIstring &type)
bool filter(edm::Event &event, edm::EventSetup const &setup) override
const bool getFinalORVeto() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
#define DEFINE_FWK_MODULE(type)
void setFinalOR(bool fOR)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1tResultsToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< bool > const & getAlgoDecisionInitial() const
Get decision bits.
static constexpr unsigned int maxPhysicsTriggers
void setPreScColumn(int psC)
Log< level::Warning, false > LogWarning
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void setAlgoDecisionFinal(unsigned int bit, bool val)
L1TGlobalPrescaler(edm::ParameterSet const &config)
const int m_l1tPrescaleColumn