Go to the documentation of this file.00001 #include <functional>
00002 #include <boost/foreach.hpp>
00003 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00004 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00005 #include "RecoTauTag/TauTagTools/interface/PFTauQualityCutWrapper.h"
00006 #include "RecoTauTag/RecoTau/interface/ConeTools.h"
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 using namespace reco;
00017 using namespace std;
00018
00019 class PFRecoTauDiscriminationByIsolation :
00020 public PFTauDiscriminationProducerBase {
00021 public:
00022 explicit PFRecoTauDiscriminationByIsolation(
00023 const edm::ParameterSet& pset):
00024 PFTauDiscriminationProducerBase(pset),
00025 qualityCuts_(pset.getParameter<edm::ParameterSet>("qualityCuts")) {
00026 includeTracks_ = pset.getParameter<bool>(
00027 "ApplyDiscriminationByTrackerIsolation");
00028 includeGammas_ = pset.getParameter<bool>(
00029 "ApplyDiscriminationByECALIsolation");
00030
00031 applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
00032 maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
00033
00034 applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
00035 maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
00036
00037 applyRelativeSumPtCut_ = pset.getParameter<bool>(
00038 "applyRelativeSumPtCut");
00039 maximumRelativeSumPt_ = pset.getParameter<double>(
00040 "relativeSumPtCut");
00041
00042 pvProducer_ = pset.getParameter<edm::InputTag>("PVProducer");
00043
00044 if (pset.exists("customOuterCone")) {
00045 customIsoCone_ = pset.getParameter<double>("customOuterCone");
00046 } else {
00047 customIsoCone_ = -1;
00048 }
00049 }
00050
00051 ~PFRecoTauDiscriminationByIsolation(){}
00052
00053 void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup);
00054 double discriminate(const PFTauRef& pfTau);
00055
00056 private:
00057 PFTauQualityCutWrapper qualityCuts_;
00058
00059 bool includeTracks_;
00060 bool includeGammas_;
00061
00062 bool applyOccupancyCut_;
00063 uint32_t maximumOccupancy_;
00064
00065 bool applySumPtCut_;
00066 double maximumSumPt_;
00067
00068 bool applyRelativeSumPtCut_;
00069 double maximumRelativeSumPt_;
00070
00071 double customIsoCone_;
00072
00073 edm::InputTag pvProducer_;
00074
00075 Vertex currentPV_;
00076 };
00077
00078 void PFRecoTauDiscriminationByIsolation::beginEvent(const edm::Event& event,
00079 const edm::EventSetup& eventSetup) {
00080
00081
00082
00083
00084
00085 edm::Handle<VertexCollection> primaryVertices;
00086 event.getByLabel(pvProducer_, primaryVertices);
00087
00088
00089 if( primaryVertices->size() ) {
00090 currentPV_ = *(primaryVertices->begin());
00091 } else {
00092 const double smearedPVsigmaY = 0.0015;
00093 const double smearedPVsigmaX = 0.0015;
00094 const double smearedPVsigmaZ = 0.005;
00095 Vertex::Error SimPVError;
00096 SimPVError(0,0) = smearedPVsigmaX*smearedPVsigmaX;
00097 SimPVError(1,1) = smearedPVsigmaY*smearedPVsigmaY;
00098 SimPVError(2,2) = smearedPVsigmaZ*smearedPVsigmaZ;
00099 Vertex::Point blankVertex(0, 0, 0);
00100
00101
00102
00103
00104 currentPV_ = Vertex(blankVertex, SimPVError,1,1,1);
00105 }
00106 }
00107
00108 double PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau) {
00109
00110 std::vector<LeafCandidate> isoObjects;
00111
00112 if (includeTracks_) {
00113 qualityCuts_.isolationChargedObjects(*pfTau, currentPV_, isoObjects);
00114 }
00115
00116 if (includeGammas_) {
00117 qualityCuts_.isolationGammaObjects(*pfTau, isoObjects);
00118 }
00119
00120 typedef reco::tau::cone::DeltaRFilter<LeafCandidate> DRFilter;
00121
00122
00123 if (customIsoCone_ >= 0.) {
00124 DRFilter filter(pfTau->p4(), 0, customIsoCone_);
00125
00126 std::remove_if(isoObjects.begin(), isoObjects.end(), std::not1(filter));
00127 }
00128
00129 bool failsOccupancyCut = false;
00130 bool failsSumPtCut = false;
00131 bool failsRelativeSumPtCut = false;
00132
00133
00134 failsOccupancyCut = ( isoObjects.size() > maximumOccupancy_ );
00135
00136
00137 if( applySumPtCut_ || applyRelativeSumPtCut_ ) {
00138 reco::Particle::LorentzVector totalP4;
00139 BOOST_FOREACH(const LeafCandidate& isoObject, isoObjects) {
00140 totalP4 += isoObject.p4();
00141 }
00142
00143 failsSumPtCut = (totalP4.pt() > maximumSumPt_);
00144
00145
00146 failsRelativeSumPtCut = (
00147 (pfTau->pt() > 0 ? totalP4.pt()/pfTau->pt() : 0 )
00148 > maximumRelativeSumPt_ );
00149 }
00150
00151 bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
00152 (applySumPtCut_ && failsSumPtCut) ||
00153 (applyRelativeSumPtCut_ && failsRelativeSumPtCut) ;
00154
00155 return (fails ? 0. : 1.);
00156 }
00157
00158 DEFINE_FWK_MODULE(PFRecoTauDiscriminationByIsolation);