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 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_
 
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 >, int8_t > Int8Var
 
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.

◆ Int8DetVar

template<class DETECTOR_T , class RECO_T , class GEOM_T >
using MuRecObjBaseProducer< DETECTOR_T, RECO_T, GEOM_T >::Int8DetVar = FuncVariable<DETECTOR_T, StringObjectFunction<DETECTOR_T>, int8_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 == "int8") {
71  detVarPtr = std::move(std::make_unique<Int8DetVar>(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:303
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::ConfigurationDescriptions::addWithDefaultLabel(), SimpleFlatTableProducerBase< T, TProd >::baseDescriptions(), 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 
109  return varBase;
110  };
111 
112  auto fullDescription = [](auto const &var, std::string const label) {
114 
116  fullDesc.setComment("a parameters set to define all " + label + " variables to the flat table");
117  fullDesc.addNode(detIdVarWildCard);
118 
119  return fullDesc;
120  };
121 
122  auto detIdVar{baseDescription()};
123  auto globalGeomVar{baseDescription()};
124 
125  edm::Comment comType{"the c++ type of the branch in the flat table"};
126  detIdVar.ifValue(edm::ParameterDescription<std::string>{"type", "int", true, comType},
127  edm::allowedValues<std::string>("int", "uint", "int8", "uint8"));
128 
129  edm::Comment comPrecision{"the precision with which to store the value in the flat table"};
130  globalGeomVar.addOptionalNode(edm::ParameterDescription<int>{"precision", true, comPrecision}, false);
131 
132  desc.add<edm::ParameterSetDescription>("detIdVariables", fullDescription(detIdVar, "DetId"));
133  desc.add<edm::ParameterSetDescription>("globalPosVariables", fullDescription(globalGeomVar, "Global Position"));
134 
135  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
136  desc.add<edm::ParameterSetDescription>("globalDirVariables", fullDescription(globalGeomVar, "Global Direction"));
137  }
138 
139  descriptions.addWithDefaultLabel(desc);
140  }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
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 142 of file MuLocalRecoBaseProducer.h.

References 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().

143  {
144  std::vector<const RECO_T *> objs;
145  std::vector<const DETECTOR_T *> detIds;
146  std::vector<const GlobalPoint *> globalPositions;
147  std::vector<const GlobalVector *> globalDirections;
148 
149  // CB needed to store DetIds, global points and vectors (they are transient)
150  std::list<DETECTOR_T> detIdObjs;
151  std::list<GlobalPoint> globalPointObjs;
152  std::list<GlobalVector> globalVectorObjs;
153 
154  if (product.isValid()) {
155  auto detIdIt = product->id_begin();
156  const auto detIdEnd = product->id_end();
157 
158  for (; detIdIt != detIdEnd; ++detIdIt) {
159  const auto &range = product->get(*detIdIt);
160  const GeomDet *geomDet = m_geometry->idToDet(*detIdIt);
161 
162  detIdObjs.push_back(*detIdIt);
163  std::fill_n(std::back_inserter(detIds), range.second - range.first, &detIdObjs.back());
164 
165  for (auto objIt{range.first}; objIt != range.second; ++objIt) {
166  objs.push_back(&(*objIt));
167  globalPointObjs.push_back(geomDet->toGlobal(objIt->localPosition()));
168  globalPositions.push_back(&globalPointObjs.back());
169  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
170  globalVectorObjs.push_back(geomDet->toGlobal(objIt->localDirection()));
171  globalDirections.push_back(&globalVectorObjs.back());
172  }
173  }
174  }
175  }
176 
177  auto table = std::make_unique<nanoaod::FlatTable>(objs.size(), this->name_, false, this->extension_);
178 
179  for (const auto &var : this->vars_) {
180  var->fill(objs, *table);
181  }
182 
183  for (const auto &var : detIdVars_) {
184  var->fill(detIds, *table);
185  }
186 
187  for (const auto &var : globalPosVars_) {
188  var->fill(globalPositions, *table);
189  }
190 
191  if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
192  for (const auto &var : globalDirVars_) {
193  var->fill(globalDirections, *table);
194  }
195  }
196 
197  return table;
198  }
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 200 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_.

200  {
202  event.getByToken(this->src_, src);
203 
204  m_geometry = environment.getHandle(m_token);
205  std::unique_ptr<nanoaod::FlatTable> out = fillTable(event, src);
206  out->setDoc(this->doc_);
207 
208  event.put(std::move(out));
209  }
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