CMS 3D CMS Logo

JetMatcherDR.cc
Go to the documentation of this file.
1 /* \class JetMatcherDR
2  *
3  * Producer for association map:
4  * class to match two collections of jet with one-to-one matching
5  * All elements of class "matched" are matched to each element of class "source" minimizing DeltaR
6  *
7  */
8 
16 
18 public:
20  explicit JetMatcherDR(const edm::ParameterSet& iConfig)
21  : sourceToken_(consumes<reco::JetView>(iConfig.getParameter<edm::InputTag>("source"))),
22  matchedToken_(consumes<reco::JetView>(iConfig.getParameter<edm::InputTag>("matched"))) {
23  produces<JetMatchMap>();
24  };
25  ~JetMatcherDR() override{};
26  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
27 
28 private:
31 };
32 
34  const auto& source = iEvent.getHandle(sourceToken_);
35  const auto& matched = iEvent.getHandle(matchedToken_);
36  auto matching = std::make_unique<JetMatchMap>(source, matched);
37  for (size_t i = 0; i < source->size(); i++) {
38  std::pair<int, float> m(-1, 999.f);
39  for (size_t j = 0; j < matched->size(); j++) {
40  const auto dR = deltaR((*source)[i].p4(), (*matched)[j].p4());
41  if (dR < m.second)
42  m = {j, dR};
43  }
44  matching->insert(source->refAt(i), m.first >= 0 ? matched->refAt(m.first) : reco::JetBaseRef());
45  }
46  iEvent.put(std::move(matching));
47 }
48 
~JetMatcherDR() override
Definition: JetMatcherDR.cc:25
edm::View< Jet > JetView
edm references
Definition: JetCollection.h:11
const edm::EDGetTokenT< reco::JetView > matchedToken_
Definition: JetMatcherDR.cc:30
edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > JetMatchMap
Definition: JetMatcherDR.cc:19
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
double f[11][100]
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::RefToBase< Jet > JetBaseRef
Definition: JetCollection.h:12
fixed size matrix
HLT enums.
const edm::EDGetTokenT< reco::JetView > sourceToken_
Definition: JetMatcherDR.cc:29
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: JetMatcherDR.cc:33
JetMatcherDR(const edm::ParameterSet &iConfig)
Definition: JetMatcherDR.cc:20
static std::string const source
Definition: EdmProvDump.cc:49
def move(src, dest)
Definition: eostools.py:511