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) {
57 if constexpr (std::is_same<ValType, float>()) {
76 template <
typename ObjType>
84 template <
typename ObjType,
typename TIn,
typename ValType = TIn>
97 std::vector<ValType> vals;
99 vals.resize(selptrs.size());
100 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
101 vals[
i] = (*vmap)[selptrs[
i]];
116 template <
typename T,
typename TProd>
130 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
131 else if (
type ==
"uint")
132 vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
133 else if (
type ==
"float")
134 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
135 else if (
type ==
"double")
136 vars_.push_back(std::make_unique<DoubleVar>(vname, varPSet));
137 else if (
type ==
"int8")
138 vars_.push_back(std::make_unique<Int8Var>(vname, varPSet));
139 else if (
type ==
"uint8")
140 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
141 else if (
type ==
"int16")
142 vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
143 else if (
type ==
"uint16")
144 vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
145 else if (
type ==
"bool")
146 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
148 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
151 produces<nanoaod::FlatTable>();
160 desc.add<
std::string>(
"doc",
"")->setComment(
"few words of self documentation");
161 desc.add<
bool>(
"extension",
false)->setComment(
"whether or not to extend an existing same table");
162 desc.add<
bool>(
"skipNonExistingSrc",
false)
163 ->setComment(
"whether or not to skip producing the table on absent input product");
164 desc.add<
edm::InputTag>(
"src")->setComment(
"input collection to fill the flat table");
167 variable.add<
std::string>(
"expr")->setComment(
"a function to define the content of the branch in the flat table");
168 variable.add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
171 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
172 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"int8",
"uint8",
"int16",
"uint16",
"bool"));
175 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
177 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
181 variables.setComment(
"a parameters set to define all variable to fill the flat table");
218 std::vector<std::unique_ptr<Variable<T>>>
vars_;
221 template <
typename T>
228 :
std::numeric_limits<unsigned
int>::
max()),
237 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
238 else if (type ==
"uint")
240 std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
241 else if (type ==
"float")
243 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
244 else if (type ==
"double")
246 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
247 else if (type ==
"int8")
249 std::make_unique<Int8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
250 else if (type ==
"uint8")
252 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
253 else if (type ==
"int16")
255 std::make_unique<Int16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
256 else if (type ==
"uint16")
258 std::make_unique<UInt16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
259 else if (type ==
"bool")
261 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
263 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
274 "singleton",
false,
true,
edm::Comment(
"whether or not the input collection is single-element")),
276 "cut",
"",
true,
edm::Comment(
"selection on the main input collection"))
or 278 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
279 "define the maximum length of the input collection to put in the branch");
282 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
283 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
286 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
287 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"int8",
"uint8",
"int16",
"uint16",
"bool"));
290 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
292 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
296 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
306 std::vector<const T *> selobjs;
307 std::vector<edm::Ptr<T>> selptrs;
311 selobjs.push_back(&(*
prod)[0]);
313 selptrs.emplace_back(
prod->ptrAt(0));
315 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
316 const auto &
obj = (*prod)[
i];
318 selobjs.push_back(&
obj);
320 selptrs.emplace_back(
prod->ptrAt(
i));
331 var->fill(iEvent, selptrs, *
out);
349 std::vector<std::unique_ptr<ExtVariable<T>>>
extvars_;
352 template <
typename T>
365 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
366 std::vector<const T *> selobjs(1,
prod.product());
373 template <
typename T>
388 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
389 std::vector<const T *> selobjs(1, &(*
prod)[0]);
400 template <
typename T,
typename TProd>
402 :
public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<int>> {
417 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
418 else if (
type ==
"float")
419 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
420 else if (
type ==
"uint8")
421 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
422 else if (
type ==
"bool")
423 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
425 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
428 produces<nanoaod::FlatTable, edm::Transition::EndLuminosityBlock>();
469 std::vector<std::unique_ptr<Variable<T>>>
vars_;
473 template <
typename T>
488 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
489 std::vector<const T *> selobjs(1,
prod.product());
497 template <
typename T,
typename TProd>
503 :
std::numeric_limits<unsigned
int>::
max()),
510 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
511 "define the maximum length of the input collection to put in the branch");
517 std::vector<const T *> selobjs;
519 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
520 const auto &
obj = (*prod)[
i];
522 selobjs.push_back(&
obj);
528 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
543 template <
typename T,
typename TProd>
559 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
560 else if (
type ==
"float")
561 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
562 else if (
type ==
"uint8")
563 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
564 else if (
type ==
"bool")
565 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
567 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
570 produces<nanoaod::FlatTable, edm::Transition::EndRun>();
607 std::vector<std::unique_ptr<Variable<T>>>
vars_;
611 template <
typename T>
619 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
620 std::vector<const T *> selobjs(1,
prod.product());
628 template <
typename T,
typename TProd>
634 :
std::numeric_limits<unsigned
int>::
max()),
640 std::vector<const T *> selobjs;
642 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
643 const auto &
obj = (*prod)[
i];
645 selobjs.push_back(&
obj);
651 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
ValueMapVariable< T, int, uint16_t > UInt16ExtVar
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
uint32_t cc[maxCellsPerHit]
ValueMapVariable< T, int, uint8_t > UInt8ExtVar
const edm::EDGetTokenT< TProd > src_
~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 >, uint32_t > UIntVar
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_
FuncVariable< T, StringObjectFunction< T >, uint16_t > UInt16Var
SimpleFlatTableProducerBase(edm::ParameterSet const ¶ms)
ValueMapVariable< T, uint32_t > UIntExtVar
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
ValueMapVariable< T, int, int16_t > Int16ExtVar
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 >, int16_t > Int16Var
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
FuncVariable< T, StringObjectFunction< T >, int32_t > IntVar
void fill(std::vector< const ObjType *> &selobjs, nanoaod::FlatTable &out) const override
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
FuncVariable< T, StringObjectFunction< T >, double > DoubleVar
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_
ValueMapVariable< T, int32_t > IntExtVar
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()