9 #include <boost/format.hpp> 11 template <
class T, std::
size_t N>
13 assert(
N == values.size());
15 std::copy(values.begin(), values.end(), ret.begin());
21 return container.empty();
24 bool empty(
const char* container) {
return container !=
nullptr; }
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>
113 if (values.size() !=
N)
115 <<
"Parameter \"" << name <<
"\" should have " <<
N <<
" elements.\n" 116 <<
"The number of elements in the configuration is incorrect.";
117 std::array<T, N>
ret;
118 std::copy(values.begin(), values.end(), ret.begin());
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;
176 : m_mode(get_enum_value(s_modes, config.getParameter<
std::
string>(
"mode").c_str(),
Mode::
Invalid)),
178 m_l1tPrescales(m_mode ==
Mode::ApplyPrescaleValues
or m_mode ==
Mode::ApplyPrescaleRatios
or 179 m_mode ==
Mode::ForcePrescaleValues
180 ? getParameterArray<double,
GlobalAlgBlk::maxPhysicsTriggers>(config,
"l1tPrescales")
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>();
224 int index = handle->
at(0, 0).getPreScColumn();
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);
T getParameter(std::string const &) const
void setComment(std::string const &value)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
std::vector< bool > const & getAlgoDecisionInitial() const
Get decision bits.
void setFinalORPreVeto(bool fOR)
std::vector< bool > const & getAlgoDecisionFinal() const
ret
prodAgent to be discontinued
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_l1tPrescales
std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
bool isEmpty(int bx) const
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
const bool getFinalORVeto() const
std::array< T, N > make_array(std::vector< T > const &values)
Entry(const ALIstring &type)
bool filter(edm::Event &event, edm::EventSetup const &setup) override
#define DEFINE_FWK_MODULE(type)
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
bool empty(T const &container)
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)
static unsigned int maxPhysicsTriggers
std::vector< std::vector< int > > prescale_table_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void setPreScColumn(int psC)
static const Entry< Mode > s_modes[]
void setAlgoDecisionFinal(unsigned int bit, bool val)
L1TGlobalPrescaler(edm::ParameterSet const &config)
const int m_l1tPrescaleColumn
const T & at(int bx, unsigned i) const