CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | 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<>

Classes

class  ExtVariable
 
class  ValueMapVariable
 

Public Types

typedef
SimpleFlatTableProducerBase< T,
edm::View< T > > 
base
 
- 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
 

Public Member Functions

std::unique_ptr
< nanoaod::FlatTable
fillTable (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::FlatTable
fillTable (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< bool > BoolExtVar
 
typedef ValueMapVariable
< double, float > 
DoubleExtVar
 
typedef ValueMapVariable< float > FloatExtVar
 
typedef ValueMapVariable< int > IntExtVar
 
typedef ValueMapVariable< int,
uint8_t > 
UInt8ExtVar
 
- Protected Types inherited from SimpleFlatTableProducerBase< T, edm::View< T > >
typedef FuncVariable
< StringCutObjectSelector< T >
, bool > 
BoolVar
 
typedef FuncVariable
< StringObjectFunction< T >
, float > 
FloatVar
 
typedef FuncVariable
< StringObjectFunction< T >
, int > 
IntVar
 
typedef FuncVariable
< StringObjectFunction< T >
, uint8_t > 
UInt8Var
 

Protected Attributes

const StringCutObjectSelector< Tcut_
 
std::vector< std::unique_ptr
< ExtVariable > > 
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 > > 
vars_
 

Detailed Description

template<typename T>
class SimpleFlatTableProducer< T >

Definition at line 126 of file SimpleFlatTableProducer.h.

Member Typedef Documentation

template<typename T >
typedef SimpleFlatTableProducerBase<T, edm::View<T> > SimpleFlatTableProducer< T >::base

Definition at line 128 of file SimpleFlatTableProducer.h.

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

Definition at line 236 of file SimpleFlatTableProducer.h.

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

Definition at line 235 of file SimpleFlatTableProducer.h.

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

Definition at line 234 of file SimpleFlatTableProducer.h.

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

Definition at line 233 of file SimpleFlatTableProducer.h.

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

Definition at line 237 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

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

Definition at line 130 of file SimpleFlatTableProducer.h.

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

132  singleton_(params.getParameter<bool>("singleton")),
133  maxLen_(params.existsAs<unsigned int>("maxLen") ? params.getParameter<unsigned int>("maxLen")
135  cut_(!singleton_ ? params.getParameter<std::string>("cut") : "", true) {
136  if (params.existsAs<edm::ParameterSet>("externalVariables")) {
137  edm::ParameterSet const &extvarsPSet = params.getParameter<edm::ParameterSet>("externalVariables");
138  for (const std::string &vname : extvarsPSet.getParameterNamesForType<edm::ParameterSet>()) {
139  const auto &varPSet = extvarsPSet.getParameter<edm::ParameterSet>(vname);
140  const std::string &type = varPSet.getParameter<std::string>("type");
141  if (type == "int")
142  extvars_.push_back(
143  std::make_unique<IntExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
144  else if (type == "float")
145  extvars_.push_back(
146  std::make_unique<FloatExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
147  else if (type == "double")
148  extvars_.push_back(
149  std::make_unique<DoubleExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
150  else if (type == "uint8")
151  extvars_.push_back(
152  std::make_unique<UInt8ExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
153  else if (type == "bool")
154  extvars_.push_back(
155  std::make_unique<BoolExtVar>(vname, varPSet, this->consumesCollector(), this->skipNonExistingSrc_));
156  else
157  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
158  }
159  }
160  }
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
std::vector< std::unique_ptr< ExtVariable > > extvars_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const StringCutObjectSelector< T > cut_
template<typename T >
SimpleFlatTableProducer< T >::~SimpleFlatTableProducer ( )
inlineoverride

Definition at line 162 of file SimpleFlatTableProducer.h.

162 {}

Member Function Documentation

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 164 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, submitPVResolutionJobs::out, SimpleFlatTableProducer< T >::singleton_, SimpleFlatTableProducerBase< T, edm::View< T > >::skipNonExistingSrc_, isotrackApplyRegressor::var, and SimpleFlatTableProducerBase< T, edm::View< T > >::vars_.

165  {
166  std::vector<const T *> selobjs;
167  std::vector<edm::Ptr<T>> selptrs; // for external variables
168  if (prod.isValid() || !(this->skipNonExistingSrc_)) {
169  if (singleton_) {
170  assert(prod->size() == 1);
171  selobjs.push_back(&(*prod)[0]);
172  if (!extvars_.empty())
173  selptrs.emplace_back(prod->ptrAt(0));
174  } else {
175  for (unsigned int i = 0, n = prod->size(); i < n; ++i) {
176  const auto &obj = (*prod)[i];
177  if (cut_(obj)) {
178  selobjs.push_back(&obj);
179  if (!extvars_.empty())
180  selptrs.emplace_back(prod->ptrAt(i));
181  }
182  if (selobjs.size() >= maxLen_)
183  break;
184  }
185  }
186  }
187  auto out = std::make_unique<nanoaod::FlatTable>(selobjs.size(), this->name_, singleton_, this->extension_);
188  for (const auto &var : this->vars_)
189  var->fill(selobjs, *out);
190  for (const auto &var : this->extvars_)
191  var->fill(iEvent, selptrs, *out);
192  return out;
193  }
assert(be >=bs)
std::vector< std::unique_ptr< ExtVariable > > extvars_
list var
if using global norm cols_to_minmax = [&#39;t_delta&#39;, &#39;t_hmaxNearP&#39;,&#39;t_emaxNearP&#39;, &#39;t_hAnnular&#39;, &#39;t_eAnnular&#39;,&#39;t_pt&#39;,&#39;t_nVtx&#39;,&#39;t_ieta&#39;,&#39;t_eHcal10&#39;, &#39;t_eHcal30&#39;,&#39;t_rhoh&#39;,&#39;t_eHcal&#39;] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() &gt; 0) else 1.0/200.0)
bool isValid() const
Definition: HandleBase.h:70
std::vector< std::unique_ptr< Variable > > vars_
const StringCutObjectSelector< T > cut_

Member Data Documentation

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

Definition at line 198 of file SimpleFlatTableProducer.h.

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

template<typename T >
std::vector<std::unique_ptr<ExtVariable> > SimpleFlatTableProducer< T >::extvars_
protected
template<typename T >
const unsigned int SimpleFlatTableProducer< T >::maxLen_
protected

Definition at line 197 of file SimpleFlatTableProducer.h.

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

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

Definition at line 196 of file SimpleFlatTableProducer.h.

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