38 template <
typename ObjType>
45 template <
typename ObjType,
typename StringFunctor,
typename ValType>
55 std::vector<ValType> vals(selobjs.size());
56 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
58 if constexpr (std::is_same<ValType, float>()) {
77 template <
typename ObjType>
85 template <
typename ObjType,
typename TIn,
typename ValType = TIn>
98 std::vector<ValType> vals;
100 vals.resize(selptrs.size());
101 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
102 vals[
i] = (*vmap)[selptrs[
i]];
117 template <
typename T,
typename TProd>
131 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
132 else if (
type ==
"uint")
133 vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
134 else if (
type ==
"float")
135 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
136 else if (
type ==
"double")
137 vars_.push_back(std::make_unique<DoubleVar>(vname, varPSet));
138 else if (
type ==
"int8")
139 vars_.push_back(std::make_unique<Int8Var>(vname, varPSet));
140 else if (
type ==
"uint8")
141 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
142 else if (
type ==
"int16")
143 vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
144 else if (
type ==
"uint16")
145 vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
146 else if (
type ==
"bool")
147 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
149 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
152 produces<nanoaod::FlatTable>();
161 desc.add<
std::string>(
"doc",
"")->setComment(
"few words of self documentation");
162 desc.add<
bool>(
"extension",
false)->setComment(
"whether or not to extend an existing same table");
163 desc.add<
bool>(
"skipNonExistingSrc",
false)
164 ->setComment(
"whether or not to skip producing the table on absent input product");
165 desc.add<
edm::InputTag>(
"src")->setComment(
"input collection to fill the flat table");
168 variable.add<
std::string>(
"expr")->setComment(
"a function to define the content of the branch in the flat table");
169 variable.add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
172 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
173 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"int8",
"uint8",
"int16",
"uint16",
"bool"));
176 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
178 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
182 variables.setComment(
"a parameters set to define all variable to fill the flat table");
219 std::vector<std::unique_ptr<Variable<T>>>
vars_;
222 template <
typename T>
229 :
std::numeric_limits<unsigned
int>::
max()),
238 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
239 else if (type ==
"uint")
241 std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
242 else if (type ==
"float")
244 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
245 else if (type ==
"double")
247 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
248 else if (type ==
"int8")
250 std::make_unique<Int8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
251 else if (type ==
"uint8")
253 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
254 else if (type ==
"int16")
256 std::make_unique<Int16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
257 else if (type ==
"uint16")
259 std::make_unique<UInt16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
260 else if (type ==
"bool")
262 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
264 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
275 "singleton",
false,
true,
edm::Comment(
"whether or not the input collection is single-element")),
277 "cut",
"",
true,
edm::Comment(
"selection on the main input collection"))
or 279 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
280 "define the maximum length of the input collection to put in the branch");
283 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
284 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
287 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
288 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"int8",
"uint8",
"int16",
"uint16",
"bool"));
291 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
293 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
297 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
307 std::vector<const T *> selobjs;
308 std::vector<edm::Ptr<T>> selptrs;
312 selobjs.push_back(&(*
prod)[0]);
314 selptrs.emplace_back(
prod->ptrAt(0));
316 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
317 const auto &
obj = (*prod)[
i];
319 selobjs.push_back(&
obj);
321 selptrs.emplace_back(
prod->ptrAt(
i));
332 var->fill(iEvent, selptrs, *
out);
350 std::vector<std::unique_ptr<ExtVariable<T>>>
extvars_;
353 template <
typename T>
359 :
std::numeric_limits<unsigned
int>::
max()),
369 "BXVectorSimpleFlatTableProducer already defines the " +
bxVarName_ +
370 "internally and thus you should not specify it yourself");
377 "selection on the main input collection (but selection can not be bx based)");
378 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
379 "define the maximum length of the input collection to put in the branch");
380 desc.add<
int>(
"minBX", -2)->setComment(
"min bx (inclusive) to include");
381 desc.add<
int>(
"maxBX", 2)->setComment(
"max bx (inclusive) to include");
382 desc.add<
bool>(
"alwaysWriteBXValue",
true)
383 ->setComment(
"always write the bx number (event when only one bx can be present, ie minBX==maxBX)");
389 std::vector<const T *> selObjs;
390 std::vector<int> selObjBXs;
396 for (
size_t objNr = 0, nrObjs =
prod->size(
bx); objNr < nrObjs; ++objNr) {
399 selObjs.push_back(&
obj);
400 selObjBXs.push_back(
bx);
407 auto out = std::make_unique<nanoaod::FlatTable>(selObjs.size(), this->
name_,
false, this->
extension_);
411 out->template addColumn<int16_t>(
bxVarName_, selObjBXs,
"BX of the L1 candidate");
425 template <
typename T>
438 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
439 std::vector<const T *> selobjs(1,
prod.product());
446 template <
typename T>
461 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
462 std::vector<const T *> selobjs(1, &(*
prod)[0]);
473 template <
typename T,
typename TProd>
475 :
public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<int>> {
490 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
491 else if (
type ==
"float")
492 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
493 else if (
type ==
"uint8")
494 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
495 else if (
type ==
"bool")
496 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
498 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
501 produces<nanoaod::FlatTable, edm::Transition::EndLuminosityBlock>();
542 std::vector<std::unique_ptr<Variable<T>>>
vars_;
546 template <
typename T>
561 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
562 std::vector<const T *> selobjs(1,
prod.product());
570 template <
typename T,
typename TProd>
576 :
std::numeric_limits<unsigned
int>::
max()),
583 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
584 "define the maximum length of the input collection to put in the branch");
590 std::vector<const T *> selobjs;
592 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
593 const auto &
obj = (*prod)[
i];
595 selobjs.push_back(&
obj);
601 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
616 template <
typename T,
typename TProd>
632 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
633 else if (
type ==
"float")
634 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
635 else if (
type ==
"uint8")
636 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
637 else if (
type ==
"bool")
638 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
640 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
643 produces<nanoaod::FlatTable, edm::Transition::EndRun>();
680 std::vector<std::unique_ptr<Variable<T>>>
vars_;
684 template <
typename T>
692 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
693 std::vector<const T *> selobjs(1,
prod.product());
701 template <
typename T,
typename TProd>
707 :
std::numeric_limits<unsigned
int>::
max()),
713 std::vector<const T *> selobjs;
715 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
716 const auto &
obj = (*prod)[
i];
718 selobjs.push_back(&
obj);
724 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
constexpr char const * varNames[]
FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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
const StringCutObjectSelector< T > cut_
~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_
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
BXVectorSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
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
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< BXVector< T >> &prod) const override
static float reduceMantissaToNbitsRounding(const float &f)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
const bool alwaysWriteBXValue_
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()
const std::string bxVarName_