CMS 3D CMS Logo

MatchingUtils.h
Go to the documentation of this file.
1 #ifndef NanoAOD_MatchingUtils_h
2 #define NanoAOD_MatchingUtils_h
3 
4 /*#include <utility>
5 #include <vector>
6 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
7 */
8 template <class C1, class C2>
9 bool matchByCommonSourceCandidatePtr(const C1 & c1, const C2 & c2) {
10  for(unsigned int i1 = 0 ; i1 < c1.numberOfSourceCandidatePtrs();i1++){
11  auto c1s=c1.sourceCandidatePtr(i1);
12  for(unsigned int i2 = 0 ; i2 < c2.numberOfSourceCandidatePtrs();i2++) {
13  if(c2.sourceCandidatePtr(i2)==c1s) return true;
14  }
15  }
16  return false;
17 }
18 
19 template <class C1, class C2>
20 bool matchByCommonParentSuperClusterRef(const C1 & c1, const C2 & c2) {
21  auto c1s = c1.parentSuperCluster();
22  auto c2s = c2.parentSuperCluster();
23  return (c1s == c2s);
24 }
25 
26 /*
27 template<typename I>
28 std::pair<const I &,float> bestMatch(auto item, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
29  float deltaR2Min = 9e99;
30  const I & bm;
31  for(const auto & t : targetColl){
32  if(cut(t)) {
33  float dR2 = deltaR2(item,t);
34  if(dR2 < deltaR2Min){
35  deltaR2Min = dR2;
36  bm = t;
37  }
38  }
39  }
40  return std::pair<const I &,float>(bm, deltaR2Min);
41 }
42 
43 
44 template<typename I>
45 std::vector<std::pair<const I &,float>> matchCollections(auto coll, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
46  std::vector<std::pair<I,float>> pairs;
47  if(coll.empty()) return pairs;
48  for(auto & p : coll){
49  pairs.push_back(bestMatch(p,targetColl,cut));
50  }
51  return pairs;
52 }
53 
54 */
55 
56 #endif
bool matchByCommonParentSuperClusterRef(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:20
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9