CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes
SimpleFlatTableProducer< T > Class Template Reference

#include <SimpleFlatTableProducer.h>

Inheritance diagram for SimpleFlatTableProducer< T >:
SimpleFlatTableProducerBase< T, edm::View< T > > edm::stream::EDProducer<> SimpleTypedExternalFlatTableProducer< T, V >

Public Member Functions

std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< edm::View< T >> &prod) const override
 
 SimpleFlatTableProducer (edm::ParameterSet const &params)
 
 ~SimpleFlatTableProducer () override
 
- Public Member Functions inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
virtual std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< edm::View< T > > &prod) const=0
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 SimpleFlatTableProducerBase (edm::ParameterSet const &params)
 
 ~SimpleFlatTableProducerBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static edm::ParameterSetDescription baseDescriptions ()
 
static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
static edm::ParameterSetDescription baseDescriptions ()
 

Protected Types

typedef ValueMapVariable< T, bool > BoolExtVar
 
typedef ValueMapVariable< T, double, float > DoubleExtVar
 
typedef ValueMapVariable< T, float > FloatExtVar
 
typedef ValueMapVariable< T, int, int16_t > Int16ExtVar
 
typedef ValueMapVariable< T, int32_t > IntExtVar
 
typedef ValueMapVariable< T, int, uint16_t > UInt16ExtVar
 
typedef ValueMapVariable< T, int, uint8_t > UInt8ExtVar
 
typedef ValueMapVariable< T, uint32_t > UIntExtVar
 
- Protected Types inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
typedef FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
 
typedef FuncVariable< T, StringObjectFunction< T >, double > DoubleVar
 
typedef FuncVariable< T, StringObjectFunction< T >, float > FloatVar
 
typedef FuncVariable< T, StringObjectFunction< T >, int16_t > Int16Var
 
typedef FuncVariable< T, StringObjectFunction< T >, int32_t > IntVar
 
typedef FuncVariable< T, StringObjectFunction< T >, uint16_t > UInt16Var
 
typedef FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
 
typedef FuncVariable< T, StringObjectFunction< T >, uint32_t > UIntVar
 

Protected Attributes

const StringCutObjectSelector< Tcut_
 
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
 
const unsigned int maxLen_
 
bool singleton_
 
std::vector< std::unique_ptr< ExtVariable< T > > > typedextvars_
 
- Protected Attributes inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
const std::string doc_
 
const bool extension_
 
const std::string name_
 
const bool skipNonExistingSrc_
 
const edm::EDGetTokenT< edm::View< T > > src_
 
std::vector< std::unique_ptr< Variable< T > > > vars_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T>
class SimpleFlatTableProducer< T >

Definition at line 269 of file SimpleFlatTableProducer.h.

Member Typedef Documentation

◆ BoolExtVar

template<typename T >
typedef ValueMapVariable<T, bool> SimpleFlatTableProducer< T >::BoolExtVar
protected

Definition at line 402 of file SimpleFlatTableProducer.h.

◆ DoubleExtVar

template<typename T >
typedef ValueMapVariable<T, double, float> SimpleFlatTableProducer< T >::DoubleExtVar
protected

Definition at line 401 of file SimpleFlatTableProducer.h.

◆ FloatExtVar

template<typename T >
typedef ValueMapVariable<T, float> SimpleFlatTableProducer< T >::FloatExtVar
protected

Definition at line 400 of file SimpleFlatTableProducer.h.

◆ Int16ExtVar

template<typename T >
typedef ValueMapVariable<T, int, int16_t> SimpleFlatTableProducer< T >::Int16ExtVar
protected

Definition at line 404 of file SimpleFlatTableProducer.h.

◆ IntExtVar

template<typename T >
typedef ValueMapVariable<T, int32_t> SimpleFlatTableProducer< T >::IntExtVar
protected

Definition at line 398 of file SimpleFlatTableProducer.h.

◆ UInt16ExtVar

template<typename T >
typedef ValueMapVariable<T, int, uint16_t> SimpleFlatTableProducer< T >::UInt16ExtVar
protected

Definition at line 405 of file SimpleFlatTableProducer.h.

◆ UInt8ExtVar

template<typename T >
typedef ValueMapVariable<T, int, uint8_t> SimpleFlatTableProducer< T >::UInt8ExtVar
protected

Definition at line 403 of file SimpleFlatTableProducer.h.

◆ UIntExtVar

template<typename T >
typedef ValueMapVariable<T, uint32_t> SimpleFlatTableProducer< T >::UIntExtVar
protected

Definition at line 399 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ SimpleFlatTableProducer()

template<typename T >
SimpleFlatTableProducer< T >::SimpleFlatTableProducer ( edm::ParameterSet const &  params)
inline

Definition at line 271 of file SimpleFlatTableProducer.h.

References Exception, SimpleFlatTableProducer< T >::extvars_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), submitPVValidationJobs::params, SimpleFlatTableProducerBase< T, edm::View< T > >::skipNonExistingSrc_, and AlCaHLTBitMon_QueryRunRegistry::string.

273  singleton_(params.getParameter<bool>("singleton")),
274  maxLen_(params.existsAs<unsigned int>("maxLen") ? params.getParameter<unsigned int>("maxLen")
276  cut_(!singleton_ ? params.getParameter<std::string>("cut") : "",
277  !singleton_ ? params.getUntrackedParameter<bool>("lazyEval") : false) {
278  if (params.existsAs<edm::ParameterSet>("externalVariables")) {
279  edm::ParameterSet const &extvarsPSet = params.getParameter<edm::ParameterSet>("externalVariables");
280  for (const std::string &vname : extvarsPSet.getParameterNamesForType<edm::ParameterSet>()) {
281  const auto &varPSet = extvarsPSet.getParameter<edm::ParameterSet>(vname);
282  const std::string &type = varPSet.getParameter<std::string>("type");
283  if (type == "int")
284  extvars_.push_back(
285  std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
286  else if (type == "uint")
287  extvars_.push_back(
288  std::make_unique<UIntExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
289  else if (type == "float")
290  extvars_.push_back(
291  std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
292  else if (type == "double")
293  extvars_.push_back(
294  std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
295  else if (type == "uint8")
296  extvars_.push_back(
297  std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
298  else if (type == "int16")
299  extvars_.push_back(
300  std::make_unique<Int16ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
301  else if (type == "uint16")
302  extvars_.push_back(
303  std::make_unique<UInt16ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
304  else if (type == "bool")
305  extvars_.push_back(
306  std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
307  else
308  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
309  }
310  }
311  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:180
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
const StringCutObjectSelector< T > cut_

◆ ~SimpleFlatTableProducer()

template<typename T >
SimpleFlatTableProducer< T >::~SimpleFlatTableProducer ( )
inlineoverride

Definition at line 313 of file SimpleFlatTableProducer.h.

313 {}

Member Function Documentation

◆ baseDescriptions()

template<typename T >
static edm::ParameterSetDescription SimpleFlatTableProducer< T >::baseDescriptions ( )
inlinestatic

Definition at line 315 of file SimpleFlatTableProducer.h.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptionalNode(), submitPVResolutionJobs::desc, edm::ParameterSetDescription::ifValue(), or, edm::RequireZeroOrMore, edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by SimpleFlatTableProducer< T >::fillDescriptions(), and SimpleTypedExternalFlatTableProducer< T, V >::fillDescriptions().

315  {
317 
318  desc.ifValue(
320  "singleton", false, true, edm::Comment("whether or not the input collection is single-element")),
322  "cut", "", true, edm::Comment("selection on the main input collection")) and
324  false,
325  false,
326  edm::Comment("if true, can use methods of inheriting classes. Can "
327  "cause problems when multi-threading."))) or
328  true >> edm::EmptyGroupDescription());
329  desc.addOptional<unsigned int>("maxLen")->setComment(
330  "define the maximum length of the input collection to put in the branch");
331 
332  edm::ParameterSetDescription extvariable;
333  extvariable.add<edm::InputTag>("src")->setComment("valuemap input collection to fill the flat table");
334  extvariable.add<std::string>("doc")->setComment("few words description of the branch content");
335  extvariable.ifValue(
337  "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
338  edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16", "bool"));
339  extvariable.addOptionalNode(
341  "precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
343  true,
344  edm::Comment("the precision with which to store the value in the "
345  "flat table, as a function of the object evaluated")),
346  false);
347 
348  edm::ParameterSetDescription extvariables;
349  extvariables.setComment("a parameters set to define all variable taken form valuemap to fill the flat table");
350  extvariables.addOptionalNode(
352  desc.addOptional<edm::ParameterSetDescription>("externalVariables", extvariables);
353 
354  return desc;
355  }
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T >> cases)
void setComment(std::string const &value)
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
Definition: Activities.doc:12
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
static edm::ParameterSetDescription baseDescriptions()
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ fillDescriptions()

template<typename T >
static void SimpleFlatTableProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

◆ fillTable()

template<typename T >
std::unique_ptr<nanoaod::FlatTable> SimpleFlatTableProducer< T >::fillTable ( const edm::Event iEvent,
const edm::Handle< edm::View< T >> &  prod 
) const
inlineoverride

Definition at line 360 of file SimpleFlatTableProducer.h.

References cms::cuda::assert(), SimpleFlatTableProducer< T >::cut_, SimpleFlatTableProducerBase< T, edm::View< T > >::extension_, SimpleFlatTableProducer< T >::extvars_, mps_fire::i, SimpleFlatTableProducer< T >::maxLen_, create_idmaps::n, SimpleFlatTableProducerBase< T, edm::View< T > >::name_, getGTfromDQMFile::obj, MillePedeFileConverter_cfg::out, copyEcalPFRecHitThresholds_cfg::prod, SimpleFlatTableProducer< T >::singleton_, SimpleFlatTableProducerBase< T, edm::View< T > >::skipNonExistingSrc_, SimpleFlatTableProducer< T >::typedextvars_, ALCARECOEcalPhiSym_cff::var, and SimpleFlatTableProducerBase< T, edm::View< T > >::vars_.

361  {
362  std::vector<const T *> selobjs;
363  std::vector<edm::Ptr<T>> selptrs; // for external variables
364  if (prod.isValid() || !(this->skipNonExistingSrc_)) {
365  if (singleton_) {
366  assert(prod->size() == 1);
367  selobjs.push_back(&(*prod)[0]);
368  if (!extvars_.empty() || !typedextvars_.empty())
369  selptrs.emplace_back(prod->ptrAt(0));
370  } else {
371  for (unsigned int i = 0, n = prod->size(); i < n; ++i) {
372  const auto &obj = (*prod)[i];
373  if (cut_(obj)) {
374  selobjs.push_back(&obj);
375  if (!extvars_.empty() || !typedextvars_.empty())
376  selptrs.emplace_back(prod->ptrAt(i));
377  }
378  if (selobjs.size() >= maxLen_)
379  break;
380  }
381  }
382  }
383  auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->name_, singleton_, this->extension_);
384  for (const auto &var : this->vars_)
385  var->fill(selobjs, *out);
386  for (const auto &var : this->extvars_)
387  var->fill(iEvent, selptrs, *out);
388  for (const auto &var : this->typedextvars_)
389  var->fill(iEvent, selptrs, *out);
390  return out;
391  }
assert(be >=bs)
std::vector< std::unique_ptr< ExtVariable< T > > > typedextvars_
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
std::vector< std::unique_ptr< Variable< T > > > vars_
const StringCutObjectSelector< T > cut_

Member Data Documentation

◆ cut_

template<typename T >
const StringCutObjectSelector<T> SimpleFlatTableProducer< T >::cut_
protected

Definition at line 396 of file SimpleFlatTableProducer.h.

Referenced by SimpleFlatTableProducer< T >::fillTable().

◆ extvars_

template<typename T >
std::vector<std::unique_ptr<ExtVariable<T> > > SimpleFlatTableProducer< T >::extvars_
protected

◆ maxLen_

template<typename T >
const unsigned int SimpleFlatTableProducer< T >::maxLen_
protected

Definition at line 395 of file SimpleFlatTableProducer.h.

Referenced by SimpleFlatTableProducer< T >::fillTable().

◆ singleton_

template<typename T >
bool SimpleFlatTableProducer< T >::singleton_
protected

Definition at line 394 of file SimpleFlatTableProducer.h.

Referenced by SimpleFlatTableProducer< T >::fillTable().

◆ typedextvars_

template<typename T >
std::vector<std::unique_ptr<ExtVariable<T> > > SimpleFlatTableProducer< T >::typedextvars_
protected