00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <vector>
00013 #include <algorithm>
00014
00015 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
00016 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h"
00017 #include "RecoTauTag/RecoTau/interface/ConeTools.h"
00018 #include "RecoTauTag/RecoTau/interface/RecoTauConstructor.h"
00019 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
00020
00021 #include "DataFormats/TauReco/interface/PFTau.h"
00022 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
00023 #include "DataFormats/Math/interface/deltaR.h"
00024
00025 #include "CommonTools/Utils/interface/StringObjectFunction.h"
00026
00027 namespace reco { namespace tau {
00028
00029 class RecoTauBuilderConePlugin : public RecoTauBuilderPlugin {
00030 public:
00031 explicit RecoTauBuilderConePlugin(const edm::ParameterSet& pset);
00032 ~RecoTauBuilderConePlugin() {}
00033
00034 return_type operator()(const reco::PFJetRef& jet,
00035 const std::vector<RecoTauPiZero>& piZeros) const;
00036 private:
00037 RecoTauQualityCuts qcuts_;
00038 bool usePFLeptonsAsChargedHadrons_;
00039 double leadObjecPtThreshold_;
00040
00041 typedef StringObjectFunction<reco::PFJet> JetFunc;
00042
00043 JetFunc matchingCone_;
00044 JetFunc signalConeChargedHadrons_;
00045 JetFunc isoConeChargedHadrons_;
00046 JetFunc signalConePiZeros_;
00047 JetFunc isoConePiZeros_;
00048 JetFunc signalConeNeutralHadrons_;
00049 JetFunc isoConeNeutralHadrons_;
00050 };
00051
00052
00053 RecoTauBuilderConePlugin::RecoTauBuilderConePlugin(
00054 const edm::ParameterSet& pset):RecoTauBuilderPlugin(pset),
00055 qcuts_(pset.getParameter<edm::ParameterSet>("qualityCuts")),
00056 usePFLeptonsAsChargedHadrons_(pset.getParameter<bool>("usePFLeptons")),
00057 leadObjecPtThreshold_(pset.getParameter<double>("leadObjectPt")),
00058 matchingCone_(pset.getParameter<std::string>("matchingCone")),
00059 signalConeChargedHadrons_(pset.getParameter<std::string>(
00060 "signalConeChargedHadrons")),
00061 isoConeChargedHadrons_(
00062 pset.getParameter<std::string>("isoConeChargedHadrons")),
00063 signalConePiZeros_(
00064 pset.getParameter<std::string>("signalConePiZeros")),
00065 isoConePiZeros_(
00066 pset.getParameter<std::string>("isoConePiZeros")),
00067 signalConeNeutralHadrons_(
00068 pset.getParameter<std::string>("signalConeNeutralHadrons")),
00069 isoConeNeutralHadrons_(
00070 pset.getParameter<std::string>("isoConeNeutralHadrons"))
00071 {}
00072
00073 RecoTauBuilderConePlugin::return_type RecoTauBuilderConePlugin::operator()(
00074 const reco::PFJetRef& jet,
00075 const std::vector<RecoTauPiZero>& piZeros) const {
00076
00077 using namespace cone;
00078
00079 output_type output;
00080
00081
00082
00083 RecoTauConstructor tau(jet, getPFCands(), true);
00084
00085 qcuts_.setPV(primaryVertex());
00086
00087 typedef std::vector<PFCandidatePtr> PFCandPtrs;
00088
00089
00090 PFCandPtrs pfchs;
00091 if (!usePFLeptonsAsChargedHadrons_) {
00092 pfchs = qcuts_.filterRefs(pfCandidates(*jet, reco::PFCandidate::h));
00093 } else {
00094
00095
00096
00097 pfchs = qcuts_.filterRefs(pfChargedCands(*jet));
00098 }
00099
00100
00101 PFCandPtrs pfGammas = qcuts_.filterRefs(
00102 pfCandidates(*jet, reco::PFCandidate::gamma));
00103
00104 PFCandPtrs pfnhs = qcuts_.filterRefs(
00105 pfCandidates(*jet, reco::PFCandidate::h0));
00106
00107
00108
00109
00110
00111
00112 double matchingCone = matchingCone_(*jet);
00113 PFCandPtrDRFilter matchingConeFilter(jet->p4(), 0, matchingCone);
00114
00115
00116
00117
00118 PFCandidatePtr leadPFCH;
00119 PFCandPtrs::iterator leadPFCH_iter =
00120 std::find_if(pfchs.begin(), pfchs.end(), matchingConeFilter);
00121
00122 if (leadPFCH_iter != pfchs.end()) {
00123 leadPFCH = *leadPFCH_iter;
00124
00125 tau.setleadPFChargedHadrCand(leadPFCH);
00126 } else {
00127
00128
00129 return output.release();
00130 }
00131
00132
00133 PFCandidatePtr leadPFGamma;
00134 PFCandPtrs::iterator leadPFGamma_iter =
00135 std::find_if(pfGammas.begin(), pfGammas.end(), matchingConeFilter);
00136
00137 if (leadPFGamma_iter != pfGammas.end()) {
00138 leadPFGamma = *leadPFGamma_iter;
00139
00140 tau.setleadPFNeutralCand(leadPFGamma);
00141 }
00142
00143 PFCandidatePtr leadPFCand;
00144
00145 if (leadPFCH.isNonnull() && leadPFCH->pt() > leadObjecPtThreshold_) {
00146 leadPFCand = leadPFCH;
00147 } else if (leadPFGamma.isNonnull() &&
00148 leadPFGamma->pt() > leadObjecPtThreshold_) {
00149
00150 leadPFCand = leadPFGamma;
00151 } else {
00152
00153 leadPFCand = leadPFCH;
00154 }
00155
00156 tau.setleadPFCand(leadPFCand);
00157
00158
00159 reco::Candidate::LorentzVector coneAxis = leadPFCH->p4();
00160
00161
00162
00163
00164
00165
00166
00167
00168 PFCandPtrDRFilter signalConePFCHFilter(
00169 coneAxis, -0.1, signalConeChargedHadrons_(*jet));
00170 PFCandPtrDRFilter signalConePFNHFilter(
00171 coneAxis, -0.1, signalConeNeutralHadrons_(*jet));
00172 PiZeroDRFilter signalConePiZeroFilter(
00173 coneAxis, -0.1, signalConePiZeros_(*jet));
00174
00175 PFCandPtrDRFilter isoConePFCHFilter(
00176 coneAxis, signalConeChargedHadrons_(*jet), isoConeChargedHadrons_(*jet));
00177 PFCandPtrDRFilter isoConePFNHFilter(
00178 coneAxis, signalConeNeutralHadrons_(*jet), isoConeNeutralHadrons_(*jet));
00179 PiZeroDRFilter isoConePiZeroFilter(
00180 coneAxis, signalConePiZeros_(*jet), isoConePiZeros_(*jet));
00181
00182
00183 tau.addPFCands(RecoTauConstructor::kSignal,
00184 RecoTauConstructor::kChargedHadron,
00185 PFCandPtrDRFilterIter(signalConePFCHFilter, pfchs.begin(),
00186 pfchs.end()),
00187 PFCandPtrDRFilterIter(signalConePFCHFilter, pfchs.end(),
00188 pfchs.end()));
00189
00190
00191 tau.addPFCands(RecoTauConstructor::kSignal,
00192 RecoTauConstructor::kNeutralHadron,
00193 PFCandPtrDRFilterIter(signalConePFNHFilter, pfnhs.begin(),
00194 pfnhs.end()),
00195 PFCandPtrDRFilterIter(signalConePFNHFilter, pfnhs.end(),
00196 pfnhs.end()));
00197
00198
00199 tau.addPiZeros(RecoTauConstructor::kSignal,
00200 PiZeroDRFilterIter(signalConePiZeroFilter,
00201 piZeros.begin(), piZeros.end()),
00202 PiZeroDRFilterIter(signalConePiZeroFilter,
00203 piZeros.end(), piZeros.end()));
00204
00205
00206 tau.addPFCands(RecoTauConstructor::kIsolation,
00207 RecoTauConstructor::kChargedHadron,
00208 PFCandPtrDRFilterIter(isoConePFCHFilter, pfchs.begin(),
00209 pfchs.end()),
00210 PFCandPtrDRFilterIter(isoConePFCHFilter, pfchs.end(),
00211 pfchs.end()));
00212
00213
00214 tau.addPFCands(RecoTauConstructor::kIsolation,
00215 RecoTauConstructor::kNeutralHadron,
00216 PFCandPtrDRFilterIter(isoConePFNHFilter, pfnhs.begin(),
00217 pfnhs.end()),
00218 PFCandPtrDRFilterIter(isoConePFNHFilter, pfnhs.end(),
00219 pfnhs.end()));
00220
00221
00222 tau.addPiZeros(RecoTauConstructor::kIsolation,
00223 PiZeroDRFilterIter(isoConePiZeroFilter, piZeros.begin(),
00224 piZeros.end()),
00225 PiZeroDRFilterIter(isoConePiZeroFilter, piZeros.end(),
00226 piZeros.end()));
00227
00228
00229
00230
00231 output.push_back(tau.get(false));
00232 return output.release();
00233 }
00234 }}
00235
00236 #include "FWCore/Framework/interface/MakerMacros.h"
00237 DEFINE_EDM_PLUGIN(RecoTauBuilderPluginFactory,
00238 reco::tau::RecoTauBuilderConePlugin,
00239 "RecoTauBuilderConePlugin");