CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/HLTriggerOffline/Muon/src/L1MuonMatcherAlgo.cc

Go to the documentation of this file.
00001 #include "HLTriggerOffline/Muon/interface/L1MuonMatcherAlgo.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 
00005 L1MuonMatcherAlgo::L1MuonMatcherAlgo(const edm::ParameterSet & iConfig) :
00006     prop_(iConfig),
00007     preselectionCut_(iConfig.existsAs<std::string>("preselection") ? iConfig.getParameter<std::string>("preselection") : ""),
00008     deltaR2_(std::pow(iConfig.getParameter<double>("maxDeltaR"),2)),
00009     deltaPhi_(iConfig.existsAs<double>("maxDeltaPhi") ? iConfig.getParameter<double>("maxDeltaPhi") : 10),
00010     sortByDeltaPhi_(iConfig.existsAs<bool>("sortByDeltaPhi") ? iConfig.getParameter<bool>("sortByDeltaPhi") : false)
00011 {
00012 }
00013 
00014 L1MuonMatcherAlgo::~L1MuonMatcherAlgo() {}
00015 
00016 void
00017 L1MuonMatcherAlgo::init(const edm::EventSetup & iSetup) {
00018     prop_.init(iSetup);
00019 }
00020 
00021 bool
00022 L1MuonMatcherAlgo::match(TrajectoryStateOnSurface & propagated, const l1extra::L1MuonParticle &l1, float &deltaR, float &deltaPhi) const {
00023     if (preselectionCut_(l1)) {
00024         GlobalPoint pos = propagated.globalPosition();
00025         double thisDeltaPhi = ::deltaPhi(double(pos.phi()),  l1.phi());
00026         double thisDeltaR2  = ::deltaR2(double(pos.eta()), double(pos.phi()), l1.eta(), l1.phi());
00027         if ((fabs(thisDeltaPhi) < deltaPhi_) && (thisDeltaR2 < deltaR2_)) {
00028             deltaR   = std::sqrt(thisDeltaR2);
00029             deltaPhi = thisDeltaPhi;
00030             return true;
00031         }
00032     }
00033     return false;
00034 }
00035 
00036 int
00037 L1MuonMatcherAlgo::match(TrajectoryStateOnSurface & propagated, const std::vector<l1extra::L1MuonParticle> &l1s, float &deltaR, float &deltaPhi) const {
00038     return matchGeneric(propagated, l1s, preselectionCut_, deltaR, deltaPhi);
00039 /*
00040     int match = -1;
00041     double minDeltaPhi = deltaPhi_;
00042     double minDeltaR2  = deltaR2_;
00043     GlobalPoint pos = propagated.globalPosition();
00044     for (int i = 0, n = l1s.size(); i < n; ++i) {
00045         const l1extra::L1MuonParticle &l1 = l1s[i];
00046         if (preselectionCut_(l1)) {
00047             double thisDeltaPhi = ::deltaPhi(double(pos.phi()),  l1.phi());
00048             double thisDeltaR2  = ::deltaR2(double(pos.eta()), double(pos.phi()), l1.eta(), l1.phi());
00049             if ((fabs(thisDeltaPhi) < deltaPhi_) && (thisDeltaR2 < deltaR2_)) { // check both
00050                 if (sortByDeltaPhi_ ? (fabs(thisDeltaPhi) < fabs(minDeltaPhi)) : (thisDeltaR2 < minDeltaR2)) { // sort on one
00051                     match = i;
00052                     deltaR   = std::sqrt(thisDeltaR2);
00053                     deltaPhi = thisDeltaPhi;
00054                     if (sortByDeltaPhi_) minDeltaPhi = thisDeltaPhi; else minDeltaR2 = thisDeltaR2;
00055                 }
00056             }
00057         }
00058     }
00059     return match;
00060 */
00061 }
00062 
00063