37 template <
typename ObjType>
44 template <
typename ObjType,
typename StringFunctor,
typename ValType>
54 std::vector<ValType> vals(selobjs.size());
55 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
56 if constexpr (std::is_same<ValType, float>()) {
75 template <
typename ObjType>
83 template <
typename ObjType,
typename TIn,
typename ValType = TIn>
96 std::vector<ValType> vals;
98 vals.resize(selptrs.size());
99 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
100 vals[
i] = (*vmap)[selptrs[
i]];
115 template <
typename T,
typename TProd>
129 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
130 else if (
type ==
"uint")
131 vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
132 else if (
type ==
"float")
133 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
134 else if (
type ==
"int8")
135 vars_.push_back(std::make_unique<Int8Var>(vname, varPSet));
136 else if (
type ==
"uint8")
137 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
138 else if (
type ==
"bool")
139 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
141 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
144 produces<nanoaod::FlatTable>();
153 desc.add<
std::string>(
"doc",
"")->setComment(
"few words of self documentation");
154 desc.add<
bool>(
"extension",
false)->setComment(
"whether or not to extend an existing same table");
155 desc.add<
bool>(
"skipNonExistingSrc",
false)
156 ->setComment(
"whether or not to skip producing the table on absent input product");
157 desc.add<
edm::InputTag>(
"src")->setComment(
"input collection to fill the flat table");
160 variable.add<
std::string>(
"expr")->setComment(
"a function to define the content of the branch in the flat table");
161 variable.add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
163 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
164 edm::allowedValues<std::string>(
"int",
"unit",
"float",
"int8",
"uint8",
"bool"));
167 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
169 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
173 variables.setComment(
"a parameters set to define all variable to fill the flat table");
207 std::vector<std::unique_ptr<Variable<T>>>
vars_;
210 template <
typename T>
217 :
std::numeric_limits<unsigned
int>::
max()),
226 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
227 else if (type ==
"float")
229 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
230 else if (type ==
"double")
232 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
233 else if (type ==
"int8")
235 std::make_unique<Int8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
236 else if (type ==
"uint8")
238 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
239 else if (type ==
"bool")
241 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
243 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
254 "singleton",
false,
true,
edm::Comment(
"whether or not the input collection is single-element")),
256 "cut",
"",
true,
edm::Comment(
"selection on the main input collection"))
or 258 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
259 "define the maximum length of the input collection to put in the branch");
262 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
263 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
265 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
266 edm::allowedValues<std::string>(
"int",
"unit",
"float",
"int8",
"uint8",
"bool"));
269 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
271 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
275 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
285 std::vector<const T *> selobjs;
286 std::vector<edm::Ptr<T>> selptrs;
290 selobjs.push_back(&(*
prod)[0]);
292 selptrs.emplace_back(
prod->ptrAt(0));
294 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
295 const auto &
obj = (*prod)[
i];
297 selobjs.push_back(&
obj);
299 selptrs.emplace_back(
prod->ptrAt(
i));
310 var->fill(iEvent, selptrs, *
out);
325 std::vector<std::unique_ptr<ExtVariable<T>>>
extvars_;
328 template <
typename T>
341 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
342 std::vector<const T *> selobjs(1,
prod.product());
349 template <
typename T>
364 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
365 std::vector<const T *> selobjs(1, &(*
prod)[0]);
376 template <
typename T,
typename TProd>
378 :
public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<int>> {
393 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
394 else if (
type ==
"float")
395 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
396 else if (
type ==
"uint8")
397 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
398 else if (
type ==
"bool")
399 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
401 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
404 produces<nanoaod::FlatTable, edm::Transition::EndLuminosityBlock>();
445 std::vector<std::unique_ptr<Variable<T>>>
vars_;
449 template <
typename T>
464 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
465 std::vector<const T *> selobjs(1,
prod.product());
473 template <
typename T,
typename TProd>
479 :
std::numeric_limits<unsigned
int>::
max()),
486 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
487 "define the maximum length of the input collection to put in the branch");
493 std::vector<const T *> selobjs;
495 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
496 const auto &
obj = (*prod)[
i];
498 selobjs.push_back(&
obj);
504 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
519 template <
typename T,
typename TProd>
535 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
536 else if (
type ==
"float")
537 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
538 else if (
type ==
"uint8")
539 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
540 else if (
type ==
"bool")
541 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
543 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
546 produces<nanoaod::FlatTable, edm::Transition::EndRun>();
583 std::vector<std::unique_ptr<Variable<T>>>
vars_;
587 template <
typename T>
595 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
596 std::vector<const T *> selobjs(1,
prod.product());
604 template <
typename T,
typename TProd>
610 :
std::numeric_limits<unsigned
int>::
max()),
616 std::vector<const T *> selobjs;
618 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
619 const auto &
obj = (*prod)[
i];
621 selobjs.push_back(&
obj);
627 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
ValueMapVariable< T, double, float > DoubleExtVar
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Variable(const std::string &aname, const edm::ParameterSet &cfg)
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ValueMapVariable< T, bool > BoolExtVar
FuncVariable< T, StringObjectFunction< T >, int > IntVar
~SimpleFlatTableProducerBase() override
std::vector< std::unique_ptr< Variable< T > > > vars_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::LuminosityBlock &, const edm::Handle< T > &prod) const override
~RunSingletonSimpleFlatTableProducer() override
FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
virtual void fill(const edm::Event &iEvent, std::vector< edm::Ptr< ObjType >> selptrs, nanoaod::FlatTable &out) const =0
std::shared_ptr< int > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
ValueMapVariable< T, int, uint8_t > UInt8ExtVar
const edm::EDGetTokenT< TProd > src_
FuncVariable< T, StringObjectFunction< T >, unsigned int > UIntVar
~FirstObjectSimpleFlatTableProducer() override
void globalEndRun(edm::Run const &, edm::EventSetup const &) override
const StringCutObjectSelector< T > cut_
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< edm::View< T >> &prod) const override
FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
VariableBase(const std::string &aname, const edm::ParameterSet &cfg)
~LumiSimpleFlatTableProducer() override
const bool skipNonExistingSrc_
SimpleFlatTableProducerBase(edm::ParameterSet const ¶ms)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
ValueMapVariable< T, int, int8_t > Int8ExtVar
virtual std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Run &iRun, const edm::Handle< TProd > &prod) const =0
~LumiSingletonSimpleFlatTableProducer() override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &, const edm::Handle< T > &prod) const override
FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
void setComment(std::string const &value)
void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
~EventSingletonSimpleFlatTableProducer() override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::LuminosityBlock &iLumi, const edm::Handle< TProd > &prod) const override
const StringCutObjectSelector< T > cut_
void fill(const edm::Event &iEvent, std::vector< edm::Ptr< ObjType >> selptrs, nanoaod::FlatTable &out) const override
~SimpleFlatTableProducer() override
const bool skipNonExistingSrc_
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
const unsigned int maxLen_
FuncVariable< T, StringObjectFunction< T >, float > FloatVar
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
static const std::string & name()
const unsigned int maxLen_
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
LumiSingletonSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
RunSingletonSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
edm::EDGetTokenT< edm::ValueMap< TIn > > token_
ExtVariable(const std::string &aname, const edm::ParameterSet &cfg)
SimpleFlatTableProducer(edm::ParameterSet const ¶ms)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Run &iRun, const edm::Handle< TProd > &prod) const override
FuncVariable< T, StringObjectFunction< T >, int8_t > Int8Var
const unsigned int maxLen_
void endRunProduce(edm::Run &iRun, const edm::EventSetup &iSetup) final
const bool skipNonExistingSrc_
const edm::EDGetTokenT< TProd > src_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
FuncVariable< T, StringObjectFunction< T >, float > FloatVar
~SimpleFlatTableProducerBaseLumi() override
void fill(std::vector< const ObjType *> &selobjs, nanoaod::FlatTable &out) const override
FuncVariable< T, StringObjectFunction< T >, int > IntVar
FuncVariable< T, StringObjectFunction< T >, int > IntVar
StringFunctor precisionFunc_
RunSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
const std::string & name() const
SimpleFlatTableProducerBaseRun(edm::ParameterSet const ¶ms)
FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
FuncVariable< T, StringObjectFunction< T >, float > FloatVar
SimpleFlatTableProducerBaseLumi(edm::ParameterSet const ¶ms)
virtual std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< TProd > &prod) const =0
std::vector< std::unique_ptr< Variable< T > > > vars_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::shared_ptr< int > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< edm::View< T >> &prod) const override
static float reduceMantissaToNbitsRounding(const float &f)
ValueMapVariable(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc=false)
FirstObjectSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
EventSingletonSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
ValueMapVariable< T, float > FloatExtVar
FuncVariable(const std::string &aname, const edm::ParameterSet &cfg)
~RunSimpleFlatTableProducer() override
virtual void fill(std::vector< const ObjType *> &selobjs, nanoaod::FlatTable &out) const =0
const bool skipNonExistingSrc_
std::vector< std::unique_ptr< Variable< T > > > vars_
LumiSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Run &, const edm::Handle< T > &prod) const override
void endLuminosityBlockProduce(edm::LuminosityBlock &iLumi, const edm::EventSetup &iSetup) final
~SimpleFlatTableProducerBaseRun() override
const StringCutObjectSelector< T > cut_
FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
virtual std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::LuminosityBlock &iLumi, const edm::Handle< TProd > &prod) const =0
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< TProd > src_
static edm::ParameterSetDescription baseDescriptions()
ValueMapVariable< T, int > IntExtVar