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");
116 fullDesc.
setComment(
"a parameters set to define all " +
label +
" variables to the flat table");
117 fullDesc.
addNode(detIdVarWildCard);
122 auto detIdVar{baseDescription()};
123 auto globalGeomVar{baseDescription()};
125 edm::Comment comType{
"the c++ type of the branch in the flat table"};
127 edm::allowedValues<std::string>(
"int",
"uint",
"int16",
"uint8"));
129 edm::Comment comPrecision{
"the precision with which to store the value in the flat table"};
135 if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
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;
150 std::list<DETECTOR_T> detIdObjs;
151 std::list<GlobalPoint> globalPointObjs;
152 std::list<GlobalVector> globalVectorObjs;
156 const auto detIdEnd = product->
id_end();
158 for (; detIdIt != detIdEnd; ++detIdIt) {
159 const auto &
range = product->
get(*detIdIt);
162 detIdObjs.push_back(*detIdIt);
163 std::fill_n(std::back_inserter(detIds),
range.second -
range.first, &detIdObjs.back());
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());
179 for (
const auto &
var : this->
vars_) {
191 if constexpr (std::is_base_of_v<RecSegment, RECO_T>) {
193 var->fill(globalDirections, *
table);
202 event.getByToken(this->
src_, src);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
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()