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 118 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 218 of file SimpleFlatTableProducer.h.

◆ DoubleVar

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

Definition at line 213 of file SimpleFlatTableProducer.h.

◆ FloatVar

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

Definition at line 212 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 216 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 214 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 210 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 217 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 215 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 211 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 120 of file SimpleFlatTableProducer.h.

121  : name_(params.getParameter<std::string>("name")),
122  doc_(params.getParameter<std::string>("doc")),
123  extension_(params.getParameter<bool>("extension")),
124  skipNonExistingSrc_(params.getParameter<bool>("skipNonExistingSrc")),
125  src_(consumes<TProd>(params.getParameter<edm::InputTag>("src"))) {
126  edm::ParameterSet const &varsPSet = params.getParameter<edm::ParameterSet>("variables");
127  for (const std::string &vname : varsPSet.getParameterNamesForType<edm::ParameterSet>()) {
128  const auto &varPSet = varsPSet.getParameter<edm::ParameterSet>(vname);
129  const std::string &type = varPSet.getParameter<std::string>("type");
130  if (type == "int")
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 == "int8")
139  vars_.push_back(std::make_unique<Int8Var>(vname, varPSet));
140  else if (type == "uint8")
141  vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
142  else if (type == "int16")
143  vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
144  else if (type == "uint16")
145  vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
146  else if (type == "bool")
147  vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
148  else
149  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
150  }
151 
152  produces<nanoaod::FlatTable>();
153  }
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 155 of file SimpleFlatTableProducer.h.

155 {}

Member Function Documentation

◆ baseDescriptions()

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

Definition at line 157 of file SimpleFlatTableProducer.h.

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

157  {
160  desc.add<std::string>("name")->setComment("name of the branch in the flat table output for " + classname);
161  desc.add<std::string>("doc", "")->setComment("few words of self documentation");
162  desc.add<bool>("extension", false)->setComment("whether or not to extend an existing same table");
163  desc.add<bool>("skipNonExistingSrc", false)
164  ->setComment("whether or not to skip producing the table on absent input product");
165  desc.add<edm::InputTag>("src")->setComment("input collection to fill the flat table");
166 
168  variable.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
169  variable.add<std::string>("doc")->setComment("few words description of the branch content");
170  variable.ifValue(
172  "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
173  edm::allowedValues<std::string>("int", "uint", "float", "double", "int8", "uint8", "int16", "uint16", "bool"));
174  variable.addOptionalNode(
176  "precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
178  "precision", true, edm::Comment("the precision with which to store the value in the flat table")),
179  false);
180 
182  variables.setComment("a parameters set to define all variable to fill the flat table");
183  variables.addNode(
185  desc.add<edm::ParameterSetDescription>("variables", variables);
186 
187  return desc;
188  }
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 193 of file SimpleFlatTableProducer.h.

193  {
195  iEvent.getByToken(src_, src);
196 
197  std::unique_ptr<nanoaod::FlatTable> out = fillTable(iEvent, src);
198  out->setDoc(doc_);
199 
200  iEvent.put(std::move(out));
201  }
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 206 of file SimpleFlatTableProducer.h.

◆ name_

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

Definition at line 204 of file SimpleFlatTableProducer.h.

◆ skipNonExistingSrc_

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

Definition at line 207 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