38 template <
typename ObjType>
45 template <
typename ObjType,
typename StringFunctor,
typename ValType>
56 std::vector<ValType> vals(selobjs.size());
57 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
59 if constexpr (std::is_same<ValType, float>()) {
77 template <
typename ObjType>
86 template <
typename ObjType,
typename TIn,
typename ValType = TIn>
100 std::vector<ValType> vals;
102 vals.resize(selptrs.size());
103 for (
unsigned int i = 0,
n = vals.size();
i <
n; ++
i) {
105 vals[
i] = this->
eval(vmap, selptrs[
i]);
116 template <
typename ObjType,
typename TIn,
typename ValType = TIn>
125 ValType
val = (*vmap)[
op];
130 template <
typename ObjType,
typename TIn,
typename StringFunctor,
typename ValType>
144 if constexpr (std::is_same<ValType, float>()) {
164 template <
typename T,
typename TProd>
178 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
179 else if (
type ==
"uint")
180 vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
181 else if (
type ==
"float")
182 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
183 else if (
type ==
"double")
184 vars_.push_back(std::make_unique<DoubleVar>(vname, varPSet));
185 else if (
type ==
"uint8")
186 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
187 else if (
type ==
"int16")
188 vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
189 else if (
type ==
"uint16")
190 vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
191 else if (
type ==
"bool")
192 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
194 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
197 produces<nanoaod::FlatTable>();
206 desc.add<
std::string>(
"doc",
"")->setComment(
"few words of self documentation");
207 desc.add<
bool>(
"extension",
false)->setComment(
"whether or not to extend an existing same table");
208 desc.add<
bool>(
"skipNonExistingSrc",
false)
209 ->setComment(
"whether or not to skip producing the table on absent input product");
210 desc.add<
edm::InputTag>(
"src")->setComment(
"input collection to fill the flat table");
213 variable.add<
std::string>(
"expr")->setComment(
"a function to define the content of the branch in the flat table");
214 variable.add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
217 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
218 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"uint8",
"int16",
"uint16",
"bool"));
221 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
223 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
227 variables.setComment(
"a parameters set to define all variable to fill the flat table");
263 std::vector<std::unique_ptr<Variable<T>>>
vars_;
266 template <
typename T>
273 :
std::numeric_limits<unsigned
int>::
max()),
282 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
283 else if (type ==
"uint")
285 std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
286 else if (type ==
"float")
288 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
289 else if (type ==
"double")
291 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
292 else if (type ==
"uint8")
294 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
295 else if (type ==
"int16")
297 std::make_unique<Int16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
298 else if (type ==
"uint16")
300 std::make_unique<UInt16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
301 else if (type ==
"bool")
303 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
305 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
316 "singleton",
false,
true,
edm::Comment(
"whether or not the input collection is single-element")),
318 "cut",
"",
true,
edm::Comment(
"selection on the main input collection"))
or 320 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
321 "define the maximum length of the input collection to put in the branch");
324 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
325 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
328 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
329 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"uint8",
"int16",
"uint16",
"bool"));
332 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
335 edm::Comment(
"the precision with which to store the value in the " 336 "flat table, as a function of the object evaluated")),
340 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
353 std::vector<const T *> selobjs;
354 std::vector<edm::Ptr<T>> selptrs;
358 selobjs.push_back(&(*
prod)[0]);
360 selptrs.emplace_back(
prod->ptrAt(0));
362 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
363 const auto &
obj = (*prod)[
i];
365 selobjs.push_back(&
obj);
367 selptrs.emplace_back(
prod->ptrAt(
i));
378 var->fill(iEvent, selptrs, *
out);
380 var->fill(iEvent, selptrs, *
out);
397 std::vector<std::unique_ptr<ExtVariable<T>>>
extvars_;
401 template <
typename T,
typename V>
411 std::make_unique<IntTypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
412 else if (type ==
"uint")
414 std::make_unique<UIntTypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
415 else if (type ==
"float")
417 std::make_unique<FloatTypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
418 else if (type ==
"double")
420 std::make_unique<DoubleTypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
421 else if (type ==
"uint8")
423 std::make_unique<UInt8TypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
424 else if (type ==
"int16")
426 std::make_unique<Int16TypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
427 else if (type ==
"uint16")
429 std::make_unique<UInt16TypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
430 else if (type ==
"bool")
432 std::make_unique<BoolTypedExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
434 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
441 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
443 "a function to define the content of the branch in the flat table");
444 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
447 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
448 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"uint8",
"int16",
"uint16",
"bool"));
451 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
454 edm::Comment(
"the precision with which to store the value in the " 455 "flat table, as a function of the object evaluated")),
459 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
478 template <
typename T>
484 :
std::numeric_limits<unsigned
int>::
max()),
494 "BXVectorSimpleFlatTableProducer already defines the " +
bxVarName_ +
495 "internally and thus you should not specify it yourself");
502 "selection on the main input collection (but selection can not be bx based)");
503 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
504 "define the maximum length of the input collection to put in the branch");
505 desc.add<
int>(
"minBX", -2)->setComment(
"min bx (inclusive) to include");
506 desc.add<
int>(
"maxBX", 2)->setComment(
"max bx (inclusive) to include");
507 desc.add<
bool>(
"alwaysWriteBXValue",
true)
508 ->setComment(
"always write the bx number (event when only one bx can be present, ie minBX==maxBX)");
514 std::vector<const T *> selObjs;
515 std::vector<int> selObjBXs;
521 for (
size_t objNr = 0, nrObjs =
prod->size(
bx); objNr < nrObjs; ++objNr) {
524 selObjs.push_back(&
obj);
525 selObjBXs.push_back(
bx);
532 auto out = std::make_unique<nanoaod::FlatTable>(selObjs.size(), this->
name_,
false, this->
extension_);
536 out->template addColumn<int16_t>(
bxVarName_, selObjBXs,
"BX of the L1 candidate");
550 template <
typename T>
563 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
564 std::vector<const T *> selobjs(1,
prod.product());
571 template <
typename T>
586 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
587 std::vector<const T *> selobjs(1, &(*
prod)[0]);
598 template <
typename T,
typename TProd>
600 :
public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<int>> {
615 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
616 else if (
type ==
"float")
617 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
618 else if (
type ==
"uint8")
619 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
620 else if (
type ==
"bool")
621 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
623 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
626 produces<nanoaod::FlatTable, edm::Transition::EndLuminosityBlock>();
667 std::vector<std::unique_ptr<Variable<T>>>
vars_;
671 template <
typename T>
686 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
687 std::vector<const T *> selobjs(1,
prod.product());
695 template <
typename T,
typename TProd>
701 :
std::numeric_limits<unsigned
int>::
max()),
708 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
709 "define the maximum length of the input collection to put in the branch");
715 std::vector<const T *> selobjs;
717 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
718 const auto &
obj = (*prod)[
i];
720 selobjs.push_back(&
obj);
726 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
741 template <
typename T,
typename TProd>
757 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
758 else if (
type ==
"float")
759 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
760 else if (
type ==
"uint8")
761 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
762 else if (
type ==
"bool")
763 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
765 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
768 produces<nanoaod::FlatTable, edm::Transition::EndRun>();
805 std::vector<std::unique_ptr<Variable<T>>>
vars_;
809 template <
typename T>
817 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
818 std::vector<const T *> selobjs(1,
prod.product());
826 template <
typename T,
typename TProd>
832 :
std::numeric_limits<unsigned
int>::
max()),
838 std::vector<const T *> selobjs;
840 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
841 const auto &
obj = (*prod)[
i];
843 selobjs.push_back(&
obj);
849 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
ValueMapVariable< T, double, float > DoubleExtVar
SimpleTypedExternalFlatTableProducer(edm::ParameterSet const ¶ms)
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
TypedValueMapVariable< T, V, StringObjectFunction< V >, double > DoubleTypedExtVar
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
TypedValueMapVariable< T, V, StringObjectFunction< V >, uint16_t > UInt16TypedExtVar
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
TypedValueMapVariable< T, V, StringObjectFunction< V >, uint32_t > UIntTypedExtVar
FuncVariable< T, StringObjectFunction< T >, uint32_t > UIntVar
FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
const bool skipNonExistingSrc_
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)
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
ValType eval(const edm::Handle< edm::ValueMap< TIn >> &vmap, const edm::Ptr< ObjType > &op) const override
TypedValueMapVariable(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc=false)
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_
TypedValueMapVariable< T, V, StringObjectFunction< V >, float > FloatTypedExtVar
~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
TypedValueMapVariable< T, V, StringObjectFunction< V >, int16_t > Int16TypedExtVar
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 > > > typedextvars_
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)
static edm::ParameterSetDescription baseDescriptions()
ExtVariable(const std::string &aname, const edm::ParameterSet &cfg)
TypedValueMapVariable< T, V, StringCutObjectSelector< V >, bool > BoolTypedExtVar
SimpleFlatTableProducer(edm::ParameterSet const ¶ms)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual ValType eval(const edm::Handle< edm::ValueMap< TIn >> &vmap, const edm::Ptr< ObjType > &op) const =0
ValueMapVariableBase(const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc=false)
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Run &iRun, const edm::Handle< TProd > &prod) const override
edm::EDGetTokenT< edm::ValueMap< TIn > > token_
const unsigned int maxLen_
const unsigned int maxLen_
TypedValueMapVariable< T, V, StringObjectFunction< V >, int32_t > IntTypedExtVar
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
StringObjectFunction< ObjType > precisionFunc_
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)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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
TypedValueMapVariable< T, V, StringObjectFunction< V >, uint8_t > UInt8TypedExtVar
ValueMapVariable< T, int32_t > IntExtVar
std::vector< std::unique_ptr< Variable< T > > > vars_
ValType eval(const edm::Handle< edm::ValueMap< TIn >> &vmap, const edm::Ptr< ObjType > &op) const override
LumiSimpleFlatTableProducer(edm::ParameterSet const ¶ms)
~SimpleTypedExternalFlatTableProducer() override
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_
void fill(const edm::Event &iEvent, std::vector< edm::Ptr< ObjType >> selptrs, nanoaod::FlatTable &out) const override