CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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     maxNumberOfMatches_ = iConfig.exists("maxNumberOfMatches") ? iConfig.getParameter<int>("maxNumberOfMatches") : 0;
00032     checkNumMatches_ = iConfig.exists("checkNumMatches") ? iConfig.getParameter<bool>("checkNumMatches") : false;
00033   }
00034 
00035   ~PFRecoTauDiscriminationAgainstMuon() {} 
00036 
00037   double discriminate(const PFTauRef& pfTau);
00038 
00039  private:  
00040   std::string discriminatorOption_;
00041   double hop_;
00042   double a;
00043   double b;
00044   double c;
00045   int maxNumberOfMatches_;
00046   bool checkNumMatches_;
00047 };
00048 
00049 double PFRecoTauDiscriminationAgainstMuon::discriminate(const PFTauRef& thePFTauRef)
00050 {
00051   bool decision = true;
00052 
00053   if ( thePFTauRef->hasMuonReference() ) {
00054 
00055     MuonRef muonref = thePFTauRef->leadPFChargedHadrCand()->muonRef();
00056     if ( discriminatorOption_ == "noSegMatch" ) {
00057       if ( muonref ->numberOfMatches() > maxNumberOfMatches_ ) decision = false;
00058     } else if (discriminatorOption_ == "twoDCut") {
00059       double seg = muon::segmentCompatibility(*muonref);
00060       double calo= muonref->caloCompatibility(); 
00061       double border = calo * a + seg * b +c;
00062       if ( border > 0 ) decision = false; 
00063     } else if ( discriminatorOption_ == "merePresence" ) {
00064       decision = false;
00065     } else if (discriminatorOption_ == "combined" ) { // testing purpose only
00066       unsigned int muType = 0;
00067       if      ( muonref->isGlobalMuon()  ) muType = 1;
00068       else if ( muonref->isCaloMuon()    ) muType = 2;
00069       else if ( muonref->isTrackerMuon() ) muType = 3;
00070       double muonEnergyFraction = thePFTauRef->pfTauTagInfoRef()->pfjetRef()->chargedMuEnergyFraction();
00071       bool eta_veto = false;
00072       bool phi_veto = false;
00073       if ( fabs(muonref->eta()) > 2.3 || (fabs(muonref->eta()) > 1.4 && fabs(muonref->eta()) < 1.6)) eta_veto = true;
00074       if ( muonref->phi() < 0.1 && muonref->phi() > -0.1) phi_veto = true;
00075       if ( muType != 1 || muonref ->numberOfMatches() > 0 || eta_veto || phi_veto || muonEnergyFraction > 0.9 ) decision = false; // as place holder
00076     } else if ( discriminatorOption_ == "noAllArbitrated" || discriminatorOption_ == "noAllArbitratedWithHOP" ) {
00077       if(checkNumMatches_ && muonref ->numberOfMatches() > maxNumberOfMatches_) decision = false;
00078       if ( muon::isGoodMuon(*muonref, muon::AllArbitrated) ) decision = false;      
00079     } else if ( discriminatorOption_ == "HOP" ) { 
00080       decision = true; // only calo. muon cut requested: keep all tau candidates, regardless of signals in muon system
00081     } else {
00082       throw edm::Exception(edm::errors::UnimplementedFeature) 
00083         << " Invalid Discriminator option = " << discriminatorOption_ << " --> please check cfi file !!\n";
00084     }
00085   } // valid muon ref
00086 
00087   // Additional calo. muon cut: veto one prongs compatible with MIP signature
00088   if ( discriminatorOption_ == "HOP" || discriminatorOption_ == "noAllArbitratedWithHOP" ) {
00089     if ( thePFTauRef->leadPFChargedHadrCand().isNonnull() ) {
00090       double muonCaloEn = thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() + thePFTauRef->leadPFChargedHadrCand()->ecalEnergy();
00091       if ( thePFTauRef->decayMode() == 0 && muonCaloEn < (hop_*thePFTauRef->leadPFChargedHadrCand()->p()) ) decision = false;
00092     }
00093   }
00094 
00095   return (decision ? 1. : 0.);
00096 } 
00097 
00098 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstMuon);