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 Int16DetVar = FuncVariable< DETECTOR_T, StringObjectFunction< DETECTOR_T >, int16_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 >, 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.

◆ Int16DetVar

template<class DETECTOR_T , class DIGI_T >
using MuDigiBaseProducer< DETECTOR_T, DIGI_T >::Int16DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int16_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 == "int16") {
48  detVarPtr = std::move(std::make_unique<Int16DetVar>(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, HPSPFTaus_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  variable.addUntracked<bool>("lazyEval")->setComment("set to True if the type read from the Event is unknown");
71 
72  variable.ifValue(edm::ParameterDescription<std::string>("type", "int", true, comType),
73  edm::allowedValues<std::string>("int", "uint", "int16", "uint8"));
74 
76 
77  variables.setComment("a parameters set to define all variable taken form detId to fill the flat table");
78 
80  variables.addNode(variableWildCard);
81 
82  desc.add<edm::ParameterSetDescription>("detIdVariables", variables);
83 
84  descriptions.addWithDefaultLabel(desc);
85  }
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 87 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_.

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