Go to the documentation of this file.00001 #include "RecoTauTag/RecoTau/interface/TauDiscriminationProducerBase.h"
00002 #include "DataFormats/Candidate/interface/LeafCandidate.h"
00003 #include "RecoTauTag/TauTagTools/interface/PFTauQualityCutWrapper.h"
00004
00005
00006
00007
00008
00009
00010
00011
00012 using namespace reco;
00013 using namespace std;
00014
00015 class PFRecoTauDiscriminationByIsolation : public PFTauDiscriminationProducerBase {
00016 public:
00017 explicit PFRecoTauDiscriminationByIsolation(const edm::ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig),
00018 qualityCuts_(iConfig.getParameter<edm::ParameterSet>("qualityCuts"))
00019 {
00020 includeTracks_ = iConfig.getParameter<bool>("ApplyDiscriminationByTrackerIsolation");
00021 includeGammas_ = iConfig.getParameter<bool>("ApplyDiscriminationByECALIsolation");
00022
00023 applyOccupancyCut_ = iConfig.getParameter<bool>("applyOccupancyCut");
00024 maximumOccupancy_ = iConfig.getParameter<uint32_t>("maximumOccupancy");
00025
00026 applySumPtCut_ = iConfig.getParameter<bool>("applySumPtCut");
00027 maximumSumPt_ = iConfig.getParameter<double>("maximumSumPtCut");
00028
00029 applyRelativeSumPtCut_ = iConfig.getParameter<bool>("applyRelativeSumPtCut");
00030 maximumRelativeSumPt_ = iConfig.getParameter<double>("relativeSumPtCut");
00031
00032 pvProducer_ = iConfig.getParameter<edm::InputTag>("PVProducer");
00033 }
00034
00035 ~PFRecoTauDiscriminationByIsolation(){}
00036
00037 void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup);
00038 double discriminate(const PFTauRef& pfTau);
00039
00040 private:
00041 PFTauQualityCutWrapper qualityCuts_;
00042
00043 bool includeTracks_;
00044 bool includeGammas_;
00045
00046 bool applyOccupancyCut_;
00047 uint32_t maximumOccupancy_;
00048
00049 bool applySumPtCut_;
00050 double maximumSumPt_;
00051
00052 bool applyRelativeSumPtCut_;
00053 double maximumRelativeSumPt_;
00054
00055 edm::InputTag pvProducer_;
00056
00057 Vertex currentPV_;
00058 };
00059
00060 void PFRecoTauDiscriminationByIsolation::beginEvent(const edm::Event& event, const edm::EventSetup& eventSetup)
00061 {
00062
00063
00064
00065
00066 edm::Handle<VertexCollection> primaryVertices;
00067 event.getByLabel(pvProducer_, primaryVertices);
00068
00069
00070 if( primaryVertices->size() )
00071 {
00072 currentPV_ = *(primaryVertices->begin());
00073 } else
00074 {
00075 const double smearedPVsigmaY = 0.0015;
00076 const double smearedPVsigmaX = 0.0015;
00077 const double smearedPVsigmaZ = 0.005;
00078 Vertex::Error SimPVError;
00079 SimPVError(0,0) = smearedPVsigmaX*smearedPVsigmaX;
00080 SimPVError(1,1) = smearedPVsigmaY*smearedPVsigmaY;
00081 SimPVError(2,2) = smearedPVsigmaZ*smearedPVsigmaZ;
00082 Vertex::Point blankVertex(0, 0, 0);
00083
00084
00085 currentPV_ = Vertex(blankVertex, SimPVError,1,1,1);
00086 }
00087 }
00088
00089 double PFRecoTauDiscriminationByIsolation::discriminate(const PFTauRef& pfTau)
00090 {
00091
00092 std::vector<LeafCandidate> isoObjects;
00093
00094 if( includeTracks_ )
00095 {
00096 qualityCuts_.isolationChargedObjects(*pfTau, currentPV_, isoObjects);
00097 }
00098
00099 if( includeGammas_ )
00100 {
00101 qualityCuts_.isolationGammaObjects(*pfTau, isoObjects);
00102 }
00103
00104 bool failsOccupancyCut = false;
00105 bool failsSumPtCut = false;
00106 bool failsRelativeSumPtCut = false;
00107
00108
00109 failsOccupancyCut = ( isoObjects.size() > maximumOccupancy_ );
00110
00111
00112 if( applySumPtCut_ || applyRelativeSumPtCut_ )
00113 {
00114 reco::Particle::LorentzVector totalP4;
00115 for(std::vector<LeafCandidate>::const_iterator iIsoObject = isoObjects.begin();
00116 iIsoObject != isoObjects.end();
00117 ++iIsoObject)
00118 {
00119 totalP4 += iIsoObject->p4();
00120 }
00121
00122 failsSumPtCut = ( totalP4.pt() > maximumSumPt_ );
00123
00124
00125 failsRelativeSumPtCut = ( ( pfTau->pt() > 0 ? totalP4.pt()/pfTau->pt() : 0 ) > maximumRelativeSumPt_ );
00126 }
00127
00128 bool fails = ( applyOccupancyCut_ && failsOccupancyCut ) ||
00129 ( applySumPtCut_ && failsSumPtCut ) ||
00130 ( applyRelativeSumPtCut_ && failsRelativeSumPtCut ) ;
00131
00132 return ( fails ? 0. : 1. );
00133 }
00134
00135 DEFINE_FWK_MODULE(PFRecoTauDiscriminationByIsolation);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265