CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
MuDigiBaseProducer< DETECTOR_T, DIGI_T > Class Template Reference

#include <DPGAnalysis/MuonTools/src/MuDigiBaseProducer.h>

Inheritance diagram for MuDigiBaseProducer< DETECTOR_T, DIGI_T >:
SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > > edm::stream::EDProducer<>

Public Member Functions

std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< COLLECTION > &prod) const override
 
 MuDigiBaseProducer (edm::ParameterSet const &params)
 
 ~MuDigiBaseProducer () override
 
- Public Member Functions inherited from SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >
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 void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >
static edm::ParameterSetDescription baseDescriptions ()
 

Private Types

using COLLECTION = MuonDigiCollection< DETECTOR_T, DIGI_T >
 
using Int8DetVar = FuncVariable< DETECTOR_T, StringObjectFunction< DETECTOR_T >, int8_t >
 
using IntDetVar = FuncVariable< DETECTOR_T, StringObjectFunction< DETECTOR_T >, int >
 
using UInt8DetVar = FuncVariable< DETECTOR_T, StringObjectFunction< DETECTOR_T >, uint8_t >
 
using UIntDetVar = FuncVariable< DETECTOR_T, StringObjectFunction< DETECTOR_T >, unsigned int >
 

Private Attributes

std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
 

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
 
- Protected Types inherited from SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >
typedef FuncVariable< DIGI_T, StringCutObjectSelector< DIGI_T >, bool > BoolVar
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, double > DoubleVar
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, float > FloatVar
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, int16_t > Int16Var
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, int8_t > Int8Var
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, int32_t > IntVar
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, uint16_t > UInt16Var
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, uint8_t > UInt8Var
 
typedef FuncVariable< DIGI_T, StringObjectFunction< DIGI_T >, uint32_t > UIntVar
 
- Protected Attributes inherited from SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >
const std::string doc_
 
const bool extension_
 
const std::string name_
 
const bool skipNonExistingSrc_
 
const edm::EDGetTokenT< MuonDigiCollection< DETECTOR_T, DIGI_T > > src_
 
std::vector< std::unique_ptr< Variable< DIGI_T > > > vars_
 

Detailed Description

template<class DETECTOR_T, class DIGI_T>
class MuDigiBaseProducer< DETECTOR_T, DIGI_T >

Helper class defining the generic interface of a muon digi Producer

Author
C. Battilana (INFN BO)

Definition at line 22 of file MuDigiBaseProducer.h.

Member Typedef Documentation

◆ COLLECTION

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::COLLECTION = MuonDigiCollection<DETECTOR_T, DIGI_T>
private

Definition at line 23 of file MuDigiBaseProducer.h.

◆ Int8DetVar

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::Int8DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int8_t>
private

Definition at line 27 of file MuDigiBaseProducer.h.

◆ IntDetVar

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::IntDetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int>
private

Definition at line 25 of file MuDigiBaseProducer.h.

◆ UInt8DetVar

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::UInt8DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, uint8_t>
private

Definition at line 28 of file MuDigiBaseProducer.h.

◆ UIntDetVar

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::UIntDetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, unsigned int>
private

Definition at line 26 of file MuDigiBaseProducer.h.

Constructor & Destructor Documentation

◆ MuDigiBaseProducer()

template<class DETECTOR_T , class DIGI_T >
MuDigiBaseProducer< DETECTOR_T, DIGI_T >::MuDigiBaseProducer ( edm::ParameterSet const &  params)
inline

Definition at line 33 of file MuDigiBaseProducer.h.

References MuDigiBaseProducer< DETECTOR_T, DIGI_T >::detIdVars_, Exception, edm::ParameterSet::getParameter(), eostools::move(), Skims_PA_cff::name, submitPVValidationJobs::params, AlCaHLTBitMon_QueryRunRegistry::string, HcalDetIdTransform::transform(), and varNames.

34  const auto &varCfgs = params.getParameter<edm::ParameterSet>("detIdVariables");
35  const auto &varNames = varCfgs.getParameterNamesForType<edm::ParameterSet>();
36 
37  std::transform(varNames.begin(), varNames.end(), std::back_inserter(detIdVars_), [&](const auto &name) {
38  const edm::ParameterSet &varCfg = varCfgs.getParameter<edm::ParameterSet>(name);
39  const std::string &type = varCfg.getParameter<std::string>("type");
40 
41  std::unique_ptr<Variable<DETECTOR_T>> detVarPtr;
42 
43  if (type == "int") {
44  detVarPtr = std::move(std::make_unique<IntDetVar>(name, varCfg));
45  } else if (type == "uint") {
46  detVarPtr = std::move(std::make_unique<UIntDetVar>(name, varCfg));
47  } else if (type == "int8") {
48  detVarPtr = std::move(std::make_unique<Int8DetVar>(name, varCfg));
49  } else if (type == "uint8") {
50  detVarPtr = std::move(std::make_unique<UInt8DetVar>(name, varCfg));
51  } else {
52  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + name);
53  }
54 
55  return detVarPtr;
56  });
57  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
constexpr char const * varNames[]
std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
def move(src, dest)
Definition: eostools.py:511
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ ~MuDigiBaseProducer()

template<class DETECTOR_T , class DIGI_T >
MuDigiBaseProducer< DETECTOR_T, DIGI_T >::~MuDigiBaseProducer ( )
inlineoverride

Definition at line 59 of file MuDigiBaseProducer.h.

59 {}

Member Function Documentation

◆ fillDescriptions()

template<class DETECTOR_T , class DIGI_T >
static void MuDigiBaseProducer< DETECTOR_T, DIGI_T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 61 of file MuDigiBaseProducer.h.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), SimpleFlatTableProducerBase< T, TProd >::baseDescriptions(), submitPVResolutionJobs::desc, edm::RequireZeroOrMore, AlCaHLTBitMon_QueryRunRegistry::string, taus_updatedMVAIds_cff::variable, and hcalRecHitTable_cff::variables.

61  {
63 
65  edm::Comment comType{"the c++ type of the branch in the flat table"};
66  edm::Comment comPrecision{"the precision with which to store the value in the flat table"};
67 
68  variable.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
69  variable.add<std::string>("doc")->setComment("few words description of the branch content");
70 
71  variable.ifValue(edm::ParameterDescription<std::string>("type", "int", true, comType),
72  edm::allowedValues<std::string>("int", "uint", "int8", "uint8"));
73 
75 
76  variables.setComment("a parameters set to define all variable taken form detId to fill the flat table");
77 
79  variables.addNode(variableWildCard);
80 
81  desc.add<edm::ParameterSetDescription>("detIdVariables", variables);
82 
83  descriptions.addWithDefaultLabel(desc);
84  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static edm::ParameterSetDescription baseDescriptions()

◆ fillTable()

template<class DETECTOR_T , class DIGI_T >
std::unique_ptr<nanoaod::FlatTable> MuDigiBaseProducer< DETECTOR_T, DIGI_T >::fillTable ( const edm::Event iEvent,
const edm::Handle< COLLECTION > &  prod 
) const
inlineoverridevirtual

Implements SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >.

Definition at line 86 of file MuDigiBaseProducer.h.

References hcalRecHitTable_cff::detId, MuDigiBaseProducer< DETECTOR_T, DIGI_T >::detIdVars_, SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >::extension_, SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >::name_, dumpMFGeometry_cfg::prod, FastTimerService_cff::range, TableParser::table, HcalDetIdTransform::transform(), trigObjTnPSource_cfi::var, and SimpleFlatTableProducerBase< DIGI_T, MuonDigiCollection< DETECTOR_T, DIGI_T > >::vars_.

87  {
88  std::vector<const DIGI_T *> digis;
89  std::vector<const DETECTOR_T *> detIds;
90  std::list<DETECTOR_T> detIdObjs; // CB needed to store DetIds (they are transient)
91 
92  if (prod.isValid()) {
93  auto detIdIt = prod->begin();
94  auto detIdEnd = prod->end();
95 
96  for (; detIdIt != detIdEnd; ++detIdIt) {
97  const auto &[detId, range] = (*detIdIt);
98  detIdObjs.push_back(detId);
99  std::fill_n(std::back_inserter(detIds), range.second - range.first, &detIdObjs.back());
100  std::transform(range.first, range.second, std::back_inserter(digis), [](const auto &digi) { return &digi; });
101  }
102  }
103 
104  auto table = std::make_unique<nanoaod::FlatTable>(digis.size(), this->name_, false, this->extension_);
105 
106  for (const auto &var : this->vars_) {
107  var->fill(digis, *table);
108  }
109 
110  for (const auto &var : detIdVars_) {
111  var->fill(detIds, *table);
112  }
113 
114  return table;
115  }
std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Data Documentation

◆ detIdVars_

template<class DETECTOR_T , class DIGI_T >
std::vector<std::unique_ptr<Variable<DETECTOR_T> > > MuDigiBaseProducer< DETECTOR_T, DIGI_T >::detIdVars_
private