CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T > Class Template Reference

#include <MuLocalRecoBaseProducer.h>

Inheritance diagram for MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >:
SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > > edm::stream::EDProducer<>

Public Member Functions

std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< COLLECTION > &product) const override
 
 MuRecObjBaseProducer (edm::ParameterSet const &params)
 
void produce (edm::Event &event, const edm::EventSetup &environment) override
 
 ~MuRecObjBaseProducer () override
 
- Public Member Functions inherited from SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >
virtual std::unique_ptr< nanoaod::FlatTablefillTable (const edm::Event &iEvent, const edm::Handle< edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > > &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 void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >
static edm::ParameterSetDescription baseDescriptions ()
 

Private Types

using COLLECTION = edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > >
 
using GlobalDirVar = FuncVariable< GlobalVector, StringObjectFunction< GlobalVector >, float >
 
using GlobalPosVar = FuncVariable< GlobalPoint, StringObjectFunction< GlobalPoint >, float >
 
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_
 
std::vector< std::unique_ptr< Variable< GlobalVector > > > globalDirVars_
 
std::vector< std::unique_ptr< Variable< GlobalPoint > > > globalPosVars_
 
edm::ESHandle< GEOM_T > m_geometry
 
edm::ESGetToken< GEOM_T, MuonGeometryRecordm_token
 

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

Detailed Description

template<class DETECTOR_T, class RECO_T, class GEOM_T>
class MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >

Helper class defining the generic interface of a muon digi Producer

Author
C. Battilana (INFN BO)

Definition at line 34 of file MuLocalRecoBaseProducer.h.

Member Typedef Documentation

◆ COLLECTION

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::COLLECTION = edm::RangeMap<DETECTOR_T, edm::OwnVector<RECO_T> >
private

Definition at line 36 of file MuLocalRecoBaseProducer.h.

◆ GlobalDirVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::GlobalDirVar = FuncVariable<GlobalVector, StringObjectFunction<GlobalVector>, float>
private

Definition at line 49 of file MuLocalRecoBaseProducer.h.

◆ GlobalPosVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::GlobalPosVar = FuncVariable<GlobalPoint, StringObjectFunction<GlobalPoint>, float>
private

Definition at line 48 of file MuLocalRecoBaseProducer.h.

◆ Int16DetVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::Int16DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int16_t>
private

Definition at line 43 of file MuLocalRecoBaseProducer.h.

◆ IntDetVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::IntDetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int>
private

Definition at line 41 of file MuLocalRecoBaseProducer.h.

◆ UInt8DetVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::UInt8DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, uint8_t>
private

Definition at line 44 of file MuLocalRecoBaseProducer.h.

◆ UIntDetVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::UIntDetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, unsigned int>
private

Definition at line 42 of file MuLocalRecoBaseProducer.h.

Constructor & Destructor Documentation

◆ MuRecObjBaseProducer()

template<class DETECTOR_T , class RECO_T , class GEOM_T >
MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::MuRecObjBaseProducer ( edm::ParameterSet const &  params)
inline

Definition at line 55 of file MuLocalRecoBaseProducer.h.

References deDxTools::esConsumes().

57  auto varCfgs = params.getParameter<edm::ParameterSet>("detIdVariables");
58  auto varNames = varCfgs.getParameterNamesForType<edm::ParameterSet>();
59 
60  std::transform(varNames.begin(), varNames.end(), std::back_inserter(detIdVars_), [&](const auto &name) {
61  const edm::ParameterSet &varCfg = varCfgs.getParameter<edm::ParameterSet>(name);
62  const std::string &type = varCfg.getParameter<std::string>("type");
63 
64  std::unique_ptr<Variable<DETECTOR_T>> detVarPtr;
65 
66  if (type == "int") {
67  detVarPtr = std::move(std::make_unique<IntDetVar>(name, varCfg)); // CB can improve?
68  } else if (type == "uint") {
69  detVarPtr = std::move(std::make_unique<UIntDetVar>(name, varCfg));
70  } else if (type == "int16") {
71  detVarPtr = std::move(std::make_unique<Int16DetVar>(name, varCfg));
72  } else if (type == "uint8") {
73  detVarPtr = std::move(std::make_unique<UInt8DetVar>(name, varCfg));
74  } else {
75  throw cms::Exception("Configuration", "unsupported type " + type + " for variable " + name);
76  }
77 
78  return detVarPtr;
79  });
80 
81  varCfgs = params.getParameter<edm::ParameterSet>("globalPosVariables");
82  varNames = varCfgs.getParameterNamesForType<edm::ParameterSet>();
83 
84  std::transform(varNames.begin(), varNames.end(), std::back_inserter(globalPosVars_), [&](const auto &name) {
85  return std::make_unique<GlobalPosVar>(name, varCfgs.getParameter<edm::ParameterSet>(name));
86  });
87 
88  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
89  varCfgs = params.getParameter<edm::ParameterSet>("globalDirVariables");
90  varNames = varCfgs.getParameterNamesForType<edm::ParameterSet>();
91 
92  std::transform(varNames.begin(), varNames.end(), std::back_inserter(globalDirVars_), [&](const auto &name) {
93  return std::make_unique<GlobalDirVar>(name, varCfgs.getParameter<edm::ParameterSet>(name));
94  });
95  }
96  }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
constexpr char const * varNames[]
std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
edm::ESGetToken< GEOM_T, MuonGeometryRecord > m_token
std::vector< std::unique_ptr< Variable< GlobalPoint > > > globalPosVars_
std::vector< std::unique_ptr< Variable< GlobalVector > > > globalDirVars_
def move(src, dest)
Definition: eostools.py:511
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ ~MuRecObjBaseProducer()

template<class DETECTOR_T , class RECO_T , class GEOM_T >
MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::~MuRecObjBaseProducer ( )
inlineoverride

Definition at line 98 of file MuLocalRecoBaseProducer.h.

98 {}

Member Function Documentation

◆ fillDescriptions()

template<class DETECTOR_T , class RECO_T , class GEOM_T >
static void MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 100 of file MuLocalRecoBaseProducer.h.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addNode(), edm::ParameterSetDescription::addUntracked(), edm::ConfigurationDescriptions::addWithDefaultLabel(), SimpleFlatTableProducerBase< T, TProd >::baseDescriptions(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), submitPVResolutionJobs::desc, label, edm::RequireZeroOrMore, edm::ParameterSetDescription::setComment(), AlCaHLTBitMon_QueryRunRegistry::string, and trigObjTnPSource_cfi::var.

100  {
102 
103  auto baseDescription = []() {
105 
106  varBase.add<std::string>("expr")->setComment("a function to define the content of the branch in the flat table");
107  varBase.add<std::string>("doc")->setComment("few words description of the branch content");
108  varBase.addUntracked<bool>("lazyEval")->setComment("if True, check object type during Event processing.");
109 
110  return varBase;
111  };
112 
113  auto fullDescription = [](auto const &var, std::string const label) {
115 
117  fullDesc.setComment("a parameters set to define all " + label + " variables to the flat table");
118  fullDesc.addNode(detIdVarWildCard);
119 
120  return fullDesc;
121  };
122 
123  auto detIdVar{baseDescription()};
124  auto globalGeomVar{baseDescription()};
125 
126  edm::Comment comType{"the c++ type of the branch in the flat table"};
127  detIdVar.ifValue(edm::ParameterDescription<std::string>{"type", "int", true, comType},
128  edm::allowedValues<std::string>("int", "uint", "int16", "uint8"));
129 
130  edm::Comment comPrecision{"the precision with which to store the value in the flat table"};
131  globalGeomVar.addOptionalNode(edm::ParameterDescription<int>{"precision", true, comPrecision}, false);
132 
133  desc.add<edm::ParameterSetDescription>("detIdVariables", fullDescription(detIdVar, "DetId"));
134  desc.add<edm::ParameterSetDescription>("globalPosVariables", fullDescription(globalGeomVar, "Global Position"));
135 
136  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
137  desc.add<edm::ParameterSetDescription>("globalDirVariables", fullDescription(globalGeomVar, "Global Direction"));
138  }
139 
140  descriptions.addWithDefaultLabel(desc);
141  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
char const * label
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static edm::ParameterSetDescription baseDescriptions()

◆ fillTable()

template<class DETECTOR_T , class RECO_T , class GEOM_T >
std::unique_ptr<nanoaod::FlatTable> MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillTable ( const edm::Event iEvent,
const edm::Handle< COLLECTION > &  product 
) const
inlineoverride

Definition at line 143 of file MuLocalRecoBaseProducer.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::detIdVars_, SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >::extension_, edm::RangeMap< ID, C, P >::get(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::globalDirVars_, MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::globalPosVars_, edm::RangeMap< ID, C, P >::id_begin(), edm::RangeMap< ID, C, P >::id_end(), edm::HandleBase::isValid(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::m_geometry, SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >::name_, HLTEGTnPMonitor_cfi::objs, FastTimerService_cff::range, TableParser::table, GeomDet::toGlobal(), trigObjTnPSource_cfi::var, and SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >::vars_.

Referenced by MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::produce().

144  {
145  std::vector<const RECO_T *> objs;
146  std::vector<const DETECTOR_T *> detIds;
147  std::vector<const GlobalPoint *> globalPositions;
148  std::vector<const GlobalVector *> globalDirections;
149 
150  // CB needed to store DetIds, global points and vectors (they are transient)
151  std::list<DETECTOR_T> detIdObjs;
152  std::list<GlobalPoint> globalPointObjs;
153  std::list<GlobalVector> globalVectorObjs;
154 
155  if (product.isValid()) {
156  auto detIdIt = product->id_begin();
157  const auto detIdEnd = product->id_end();
158 
159  for (; detIdIt != detIdEnd; ++detIdIt) {
160  const auto &range = product->get(*detIdIt);
161  const GeomDet *geomDet = m_geometry->idToDet(*detIdIt);
162 
163  detIdObjs.push_back(*detIdIt);
164  std::fill_n(std::back_inserter(detIds), range.second - range.first, &detIdObjs.back());
165 
166  for (auto objIt{range.first}; objIt != range.second; ++objIt) {
167  objs.push_back(&(*objIt));
168  globalPointObjs.push_back(geomDet->toGlobal(objIt->localPosition()));
169  globalPositions.push_back(&globalPointObjs.back());
170  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
171  globalVectorObjs.push_back(geomDet->toGlobal(objIt->localDirection()));
172  globalDirections.push_back(&globalVectorObjs.back());
173  }
174  }
175  }
176  }
177 
178  auto table = std::make_unique<nanoaod::FlatTable>(objs.size(), this->name_, false, this->extension_);
179 
180  for (const auto &var : this->vars_) {
181  var->fill(objs, *table);
182  }
183 
184  for (const auto &var : detIdVars_) {
185  var->fill(detIds, *table);
186  }
187 
188  for (const auto &var : globalPosVars_) {
189  var->fill(globalPositions, *table);
190  }
191 
192  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
193  for (const auto &var : globalDirVars_) {
194  var->fill(globalDirections, *table);
195  }
196  }
197 
198  return table;
199  }
edm::ESHandle< GEOM_T > m_geometry
std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
id_iterator id_end() const
last identifier iterator
Definition: RangeMap.h:182
range get(ID id, CMP comparator) const
Definition: RangeMap.h:75
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
bool isValid() const
Definition: HandleBase.h:70
std::vector< std::unique_ptr< Variable< GlobalPoint > > > globalPosVars_
id_iterator id_begin() const
first identifier iterator
Definition: RangeMap.h:180
std::vector< std::unique_ptr< Variable< GlobalVector > > > globalDirVars_

◆ produce()

template<class DETECTOR_T , class RECO_T , class GEOM_T >
void MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::produce ( edm::Event event,
const edm::EventSetup environment 
)
inlineoverride

Definition at line 201 of file MuLocalRecoBaseProducer.h.

References SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >::doc_, reco_calib_source_client_cfg::environment, MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::fillTable(), MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::m_geometry, MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::m_token, eostools::move(), MillePedeFileConverter_cfg::out, TrackRefitter_38T_cff::src, and SimpleFlatTableProducerBase< RECO_T, edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > >::src_.

201  {
203  event.getByToken(this->src_, src);
204 
205  m_geometry = environment.getHandle(m_token);
206  std::unique_ptr<nanoaod::FlatTable> out = fillTable(event, src);
207  out->setDoc(this->doc_);
208 
209  event.put(std::move(out));
210  }
const edm::EDGetTokenT< edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > > src_
edm::ESHandle< GEOM_T > m_geometry
edm::ESGetToken< GEOM_T, MuonGeometryRecord > m_token
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< COLLECTION > &product) const override
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ detIdVars_

template<class DETECTOR_T , class RECO_T , class GEOM_T >
std::vector<std::unique_ptr<Variable<DETECTOR_T> > > MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::detIdVars_
private

◆ globalDirVars_

template<class DETECTOR_T , class RECO_T , class GEOM_T >
std::vector<std::unique_ptr<Variable<GlobalVector> > > MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::globalDirVars_
private

◆ globalPosVars_

template<class DETECTOR_T , class RECO_T , class GEOM_T >
std::vector<std::unique_ptr<Variable<GlobalPoint> > > MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::globalPosVars_
private

◆ m_geometry

template<class DETECTOR_T , class RECO_T , class GEOM_T >
edm::ESHandle<GEOM_T> MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::m_geometry
private

◆ m_token

template<class DETECTOR_T , class RECO_T , class GEOM_T >
edm::ESGetToken<GEOM_T, MuonGeometryRecord> MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::m_token
private