Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
00016
00017 #include "DataFormats/TauReco/interface/PFTau.h"
00018 #include "DataFormats/TauReco/interface/PFTauFwd.h"
00019 #include "DataFormats/JetReco/interface/GenJet.h"
00020 #include "DataFormats/JetReco/interface/GenJetCollection.h"
00021 #include "DataFormats/Common/interface/Association.h"
00022
00023 #include "PhysicsTools/JetMCUtils/interface/JetMCTag.h"
00024
00025 #include <boost/foreach.hpp>
00026 #include <boost/assign.hpp>
00027 #include <map>
00028
00029 namespace {
00030
00031
00032 static std::map<std::string, reco::PFTau::hadronicDecayMode> dmTranslator =
00033 boost::assign::map_list_of
00034 ("oneProng0Pi0", reco::PFTau::kOneProng0PiZero)
00035 ("oneProng1Pi0", reco::PFTau::kOneProng1PiZero)
00036 ("oneProng2Pi0", reco::PFTau::kOneProng2PiZero)
00037 ("oneProngOther", reco::PFTau::kOneProngNPiZero)
00038 ("threeProng0Pi0", reco::PFTau::kThreeProng0PiZero)
00039 ("threeProng1Pi0", reco::PFTau::kThreeProng1PiZero)
00040 ("threeProngOther", reco::PFTau::kThreeProngNPiZero)
00041 ("electron", reco::PFTau::kNull)
00042 ("muon", reco::PFTau::kNull);
00043 }
00044
00045 namespace tautools {
00046
00047 class RecoTauDecayModeTruthMatchPlugin : public reco::tau::RecoTauCleanerPlugin
00048 {
00049 public:
00050 explicit RecoTauDecayModeTruthMatchPlugin(const edm::ParameterSet& pset);
00051 virtual ~RecoTauDecayModeTruthMatchPlugin() {}
00052 double operator()(const reco::PFTauRef&) const;
00053 void beginEvent();
00054
00055 private:
00056 edm::InputTag matchingSrc_;
00057 typedef edm::Association<reco::GenJetCollection> GenJetAssociation;
00058 edm::Handle<GenJetAssociation> genTauMatch_;
00059 };
00060
00061
00062 RecoTauDecayModeTruthMatchPlugin::RecoTauDecayModeTruthMatchPlugin(
00063 const edm::ParameterSet& pset): RecoTauCleanerPlugin(pset),
00064 matchingSrc_(pset.getParameter<edm::InputTag>("matching")) {}
00065
00066
00067 void RecoTauDecayModeTruthMatchPlugin::beginEvent() {
00068
00069 evt()->getByLabel(matchingSrc_, genTauMatch_);
00070 }
00071
00072
00073
00074 double RecoTauDecayModeTruthMatchPlugin::operator()(const reco::PFTauRef& tau)
00075 const {
00076 GenJetAssociation::reference_type truth = (*genTauMatch_)[tau];
00077
00078 if (truth.isNull())
00079 return std::numeric_limits<double>::infinity();
00080
00081
00082 return std::abs(
00083 dmTranslator[JetMCTagUtils::genTauDecayMode(*truth)] - tau->decayMode());
00084 }
00085
00086 }
00087
00088 #include "FWCore/Framework/interface/MakerMacros.h"
00089 DEFINE_EDM_PLUGIN(RecoTauCleanerPluginFactory, tautools::RecoTauDecayModeTruthMatchPlugin, "RecoTauDecayModeTruthMatchPlugin");