55 const std::vector<T> &
values,
65 dontFailOnMissingInput_(iConfig.existsAs<
bool>(
"dontFailOnMissingInput")
66 ? iConfig.getParameter<
bool>(
"dontFailOnMissingInput")
69 iConfig.existsAs<
bool>(
"writeExtraPATOutput") ? iConfig.getParameter<
bool>(
"writeExtraPATOutput") :
false) {
71 produces<edm::ValueMap<reco::CandidatePtr> >();
74 produces<edm::OwnVector<pat::UserData> >();
75 produces<edm::ValueMap<edm::Ptr<pat::UserData> > >();
78 if (
algo_.hasMetrics()) {
79 produces<edm::ValueMap<float> >(
"deltaR");
80 produces<edm::ValueMap<float> >(
"deltaEta");
81 produces<edm::ValueMap<float> >(
"deltaPhi");
82 produces<edm::ValueMap<float> >(
"deltaLocalPos");
83 produces<edm::ValueMap<float> >(
"deltaPtRel");
84 if (
algo_.hasChi2()) {
85 produces<edm::ValueMap<float> >(
"chi2");
88 produces<edm::ValueMap<int> >(
"matched");
105 int isrc, nsrc =
src->size();
108 vector<int>
match(nsrc, -1);
109 vector<float> deltaRs(nsrc, 999);
110 vector<float> deltaEtas(nsrc, 999);
111 vector<float> deltaPhis(nsrc, 999);
112 vector<float> deltaPtRel(nsrc, 999);
113 vector<float> deltaLocalPos(nsrc, 999);
114 vector<float>
chi2(nsrc, 999999);
117 if (!(
matched.failedToGet() && dontFailOnMissingInput_)) {
119 for (itsrc =
src->begin(), edsrc =
src->end(), isrc = 0; itsrc != edsrc; ++itsrc, ++isrc) {
120 match[isrc] = algo_.match(*itsrc,
131 std::vector<reco::CandidatePtr> ptrs(nsrc);
132 for (isrc = 0; isrc < nsrc; ++isrc) {
133 if (
match[isrc] != -1) {
137 storeValueMap<reco::CandidatePtr>(
iEvent,
src, ptrs,
"");
139 if (writeExtraPATOutput_) {
140 auto outUDVect = std::make_unique<edm::OwnVector<pat::UserData> >();
141 std::vector<int> idxUD(nsrc, -1);
142 for (isrc = 0; isrc < nsrc; ++isrc) {
143 if (
match[isrc] != -1) {
145 idxUD[isrc] = outUDVect->size() - 1;
149 std::vector<edm::Ptr<pat::UserData> > ptrUD(nsrc);
150 for (isrc = 0; isrc < nsrc; ++isrc) {
151 if (idxUD[isrc] != -1)
154 storeValueMap<edm::Ptr<pat::UserData> >(
iEvent,
src, ptrUD,
"");
157 if (algo_.hasMetrics()) {
158 storeValueMap<float>(
iEvent,
src, deltaRs,
"deltaR");
159 storeValueMap<float>(
iEvent,
src, deltaEtas,
"deltaEta");
160 storeValueMap<float>(
iEvent,
src, deltaPhis,
"deltaPhi");
161 storeValueMap<float>(
iEvent,
src, deltaLocalPos,
"deltaLocalPos");
162 storeValueMap<float>(
iEvent,
src, deltaPtRel,
"deltaPtRel");
163 if (algo_.hasChi2()) {
167 std::vector<int> ismatched(nsrc, 0);
168 for (isrc = 0; isrc < nsrc; ++isrc) {
169 ismatched[isrc] = (
match[isrc] != -1);
171 storeValueMap<int>(
iEvent,
src, ismatched,
"matched");
175 template <
typename T>
178 const std::vector<T> &
values,
182 unique_ptr<ValueMap<T> > valMap(
new ValueMap<T>());