9 #include <fmt/printf.h>
11 using namespace std::literals;
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>
43 std::string build_comment_from_entries(S1 pre,
const Entry<T> (&entries)[N], S2 post) {
44 std::string comment = build_comment_from_entries(pre, entries);
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
141 ? config.getParameter<std::
array<double,
GlobalAlgBlk::maxPhysicsTriggers>>(
"l1tPrescales")
144 m_mode == Mode::ForceColumnValues
145 ?
config.getParameter<uint32_t>(
"l1tPrescaleColumn")
150 case Mode::ApplyPrescaleValues:
151 case Mode::ForcePrescaleValues:
152 m_prescales = m_l1tPrescales;
156 case Mode::ApplyColumnValues:
157 case Mode::ApplyPrescaleRatios:
158 case Mode::ApplyColumnRatios:
159 case Mode::ForceColumnValues:
160 m_l1tGtPrescalesVetosToken = esConsumes<L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd>();
170 produces<GlobalAlgBlkBxCollection>();
179 if (handle->isEmpty(0)) {
186 int index = handle->at(0, 0).getPreScColumn();
197 << fmt::sprintf(
"The prescale index %d is invalid, it should be smaller than the prescale table size %d.",
206 }
else if (prescales[i] == 0) {
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.",
271 if (prescales[i] == 0)
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)
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
std::vector< bool > const & getAlgoDecisionInitial() const
Get decision bits.
edm::ESGetToken< L1TGlobalPrescalesVetos, L1TGlobalPrescalesVetosRcd > m_l1tGtPrescalesVetosToken
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void setFinalORPreVeto(bool fOR)
std::vector< bool > const & getAlgoDecisionFinal() const
#define DEFINE_FWK_MODULE(type)
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_l1tPrescales
std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
m_l1tPrescaleColumn(m_mode==Mode::ApplyColumnValues or m_mode==Mode::ApplyColumnRatios or m_mode==Mode::ForceColumnValues?config.getParameter< uint32_t >("l1tPrescaleColumn"):0)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
const bool getFinalORVeto() const
Entry(const ALIstring &type)
bool filter(edm::Event &event, edm::EventSetup const &setup) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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)
tuple config
parse the configuration file
static constexpr unsigned int maxPhysicsTriggers
void setPreScColumn(int psC)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
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