1 #ifndef MuonTools_MuRecObjBaseProducer_h 2 #define MuonTools_MuRecObjBaseProducer_h 29 #include <type_traits> 33 template <
class DETECTOR_T,
class RECO_T,
class GEOM_T>
46 std::vector<std::unique_ptr<Variable<DETECTOR_T>>>
detIdVars_;
64 std::unique_ptr<Variable<DETECTOR_T>> detVarPtr;
67 detVarPtr =
std::move(std::make_unique<IntDetVar>(
name, varCfg));
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));
88 if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
103 auto baseDescription = []() {
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.");
117 fullDesc.
setComment(
"a parameters set to define all " +
label +
" variables to the flat table");
118 fullDesc.
addNode(detIdVarWildCard);
123 auto detIdVar{baseDescription()};
124 auto globalGeomVar{baseDescription()};
126 edm::Comment comType{
"the c++ type of the branch in the flat table"};
128 edm::allowedValues<std::string>(
"int",
"uint",
"int16",
"uint8"));
130 edm::Comment comPrecision{
"the precision with which to store the value in the flat table"};
136 if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
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;
151 std::list<DETECTOR_T> detIdObjs;
152 std::list<GlobalPoint> globalPointObjs;
153 std::list<GlobalVector> globalVectorObjs;
157 const auto detIdEnd = product->
id_end();
159 for (; detIdIt != detIdEnd; ++detIdIt) {
160 const auto &
range = product->
get(*detIdIt);
163 detIdObjs.push_back(*detIdIt);
164 std::fill_n(std::back_inserter(detIds),
range.second -
range.first, &detIdObjs.back());
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());
180 for (
const auto &
var : this->
vars_) {
192 if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
194 var->fill(globalDirections, *
table);
203 event.getByToken(this->
src_, src);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const edm::EDGetTokenT< edm::RangeMap< DETECTOR_T, edm::OwnVector< RECO_T > > > src_
MuRecObjBaseProducer(edm::ParameterSet const ¶ms)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
constexpr char const * varNames[]
void setComment(std::string const &value)
void produce(edm::Event &event, const edm::EventSetup &environment) override
edm::ESHandle< GEOM_T > m_geometry
std::vector< std::unique_ptr< Variable< DETECTOR_T > > > detIdVars_
id_iterator id_end() const
last identifier iterator
range get(ID id, CMP comparator) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
~MuRecObjBaseProducer() override
edm::ESGetToken< GEOM_T, MuonGeometryRecord > m_token
std::vector< std::unique_ptr< Variable< RECO_T > > > vars_
std::unique_ptr< nanoaod::FlatTable > fillTable(const edm::Event &iEvent, const edm::Handle< COLLECTION > &product) const override
std::vector< std::unique_ptr< Variable< GlobalPoint > > > globalPosVars_
id_iterator id_begin() const
first identifier iterator
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< std::unique_ptr< Variable< GlobalVector > > > globalDirVars_
static edm::ParameterSetDescription baseDescriptions()