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 >, 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 165 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 264 of file SimpleFlatTableProducer.h.

◆ DoubleVar

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

Definition at line 260 of file SimpleFlatTableProducer.h.

◆ FloatVar

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

Definition at line 259 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 262 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 257 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 263 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 261 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 258 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 167 of file SimpleFlatTableProducer.h.

168  : name_(params.getParameter<std::string>("name")),
169  doc_(params.getParameter<std::string>("doc")),
170  extension_(params.getParameter<bool>("extension")),
171  skipNonExistingSrc_(params.getParameter<bool>("skipNonExistingSrc")),
172  src_(consumes<TProd>(params.getParameter<edm::InputTag>("src"))) {
173  edm::ParameterSet const &varsPSet = params.getParameter<edm::ParameterSet>("variables");
174  for (const std::string &vname : varsPSet.getParameterNamesForType<edm::ParameterSet>()) {
175  const auto &varPSet = varsPSet.getParameter<edm::ParameterSet>(vname);
176  const std::string &type = varPSet.getParameter<std::string>("type");
177  if (type == "int")
178  vars_.push_back(std::make_unique<IntVar>(vname, varPSet));
179  else if (type == "uint")
180  vars_.push_back(std::make_unique<UIntVar>(vname, varPSet));
181  else if (type == "float")
182  vars_.push_back(std::make_unique<FloatVar>(vname, varPSet));
183  else if (type == "double")
184  vars_.push_back(std::make_unique<DoubleVar>(vname, varPSet));
185  else if (type == "uint8")
186  vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
187  else if (type == "int16")
188  vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
189  else if (type == "uint16")
190  vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
191  else if (type == "bool")
192  vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
193  else
194  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
195  }
196 
197  produces<nanoaod::FlatTable>();
198  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< TProd > src_
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:180
std::vector< std::unique_ptr< Variable< T > > > vars_

◆ ~SimpleFlatTableProducerBase()

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

Definition at line 200 of file SimpleFlatTableProducer.h.

200 {}

Member Function Documentation

◆ baseDescriptions()

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

Definition at line 202 of file SimpleFlatTableProducer.h.

Referenced by MuDigiBaseProducer< DETECTOR_T, DIGI_T >::fillDescriptions(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillDescriptions(), EventSingletonSimpleFlatTableProducer< T >::fillDescriptions(), LumiSingletonSimpleFlatTableProducer< T >::fillDescriptions(), and LumiSimpleFlatTableProducer< T, TProd >::fillDescriptions().

202  {
205  desc.add<std::string>("name")->setComment("name of the branch in the flat table output for " + classname);
206  desc.add<std::string>("doc", "")->setComment("few words of self documentation");
207  desc.add<bool>("extension", false)->setComment("whether or not to extend an existing same table");
208  desc.add<bool>("skipNonExistingSrc", false)
209  ->setComment("whether or not to skip producing the table on absent input product");
210  desc.add<edm::InputTag>("src")->setComment("input collection to fill the flat table");
211 
213  variable.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
214  variable.add<std::string>("doc")->setComment("few words description of the branch content");
215  variable.addUntracked<bool>("lazyEval", false)
216  ->setComment("if true, can use methods of inheriting classes in `expr`. Can cause problems with threading.");
217  variable.ifValue(
219  "type", "int", true, edm::Comment("the c++ type of the branch in the flat table")),
220  edm::allowedValues<std::string>("int", "uint", "float", "double", "uint8", "int16", "uint16", "bool"));
221  variable.addOptionalNode(
223  "precision", true, edm::Comment("the precision with which to store the value in the flat table")) xor
225  "precision", true, edm::Comment("the precision with which to store the value in the flat table")),
226  false);
227 
229  variables.setComment("a parameters set to define all variable to fill the flat table");
230  variables.addNode(
232  desc.add<edm::ParameterSetDescription>("variables", variables);
233 
234  return desc;
235  }
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 240 of file SimpleFlatTableProducer.h.

240  {
242  iEvent.getByToken(src_, src);
243 
244  std::unique_ptr<nanoaod::FlatTable> out = fillTable(iEvent, src);
245  out->setDoc(doc_);
246 
247  iEvent.put(std::move(out));
248  }
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 253 of file SimpleFlatTableProducer.h.

◆ name_

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

Definition at line 251 of file SimpleFlatTableProducer.h.

◆ skipNonExistingSrc_

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

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