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 ==
"uint8")
139 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
140 else if (
type ==
"int16")
141 vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
142 else if (
type ==
"uint16")
143 vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
144 else if (
type ==
"bool")
145 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
147 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
150 produces<nanoaod::FlatTable>();
159 desc.add<
std::string>(
"doc",
"")->setComment(
"few words of self documentation");
160 desc.add<
bool>(
"extension",
false)->setComment(
"whether or not to extend an existing same table");
161 desc.add<
bool>(
"skipNonExistingSrc",
false)
162 ->setComment(
"whether or not to skip producing the table on absent input product");
163 desc.add<
edm::InputTag>(
"src")->setComment(
"input collection to fill the flat table");
166 variable.add<
std::string>(
"expr")->setComment(
"a function to define the content of the branch in the flat table");
167 variable.add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
170 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
171 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"uint8",
"int16",
"uint16",
"bool"));
174 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
176 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
180 variables.setComment(
"a parameters set to define all variable to fill the flat table");
216 std::vector<std::unique_ptr<Variable<T>>>
vars_;
219 template <
typename T>
226 :
std::numeric_limits<unsigned
int>::
max()),
235 std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
236 else if (type ==
"uint")
238 std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
239 else if (type ==
"float")
241 std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
242 else if (type ==
"double")
244 std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
245 else if (type ==
"uint8")
247 std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
248 else if (type ==
"int16")
250 std::make_unique<Int16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
251 else if (type ==
"uint16")
253 std::make_unique<UInt16ExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
254 else if (type ==
"bool")
256 std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->
skipNonExistingSrc_));
258 throw cms::Exception(
"Configuration",
"unsupported type " + type +
" for variable " + vname);
269 "singleton",
false,
true,
edm::Comment(
"whether or not the input collection is single-element")),
271 "cut",
"",
true,
edm::Comment(
"selection on the main input collection"))
or 273 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
274 "define the maximum length of the input collection to put in the branch");
277 extvariable.
add<
edm::InputTag>(
"src")->setComment(
"valuemap input collection to fill the flat table");
278 extvariable.
add<
std::string>(
"doc")->setComment(
"few words description of the branch content");
281 "type",
"int",
true,
edm::Comment(
"the c++ type of the branch in the flat table")),
282 edm::allowedValues<std::string>(
"int",
"uint",
"float",
"double",
"uint8",
"int16",
"uint16",
"bool"));
285 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")) xor
287 "precision",
true,
edm::Comment(
"the precision with which to store the value in the flat table")),
291 extvariables.
setComment(
"a parameters set to define all variable taken form valuemap to fill the flat table");
301 std::vector<const T *> selobjs;
302 std::vector<edm::Ptr<T>> selptrs;
306 selobjs.push_back(&(*
prod)[0]);
308 selptrs.emplace_back(
prod->ptrAt(0));
310 for (
unsigned int i = 0,
n =
prod->size();
i <
n; ++
i) {
311 const auto &
obj = (*prod)[
i];
313 selobjs.push_back(&
obj);
315 selptrs.emplace_back(
prod->ptrAt(
i));
326 var->fill(iEvent, selptrs, *
out);
343 std::vector<std::unique_ptr<ExtVariable<T>>>
extvars_;
346 template <
typename T>
352 :
std::numeric_limits<unsigned
int>::
max()),
362 "BXVectorSimpleFlatTableProducer already defines the " +
bxVarName_ +
363 "internally and thus you should not specify it yourself");
370 "selection on the main input collection (but selection can not be bx based)");
371 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
372 "define the maximum length of the input collection to put in the branch");
373 desc.add<
int>(
"minBX", -2)->setComment(
"min bx (inclusive) to include");
374 desc.add<
int>(
"maxBX", 2)->setComment(
"max bx (inclusive) to include");
375 desc.add<
bool>(
"alwaysWriteBXValue",
true)
376 ->setComment(
"always write the bx number (event when only one bx can be present, ie minBX==maxBX)");
382 std::vector<const T *> selObjs;
383 std::vector<int> selObjBXs;
389 for (
size_t objNr = 0, nrObjs =
prod->size(
bx); objNr < nrObjs; ++objNr) {
392 selObjs.push_back(&
obj);
393 selObjBXs.push_back(
bx);
400 auto out = std::make_unique<nanoaod::FlatTable>(selObjs.size(), this->
name_,
false, this->
extension_);
404 out->template addColumn<int16_t>(
bxVarName_, selObjBXs,
"BX of the L1 candidate");
418 template <
typename T>
431 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
432 std::vector<const T *> selobjs(1,
prod.product());
439 template <
typename T>
454 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
455 std::vector<const T *> selobjs(1, &(*
prod)[0]);
466 template <
typename T,
typename TProd>
468 :
public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::LuminosityBlockCache<int>> {
483 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
484 else if (
type ==
"float")
485 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
486 else if (
type ==
"uint8")
487 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
488 else if (
type ==
"bool")
489 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
491 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
494 produces<nanoaod::FlatTable, edm::Transition::EndLuminosityBlock>();
535 std::vector<std::unique_ptr<Variable<T>>>
vars_;
539 template <
typename T>
554 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
555 std::vector<const T *> selobjs(1,
prod.product());
563 template <
typename T,
typename TProd>
569 :
std::numeric_limits<unsigned
int>::
max()),
576 desc.addOptional<
unsigned int>(
"maxLen")->setComment(
577 "define the maximum length of the input collection to put in the branch");
583 std::vector<const T *> selobjs;
585 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
586 const auto &
obj = (*prod)[
i];
588 selobjs.push_back(&
obj);
594 auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->
name_,
false, this->
extension_);
609 template <
typename T,
typename TProd>
625 vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
626 else if (
type ==
"float")
627 vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
628 else if (
type ==
"uint8")
629 vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
630 else if (
type ==
"bool")
631 vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
633 throw cms::Exception(
"Configuration",
"unsupported type " +
type +
" for variable " + vname);
636 produces<nanoaod::FlatTable, edm::Transition::EndRun>();
673 std::vector<std::unique_ptr<Variable<T>>>
vars_;
677 template <
typename T>
685 auto out = std::make_unique<nanoaod::FlatTable>(1, this->
name_,
true, this->
extension_);
686 std::vector<const T *> selobjs(1,
prod.product());
694 template <
typename T,
typename TProd>
700 :
std::numeric_limits<unsigned
int>::
max()),
706 std::vector<const T *> selobjs;
708 for (
unsigned int i = 0,
n = prod->size();
i <
n; ++
i) {
709 const auto &
obj = (*prod)[
i];
711 selobjs.push_back(&
obj);
717 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)
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
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_