Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:39

0001 #ifndef NanoAOD_MatchingUtils_h
0002 #define NanoAOD_MatchingUtils_h
0003 
0004 /*#include <utility>
0005 #include <vector>
0006 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
0007 */
0008 template <class C1, class C2>
0009 bool matchByCommonSourceCandidatePtr(const C1& c1, const C2& c2) {
0010   for (unsigned int i1 = 0; i1 < c1.numberOfSourceCandidatePtrs(); i1++) {
0011     auto c1s = c1.sourceCandidatePtr(i1);
0012     for (unsigned int i2 = 0; i2 < c2.numberOfSourceCandidatePtrs(); i2++) {
0013       if (c2.sourceCandidatePtr(i2) == c1s)
0014         return true;
0015     }
0016   }
0017   return false;
0018 }
0019 
0020 template <class C1, class C2>
0021 bool matchByCommonParentSuperClusterRef(const C1& c1, const C2& c2) {
0022   auto c1s = c1.parentSuperCluster();
0023   auto c2s = c2.parentSuperCluster();
0024   return (c1s == c2s);
0025 }
0026 
0027 /*
0028 template<typename I>
0029 std::pair<const I &,float> bestMatch(auto item, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
0030     float deltaR2Min = 9e99;
0031     const I & bm;
0032     for(const auto & t : targetColl){
0033     if(cut(t)) {
0034             float dR2 = deltaR2(item,t);
0035             if(dR2 < deltaR2Min){
0036                 deltaR2Min = dR2;
0037                  bm = t;
0038         }
0039         }
0040     }
0041     return std::pair<const I &,float>(bm, deltaR2Min);
0042 }
0043 
0044 
0045 template<typename I>
0046 std::vector<std::pair<const I &,float>> matchCollections(auto coll, auto targetColl,const StringCutObjectSelector<I> & cut="1") {
0047     std::vector<std::pair<I,float>> pairs;
0048     if(coll.empty()) return pairs;
0049     for(auto & p : coll){
0050     pairs.push_back(bestMatch(p,targetColl,cut));
0051     }
0052     return pairs;
0053 }
0054 
0055 */
0056 
0057 #endif