Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:16

0001 #ifndef MatchLessByDPt_h_
0002 #define MatchLessByDPt_h_
0003 
0004 /** Provides the less operator for two pairs of matched objects based
0005  *  on deltaPt. */
0006 
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 // #include "CommonTools/UtilAlgos/interface/DeltaR.h"
0009 
0010 namespace reco {
0011   template <typename C1, typename C2>
0012   struct MatchLessByDPt {
0013   public:
0014     MatchLessByDPt(const edm::ParameterSet& cfg, const C1& c1, const C2& c2)
0015         :  //       deltaR_(cfg),
0016           c1_(c1),
0017           c2_(c2) {}
0018     bool operator()(const std::pair<size_t, size_t>& p1, const std::pair<size_t, size_t>& p2) const {
0019       typedef typename C1::value_type T1;
0020       typedef typename C2::value_type T2;
0021       const T1& p1_1 = c1_[p1.first];
0022       const T2& p1_2 = c2_[p1.second];
0023       const T1& p2_1 = c1_[p2.first];
0024       const T2& p2_2 = c2_[p2.second];
0025       if (fabs(p1_1.pt() - p1_2.pt()) / p1_2.pt() < fabs(p2_1.pt() - p2_2.pt()) / p2_2.pt())
0026         return true;
0027       return false;
0028     }
0029 
0030   private:
0031     //     DeltaR deltaR_;
0032     const C1& c1_;
0033     const C2& c2_;
0034   };
0035 }  // namespace reco
0036 
0037 #endif