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)
14  return true;
15  }
16  }
17  return false;
18 }
19 
20 template <class C1, class C2>
21 bool matchByCommonParentSuperClusterRef(const C1& c1, const C2& c2) {
22  auto c1s = c1.parentSuperCluster();
23  auto c2s = c2.parentSuperCluster();
24  return (c1s == c2s);
25 }
26 
27 /*
28 template<typename I>
29 std::pair<const I &,float> bestMatch(auto item, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
30  float deltaR2Min = 9e99;
31  const I & bm;
32  for(const auto & t : targetColl){
33  if(cut(t)) {
34  float dR2 = deltaR2(item,t);
35  if(dR2 < deltaR2Min){
36  deltaR2Min = dR2;
37  bm = t;
38  }
39  }
40  }
41  return std::pair<const I &,float>(bm, deltaR2Min);
42 }
43 
44 
45 template<typename I>
46 std::vector<std::pair<const I &,float>> matchCollections(auto coll, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
47  std::vector<std::pair<I,float>> pairs;
48  if(coll.empty()) return pairs;
49  for(auto & p : coll){
50  pairs.push_back(bestMatch(p,targetColl,cut));
51  }
52  return pairs;
53 }
54 
55 */
56 
57 #endif
matchByCommonParentSuperClusterRef
bool matchByCommonParentSuperClusterRef(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:21
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
matchByCommonSourceCandidatePtr
bool matchByCommonSourceCandidatePtr(const C1 &c1, const C2 &c2)
Definition: MatchingUtils.h:9
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
alignmentValidation.c1
c1
do drawing
Definition: alignmentValidation.py:1025