CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/RecoTauTag/RecoTau/plugins/PFRecoTauDiscriminationAgainstMuon.cc

Go to the documentation of this file.
00001 /* 
00002  * class PFRecoTauDiscriminationAgainstMuon
00003  * created : May 07 2008,
00004  * revised : always,
00005  * Authors : Sho Maruyama,M.Bachtis
00006  */
00007 
00008 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00009 
00010 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00011 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00012 
00013 #include "DataFormats/MuonReco/interface/MuonSelectors.h"
00014 
00015 
00016 #include <string>
00017 
00018 using namespace reco;
00019 
00020 class PFRecoTauDiscriminationAgainstMuon : public PFTauDiscriminationProducerBase 
00021 {
00022  public:
00023   explicit PFRecoTauDiscriminationAgainstMuon(const edm::ParameterSet& iConfig)
00024     : PFTauDiscriminationProducerBase(iConfig) 
00025   {   
00026     discriminatorOption_  = iConfig.getParameter<std::string>("discriminatorOption");  
00027     hop_  = iConfig.getParameter<double>("HoPMin");  
00028     a  = iConfig.getParameter<double>("a");  
00029     b  = iConfig.getParameter<double>("b");  
00030     c  = iConfig.getParameter<double>("c");      
00031   }
00032 
00033   ~PFRecoTauDiscriminationAgainstMuon() {} 
00034 
00035   double discriminate(const PFTauRef& pfTau);
00036 
00037  private:  
00038   std::string discriminatorOption_;
00039   double hop_;
00040   double a;
00041   double b;
00042   double c;
00043 };
00044 
00045 double PFRecoTauDiscriminationAgainstMuon::discriminate(const PFTauRef& thePFTauRef)
00046 {
00047   bool decision = true;
00048 
00049   bool applyCaloMuonCut = false;
00050 
00051   if ( thePFTauRef->hasMuonReference() ) {
00052 
00053     MuonRef muonref = thePFTauRef->leadPFChargedHadrCand()->muonRef();
00054     if ( discriminatorOption_ == "noSegMatch" ) {
00055       if ( muonref ->numberOfMatches() > 0 ) decision = false;
00056     } else if (discriminatorOption_ == "twoDCut") {
00057       double seg = muon::segmentCompatibility(*muonref);
00058       double calo= muonref->caloCompatibility(); 
00059       double border = calo * a + seg * b +c;
00060       if ( border > 0 ) decision = false; 
00061     } else if ( discriminatorOption_ == "merePresence" ) {
00062       decision = false;
00063     } else if (discriminatorOption_ == "combined" ) { // testing purpose only
00064       unsigned int muType = 0;
00065       if      ( muonref->isGlobalMuon()  ) muType = 1;
00066       else if ( muonref->isCaloMuon()    ) muType = 2;
00067       else if ( muonref->isTrackerMuon() ) muType = 3;
00068       double muonEnergyFraction = thePFTauRef->pfTauTagInfoRef()->pfjetRef()->chargedMuEnergyFraction();
00069       bool eta_veto = false;
00070       bool phi_veto = false;
00071       if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true;
00072       if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true;
00073       if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder
00074     } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) { 
00075       if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false;
00076       if ( discriminatorOption_ == "noAllArbitratedWithHOP" ) applyCaloMuonCut = true;
00077     } else if ( discriminatorOption_ == "HOP" ) { 
00078       applyCaloMuonCut = true;
00079     } else {
00080       throw edm::Exception(edm::errors::UnimplementedFeature) 
00081         << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n";
00082     }
00083   } // valid muon ref
00084 
00085   // Additional calo. muon cut: veto one prongs compatible with MIP signature
00086   if ( applyCaloMuonCut ) {
00087     if ( thePFTauRef->leadPFChargedHadrCand().isNonnull() ) {
00088       double muonCaloEn = thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() + thePFTauRef->leadPFChargedHadrCand()->ecalEnergy();
00089       if ( thePFTauRef->decayMode() == 0 && (muonCaloEn/thePFTauRef->leadPFChargedHadrCand()->p()) < hop_ ) decision = false;
00090     }
00091   }
00092   
00093   return (decision ? 1. : 0.);
00094 } 
00095 
00096 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon);