23 std::map<std::string, edm::EDGetTokenT<T>>
getTokens(
const std::vector<edm::InputTag>&
tags) {
24 std::map<std::string, edm::EDGetTokenT<T>> tokens;
26 tokens.emplace(
tag.label(), consumes<T>(
tag));
36 const std::map<std::string, edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection>>>
trk2pcTokens_;
44 desc.add<std::vector<edm::InputTag>>(
47 desc.add<std::vector<edm::InputTag>>(
"dedxEstimators",
57 dedxEstimatorsTokens_(
64 produces<edm::ValueMap<reco::DeDxData>>(
d.first);
65 produces<reco::DeDxHitInfoCollection>();
66 produces<reco::DeDxHitInfoAss>();
67 produces<edm::ValueMap<std::vector<float>>>(
"momentumAtHit");
73 std::vector<reco::TrackRef> trackRefs;
74 trackRefs.reserve(
tracks->size());
78 typedef std::map<pat::PackedCandidateRef, reco::TrackRef> PCTrkMap;
79 std::vector<std::pair<edm::Handle<pat::PackedCandidateCollection>, PCTrkMap>> pcTrkMap;
84 for (
const auto&
track : trackRefs) {
85 const auto& pc = trk2pc[
track];
89 pcTrkMap.emplace_back(
iEvent.getHandle(
p.second),
map);
95 auto trackDeDxValueMap = std::make_unique<edm::ValueMap<reco::DeDxData>>();
98 for (
const auto&
h : pcTrkMap) {
99 std::vector<reco::DeDxData> dedxEstimate(
h.first->size());
100 for (
const auto&
p :
h.second)
102 filler.insert(
h.first, dedxEstimate.begin(), dedxEstimate.end());
113 auto dedxHitInfoAssociation = std::make_unique<reco::DeDxHitInfoAss>(dedxHitInfoHandle);
115 auto resultdedxHitColl = std::make_unique<reco::DeDxHitInfoCollection>();
116 resultdedxHitColl->reserve(pcTrkMap.size() > 0 ? pcTrkMap.size() * pcTrkMap[0].second.size() : 0);
117 std::vector<std::vector<float>> momenta;
118 momenta.reserve(resultdedxHitColl->capacity());
120 for (
const auto&
h : pcTrkMap) {
121 std::vector<int>
indices(
h.first->size(), -1);
122 for (
const auto&
p :
h.second) {
123 const auto& dedxHit = dedxHitAss[
p.second];
124 if (dedxHit.isNull())
126 indices[
p.first.key()] = resultdedxHitColl->size();
127 resultdedxHitColl->emplace_back(*dedxHit);
128 momenta.emplace_back(dedxHitMom[dedxHit]);
132 const auto& dedxHitCollHandle =
iEvent.put(
std::move(resultdedxHitColl));
137 auto dedxMomenta = std::make_unique<edm::ValueMap<std::vector<float>>>();
139 mfiller.insert(dedxHitCollHandle, momenta.begin(), momenta.end());
const edm::EDGetTokenT< edm::ValueMap< std::vector< float > > > dedxHitMomToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const std::map< std::string, edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > > trk2pcTokens_
~DeDxEstimatorRekeyer() override
std::vector< pat::PackedCandidate > PackedCandidateCollection
std::vector< Track > TrackCollection
collection of Tracks
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
DeDxEstimatorRekeyer(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::DeDxHitInfoAss > dedxHitAssToken_
edm::Association< DeDxHitInfoCollection > DeDxHitInfoAss
const std::map< std::string, edm::EDGetTokenT< pat::PackedCandidateCollection > > packedCandidatesTokens_
#define DEFINE_FWK_MODULE(type)
const edm::EDGetTokenT< reco::TrackCollection > tracksToken_
std::map< std::string, edm::EDGetTokenT< T > > getTokens(const std::vector< edm::InputTag > &tags)
std::vector< DeDxHitInfo > DeDxHitInfoCollection
const std::map< std::string, edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > > dedxEstimatorsTokens_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.