Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:46

0001 #ifndef MuonAnalysis_MuonAssociators_src_MatcherByPullsAlgorithm_h
0002 #define MuonAnalysis_MuonAssociators_src_MatcherByPullsAlgorithm_h
0003 // -*- C++ -*-
0004 //
0005 // Package:    MuonAnalysis/MuonAssociators
0006 // Class:      MatcherByPullsAlgorithm
0007 //
0008 /**\class MatcherByPullsAlgorithm MatcherByPullsAlgorithm.cc MuonAnalysis/MuonAssociators/interface/MatcherByPullsAlgorithm.cc
0009 
0010  Description: Matches a RecoCandidate to a GenParticle (or any other Candidate) using the pulls of the helix parameters
0011 
0012  Implementation:
0013      <Notes on implementation>
0014 */
0015 //
0016 // Original Author:  Giovanni Petrucciani (SNS Pisa and CERN PH-CMG)
0017 //         Created:  Sun Nov 16 16:14:09 CET 2008
0018 //
0019 //
0020 
0021 #include <string>
0022 #include <algorithm>
0023 #include <vector>
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 
0026 #include "DataFormats/TrackReco/interface/Track.h"
0027 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0028 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0029 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0030 
0031 //
0032 // class decleration
0033 
0034 class MatcherByPullsAlgorithm {
0035 public:
0036   explicit MatcherByPullsAlgorithm(const edm::ParameterSet &);
0037   ~MatcherByPullsAlgorithm();
0038 
0039   /// Match Track to MC Candidate, using already inverted covariance matrix
0040   /// Return status of match and pull, or (-1,9e9)
0041   std::pair<bool, float> match(const reco::Track &tk,
0042                                const reco::Candidate &mc,
0043                                const AlgebraicSymMatrix55 &invertedCovariance) const;
0044 
0045   /// Match Reco Candidate to MC Candidates, skipping the ones which are not good
0046   /// Return index of matchin and pull, or (-1,9e9)
0047   std::pair<int, float> match(const reco::RecoCandidate &src,
0048                               const std::vector<reco::GenParticle> &cands,
0049                               const std::vector<uint8_t> &good) const;
0050 
0051   /// Match Reco Candidate to MC Candidates, allowing multiple matches and skipping the ones which are not good
0052   /// It will fill in the vector of <double,int> with pull and index for all matching candidates,
0053   /// already sorted by pulls.
0054   /// This method assumes that matchesToFill is empty when the method is called
0055   void matchMany(const reco::RecoCandidate &src,
0056                  const std::vector<reco::GenParticle> &cands,
0057                  const std::vector<uint8_t> &good,
0058                  std::vector<std::pair<double, int> > &matchesToFill) const;
0059 
0060   /// Match Reco Track to MC Tracks, skipping the ones which are not good
0061   /// Return index of matchin and pull, or (-1,9e9)
0062   std::pair<int, float> match(const reco::Track &src,
0063                               const std::vector<reco::GenParticle> &cands,
0064                               const std::vector<uint8_t> &good) const;
0065 
0066   /// Match Reco Track to MC Tracks, allowing multiple matches and skipping the ones which are not good
0067   /// It will fill in the vector of <double,int> with pull and index for all matching candidates,
0068   /// already sorted by pulls.
0069   /// This method assumes that matchesToFill is empty when the method is called
0070   void matchMany(const reco::Track &src,
0071                  const std::vector<reco::GenParticle> &cands,
0072                  const std::vector<uint8_t> &good,
0073                  std::vector<std::pair<double, int> > &matchesToFill) const;
0074 
0075   /// Fill the inverse covariance matrix for the match(track, candidate, invCov) method
0076   void fillInvCov(const reco::Track &tk, AlgebraicSymMatrix55 &invCov) const;
0077 
0078 private:
0079   /// Get track out of Candidate, NULL if missing
0080   const reco::Track *track(const reco::RecoCandidate &src) const;
0081 
0082   /// Enum to define which track to use
0083   enum TrackChoice { StaTrack, TrkTrack, GlbTrack };
0084 
0085   /// Track to be used in matching
0086   TrackChoice track_;
0087 
0088   /// DeltaR of the matching cone
0089   double dr2_;
0090 
0091   /// Cut on the pull
0092   double cut_;
0093 
0094   /// Use only the diagonal terms of the covariance matrix
0095   bool diagOnly_;
0096 
0097   /// Use also dxy / dsz in the matching
0098   bool useVertex_;
0099 };
0100 
0101 #endif