Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:25

0001 #ifndef JetPartonMatching_h
0002 #define JetPartonMatching_h
0003 
0004 #include "DataFormats/JetReco/interface/GenJet.h"
0005 #include "DataFormats/JetReco/interface/CaloJet.h"
0006 #include "DataFormats/PatCandidates/interface/Jet.h"
0007 #include "DataFormats/Candidate/interface/Candidate.h"
0008 
0009 #include <vector>
0010 
0011 class JetPartonMatching {
0012   // common class for jet parton matching in ttbar
0013   // decays. Several matching algorithms are provided
0014 public:
0015   typedef std::vector<std::pair<unsigned int, int> > MatchingCollection;
0016   enum algorithms { totalMinDist, minSumDist, ptOrderedMinDist, unambiguousOnly };
0017 
0018   JetPartonMatching(){};
0019   JetPartonMatching(const std::vector<const reco::Candidate*>&,
0020                     const std::vector<reco::GenJet>&,
0021                     const int,
0022                     const bool,
0023                     const bool,
0024                     const double);
0025   JetPartonMatching(const std::vector<const reco::Candidate*>&,
0026                     const std::vector<reco::CaloJet>&,
0027                     const int,
0028                     const bool,
0029                     const bool,
0030                     const double);
0031   JetPartonMatching(const std::vector<const reco::Candidate*>&,
0032                     const std::vector<pat::Jet>&,
0033                     const int,
0034                     const bool,
0035                     const bool,
0036                     const double);
0037   JetPartonMatching(const std::vector<const reco::Candidate*>&,
0038                     const std::vector<const reco::Candidate*>&,
0039                     const int,
0040                     const bool,
0041                     const bool,
0042                     const double);
0043   ~JetPartonMatching(){};
0044 
0045   //matching meta information
0046   unsigned int getNumberOfAvailableCombinations() { return matching.size(); }
0047   int getNumberOfUnmatchedPartons(const unsigned int comb = 0) {
0048     return (comb < numberOfUnmatchedPartons.size() ? (int)numberOfUnmatchedPartons[comb] : -1);
0049   }
0050   int getMatchForParton(const unsigned int part, const unsigned int comb = 0);
0051   std::vector<int> getMatchesForPartons(const unsigned int comb = 0);
0052   double getDistanceForParton(const unsigned int part, const unsigned int comb = 0);
0053   double getSumDistances(const unsigned int comb = 0);
0054 
0055   //matching quantities
0056   double getSumDeltaE(const unsigned int comb = 0) { return (comb < sumDeltaE.size() ? sumDeltaE[comb] : -999.); }
0057   double getSumDeltaPt(const unsigned int comb = 0) { return (comb < sumDeltaPt.size() ? sumDeltaPt[comb] : -999.); }
0058   double getSumDeltaR(const unsigned int comb = 0) { return (comb < sumDeltaR.size() ? sumDeltaR[comb] : -999.); }
0059 
0060   void print();
0061 
0062 private:
0063   void calculate();
0064   double distance(const math::XYZTLorentzVector&, const math::XYZTLorentzVector&);
0065   void matchingTotalMinDist();
0066   void minSumDist_recursion(const unsigned int,
0067                             std::vector<unsigned int>&,
0068                             std::vector<bool>&,
0069                             std::vector<std::pair<double, MatchingCollection> >&);
0070   void matchingMinSumDist();
0071   void matchingPtOrderedMinDist();
0072   void matchingUnambiguousOnly();
0073 
0074 private:
0075   std::vector<const reco::Candidate*> partons;
0076   std::vector<const reco::Candidate*> jets;
0077   std::vector<MatchingCollection> matching;
0078 
0079   std::vector<unsigned int> numberOfUnmatchedPartons;
0080   std::vector<double> sumDeltaE;
0081   std::vector<double> sumDeltaPt;
0082   std::vector<double> sumDeltaR;
0083 
0084   int algorithm_;
0085   bool useMaxDist_;
0086   bool useDeltaR_;
0087   double maxDist_;
0088 };
0089 
0090 #endif