14 template <
typename T,
typename TProd>
27 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
28 else if (
type ==
"float")
29 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
30 else if (
type ==
"uint8")
31 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
32 else if (
type ==
"bool")
33 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
35 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
38 produces<nanoaod::FlatTable>();
84 template <
typename StringFunctor,
typename ValType>
94 std::vector<ValType> vals(selobjs.size());
95 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
96 if constexpr (std::is_same<ValType, float>()) {
107 out.template addColumn<ValType>(this->name_, vals, this->doc_, this->
precision_);
114 typedef FuncVariable<StringObjectFunction<T>,
int>
IntVar;
115 typedef FuncVariable<StringObjectFunction<T>,
float>
FloatVar;
116 typedef FuncVariable<StringObjectFunction<T>, uint8_t>
UInt8Var;
117 typedef FuncVariable<StringCutObjectSelector<T>,
bool>
BoolVar;
118 std::vector<std::unique_ptr<Variable>>
vars_;
121 template <
typename T>
130 :
std::numeric_limits<unsigned
int>::
max()),
138 extvars_.push_back(std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector()));
139 else if (
type ==
"float")
140 extvars_.push_back(std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector()));
141 else if (
type ==
"double")
142 extvars_.push_back(std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector()));
143 else if (
type ==
"uint8")
144 extvars_.push_back(std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector()));
145 else if (
type ==
"bool")
146 extvars_.push_back(std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector()));
148 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
157 std::vector<const T *> selobjs;
158 std::vector<edm::Ptr<T>> selptrs;
161 selobjs.push_back(&(*
prod)[0]);
163 selptrs.emplace_back(
prod->ptrAt(0));
165 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
166 const auto &
obj = (*prod)[
i];
168 selobjs.push_back(&
obj);
170 selptrs.emplace_back(
prod->ptrAt(
i));
180 var->fill(iEvent, selptrs, *
out);
194 template <
typename TIn,
typename ValType = TIn>
202 std::vector<ValType> vals(selptrs.size());
203 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
204 vals[
i] = (*vmap)[selptrs[
i]];
206 out.template addColumn<ValType>(this->
name_, vals, this->
doc_, this->precision_);
217 std::vector<std::unique_ptr<ExtVariable>>
extvars_;
220 template <
typename T>
228 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
229 std::vector<const T *> selobjs(1,
prod.product());
236 template <
typename T>
246 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
247 std::vector<const T *> selobjs(1, &(*
prod)[0]);