9 #include <boost/format.hpp>
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)
50 for (
unsigned int i = 0;
i < length - std::strlen(
entry.tag); ++
i)
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) {
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;
110 template <
typename T, std::
size_t N,
typename S>
115 <<
"Parameter \"" <<
name <<
"\" should have " <<
N <<
" elements.\n"
116 <<
"The number of elements in the configuration is incorrect.";
117 std::array<T, N>
ret;
143 static const constexpr Entry<Mode> s_modes[]{
144 {Mode::ApplyPrescaleValues,
"applyPrescaleValues",
"apply the given prescale values"},
145 {Mode::ApplyPrescaleRatios,
146 "applyPrescaleRatios",
147 "apply prescales equal to ratio between the given values and the ones read from the EventSetup"},
148 {Mode::ApplyColumnValues,
150 "apply the prescale values from the EventSetup corresponding to the given column index"},
151 {Mode::ApplyColumnRatios,
153 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read "
154 "from the EventSetup"},
155 {Mode::ForcePrescaleValues,
156 "forcePrescaleValues",
157 "apply the given prescale values, ignoring the prescales and masks already applied"},
158 {Mode::ForceColumnValues,
160 "apply the prescale values from the EventSetup corresponding to the given column index, ignoring the prescales "
161 "and masks already applied"},
168 std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers>
m_counters;
178 m_l1tPrescales(m_mode ==
Mode::ApplyPrescaleValues
or m_mode ==
Mode::ApplyPrescaleRatios
or
179 m_mode ==
Mode::ForcePrescaleValues
182 m_l1tPrescaleColumn(m_mode ==
Mode::ApplyColumnValues
or m_mode ==
Mode::ApplyColumnRatios
or
183 m_mode ==
Mode::ForceColumnValues
184 ?
config.getParameter<uint32_t>(
"l1tPrescaleColumn")
208 produces<GlobalAlgBlkBxCollection>();
235 <<
boost::format(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.") %
247 <<
"Request to enable the trigger " <<
i <<
" which was originally disabled\nIt will be kept disabled.";
252 <<
"Request to prescale the trigger " <<
i
253 <<
" less than it was originally prescaled\nNo further prescale will be applied.";
274 <<
boost::format(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.") %
297 <<
boost::format(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.") %
301 <<
boost::format(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.") %
324 bool finalOr =
false;
333 }
else if (decision[
i]) {
359 result->push_back(0, algoBlock);
368 l1tResults.setComment(
"Collection with the original uGT results");
372 mode.setComment(build_comment_from_entries(
"Define how to apply the prescale values:",
s_modes));
378 "Target prescale values (for modes \"applyPrescaleValues\", \"applyPrescaleRatios\" or \"forcePrescaleValues\")");
383 "Target prescale column (for modes \"applyColumnValues\", \"applyColumnRatios\" or \"forceColumnValues\")");
392 "applyPrescaleValues" >> l1tPrescales
or "applyPrescaleRatios" >> l1tPrescales
or
393 "forcePrescaleValues" >> l1tPrescales
or
395 "applyColumnValues" >> l1tPrescaleColumn
or "applyColumnRatios" >> l1tPrescaleColumn
or
396 "forceColumnValues" >> l1tPrescaleColumn);
397 descriptions.
add(
"l1tGlobalPrescaler", desc);
406 "apply prescales equal to ratio between the values corresponsing to the given column index, and the ones "
407 "read from the EventSetup");
408 desc.
addNode(l1tPrescaleColumn);
409 descriptions.
add(
"l1tGlobalPrescalerTargetColumn", desc);