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) {
25 return container !=
nullptr;
40 template <
typename S,
typename T,
unsigned int N>
41 std::string build_comment_from_entries(
S pre,
const Entry<T> (&entries)[
N]) {
44 for (
auto entry: entries)
47 for (
auto entry: entries)
53 for (
unsigned int i = 0;
i < length-std::strlen(
entry.tag); ++
i)
comment +=
' ';
59 template <
typename S1,
typename S2,
typename T,
unsigned int N>
60 std::string build_comment_from_entries(S1 pre,
const Entry<T> (&entries)[N], S2 post) {
69 #if __cplusplus > 201400 73 T get_enum_value(Entry<T>
const * entries,
const char *
tag) {
74 for (; entries->tag; ++entries)
75 if (std::strcmp(entries->tag, tag) == 0)
76 return entries->value;
77 throw std::logic_error(
"invalid tag "s + tag);
81 #if __cplusplus > 201400 85 T get_enum_value(Entry<T>
const * entries,
const char * tag,
T default_value) {
86 for (; entries->tag; ++entries)
87 if (std::strcmp(entries->tag, tag) == 0)
88 return entries->value;
113 template <
typename T, std::
size_t N,
typename S>
118 if (values.size() !=
N)
120 <<
"Parameter \"" << name <<
"\" should have " <<
N <<
" elements.\n" 121 <<
"The number of elements in the configuration is incorrect.";
122 std::array<T, N> ret;
123 std::copy(values.begin(), values.end(), ret.begin());
150 { Mode::ApplyPrescaleValues,
"applyPrescaleValues",
"apply the given prescale values" },
151 { Mode::ApplyPrescaleRatios,
"applyPrescaleRatios",
"apply prescales equal to ratio between the given values and the ones read from the EventSetup" },
152 { Mode::ApplyColumnValues,
"applyColumnValues",
"apply the prescale values from the EventSetup corresponding to the given column index" },
153 { Mode::ApplyColumnRatios,
"applyColumnRatios",
"apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup" },
154 { Mode::ForcePrescaleValues,
"forcePrescaleValues",
"apply the given prescale values, ignoring the prescales and masks already applied" },
155 { Mode::ForceColumnValues,
"forceColumnValues",
"apply the prescale values from the EventSetup corresponding to the given column index, ignoring the prescales and masks already applied" },
163 std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers>
m_counters;
174 m_mode( get_enum_value(s_modes, config.getParameter<
std::
string>(
"mode").c_str(),
Mode::
Invalid) ),
176 m_l1tPrescales( m_mode ==
Mode::ApplyPrescaleValues
or m_mode ==
Mode::ApplyPrescaleRatios
or m_mode ==
Mode::ForcePrescaleValues ?
177 getParameterArray<double,
GlobalAlgBlk::maxPhysicsTriggers>(config,
"l1tPrescales") :
179 m_l1tPrescaleColumn( m_mode ==
Mode::ApplyColumnValues
or m_mode ==
Mode::ApplyColumnRatios
or m_mode ==
Mode::ForceColumnValues ?
180 config.getParameter<uint32_t>(
"l1tPrescaleColumn") : 0 ),
203 produces<GlobalAlgBlkBxCollection>();
228 if (index >= (
int) prescaleTable.size())
230 auto const & prescales = prescaleTable[
index];
236 }
else if (prescales[i] == 0) {
239 edm::LogWarning(
"L1TGlobalPrescaler") <<
"Request to enable the trigger " << i <<
" which was originally disabled\nIt will be kept disabled.";
243 edm::LogWarning(
"L1TGlobalPrescaler") <<
"Request to prescale the trigger " << i <<
" less than it was originally prescaled\nNo further prescale will be applied.";
283 if (index >= (
int) prescaleTable.size())
287 auto const & prescales = prescaleTable[
index];
291 if (prescales[i] == 0)
296 m_prescales[
i] = targets[
i] < prescales[
i] ? 1. : (double) targets[i] / prescales[i];
308 bool finalOr =
false;
317 }
else if (decision[
i]) {
343 result->push_back(0, algoBlock);
353 l1tResults.
setComment(
"Collection with the original uGT results");
357 mode.
setComment(build_comment_from_entries(
"Define how to apply the prescale values:",
s_modes));
361 l1tPrescales.
setComment(
"Target prescale values (for modes \"applyPrescaleValues\", \"applyPrescaleRatios\" or \"forcePrescaleValues\")");
365 l1tPrescaleColumn.
setComment(
"Target prescale column (for modes \"applyColumnValues\", \"applyColumnRatios\" or \"forceColumnValues\")");
373 "applyPrescaleValues" >> l1tPrescales
or 374 "applyPrescaleRatios" >> l1tPrescales
or 375 "forcePrescaleValues" >> l1tPrescales
or 377 "applyColumnValues" >> l1tPrescaleColumn
or 378 "applyColumnRatios" >> l1tPrescaleColumn
or 379 "forceColumnValues" >> l1tPrescaleColumn );
380 descriptions.
add(
"l1tGlobalPrescaler", desc);
387 desc.
add<
std::string>(
"mode",
"applyColumnRatios")->setComment(
"apply prescales equal to ratio between the values corresponsing to the given column index, and the ones read from the EventSetup");
388 desc.
addNode(l1tPrescaleColumn);
389 descriptions.
add(
"l1tGlobalPrescalerTargetColumn", desc);
T getParameter(std::string const &) const
void setComment(std::string const &value)
std::vector< bool > const & getAlgoDecisionInitial() const
Get decision bits.
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
def setup(process, global_tag, zero_tesla=False)
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
const int getPreScColumn() 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
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
bool empty(T const &container)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
format
Some error handling for the usage.
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 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