CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes
SimpleFlatTableProducerBase< T, TProd > Class Template Referenceabstract

#include <SimpleFlatTableProducer.h>

Inheritance diagram for SimpleFlatTableProducerBase< T, TProd >:
edm::stream::EDProducer<>

Public Member Functions

virtual std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< TProd > &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 ()
 

Protected Types

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 >, int8_t > Int8Var
 
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 std::string doc_
 
const bool extension_
 
const std::string name_
 
const bool skipNonExistingSrc_
 
const edm::EDGetTokenT< TProd > 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, typename TProd>
class SimpleFlatTableProducerBase< T, TProd >

Definition at line 117 of file SimpleFlatTableProducer.h.

Member Typedef Documentation

◆ BoolVar

template<typename T, typename TProd>
typedef FuncVariable<T, StringCutObjectSelector<T>, bool> SimpleFlatTableProducerBase< T, TProd >::BoolVar
protected

Definition at line 217 of file SimpleFlatTableProducer.h.

◆ DoubleVar

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, double> SimpleFlatTableProducerBase< T, TProd >::DoubleVar
protected

Definition at line 212 of file SimpleFlatTableProducer.h.

◆ FloatVar

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, float> SimpleFlatTableProducerBase< T, TProd >::FloatVar
protected

Definition at line 211 of file SimpleFlatTableProducer.h.

◆ Int16Var

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, int16_t> SimpleFlatTableProducerBase< T, TProd >::Int16Var
protected

Definition at line 215 of file SimpleFlatTableProducer.h.

◆ Int8Var

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, int8_t> SimpleFlatTableProducerBase< T, TProd >::Int8Var
protected

Definition at line 213 of file SimpleFlatTableProducer.h.

◆ IntVar

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, int32_t> SimpleFlatTableProducerBase< T, TProd >::IntVar
protected

Definition at line 209 of file SimpleFlatTableProducer.h.

◆ UInt16Var

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, uint16_t> SimpleFlatTableProducerBase< T, TProd >::UInt16Var
protected

Definition at line 216 of file SimpleFlatTableProducer.h.

◆ UInt8Var

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, uint8_t> SimpleFlatTableProducerBase< T, TProd >::UInt8Var
protected

Definition at line 214 of file SimpleFlatTableProducer.h.

◆ UIntVar

template<typename T, typename TProd>
typedef FuncVariable<T, StringObjectFunction<T>, uint32_t> SimpleFlatTableProducerBase< T, TProd >::UIntVar
protected

Definition at line 210 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ SimpleFlatTableProducerBase()

template<typename T, typename TProd>
SimpleFlatTableProducerBase< T, TProd >::SimpleFlatTableProducerBase ( edm::ParameterSet const &  params)
inline

Definition at line 119 of file SimpleFlatTableProducer.h.

120  : name_(params.getParameter<std::string>("name")),
121  doc_(params.getParameter<std::string>("doc")),
122  extension_(params.getParameter<bool>("extension")),
123  skipNonExistingSrc_(params.getParameter<bool>("skipNonExistingSrc")),
124  src_(consumes<TProd>(params.getParameter<edm::InputTag>("src"))) {
125  edm::ParameterSet const &varsPSet = params.getParameter<edm::ParameterSet>("variables");
126  for (const std::string &vname : varsPSet.getParameterNamesForType<edm::ParameterSet>()) {
127  const auto &varPSet = varsPSet.getParameter<edm::ParameterSet>(vname);
128  const std::string &type = varPSet.getParameter<std::string>("type");
129  if (type == "int")
130  vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
131  else if (type == "uint")
132  vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
133  else if (type == "float")
134  vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
135  else if (type == "double")
136  vars_.push_back(std::make_unique<DoubleVar>(vname, varPSet));
137  else if (type == "int8")
138  vars_.push_back(std::make_unique<Int8Var>(vname, varPSet));
139  else if (type == "uint8")
140  vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
141  else if (type == "int16")
142  vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
143  else if (type == "uint16")
144  vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
145  else if (type == "bool")
146  vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
147  else
148  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
149  }
150 
151  produces<nanoaod::FlatTable>();
152  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< TProd > src_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
std::vector< std::unique_ptr< Variable< T > > > vars_

◆ ~SimpleFlatTableProducerBase()

template<typename T, typename TProd>
SimpleFlatTableProducerBase< T, TProd >::~SimpleFlatTableProducerBase ( )
inlineoverride

Definition at line 154 of file SimpleFlatTableProducer.h.

154 {}

Member Function Documentation

◆ baseDescriptions()

template<typename T, typename TProd>
static edm::ParameterSetDescription SimpleFlatTableProducerBase< T, TProd >::baseDescriptions ( )
inlinestatic

Definition at line 156 of file SimpleFlatTableProducer.h.

Referenced by EventSingletonSimpleFlatTableProducer< T >::fillDescriptions(), LumiSingletonSimpleFlatTableProducer< T >::fillDescriptions(), and LumiSimpleFlatTableProducer< T, TProd >::fillDescriptions().

156  {
159  desc.add<std::string>("name")->setComment("name of the branch in the flat table output for " + classname);
160  desc.add<std::string>("doc", "")->setComment("few words of self documentation");
161  desc.add<bool>("extension", false)->setComment("whether or not to extend an existing same table");
162  desc.add<bool>("skipNonExistingSrc", false)
163  ->setComment("whether or not to skip producing the table on absent input product");
164  desc.add<edm::InputTag>("src")->setComment("input collection to fill the flat table");
165 
167  variable.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
168  variable.add<std::string>("doc")->setComment("few words description of the branch content");
169  variable.ifValue(
171  "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
172  edm::allowedValues<std::string>("int", "uint", "float", "double", "int8", "uint8", "int16", "uint16", "bool"));
173  variable.addOptionalNode(
175  "precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
177  "precision", true, edm::Comment("the precision with which to store the value in the flat table")),
178  false);
179 
181  variables.setComment("a parameters set to define all variable to fill the flat table");
182  variables.addNode(
184  desc.add<edm::ParameterSetDescription>("variables", variables);
185 
186  return desc;
187  }
static const std::string & name()
Definition: ClassName.h:38

◆ fillTable()

template<typename T, typename TProd>
virtual std::unique_ptr<nanoaod::FlatTable> SimpleFlatTableProducerBase< T, TProd >::fillTable ( const edm::Event iEvent,
const edm::Handle< TProd > &  prod 
) const
pure virtual

◆ produce()

template<typename T, typename TProd>
void SimpleFlatTableProducerBase< T, TProd >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
inlineoverride

Definition at line 192 of file SimpleFlatTableProducer.h.

192  {
194  iEvent.getByToken(src_, src);
195 
196  std::unique_ptr<nanoaod::FlatTable> out = fillTable(iEvent, src);
197  out->setDoc(doc_);
198 
199  iEvent.put(std::move(out));
200  }
const edm::EDGetTokenT< TProd > src_
int iEvent
Definition: GenABIO.cc:224
virtual std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< TProd > &prod) const =0
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ doc_

template<typename T, typename TProd>
const std::string SimpleFlatTableProducerBase< T, TProd >::doc_
protected

◆ extension_

template<typename T, typename TProd>
const bool SimpleFlatTableProducerBase< T, TProd >::extension_
protected

Definition at line 205 of file SimpleFlatTableProducer.h.

◆ name_

template<typename T, typename TProd>
const std::string SimpleFlatTableProducerBase< T, TProd >::name_
protected

Definition at line 203 of file SimpleFlatTableProducer.h.

◆ skipNonExistingSrc_

template<typename T, typename TProd>
const bool SimpleFlatTableProducerBase< T, TProd >::skipNonExistingSrc_
protected

Definition at line 206 of file SimpleFlatTableProducer.h.

◆ src_

template<typename T, typename TProd>
const edm::EDGetTokenT<TProd> SimpleFlatTableProducerBase< T, TProd >::src_
protected

◆ vars_

template<typename T, typename TProd>
std::vector<std::unique_ptr<Variable<T> > > SimpleFlatTableProducerBase< T, TProd >::vars_
protected