![]() |
![]() |
00001 /* 00002 * =========================================================================== 00003 * 00004 * Filename: RecoTauTruthEmbedder 00005 * 00006 * Description: Embed truth information into (currently unused) 00007 * tau variables. This is a hack to allow some PAT-like 00008 * operations on taus without introducing new dependencies. 00009 * 00010 * Author: Evan K. Friis (UC Davis) 00011 * 00012 * =========================================================================== 00013 */ 00014 00015 #include <boost/foreach.hpp> 00016 00017 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h" 00018 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" 00019 #include "RecoTauTag/RecoTau/interface/PFTauDecayModeTools.h" 00020 #include "DataFormats/JetReco/interface/GenJetCollection.h" 00021 #include "DataFormats/JetReco/interface/GenJet.h" 00022 #include "DataFormats/Common/interface/Handle.h" 00023 #include "DataFormats/Common/interface/Association.h" 00024 00025 namespace reco { namespace tau { 00026 00027 namespace helpers { 00028 unsigned int nCharged(const GenJet& jet) { 00029 unsigned int output = 0; 00030 BOOST_FOREACH(const CandidatePtr &cand, jet.getJetConstituents()) { 00031 if (cand->charge()) 00032 ++output; 00033 } 00034 return output; 00035 } 00036 00037 unsigned int nGammas(const GenJet& jet) { 00038 unsigned int output = 0; 00039 BOOST_FOREACH(const CandidatePtr &cand, jet.getJetConstituents()) { 00040 if (cand->pdgId()==22) 00041 ++output; 00042 } 00043 return output; 00044 } 00045 } 00046 00047 class RecoTauTruthEmbedder : public RecoTauModifierPlugin { 00048 public: 00049 explicit RecoTauTruthEmbedder(const edm::ParameterSet &pset) 00050 :RecoTauModifierPlugin(pset), 00051 jetMatchSrc_(pset.getParameter<edm::InputTag>("jetTruthMatch")) {} 00052 virtual ~RecoTauTruthEmbedder() {} 00053 virtual void operator()(PFTau&) const; 00054 virtual void beginEvent(); 00055 private: 00056 edm::InputTag jetMatchSrc_; 00057 edm::Handle<edm::Association<GenJetCollection> > jetMatch_; 00058 }; 00059 00060 // Update our handle to the matching 00061 void RecoTauTruthEmbedder::beginEvent() { 00062 evt()->getByLabel(jetMatchSrc_, jetMatch_); 00063 } 00064 00065 void RecoTauTruthEmbedder::operator()(PFTau& tau) const { 00066 // Get the matched truth tau if it exists 00067 GenJetRef truth = (*jetMatch_)[tau.jetRef()]; 00068 if (truth.isNonnull()) { 00069 // Store our generator level information 00070 tau.setalternatLorentzVect(truth->p4()); 00071 // Store our generator decay mode 00072 tau.setbremsRecoveryEOverPLead( 00073 reco::tau::translateDecayMode( 00074 helpers::nCharged(*truth), 00075 helpers::nGammas(*truth)/2) 00076 ); 00077 } else { 00078 tau.setbremsRecoveryEOverPLead(-10); 00079 } 00080 } 00081 }} // end namespace reco::tau 00082 #include "FWCore/Framework/interface/MakerMacros.h" 00083 DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory, 00084 reco::tau::RecoTauTruthEmbedder, 00085 "RecoTauTruthEmbedder");