55 const std::vector<T> &
values,
64 algo_(iConfig, consumesCollector()),
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);
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");
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>());
edm::EDGetTokenT< edm::View< reco::Candidate > > matchedToken_
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Labels for input collections.
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
~MatcherUsingTracks() override
MatcherUsingTracksAlgorithm algo_
The real workhorse.
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
void storeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Candidate > > &handle, const std::vector< T > &values, const std::string &label) const
Store extra information in a ValueMap.
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
bool writeExtraPATOutput_
bool dontFailOnMissingInput_
Some extra configurables.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
MatcherUsingTracks(const edm::ParameterSet &iConfig)