|
 |
Go to the documentation of this file.
12 #include <boost/ptr_container/ptr_vector.hpp>
14 template <
typename T,
typename TProd>
28 else if (
type ==
"float")
30 else if (
type ==
"uint8")
32 else if (
type ==
"bool")
35 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
38 produces<nanoaod::FlatTable>();
86 template <
typename StringFunctor,
typename ValType>
96 std::vector<ValType> vals(selobjs.size());
97 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
103 out.template addColumn<ValType>(this->name_, vals, this->doc_, this->
type_, this->
precision_);
110 typedef FuncVariable<StringObjectFunction<T>,
int>
IntVar;
111 typedef FuncVariable<StringObjectFunction<T>,
float>
FloatVar;
112 typedef FuncVariable<StringObjectFunction<T>, uint8_t>
UInt8Var;
113 typedef FuncVariable<StringCutObjectSelector<T>, uint8_t>
BoolVar;
117 template <
typename T>
126 :
std::numeric_limits<unsigned
int>::
max()),
135 else if (
type ==
"float")
138 else if (
type ==
"double")
141 else if (
type ==
"uint8")
144 else if (
type ==
"bool")
147 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
156 std::vector<const T *> selobjs;
157 std::vector<edm::Ptr<T>> selptrs;
160 selobjs.push_back(&(*
prod)[0]);
162 selptrs.emplace_back(
prod->ptrAt(0));
164 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
165 const auto &
obj = (*prod)[
i];
167 selobjs.push_back(&
obj);
169 selptrs.emplace_back(
prod->ptrAt(
i));
179 var.fill(iEvent, selptrs, *
out);
191 :
base::VariableBase(aname, atype,
cfg) {}
194 template <
typename TIn,
typename ValType = TIn>
206 std::vector<ValType> vals(selptrs.size());
207 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
208 vals[
i] = (*vmap)[selptrs[
i]];
210 out.template addColumn<ValType>(this->
name_, vals, this->
doc_, this->type_, this->precision_);
224 template <
typename T>
232 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
233 std::vector<const T *> selobjs(1,
prod.product());
240 template <
typename T>
250 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
251 std::vector<const T *> selobjs(1, &(*
prod)[0]);
ExtVariable(const std::string &aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet &cfg)
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< edm::ValueMap< TIn > > token_
ValueMapVariable(const std::string &aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc)
ValueMapVariable< int > IntExtVar
const std::string & name() const
ValueMapVariable< int, uint8_t > UInt8ExtVar
StringFunctor precisionFunc_
SimpleFlatTableProducerBase< T, edm::View< T > > base
SimpleFlatTableProducerBase(edm::ParameterSet const ¶ms)
ValueMapVariable< float > FloatExtVar
boost::ptr_vector< Variable > vars_
VariableBase(const std::string &aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet &cfg)
FuncVariable< StringObjectFunction< T >, uint8_t > UInt8Var
FuncVariable< StringObjectFunction< T >, float > FloatVar
FuncVariable< StringCutObjectSelector< T >, uint8_t > BoolVar
const unsigned int maxLen_
~SimpleFlatTableProducerBase() override
EventSingletonSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
nanoaod::FlatTable::ColumnType type_
FirstObjectSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
void fill(std::vector< const T * > selobjs, nanoaod::FlatTable &out) const override
boost::ptr_vector< ExtVariable > extvars_
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< edm::View< T >> &prod) const override
virtual void fill(std::vector< const T * > selobjs, nanoaod::FlatTable &out) const =0
static float reduceMantissaToNbitsRounding(const float &f)
~FirstObjectSimpleFlatTableProducer() override
~SimpleFlatTableProducer() override
virtual void fill(const edm::Event &iEvent, std::vector< edm::Ptr< T >> selptrs, nanoaod::FlatTable &out) const =0
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Variable(const std::string &aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet &cfg)
const edm::EDGetTokenT< TProd > src_
SimpleFlatTableProducer(edm::ParameterSet const ¶ms)
T getParameter(std::string const &) const
FuncVariable(const std::string &aname, nanoaod::FlatTable::ColumnType atype, const edm::ParameterSet &cfg)
virtual std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< TProd > &prod) const =0
const nanoaod::FlatTable::ColumnType & type() const
ValueMapVariable< bool, uint8_t > BoolExtVar
const StringCutObjectSelector< T > cut_
~EventSingletonSimpleFlatTableProducer() override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< edm::View< T >> &prod) const override
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &, const edm::Handle< T > &prod) const override
FuncVariable< StringObjectFunction< T >, int > IntVar
ValueMapVariable< double, float > DoubleExtVar
void fill(const edm::Event &iEvent, std::vector< edm::Ptr< T >> selptrs, nanoaod::FlatTable &out) const override