9 #include <fmt/printf.h>
11 template <
class T, std::
size_t N>
21 return container.empty();
24 bool empty(
const char* container) {
return container !=
nullptr; }
26 using namespace std::literals;
37 template <
typename S,
typename T,
unsigned int N>
38 std::string build_comment_from_entries(
S pre,
const Entry<T> (&entries)[
N]) {
41 for (
auto entry : entries)
44 for (
auto entry : entries)
46 comment.reserve(comment.size() + length + std::strlen(
entry.description) + 8);
50 for (
unsigned int i = 0;
i < length - std::strlen(
entry.tag); ++
i)
52 comment +=
entry.description;
57 template <
typename S1,
typename S2,
typename T,
unsigned int N>
58 std::string build_comment_from_entries(S1 pre,
const Entry<T> (&entries)[
N], S2 post) {
59 std::string comment = build_comment_from_entries(pre, entries);
66 #if __cplusplus > 201400
71 get_enum_value(Entry<T>
const* entries,
const char*
tag) {
72 for (; entries->tag; ++entries)
73 if (std::strcmp(entries->tag,
tag) == 0)
74 return entries->value;
75 throw std::logic_error(
"invalid tag "s +
tag);
79 #if __cplusplus > 201400
84 get_enum_value(Entry<T>
const* entries,
const char*
tag,
T default_value) {
85 for (; entries->tag; ++entries)
86 if (std::strcmp(entries->tag,
tag) == 0)
87 return entries->value;
111 template <
typename T, std::
size_t N,
typename S>
116 <<
"Parameter \"" <<
name <<
"\" should have " <<
N <<
" elements.\n"
117 <<
"The number of elements in the configuration is incorrect.";
118 std::array<T, N>
ret;
144 static const constexpr Entry<Mode> s_modes[]{
145 {Mode::ApplyPrescaleValues,
"applyPrescaleValues",
"apply the given prescale values"},
146 {Mode::ApplyPrescaleRatios,
147 "applyPrescaleRatios",
148 "apply prescales equal to ratio between the given values and the ones read from the EventSetup"},
149 {Mode::ApplyColumnValues,
151 "apply the prescale values from the EventSetup corresponding to the given column index"},
152 {Mode::ApplyColumnRatios,
154 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read "
155 "from the EventSetup"},
156 {Mode::ForcePrescaleValues,
157 "forcePrescaleValues",
158 "apply the given prescale values, ignoring the prescales and masks already applied"},
159 {Mode::ForceColumnValues,
161 "apply the prescale values from the EventSetup corresponding to the given column index, ignoring the prescales "
162 "and masks already applied"},
169 std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers>
m_counters;
180 m_l1tPrescales(m_mode ==
Mode::ApplyPrescaleValues
or m_mode ==
Mode::ApplyPrescaleRatios
or
181 m_mode ==
Mode::ForcePrescaleValues
184 m_l1tPrescaleColumn(m_mode ==
Mode::ApplyColumnValues
or m_mode ==
Mode::ApplyColumnRatios
or
185 m_mode ==
Mode::ForceColumnValues
186 ?
config.getParameter<uint32_t>(
"l1tPrescaleColumn")
211 produces<GlobalAlgBlkBxCollection>();
238 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
251 <<
"Request to enable the trigger " <<
i <<
" which was originally disabled\nIt will be kept disabled.";
256 <<
"Request to prescale the trigger " <<
i
257 <<
" less than it was originally prescaled\nNo further prescale will be applied.";
277 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
300 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
305 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
329 bool finalOr =
false;
338 }
else if (decision[
i]) {
364 result->push_back(0, algoBlock);
373 l1tResults.setComment(
"Collection with the original uGT results");
377 mode.setComment(build_comment_from_entries(
"Define how to apply the prescale values:",
s_modes));
383 "Target prescale values (for modes \"applyPrescaleValues\", \"applyPrescaleRatios\" or \"forcePrescaleValues\")");
388 "Target prescale column (for modes \"applyColumnValues\", \"applyColumnRatios\" or \"forceColumnValues\")");
397 "applyPrescaleValues" >> l1tPrescales
or "applyPrescaleRatios" >> l1tPrescales
or
398 "forcePrescaleValues" >> l1tPrescales
or
400 "applyColumnValues" >> l1tPrescaleColumn
or "applyColumnRatios" >> l1tPrescaleColumn
or
401 "forceColumnValues" >> l1tPrescaleColumn);
402 descriptions.
add(
"l1tGlobalPrescaler",
desc);
411 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones "
412 "read from the EventSetup");
413 desc.addNode(l1tPrescaleColumn);
414 descriptions.
add(
"l1tGlobalPrescalerTargetColumn",
desc);