27 namespace edm {
using std::advance; }
54 const std::vector<T> &
values,
65 dontFailOnMissingInput_(iConfig.existsAs<bool>(
"dontFailOnMissingInput") ? iConfig.getParameter<bool>(
"dontFailOnMissingInput") :
false),
66 writeExtraPATOutput_(iConfig.existsAs<bool>(
"writeExtraPATOutput") ? iConfig.getParameter<bool>(
"writeExtraPATOutput") :
false)
69 produces<edm::ValueMap<reco::CandidatePtr> >();
72 produces<edm::OwnVector<pat::UserData> >();
73 produces<edm::ValueMap<edm::Ptr<pat::UserData> > >();
76 if (
algo_.hasMetrics()) {
77 produces<edm::ValueMap<float> >(
"deltaR");
78 produces<edm::ValueMap<float> >(
"deltaEta");
79 produces<edm::ValueMap<float> >(
"deltaPhi");
80 produces<edm::ValueMap<float> >(
"deltaLocalPos");
81 produces<edm::ValueMap<float> >(
"deltaPtRel");
82 if (
algo_.hasChi2()) {
83 produces<edm::ValueMap<float> >(
"chi2");
86 produces<edm::ValueMap<int> >(
"matched");
104 int isrc, nsrc =
src->size();
107 vector<int>
match(nsrc, -1);
108 vector<float> deltaRs(nsrc, 999);
109 vector<float> deltaEtas(nsrc, 999);
110 vector<float> deltaPhis(nsrc, 999);
111 vector<float> deltaPtRel(nsrc, 999);
112 vector<float> deltaLocalPos(nsrc, 999);
113 vector<float>
chi2(nsrc, 999999);
116 if (!(matched.failedToGet() && dontFailOnMissingInput_)) {
118 for (itsrc =
src->begin(), edsrc =
src->end(), isrc = 0; itsrc != edsrc; ++itsrc, ++isrc) {
119 match[isrc] =
algo_.match(*itsrc, *matched, deltaRs[isrc], deltaEtas[isrc], deltaPhis[isrc], deltaLocalPos[isrc], deltaPtRel[isrc], chi2[isrc]);
123 std::vector<reco::CandidatePtr> ptrs(nsrc);
124 for (isrc = 0; isrc < nsrc; ++isrc) {
125 if (match[isrc] != -1) {
126 ptrs[isrc] = matched->ptrAt(match[isrc]);
129 storeValueMap<reco::CandidatePtr>(
iEvent,
src, ptrs,
"");
131 if (writeExtraPATOutput_) {
132 auto outUDVect = std::make_unique<edm::OwnVector<pat::UserData> >();
133 std::vector<int> idxUD(nsrc, -1);
134 for (isrc = 0; isrc < nsrc; ++isrc) {
135 if (match[isrc] != -1) {
137 idxUD[isrc] = outUDVect->size() - 1;
141 std::vector<edm::Ptr<pat::UserData> > ptrUD(nsrc);
142 for (isrc = 0; isrc < nsrc; ++isrc) {
145 storeValueMap<edm::Ptr<pat::UserData> >(
iEvent,
src, ptrUD,
"");
148 if (
algo_.hasMetrics()) {
149 storeValueMap<float>(
iEvent,
src, deltaRs,
"deltaR");
150 storeValueMap<float>(
iEvent,
src, deltaEtas,
"deltaEta");
151 storeValueMap<float>(
iEvent,
src, deltaPhis,
"deltaPhi");
152 storeValueMap<float>(
iEvent,
src, deltaLocalPos,
"deltaLocalPos");
153 storeValueMap<float>(
iEvent,
src, deltaPtRel,
"deltaPtRel");
154 if (
algo_.hasChi2()) {
158 std::vector<int> ismatched(nsrc, 0);
159 for (isrc = 0; isrc < nsrc; ++isrc) {
160 ismatched[isrc] = (match[isrc] != -1);
162 storeValueMap<int>(
iEvent,
src, ismatched,
"matched");
170 const std::vector<T> &
values,
172 using namespace edm;
using namespace std;
173 unique_ptr<ValueMap<T> > valMap(
new ValueMap<T>());
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.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
algo_(conf.existsAs< bool >("Correct")?conf.getParameter< bool >("Correct"):true, conf.getParameter< double >("e9e25Cut"), conf.getParameter< double >("intercept2DCut"), conf.existsAs< bool >("intercept2DSlope")?conf.getParameter< double >("intercept2DSlope"):defaultSlope2D_, conf.getParameter< std::vector< double > >("e1e9Cut"), conf.getParameter< std::vector< double > >("eCOREe9Cut"), conf.getParameter< std::vector< double > >("eSeLCut"), hfvars_)
edm::EDGetTokenT< edm::View< reco::Candidate > > matchedToken_
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
edm::EDGetTokenT< edm::View< reco::Candidate > > srcToken_
Labels for input collections.
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
MatcherUsingTracksAlgorithm algo_
The real workhorse.
Matcher of reconstructed objects to other reconstructed objects using the tracks inside them...
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
virtual ~MatcherUsingTracks()
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.
volatile std::atomic< bool > shutdown_flag false
MatcherUsingTracks(const edm::ParameterSet &iConfig)