CMS 3D CMS Logo

Public Member Functions | Private Attributes

MatchJet Class Reference

#include <MatchJet.h>

List of all members.

Public Member Functions

void matchCollections (const edm::RefToBaseVector< reco::Jet > &refJets, const edm::RefToBaseVector< reco::Jet > &recJets, const edm::EventSetup &es)
 match the collections
 MatchJet ()
 MatchJet (const edm::ParameterSet &pSet)
edm::RefToBase< reco::Jetoperator() (const edm::RefToBase< reco::Jet > &recJet) const
 Returns the matched "reference" jet.
void setThreshold (const double &energy)

Private Attributes

double maxChi2
CorrectJet recJetCorrector
edm::RefToBaseVector< reco::JetrecJets
std::vector< int > recToRef
CorrectJet refJetCorrector
edm::RefToBaseVector< reco::JetrefJets
std::vector< int > refToRec
double sigmaDeltaE
double sigmaDeltaR
double threshold

Detailed Description

Match jets

Definition at line 19 of file MatchJet.h.


Constructor & Destructor Documentation

MatchJet::MatchJet ( ) [inline]

Definition at line 22 of file MatchJet.h.

{}
MatchJet::MatchJet ( const edm::ParameterSet pSet)

Definition at line 43 of file MatchJet.cc.

                                              :
  refJetCorrector(pSet.getParameter<std::string>("refJetCorrection")),
  recJetCorrector(pSet.getParameter<std::string>("recJetCorrection")),
  maxChi2(pSet.getParameter<double>("maxChi2")),
  sigmaDeltaR(pSet.getParameter<double>("sigmaDeltaR")),
  sigmaDeltaE(pSet.getParameter<double>("sigmaDeltaE")),
  threshold(1.0)
{
}

Member Function Documentation

void MatchJet::matchCollections ( const edm::RefToBaseVector< reco::Jet > &  refJets,
const edm::RefToBaseVector< reco::Jet > &  recJets,
const edm::EventSetup es 
)

match the collections

Definition at line 53 of file MatchJet.cc.

References edm::RefToBaseVector< T >::begin(), edm::RefToBaseVector< T >::clear(), edm::RefToBaseVector< T >::end(), reco::LeafCandidate::energy(), metsig::jet, MultipleCompare::Match(), btag::Matching< Delta >::match(), maxChi2, edm::RefToBaseVector< T >::push_back(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), recJetCorrector, recJets, recToRef, refJetCorrector, refJets, refToRec, CorrectJet::setEventSetup(), sigmaDeltaE, sigmaDeltaR, edm::RefToBaseVector< T >::size(), and threshold.

Referenced by BTagPerformanceAnalyzerMC::getJetWithFlavour().

{
        refJetCorrector.setEventSetup(es);
        recJetCorrector.setEventSetup(es);

        typedef ROOT::Math::Cartesian3D<double> Vector;

        std::vector<Vector> corrRefJets;
        refJets.clear();
        for(edm::RefToBaseVector<reco::Jet>::const_iterator iter = refJets.begin();
            iter != refJets_.end(); ++iter) {
                edm::RefToBase<reco::Jet> jetRef = *iter;
                reco::Jet jet = refJetCorrector(*jetRef);
                if (jet.energy() < threshold)
                        continue;

                corrRefJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
                refJets.push_back(jetRef);
        }

        std::vector<Vector> corrRecJets;
        recJets.clear();
        for(edm::RefToBaseVector<reco::Jet>::const_iterator iter = recJets.begin();
            iter != recJets_.end(); ++iter) {
                edm::RefToBase<reco::Jet> jetRec = *iter;
                reco::Jet jet = recJetCorrector(*jetRec);
                if (jet.energy() < threshold)
                        continue;

                corrRecJets.push_back(Vector(jet.px(), jet.py(), jet.pz()));
                recJets.push_back(jetRec);
        }

        this->refJets = refJets;
        refToRec.clear();
        refToRec.resize(refJets.size(), -1);

        this->recJets = recJets;
        recToRef.clear();
        recToRef.resize(recJets.size(), -1);

        Matching<double> matching(corrRefJets, corrRecJets,
                                  JetDistance<Vector, Vector, double>(
                                                sigmaDeltaR, sigmaDeltaE));
        typedef Matching<double>::Match Match;

        const std::vector<Match>& matches =
                matching.match(std::less<double>(),
                               std::bind2nd(std::less<double>(), maxChi2));
        for(std::vector<Match>::const_iterator iter = matches.begin();
            iter != matches.end(); ++iter) {
                refToRec[iter->index1] = iter->index2;
                recToRef[iter->index2] = iter->index1;
        }
}
edm::RefToBase< reco::Jet > MatchJet::operator() ( const edm::RefToBase< reco::Jet > &  recJet) const

Returns the matched "reference" jet.

Definition at line 113 of file MatchJet.cc.

References i, edm::RefToBaseVector< T >::id(), edm::RefToBase< T >::id(), match(), recJets, recToRef, refJets, query::result, and edm::RefToBaseVector< T >::size().

{
        edm::RefToBase<reco::Jet> result;
        if (recJet.id() != recJets.id())
                return result;

        for(unsigned int i = 0; i != recJets.size(); ++i) {
                if (recJets[i] == recJet) {
                        int match = recToRef[i];
                        if (match >= 0)
                                result = refJets[match];
                        break;
                }
        }

        return result;
}
void MatchJet::setThreshold ( const double &  energy) [inline]

Member Data Documentation

double MatchJet::maxChi2 [private]

Definition at line 44 of file MatchJet.h.

Referenced by matchCollections().

Definition at line 42 of file MatchJet.h.

Referenced by matchCollections().

Definition at line 39 of file MatchJet.h.

Referenced by matchCollections(), and operator()().

std::vector<int> MatchJet::recToRef [private]

Definition at line 37 of file MatchJet.h.

Referenced by matchCollections(), and operator()().

Definition at line 41 of file MatchJet.h.

Referenced by matchCollections().

Definition at line 38 of file MatchJet.h.

Referenced by matchCollections(), and operator()().

std::vector<int> MatchJet::refToRec [private]

Definition at line 37 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaE [private]

Definition at line 46 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::sigmaDeltaR [private]

Definition at line 45 of file MatchJet.h.

Referenced by matchCollections().

double MatchJet::threshold [private]

Definition at line 47 of file MatchJet.h.

Referenced by matchCollections(), and setThreshold().