Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00010
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/Utilities/interface/InputTag.h"
00013
00014 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00015 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00016
00017 #include "DataFormats/Math/interface/deltaR.h"
00018
00019 #include <string>
00020
00021 using namespace reco;
00022
00023 template<class TauType, class TauDiscriminator>
00024 class TauDiscriminationAgainstMuon : public TauDiscriminationProducerBase<TauType, TauDiscriminator>
00025 {
00026 public:
00027
00028 typedef std::vector<TauType> TauCollection;
00029 typedef edm::Ref<TauCollection> TauRef;
00030
00031 explicit TauDiscriminationAgainstMuon(const edm::ParameterSet&);
00032 ~TauDiscriminationAgainstMuon() {}
00033
00034
00035 void beginEvent(const edm::Event&, const edm::EventSetup&);
00036
00037 double discriminate(const TauRef&);
00038
00039 private:
00040 bool evaluateMuonVeto(const reco::Muon&);
00041
00042 edm::InputTag muonSource_;
00043 edm::Handle<reco::MuonCollection> muons_;
00044 double dRmatch_;
00045
00046 enum { kNoSegMatch, kTwoDCut, kMerePresence, kCombined };
00047 int discriminatorOption_;
00048
00049 double coeffCaloComp_;
00050 double coeffSegmComp_;
00051 double muonCompCut_;
00052 };
00053
00054 template<class TauType, class TauDiscriminator>
00055 TauDiscriminationAgainstMuon<TauType, TauDiscriminator>::TauDiscriminationAgainstMuon(const edm::ParameterSet& cfg)
00056 : TauDiscriminationProducerBase<TauType, TauDiscriminator>(cfg)
00057 {
00058
00059 muonSource_ = cfg.getParameter<edm::InputTag>("muonSource");
00060 dRmatch_ = ( cfg.exists("dRmatch") ) ? cfg.getParameter<double>("dRmatch") : 0.5;
00061
00062 std::string discriminatorOption_string = cfg.getParameter<std::string>("discriminatorOption");
00063 if ( discriminatorOption_string == "noSegMatch" ) discriminatorOption_ = kNoSegMatch;
00064 else if ( discriminatorOption_string == "twoDCut" ) discriminatorOption_ = kTwoDCut;
00065 else if ( discriminatorOption_string == "merePresence" ) discriminatorOption_ = kMerePresence;
00066 else if ( discriminatorOption_string == "combined" ) discriminatorOption_ = kCombined;
00067 else {
00068 throw edm::Exception(edm::errors::UnimplementedFeature) << " Invalid Discriminator Option! Please check cfi file \n";
00069 }
00070
00071 coeffCaloComp_ = cfg.getParameter<double>("caloCompCoefficient");
00072 coeffSegmComp_ = cfg.getParameter<double>("segmCompCoefficient");
00073 muonCompCut_ = cfg.getParameter<double>("muonCompCut");
00074 }
00075
00076 template<class TauType, class TauDiscriminator>
00077 void TauDiscriminationAgainstMuon<TauType, TauDiscriminator>::beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup)
00078 {
00079 evt.getByLabel(muonSource_, muons_);
00080 }
00081
00082 template<class TauType, class TauDiscriminator>
00083 bool TauDiscriminationAgainstMuon<TauType, TauDiscriminator>::evaluateMuonVeto(const reco::Muon& muon)
00084 {
00085 bool decision = true;
00086
00087 if ( discriminatorOption_ == kNoSegMatch ) {
00088 if ( muon.numberOfMatches() > 0 ) decision = false;
00089 } else if ( discriminatorOption_ == kTwoDCut ) {
00090 double segmComp = muon::segmentCompatibility(muon);
00091 double caloComp = muon.caloCompatibility();
00092 if ( (coeffCaloComp_*segmComp + coeffSegmComp_*caloComp) > muonCompCut_ ) decision = false;
00093 } else if ( discriminatorOption_ == kMerePresence ) {
00094 decision = false;
00095 } else if ( discriminatorOption_ == kCombined ) {
00096 unsigned int muonType = 0;
00097 if ( muon.isGlobalMuon() ) muonType = 1;
00098 else if ( muon.isCaloMuon() ) muonType = 2;
00099 else if ( muon.isTrackerMuon() ) muonType = 3;
00100
00101 bool eta_veto = ( fabs(muon.eta()) > 2.3 || (fabs(muon.eta()) > 1.4 && fabs(muon.eta()) < 1.6) ) ? true : false;
00102 bool phi_veto = ( muon.phi() < 0.1 && muon.phi() > -0.1 ) ? true : false;
00103
00104 if ( muonType != 1 || muon.numberOfMatches() > 0 || eta_veto || phi_veto ) decision = false;
00105 }
00106
00107 return decision;
00108 }
00109
00110 template<class TauType, class TauDiscriminator>
00111 double TauDiscriminationAgainstMuon<TauType, TauDiscriminator>::discriminate(const TauRef& tau)
00112 {
00113 bool decision = true;
00114
00115 for ( reco::MuonCollection::const_iterator muon = muons_->begin();
00116 muon != muons_->end(); ++muon ) {
00117 if ( reco::deltaR(muon->p4(), tau->p4()) < dRmatch_ ) decision &= evaluateMuonVeto(*muon);
00118 }
00119
00120 return (decision ? 1. : 0.);
00121 }
00122
00123 #include "FWCore/Framework/interface/MakerMacros.h"
00124
00125
00126 typedef TauDiscriminationAgainstMuon<CaloTau, CaloTauDiscriminator> CaloRecoTauDiscriminationAgainstMuon;
00127
00128
00129 DEFINE_FWK_MODULE(CaloRecoTauDiscriminationAgainstMuon);