DAS  3.0
Das Analysis System
JMEmatching< RecContainer, GenContainer >

Description

template<typename RecContainer = std::vector<RecJet>, typename GenContainer = std::vector<GenJet>>
struct DAS::JMEmatching< RecContainer, GenContainer >

Function that performs matching between an input list of reconstructed level jets and a list of generator level jets, based on their angular distance. The JetMET matching algorithm is used for the procedure.

JetMET matching algorithm (to what we understand):

  1. Allow all possible pairs between gen and rec jets
  2. Discard pairs with DR larger than R/2
  3. Sort by ascending DR (smaller to larger)
  4. Keep pairs that are uniquely defined

According to a page on the TWiki, the matching radius should be taken as half of the cone size radius.

#include <JMEmatching.h>

+ Collaboration diagram for JMEmatching< RecContainer, GenContainer >:

Public Types

using RecIt = RecContainer::iterator
 
using GenIt = GenContainer::iterator
 
using Couple = std::pair< RecIt, GenIt >
 

Public Member Functions

 JMEmatching (RecContainer &recJets, GenContainer &genJets)
 

Public Attributes

std::vector< RecItfake_its
 
std::vector< GenItmiss_its
 
std::vector< Couplematch_its
 

Static Public Attributes

static float maxDR = 0.2
 

Member Typedef Documentation

◆ Couple

using Couple = std::pair<RecIt, GenIt>

◆ GenIt

using GenIt = GenContainer::iterator

◆ RecIt

using RecIt = RecContainer::iterator

Constructor & Destructor Documentation

◆ JMEmatching()

JMEmatching ( RecContainer &  recJets,
GenContainer &  genJets 
)
inline
Parameters
recJetsfull container of rec jet
genJetsfull container of gen jet
42  {
43  using namespace std;
44 
45  // 1) get the size of the collections
46 
47  size_t nRec = distance(recJets.begin(), recJets.end()),
48  nGen = distance(genJets.begin(), genJets.end());
49 
50  // 2) declare a few utilities
51 
52  typedef pair<size_t,size_t> Indices;
53 
54  auto DeltaR2 = [&recJets,&genJets](const Indices& indices) {
55  const FourVector& recJet = recJets[indices.first ].p4,
56  genJet = genJets[indices.second].p4;
57  return ROOT::Math::VectorUtil::DeltaR2(recJet, genJet);
58  };
59 
60  auto ascending_DR2 = [&DeltaR2](const Indices& l, const Indices& r) {
61  return DeltaR2(l) > DeltaR2(r);
62  };
63 
64  // 3) make pair candidates
65 
66  // https://en.cppreference.com/w/cpp/container/priority_queue
67  priority_queue< Indices,
68  vector<Indices>, decltype(ascending_DR2)>
69  candidates(ascending_DR2);
70  for (size_t iRec = 0; iRec < nRec; ++iRec)
71  for (size_t iGen = 0; iGen < nGen; ++iGen) {
72  Indices indices {iRec, iGen};
73  auto DR2 = DeltaR2(indices);
74  if (DR2 >= pow(maxDR,2)) continue;
75  candidates.emplace( move(indices) );
76  }
77 
78  // 4) keep only the closest pairs (keep track of matched jets to avoid double matching)
79 
80  vector<bool> matchedRec(nRec, false),
81  matchedGen(nGen, false);
82  match_its.reserve(min(nRec,nGen));
83  while (!candidates.empty()) {
84  auto [iRec, iGen] = candidates.top();
85  candidates.pop();
86 
87  // skip already matched objects
88  if (matchedRec.at(iRec)) continue;
89  if (matchedGen.at(iGen)) continue;
90  matchedRec.at(iRec) = true;
91  matchedGen.at(iGen) = true;
92 
93  RecIt rec_it = recJets.begin();
94  GenIt gen_it = genJets.begin();
95  advance(rec_it, iRec);
96  advance(gen_it, iGen);
97 
98  match_its.push_back( make_pair(rec_it, gen_it) );
99  }
100 
101  // 5) fill the unmatched entries
102 
103  fake_its.reserve(nRec);
104  for (int iRec = 0; iRec < nRec; ++iRec) {
105  if (matchedRec.at(iRec)) continue;
106  RecIt fake_it = recJets.begin();
107  advance(fake_it, iRec);
108  fake_its.push_back(fake_it);
109  }
110 
111  miss_its.reserve(nGen);
112  for (int iGen = 0; iGen < nGen; ++iGen) {
113  if (matchedGen.at(iGen)) continue;
114  GenIt miss_it = genJets.begin();
115  advance(miss_it, iGen);
116  miss_its.push_back(miss_it);
117  }
118  }

Member Data Documentation

◆ fake_its

std::vector<RecIt> fake_its

◆ match_its

std::vector<Couple> match_its

◆ maxDR

float maxDR = 0.2
static

◆ miss_its

std::vector<GenIt> miss_its

The documentation for this struct was generated from the following file:
DAS::JMEmatching::GenIt
GenContainer::iterator GenIt
Definition: JMEmatching.h:31
DAS::JMEmatching::RecIt
RecContainer::iterator RecIt
Definition: JMEmatching.h:30
DAS::JMEmatching::fake_its
std::vector< RecIt > fake_its
Definition: JMEmatching.h:36
DAS::JMEmatching::miss_its
std::vector< GenIt > miss_its
Definition: JMEmatching.h:37
DAS::JMEmatching::maxDR
static float maxDR
Definition: JMEmatching.h:34
DAS::JMEmatching::match_its
std::vector< Couple > match_its
Definition: JMEmatching.h:38
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15