14 template <
typename T,
typename TProd>
30 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
31 else if (
type ==
"float")
32 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
33 else if (
type ==
"uint8")
34 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
35 else if (
type ==
"bool")
36 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
38 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
41 produces<nanoaod::FlatTable>();
88 template <
typename StringFunctor,
typename ValType>
98 std::vector<ValType> vals(selobjs.size());
99 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
100 if constexpr (std::is_same<ValType, float>()) {
111 out.template addColumn<ValType>(this->name_, vals, this->doc_, this->
precision_);
118 typedef FuncVariable<StringObjectFunction<T>,
int>
IntVar;
119 typedef FuncVariable<StringObjectFunction<T>,
float>
FloatVar;
120 typedef FuncVariable<StringObjectFunction<T>, uint8_t>
UInt8Var;
121 typedef FuncVariable<StringCutObjectSelector<T>,
bool>
BoolVar;
122 std::vector<std::unique_ptr<Variable>>
vars_;
125 template <
typename T>
134 :
std::numeric_limits<unsigned
int>::
max()),
143 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
144 else if (type ==
"float")
146 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
147 else if (type ==
"double")
149 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
150 else if (type ==
"uint8")
152 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
153 else if (type ==
"bool")
155 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
157 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
166 std::vector<const T *> selobjs;
167 std::vector<edm::Ptr<T>> selptrs;
171 selobjs.push_back(&(*
prod)[0]);
173 selptrs.emplace_back(
prod->ptrAt(0));
175 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
176 const auto &
obj = (*prod)[
i];
178 selobjs.push_back(&
obj);
180 selptrs.emplace_back(
prod->ptrAt(
i));
191 var->fill(iEvent, selptrs, *
out);
205 template <
typename TIn,
typename ValType = TIn>
219 std::vector<ValType> vals;
221 vals.resize(selptrs.size());
222 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
223 vals[
i] = (*vmap)[selptrs[
i]];
226 out.template addColumn<ValType>(this->
name_, vals, this->
doc_, this->precision_);
238 std::vector<std::unique_ptr<ExtVariable>>
extvars_;
241 template <
typename T>
249 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
250 std::vector<const T *> selobjs(1,
prod.product());
257 template <
typename T>
267 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
268 std::vector<const T *> selobjs(1, &(*
prod)[0]);