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

◆ DoubleVar

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

Definition at line 211 of file SimpleFlatTableProducer.h.

◆ FloatVar

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

Definition at line 210 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 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 208 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 214 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 212 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 209 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 == "uint8")
139  vars_.push_back(std::make_unique<UInt8Var>(vname, varPSet));
140  else if (type == "int16")
141  vars_.push_back(std::make_unique<Int16Var>(vname, varPSet));
142  else if (type == "uint16")
143  vars_.push_back(std::make_unique<UInt16Var>(vname, varPSet));
144  else if (type == "bool")
145  vars_.push_back(std::make_unique<BoolVar>(vname, varPSet));
146  else
147  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + vname);
148  }
149 
150  produces<nanoaod::FlatTable>();
151  }
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 153 of file SimpleFlatTableProducer.h.

153 {}

Member Function Documentation

◆ baseDescriptions()

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

Definition at line 155 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().

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

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

◆ name_

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

Definition at line 202 of file SimpleFlatTableProducer.h.

◆ skipNonExistingSrc_

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

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