CMS 3D CMS Logo

List of all members | 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<>

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
 

Protected Types

typedef ValueMapVariable< T, bool > BoolExtVar
 
typedef ValueMapVariable< T, double, float > DoubleExtVar
 
typedef ValueMapVariable< T, float > FloatExtVar
 
typedef ValueMapVariable< T, int, int8_t > Int8ExtVar
 
typedef ValueMapVariable< T, int > IntExtVar
 
typedef ValueMapVariable< T, int, uint8_t > UInt8ExtVar
 
- Protected Types inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
typedef FuncVariable< T, StringCutObjectSelector< T >, bool > BoolVar
 
typedef FuncVariable< T, StringObjectFunction< T >, float > FloatVar
 
typedef FuncVariable< T, StringObjectFunction< T >, int8_t > Int8Var
 
typedef FuncVariable< T, StringObjectFunction< T >, int > IntVar
 
typedef FuncVariable< T, StringObjectFunction< T >, uint8_t > UInt8Var
 
typedef FuncVariable< T, StringObjectFunction< T >, unsigned int > UIntVar
 

Protected Attributes

const StringCutObjectSelector< Tcut_
 
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
 
const unsigned int maxLen_
 
bool singleton_
 
- 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 176 of file SimpleFlatTableProducer.h.

Member Typedef Documentation

◆ BoolExtVar

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

Definition at line 254 of file SimpleFlatTableProducer.h.

◆ DoubleExtVar

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

Definition at line 253 of file SimpleFlatTableProducer.h.

◆ FloatExtVar

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

Definition at line 252 of file SimpleFlatTableProducer.h.

◆ Int8ExtVar

template<typename T >
typedef ValueMapVariable<T, int, int8_t> SimpleFlatTableProducer< T >::Int8ExtVar
protected

Definition at line 255 of file SimpleFlatTableProducer.h.

◆ IntExtVar

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

Definition at line 251 of file SimpleFlatTableProducer.h.

◆ UInt8ExtVar

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

Definition at line 256 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ SimpleFlatTableProducer()

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

Definition at line 178 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.

180  singleton_(params.getParameter<bool>("singleton")),
181  maxLen_(params.existsAs<unsigned int>("maxLen") ? params.getParameter<unsigned int>("maxLen")
183  cut_(!singleton_ ? params.getParameter<std::string>("cut") : "", true) {
184  if (params.existsAs<edm::ParameterSet>("externalVariables")) {
185  edm::ParameterSet const &extvarsPSet = params.getParameter<edm::ParameterSet>("externalVariables");
186  for (const std::string &vname : extvarsPSet.getParameterNamesForType<edm::ParameterSet>()) {
187  const auto &varPSet = extvarsPSet.getParameter<edm::ParameterSet>(vname);
188  const std::string &type = varPSet.getParameter<std::string>("type");
189  if (type == "int")
190  extvars_.push_back(
191  std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
192  else if (type == "float")
193  extvars_.push_back(
194  std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
195  else if (type == "double")
196  extvars_.push_back(
197  std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
198  else if (type == "int8")
199  extvars_.push_back(
200  std::make_unique<Int8ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
201  else if (type == "uint8")
202  extvars_.push_back(
203  std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
204  else if (type == "bool")
205  extvars_.push_back(
206  std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
207  else
208  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
209  }
210  }
211  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
std::vector< std::unique_ptr< ExtVariable< T > > > extvars_
const StringCutObjectSelector< T > cut_

◆ ~SimpleFlatTableProducer()

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

Definition at line 213 of file SimpleFlatTableProducer.h.

213 {}

Member Function Documentation

◆ 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 215 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_, dqmiodumpmetadata::n, SimpleFlatTableProducerBase< T, edm::View< T > >::name_, getGTfromDQMFile::obj, MillePedeFileConverter_cfg::out, dumpMFGeometry_cfg::prod, SimpleFlatTableProducer< T >::singleton_, SimpleFlatTableProducerBase< T, edm::View< T > >::skipNonExistingSrc_, trigObjTnPSource_cfi::var, and SimpleFlatTableProducerBase< T, edm::View< T > >::vars_.

216  {
217  std::vector<const T *> selobjs;
218  std::vector<edm::Ptr<T>> selptrs; // for external variables
219  if (prod.isValid() || !(this->skipNonExistingSrc_)) {
220  if (singleton_) {
221  assert(prod->size() == 1);
222  selobjs.push_back(&(*prod)[0]);
223  if (!extvars_.empty())
224  selptrs.emplace_back(prod->ptrAt(0));
225  } else {
226  for (unsigned int i = 0, n = prod->size(); i < n; ++i) {
227  const auto &obj = (*prod)[i];
228  if (cut_(obj)) {
229  selobjs.push_back(&obj);
230  if (!extvars_.empty())
231  selptrs.emplace_back(prod->ptrAt(i));
232  }
233  if (selobjs.size() >= maxLen_)
234  break;
235  }
236  }
237  }
238  auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->name_, singleton_, this->extension_);
239  for (const auto &var : this->vars_)
240  var->fill(selobjs, *out);
241  for (const auto &var : this->extvars_)
242  var->fill(iEvent, selptrs, *out);
243  return out;
244  }
assert(be >=bs)
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 249 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 248 of file SimpleFlatTableProducer.h.

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

◆ singleton_

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

Definition at line 247 of file SimpleFlatTableProducer.h.

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