27 namespace edm {
using std::advance; }
53 const std::vector<T> &
values,
61 src_(iConfig.getParameter<edm::InputTag>(
"src")),
62 matched_(iConfig.getParameter<edm::InputTag>(
"matched")),
64 dontFailOnMissingInput_(iConfig.existsAs<bool>(
"dontFailOnMissingInput") ? iConfig.getParameter<bool>(
"dontFailOnMissingInput") :
false),
65 writeExtraPATOutput_(iConfig.existsAs<bool>(
"writeExtraPATOutput") ? iConfig.getParameter<bool>(
"writeExtraPATOutput") :
false)
68 produces<edm::ValueMap<reco::CandidatePtr> >();
71 produces<edm::OwnVector<pat::UserData> >();
72 produces<edm::ValueMap<edm::Ptr<pat::UserData> > >();
75 if (
algo_.hasMetrics()) {
76 produces<edm::ValueMap<float> >(
"deltaR");
77 produces<edm::ValueMap<float> >(
"deltaEta");
78 produces<edm::ValueMap<float> >(
"deltaPhi");
79 produces<edm::ValueMap<float> >(
"deltaLocalPos");
80 produces<edm::ValueMap<float> >(
"deltaPtRel");
81 if (
algo_.hasChi2()) {
82 produces<edm::ValueMap<float> >(
"chi2");
85 produces<edm::ValueMap<int> >(
"matched");
103 int isrc, nsrc =
src->size();
106 vector<int>
match(nsrc, -1);
107 vector<float> deltaRs(nsrc, 999);
108 vector<float> deltaEtas(nsrc, 999);
109 vector<float> deltaPhis(nsrc, 999);
110 vector<float> deltaPtRel(nsrc, 999);
111 vector<float> deltaLocalPos(nsrc, 999);
112 vector<float> chi2(nsrc, 999999);
115 if (!(matched.failedToGet() && dontFailOnMissingInput_)) {
117 for (itsrc =
src->begin(), edsrc =
src->end(), isrc = 0; itsrc != edsrc; ++itsrc, ++isrc) {
118 match[isrc] = algo_.match(*itsrc, *matched, deltaRs[isrc], deltaEtas[isrc], deltaPhis[isrc], deltaLocalPos[isrc], deltaPtRel[isrc], chi2[isrc]);
122 std::vector<reco::CandidatePtr> ptrs(nsrc);
123 for (isrc = 0; isrc < nsrc; ++isrc) {
124 if (match[isrc] != -1) {
125 ptrs[isrc] = matched->ptrAt(match[isrc]);
128 storeValueMap<reco::CandidatePtr>(
iEvent,
src, ptrs,
"");
130 if (writeExtraPATOutput_) {
132 std::vector<int> idxUD(nsrc, -1);
133 for (isrc = 0; isrc < nsrc; ++isrc) {
134 if (match[isrc] != -1) {
136 idxUD[isrc] = outUDVect->size() - 1;
140 std::vector<edm::Ptr<pat::UserData> > ptrUD(nsrc);
141 for (isrc = 0; isrc < nsrc; ++isrc) {
144 storeValueMap<edm::Ptr<pat::UserData> >(
iEvent,
src, ptrUD,
"");
147 if (algo_.hasMetrics()) {
148 storeValueMap<float>(
iEvent,
src, deltaRs,
"deltaR");
149 storeValueMap<float>(
iEvent,
src, deltaEtas,
"deltaEta");
150 storeValueMap<float>(
iEvent,
src, deltaPhis,
"deltaPhi");
151 storeValueMap<float>(
iEvent,
src, deltaLocalPos,
"deltaLocalPos");
152 storeValueMap<float>(
iEvent,
src, deltaPtRel,
"deltaPtRel");
153 if (algo_.hasChi2()) {
154 storeValueMap<float>(
iEvent,
src, chi2,
"chi2");
157 std::vector<int> ismatched(nsrc, 0);
158 for (isrc = 0; isrc < nsrc; ++isrc) {
159 ismatched[isrc] = (match[isrc] != -1);
161 storeValueMap<int>(
iEvent,
src, ismatched,
"matched");
169 const std::vector<T> &
values,
171 using namespace edm;
using namespace std;
176 iEvent.
put(valMap, label);
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.
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
#define DEFINE_FWK_MODULE(type)
static std::auto_ptr< UserData > make(const T &value, bool transientOnly=false)
void insert(const H &h, I begin, I end)
edm::InputTag src_
Labels for input collections.
MatcherUsingTracksAlgorithm algo_
The real workhorse.
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
virtual ~MatcherUsingTracks()
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool writeExtraPATOutput_
bool dontFailOnMissingInput_
Some extra configurables.
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
volatile std::atomic< bool > shutdown_flag false
MatcherUsingTracks(const edm::ParameterSet &iConfig)