00001 /* 00002 * RecoTauDiscriminantCutMultiplexer 00003 * 00004 * Author: Evan K. Friis, UW 00005 * 00006 * Takes two PFTauDiscriminators. 00007 * 00008 * The "key" discriminantor is rounded to the nearest integer. 00009 * 00010 * A set of cuts for different keys on the "toMultiplex" discriminantor is 00011 * provided in the config file. 00012 * 00013 * Both the key and toMultiplex discriminators should map to the same PFTau 00014 * collection. 00015 * 00016 */ 00017 #include <boost/foreach.hpp> 00018 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h" 00019 #include "FWCore/Utilities/interface/InputTag.h" 00020 00021 #include "TMath.h" 00022 00023 class RecoTauDiscriminantCutMultiplexer : public PFTauDiscriminationProducerBase { 00024 public: 00025 explicit RecoTauDiscriminantCutMultiplexer(const edm::ParameterSet& pset); 00026 00027 ~RecoTauDiscriminantCutMultiplexer() {} 00028 double discriminate(const reco::PFTauRef&); 00029 void beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup); 00030 00031 private: 00032 typedef std::map<int, double> DiscriminantCutMap; 00033 00034 DiscriminantCutMap cuts_; 00035 edm::InputTag toMultiplex_; 00036 edm::InputTag key_; 00037 edm::Handle<reco::PFTauDiscriminator> toMultiplexHandle_; 00038 edm::Handle<reco::PFTauDiscriminator> keyHandle_; 00039 }; 00040 00041 RecoTauDiscriminantCutMultiplexer::RecoTauDiscriminantCutMultiplexer( 00042 const edm::ParameterSet& pset):PFTauDiscriminationProducerBase(pset) { 00043 toMultiplex_ = pset.getParameter<edm::InputTag>("toMultiplex"); 00044 key_ = pset.getParameter<edm::InputTag>("key"); 00045 /*code*/ 00046 typedef std::vector<edm::ParameterSet> VPSet; 00047 VPSet mapping = pset.getParameter<VPSet>("mapping"); 00048 // Setup our cut map 00049 BOOST_FOREACH(const edm::ParameterSet &dm, mapping) { 00050 // Get the mass window for each decay mode 00051 cuts_.insert(std::make_pair( 00052 // The category as a key 00053 dm.getParameter<uint32_t>("category"), 00054 // The selection 00055 dm.getParameter<double>("cut") 00056 )); 00057 } 00058 } 00059 00060 void RecoTauDiscriminantCutMultiplexer::beginEvent( 00061 const edm::Event& evt, const edm::EventSetup& es) { 00062 evt.getByLabel(toMultiplex_, toMultiplexHandle_); 00063 evt.getByLabel(key_, keyHandle_); 00064 } 00065 00066 double 00067 RecoTauDiscriminantCutMultiplexer::discriminate(const reco::PFTauRef& tau) { 00068 double disc_result = (*toMultiplexHandle_)[tau]; 00069 double key_result = (*keyHandle_)[tau]; 00070 DiscriminantCutMap::const_iterator cutIter = cuts_.find(TMath::Nint(key_result)); 00071 00072 // Return null if it doesn't exist 00073 if (cutIter == cuts_.end()) { 00074 return prediscriminantFailValue_; 00075 } 00076 // See if the discriminator passes our cuts 00077 return disc_result > cutIter->second; 00078 } 00079 00080 DEFINE_FWK_MODULE(RecoTauDiscriminantCutMultiplexer);