DAS  3.0
Das Analysis System
JMEmatching< RecContainer, GenContainer >

Description

template<typename RecContainer = std::vector<RecJet>, typename GenContainer = std::vector<GenJet>>
class 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
 

Static Private Member Functions

static FourVector getP4 (const FourVector &p4)
 
static FourVector getP4 (const PhysicsObject &phys_obj)
 

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

Member Function Documentation

◆ getP4() [1/2]

static FourVector getP4 ( const FourVector p4)
inlinestaticprivate
31  {
32  return p4;
33  }

◆ getP4() [2/2]

static FourVector getP4 ( const PhysicsObject phys_obj)
inlinestaticprivate
36  {
37  return phys_obj.p4;
38  }

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 class was generated from the following file:
DAS::JMEmatching::getP4
static FourVector getP4(const FourVector &p4)
Definition: JMEmatching.h:30
DAS::JMEmatching::match_its
std::vector< Couple > match_its
Definition: JMEmatching.h:50
DAS::JMEmatching::GenIt
GenContainer::iterator GenIt
Definition: JMEmatching.h:43
DAS::JMEmatching::fake_its
std::vector< RecIt > fake_its
Definition: JMEmatching.h:48
DAS::JMEmatching::maxDR
static float maxDR
Definition: JMEmatching.h:46
DAS::JMEmatching::miss_its
std::vector< GenIt > miss_its
Definition: JMEmatching.h:49
DAS::FourVector
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< float > > FourVector
Definition: PhysicsObject.h:15
DAS::JMEmatching::RecIt
RecContainer::iterator RecIt
Definition: JMEmatching.h:42