CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecoTauDiscriminationByIsolation.cc
Go to the documentation of this file.
1 #include <functional>
10 
11 #include "TMath.h"
12 #include "TFormula.h"
13 
14 /* class PFRecoTauDiscriminationByIsolation
15  * created : Jul 23 2007,
16  * revised : Thu Aug 13 14:44:40 PDT 2009
17  * contributors : Ludovic Houchu (IPHC, Strasbourg),
18  * Christian Veelken (UC Davis),
19  * Evan K. Friis (UC Davis)
20  * Michalis Bachtis (UW Madison)
21  */
22 
23 using namespace reco;
24 using namespace std;
25 
27 {
28  public:
31  moduleLabel_(pset.getParameter<std::string>("@module_label")),
32  qualityCutsPSet_(pset.getParameter<edm::ParameterSet>("qualityCuts"))
33  {
34  includeTracks_ = pset.getParameter<bool>(
35  "ApplyDiscriminationByTrackerIsolation");
36  includeGammas_ = pset.getParameter<bool>(
37  "ApplyDiscriminationByECALIsolation");
38 
39  calculateWeights_ = pset.exists("ApplyDiscriminationByWeightedECALIsolation") ?
40  pset.getParameter<bool>("ApplyDiscriminationByWeightedECALIsolation") : false;
41 
42  // RIC: allow to relax the isolation completely beyond a given tau pt
43  minPtForNoIso_ = pset.exists("minTauPtForNoIso") ?
44  pset.getParameter<double>("minTauPtForNoIso") : -99.;
45 
46  applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
47  maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
48 
49  applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
50  maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
51 
52  applyRelativeSumPtCut_ = pset.getParameter<bool>(
53  "applyRelativeSumPtCut");
54  maximumRelativeSumPt_ = pset.getParameter<double>(
55  "relativeSumPtCut");
56  offsetRelativeSumPt_ = pset.exists("relativeSumPtOffset") ?
57  pset.getParameter<double>("relativeSumPtOffset") : 0.0;
58 
59  storeRawOccupancy_ = pset.exists("storeRawOccupancy") ?
60  pset.getParameter<bool>("storeRawOccupancy") : false;
61  storeRawSumPt_ = pset.exists("storeRawSumPt") ?
62  pset.getParameter<bool>("storeRawSumPt") : false;
63  storeRawPUsumPt_ = pset.exists("storeRawPUsumPt") ?
64  pset.getParameter<bool>("storeRawPUsumPt") : false;
65  storeRawFootprintCorrection_ = pset.exists("storeRawFootprintCorrection") ?
66  pset.getParameter<bool>("storeRawFootprintCorrection") : false;
67  storeRawPhotonSumPt_outsideSignalCone_ = pset.exists("storeRawPhotonSumPt_outsideSignalCone") ?
68  pset.getParameter<bool>("storeRawPhotonSumPt_outsideSignalCone") : false;
69 
70  // Sanity check on requested options. We can't apply cuts and store the
71  // raw output at the same time
72  if ( applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_ ) {
73  if ( storeRawSumPt_ || storeRawOccupancy_ || storeRawPUsumPt_ ) {
74  throw cms::Exception("BadIsoConfig")
75  << "A 'store raw' and a 'apply cut' option have been set to true "
76  << "simultaneously. These options are mutually exclusive.";
77  }
78  }
79 
80  // sanity check2 - can't use weighted and unweighted iso at the same time
81  if ( includeGammas_ && calculateWeights_ ) {
82  throw cms::Exception("BasIsoConfig")
83  << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' "
84  << "have been set to true. These options are mutually exclusive.";
85  }
86 
87  // Can only store one type
88  int numStoreOptions = 0;
89  if ( storeRawSumPt_ ) ++numStoreOptions;
90  if ( storeRawOccupancy_ ) ++numStoreOptions;
91  if ( storeRawPUsumPt_ ) ++numStoreOptions;
92  if ( storeRawFootprintCorrection_ ) ++numStoreOptions;
93  if ( storeRawPhotonSumPt_outsideSignalCone_ ) ++numStoreOptions;
94  if ( numStoreOptions > 1 ) {
95  throw cms::Exception("BadIsoConfig")
96  << "Multiple 'store sum pt' and/or 'store occupancy' options are set."
97  << " These options are mutually exclusive.";
98  }
99 
100  if ( pset.exists("customOuterCone") ) {
101  customIsoCone_ = pset.getParameter<double>("customOuterCone");
102  } else {
103  customIsoCone_ = -1;
104  }
105 
106  applyPhotonPtSumOutsideSignalConeCut_ = ( pset.exists("applyPhotonPtSumOutsideSignalConeCut") ) ?
107  pset.getParameter<bool>("applyPhotonPtSumOutsideSignalConeCut") : false;
108  if ( applyPhotonPtSumOutsideSignalConeCut_ ) {
109  maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxAbsPhotonSumPt_outsideSignalCone");
110  maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxRelPhotonSumPt_outsideSignalCone");
111  }
112 
113  applyFootprintCorrection_ = ( pset.exists("applyFootprintCorrection") ) ?
114  pset.getParameter<bool>("applyFootprintCorrection") : false;
115  if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) {
116  edm::VParameterSet cfgFootprintCorrections = pset.getParameter<edm::VParameterSet>("footprintCorrections");
117  for ( edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin();
118  cfgFootprintCorrection != cfgFootprintCorrections.end(); ++cfgFootprintCorrection ) {
119  std::string selection = cfgFootprintCorrection->getParameter<std::string>("selection");
120  std::string offset = cfgFootprintCorrection->getParameter<std::string>("offset");
121  std::unique_ptr<FootprintCorrection> footprintCorrection(new FootprintCorrection(selection, offset));
122  footprintCorrections_.push_back(std::move(footprintCorrection));
123  }
124  }
125 
126  // Get the quality cuts specific to the isolation region
127  edm::ParameterSet isolationQCuts = qualityCutsPSet_.getParameterSet(
128  "isolationQualityCuts");
129 
130  qcuts_.reset(new tau::RecoTauQualityCuts(isolationQCuts));
131 
132  vertexAssociator_.reset(
133  new tau::RecoTauVertexAssociator(qualityCutsPSet_,consumesCollector()));
134 
135  applyDeltaBeta_ = pset.exists("applyDeltaBetaCorrection") ?
136  pset.getParameter<bool>("applyDeltaBetaCorrection") : false;
137 
138  if ( applyDeltaBeta_ || calculateWeights_ ) {
139  // Factorize the isolation QCuts into those that are used to
140  // select PU and those that are not.
141  std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
142  reco::tau::factorizePUQCuts(isolationQCuts);
143 
144  // Determine the pt threshold for the PU tracks
145  // First check if the user specifies explicitly the cut.
146  if ( pset.exists("deltaBetaPUTrackPtCutOverride") ) {
147  puFactorizedIsoQCuts.second.addParameter<double>(
148  "minTrackPt",
149  pset.getParameter<double>("deltaBetaPUTrackPtCutOverride"));
150  } else {
151  // Secondly take it from the minGammaEt
152  puFactorizedIsoQCuts.second.addParameter<double>(
153  "minTrackPt",
154  isolationQCuts.getParameter<double>("minGammaEt"));
155  }
156 
157  pileupQcutsPUTrackSelection_.reset(new tau::RecoTauQualityCuts(
158  puFactorizedIsoQCuts.first));
159 
160  pileupQcutsGeneralQCuts_.reset(new tau::RecoTauQualityCuts(
161  puFactorizedIsoQCuts.second));
162 
163  pfCandSrc_ = pset.getParameter<edm::InputTag>("particleFlowSrc");
164  pfCand_token = consumes<reco::PFCandidateCollection>(pfCandSrc_);
165  vertexSrc_ = pset.getParameter<edm::InputTag>("vertexSrc");
166  vertex_token = consumes<reco::VertexCollection>(vertexSrc_);
167  deltaBetaCollectionCone_ = pset.getParameter<double>(
168  "isoConeSizeForDeltaBeta");
169  std::string deltaBetaFactorFormula =
170  pset.getParameter<string>("deltaBetaFactor");
171  deltaBetaFormula_.reset(
172  new TFormula("DB_corr", deltaBetaFactorFormula.c_str()));
173  }
174 
175  applyRhoCorrection_ = pset.exists("applyRhoCorrection") ?
176  pset.getParameter<bool>("applyRhoCorrection") : false;
177  if ( applyRhoCorrection_ ) {
178  rhoProducer_ = pset.getParameter<edm::InputTag>("rhoProducer");
179  rho_token=consumes<double>(rhoProducer_);
180  rhoConeSize_ = pset.getParameter<double>("rhoConeSize");
181  rhoUEOffsetCorrection_ =
182  pset.getParameter<double>("rhoUEOffsetCorrection");
183  }
184  useAllPFCands_ = pset.exists("UseAllPFCandsForWeights") ?
185  pset.getParameter<bool>("UseAllPFCandsForWeights") : false;
186 
187  verbosity_ = ( pset.exists("verbosity") ) ?
188  pset.getParameter<int>("verbosity") : 0;
189  }
190 
192  {
193  }
194 
195  void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
196  double discriminate(const PFTauRef& pfTau) const override;
197 
198  inline double weightedSum(const std::vector<PFCandidatePtr>& inColl_, double eta, double phi) const {
199  double out = 1.0;
200  for (auto const & inObj_ : inColl_){
201  double sum = (inObj_->pt()*inObj_->pt())/(deltaR2(eta,phi,inObj_->eta(),inObj_->phi()));
202  if(sum > 1.0) out *= sum;
203  }
204  return out;
205  }
206 
207  private:
209 
211  std::auto_ptr<tau::RecoTauQualityCuts> qcuts_;
212 
213  // Inverted QCut which selects tracks with bad DZ/trackWeight
214  std::auto_ptr<tau::RecoTauQualityCuts> pileupQcutsPUTrackSelection_;
215  std::auto_ptr<tau::RecoTauQualityCuts> pileupQcutsGeneralQCuts_;
216 
217  std::auto_ptr<tau::RecoTauVertexAssociator> vertexAssociator_;
218 
230  // RIC:
232 
236 
239  {
241  : selection_(selection),
242  offset_(offset)
243  {}
247  };
248  std::vector<std::unique_ptr<FootprintCorrection> > footprintCorrections_;
249 
250  // Options to store the raw value in the discriminator instead of boolean pass/fail flag
256 
257  /* **********************************************************************
258  **** Pileup Subtraction Parameters ***********************************
259  **********************************************************************/
260 
261  // Delta Beta correction
265  // Keep track of how many vertices are in the event
268  std::vector<reco::PFCandidatePtr> chargedPFCandidatesInEvent_;
269  // Size of cone used to collect PU tracks
271  std::auto_ptr<TFormula> deltaBetaFormula_;
273 
274  // Rho correction
279  double rhoConeSize_;
283 
284  // Flag to enable/disable debug output
286 };
287 
289 {
290  // NB: The use of the PV in this context is necessitated by its use in
291  // applying quality cuts to the different objects in the isolation cone
292  // The vertex associator contains the logic to select the appropriate vertex
293  // We need to pass it the event so it can load the vertices.
294  vertexAssociator_->setEvent(event);
295 
296  // If we are applying the delta beta correction, we need to get the PF
297  // candidates from the event so we can find the PU tracks.
298  if ( applyDeltaBeta_ || calculateWeights_ ) {
299  // Collect all the PF pile up tracks
301  event.getByToken(pfCand_token, pfCandidates);
302  chargedPFCandidatesInEvent_.clear();
303  chargedPFCandidatesInEvent_.reserve(pfCandidates->size());
304  size_t numPFCandidates = pfCandidates->size();
305  for ( size_t i = 0; i < numPFCandidates; ++i ) {
306  reco::PFCandidatePtr pfCandidate(pfCandidates, i);
307  if ( pfCandidate->charge() != 0 ) {
308  chargedPFCandidatesInEvent_.push_back(pfCandidate);
309  }
310  }
311  // Count all the vertices in the event, to parameterize the DB
312  // correction factor
314  event.getByToken(vertex_token, vertices);
315  size_t nVtxThisEvent = vertices->size();
316  deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
317  }
318 
319  if ( applyRhoCorrection_ ) {
320  edm::Handle<double> rhoHandle_;
321  event.getByToken(rho_token, rhoHandle_);
322  rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_)*
323  (3.14159)*rhoConeSize_*rhoConeSize_;
324  }
325 }
326 
327 double
329 {
330  LogDebug("discriminate") << " tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi();
331  LogDebug("discriminate") << *pfTau ;
332 
333  // collect the objects we are working with (ie tracks, tracks+gammas, etc)
334  std::vector<PFCandidatePtr> isoCharged_;
335  std::vector<PFCandidatePtr> isoNeutral_;
336  std::vector<PFCandidatePtr> isoPU_;
337  PFCandidateCollection isoNeutralWeight_;
338  std::vector<PFCandidatePtr> chPV_;
339  isoCharged_.reserve(pfTau->isolationPFChargedHadrCands().size());
340  isoNeutral_.reserve(pfTau->isolationPFGammaCands().size());
341  isoPU_.reserve(std::min(100UL, chargedPFCandidatesInEvent_.size()));
342  isoNeutralWeight_.reserve(pfTau->isolationPFGammaCands().size());
343 
344  chPV_.reserve(std::min(50UL, chargedPFCandidatesInEvent_.size()));
345 
346  // Get the primary vertex associated to this tau
347  reco::VertexRef pv = vertexAssociator_->associatedVertex(*pfTau);
348  // Let the quality cuts know which the vertex to use when applying selections
349  // on dz, etc.
350  if ( verbosity_ ) {
351  if ( pv.isNonnull() ) {
352  LogTrace("discriminate") << "pv: x = " << pv->position().x() << ", y = " << pv->position().y() << ", z = " << pv->position().z() ;
353  } else {
354  LogTrace("discriminate") << "pv: N/A" ;
355  }
356  if ( pfTau->leadPFChargedHadrCand().isNonnull() ) {
357  LogTrace("discriminate") << "leadPFChargedHadron:"
358  << " Pt = " << pfTau->leadPFChargedHadrCand()->pt() << ","
359  << " eta = " << pfTau->leadPFChargedHadrCand()->eta() << ","
360  << " phi = " << pfTau->leadPFChargedHadrCand()->phi() ;
361  } else {
362  LogTrace("discriminate") << "leadPFChargedHadron: N/A" ;
363  }
364  }
365 
366  // CV: isolation is not well defined in case primary vertex or leading charged hadron do not exist
367  if ( !(pv.isNonnull() && pfTau->leadPFChargedHadrCand().isNonnull()) ) return 0.;
368 
369  qcuts_->setPV(pv);
370  qcuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
371 
372  if ( applyDeltaBeta_ || calculateWeights_) {
373  pileupQcutsGeneralQCuts_->setPV(pv);
374  pileupQcutsGeneralQCuts_->setLeadTrack(pfTau->leadPFChargedHadrCand());
375  pileupQcutsPUTrackSelection_->setPV(pv);
376  pileupQcutsPUTrackSelection_->setLeadTrack(pfTau->leadPFChargedHadrCand());
377  }
378 
379  // Load the tracks if they are being used.
380  if ( includeTracks_ ) {
381  for( auto const & cand : pfTau->isolationPFChargedHadrCands() ) {
382  if ( qcuts_->filterCandRef(cand) ) {
383  LogTrace("discriminate") << "adding charged iso cand with pt " << cand->pt() ;
384  isoCharged_.push_back(cand);
385  }
386  }
387  }
388  if ( includeGammas_ || calculateWeights_ ) {
389  for( auto const & cand : pfTau->isolationPFGammaCands() ) {
390  if ( qcuts_->filterCandRef(cand) ) {
391  LogTrace("discriminate") << "adding neutral iso cand with pt " << cand->pt() ;
392  isoNeutral_.push_back(cand);
393  }
394  }
395  }
396 
399 
400  // If desired, get PU tracks.
401  if ( applyDeltaBeta_ || calculateWeights_) {
402  // First select by inverted the DZ/track weight cuts. True = invert
403  if ( verbosity_ ) {
404  std::cout << "Initial PFCands: " << chargedPFCandidatesInEvent_.size() << std::endl;
405  }
406 
407  std::vector<PFCandidatePtr> allPU =
408  pileupQcutsPUTrackSelection_->filterCandRefs(
409  chargedPFCandidatesInEvent_, true);
410 
411  std::vector<PFCandidatePtr> allNPU =
412  pileupQcutsPUTrackSelection_->filterCandRefs(
413  chargedPFCandidatesInEvent_);
414  LogTrace("discriminate") << "After track cuts: " << allPU.size() ;
415 
416  // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc
417  if ( !useAllPFCands_ ) {
418  std::vector<PFCandidatePtr> cleanPU =
419  pileupQcutsGeneralQCuts_->filterCandRefs(allPU);
420 
421  std::vector<PFCandidatePtr> cleanNPU =
422  pileupQcutsGeneralQCuts_->filterCandRefs(allNPU);
423 
424  LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size() ;
425 
426  // Only select PU tracks inside the isolation cone.
427  DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
428  for ( auto const & cand : cleanPU ) {
429  if ( deltaBetaFilter(cand) ) isoPU_.push_back(cand);
430  }
431 
432  for ( auto const & cand : cleanNPU ) {
433  if ( deltaBetaFilter(cand) ) chPV_.push_back(cand);
434  }
435  LogTrace("discriminate") << "After cone cuts: " << isoPU_.size() << " " << chPV_.size() ;
436  } else {
437  isoPU_ = std::move(allPU);
438  chPV_ = std::move(allNPU);
439  }
440  }
441 
442  if ( calculateWeights_ ) {
443  for ( auto const & isoObject : isoNeutral_ ) {
444  if ( isoObject->charge() != 0 ) {
445  // weight only neutral objects
446  isoNeutralWeight_.push_back(*isoObject);
447  continue;
448  }
449 
450  double eta = isoObject->eta();
451  double phi = isoObject->phi();
452  double sumNPU = 0.5*log(weightedSum(chPV_, eta, phi));
453 
454  double sumPU = 0.5*log(weightedSum(isoPU_, eta, phi));
455  PFCandidate neutral = (*isoObject);
456  if ( (sumNPU + sumPU) > 0 ) neutral.setP4(((sumNPU)/(sumNPU + sumPU))*neutral.p4());
457 
458  isoNeutralWeight_.push_back(neutral);
459  }
460  }
461 
462  // Check if we want a custom iso cone
463  if ( customIsoCone_ >= 0. ) {
464  DRFilter filter(pfTau->p4(), 0, customIsoCone_);
465  DRFilter2 filter2(pfTau->p4(), 0, customIsoCone_);
466  std::vector<PFCandidatePtr> isoCharged_filter;
467  std::vector<PFCandidatePtr> isoNeutral_filter;
468  PFCandidateCollection isoNeutralWeight_filter;
469  // Remove all the objects not in our iso cone
470  for( auto const & isoObject : isoCharged_ ) {
471  if ( filter(isoObject) ) isoCharged_filter.push_back(isoObject);
472  }
473  if(!calculateWeights_){
474  for( auto const & isoObject : isoNeutral_ ) {
475  if ( filter(isoObject) ) isoNeutral_filter.push_back(isoObject);
476  }
477  isoNeutral_ = isoNeutral_filter;
478  }else{
479  for( auto const & isoObject : isoNeutralWeight_){
480  if ( filter2(isoObject) ) isoNeutralWeight_filter.push_back(isoObject);
481  }
482  isoNeutralWeight_ = isoNeutralWeight_filter;
483  }
484  isoCharged_ = isoCharged_filter;
485  }
486 
487  bool failsOccupancyCut = false;
488  bool failsSumPtCut = false;
489  bool failsRelativeSumPtCut = false;
490 
491 //--- nObjects requirement
492  int neutrals = isoNeutral_.size();
493 
494  if ( applyDeltaBeta_ ) {
495  neutrals -= TMath::Nint(deltaBetaFactorThisEvent_*isoPU_.size());
496  }
497  if ( neutrals < 0 ) {
498  neutrals = 0;
499  }
500 
501  size_t nOccupants = isoCharged_.size() + neutrals;
502 
503  failsOccupancyCut = ( nOccupants > maximumOccupancy_ );
504 
505  double footprintCorrection_value = 0.;
506  if ( applyFootprintCorrection_ || storeRawFootprintCorrection_ ) {
507  for ( std::vector<std::unique_ptr<FootprintCorrection> >::const_iterator footprintCorrection = footprintCorrections_.begin();
508  footprintCorrection != footprintCorrections_.end(); ++footprintCorrection ) {
509  if ( (*footprintCorrection)->selection_(*pfTau) ) {
510  footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau);
511  }
512  }
513  }
514 
515  double totalPt = 0.;
516  double puPt = 0.;
517 //--- Sum PT requirement
518  if ( applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_ || storeRawPUsumPt_ ) {
519  double chargedPt = 0.;
520  double neutralPt = 0.;
521  double weightedNeutralPt = 0.;
522  for ( auto const & isoObject : isoCharged_ ) {
523  chargedPt += isoObject->pt();
524  }
525  if ( !calculateWeights_ ) {
526  for ( auto const & isoObject : isoNeutral_ ) {
527  neutralPt += isoObject->pt();
528  }
529  } else {
530  for ( auto const & isoObject : isoNeutralWeight_ ) {
531  weightedNeutralPt += isoObject.pt();
532  }
533  }
534  for ( auto const & isoObject : isoPU_ ) {
535  puPt += isoObject->pt();
536  }
537  LogTrace("discriminate") << "chargedPt = " << chargedPt ;
538  LogTrace("discriminate") << "neutralPt = " << neutralPt ;
539  LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt ;
540  LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_*puPt) << ")" ;
541 
542  if ( calculateWeights_ ) {
543  neutralPt = weightedNeutralPt;
544  }
545 
546  if ( applyDeltaBeta_ ) {
547  neutralPt -= (deltaBetaFactorThisEvent_*puPt);
548  }
549 
550  if ( applyFootprintCorrection_ ) {
551  neutralPt -= footprintCorrection_value;
552  }
553 
554  if ( applyRhoCorrection_ ) {
555  neutralPt -= rhoThisEvent_;
556  }
557 
558  if ( neutralPt < 0. ) {
559  neutralPt = 0.;
560  }
561 
562  totalPt = chargedPt + neutralPt;
563  LogTrace("discriminate") << "totalPt = " << totalPt << " (cut = " << maximumSumPt_ << ")" ;
564 
565  failsSumPtCut = (totalPt > maximumSumPt_);
566 
567 //--- Relative Sum PT requirement
568  failsRelativeSumPtCut = (totalPt > ((pfTau->pt() - offsetRelativeSumPt_)*maximumRelativeSumPt_));
569  }
570 
571  bool failsPhotonPtSumOutsideSignalConeCut = false;
572  double photonSumPt_outsideSignalCone = 0.;
573  if ( applyPhotonPtSumOutsideSignalConeCut_ || storeRawPhotonSumPt_outsideSignalCone_ ) {
574  const std::vector<reco::PFCandidatePtr>& signalPFGammas = pfTau->signalPFGammaCands();
575  for ( std::vector<reco::PFCandidatePtr>::const_iterator signalPFGamma = signalPFGammas.begin();
576  signalPFGamma != signalPFGammas.end(); ++signalPFGamma ) {
577  double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalPFGamma)->eta(), (*signalPFGamma)->phi());
578  if ( dR > pfTau->signalConeSize() ) photonSumPt_outsideSignalCone += (*signalPFGamma)->pt();
579  }
580  if ( photonSumPt_outsideSignalCone > maxAbsPhotonSumPt_outsideSignalCone_ || photonSumPt_outsideSignalCone > (maxRelPhotonSumPt_outsideSignalCone_*pfTau->pt()) ) {
581  failsPhotonPtSumOutsideSignalConeCut = true;
582  }
583  }
584 
585  bool fails = (applyOccupancyCut_ && failsOccupancyCut) ||
586  (applySumPtCut_ && failsSumPtCut) ||
587  (applyRelativeSumPtCut_ && failsRelativeSumPtCut) ||
588  (applyPhotonPtSumOutsideSignalConeCut_ && failsPhotonPtSumOutsideSignalConeCut);
589 
590 
591  if (pfTau->pt() > minPtForNoIso_ && minPtForNoIso_ > 0.){
592  return 1.;
593  LogDebug("discriminate") << "tau pt = " << pfTau->pt() << "\t min cutoff pt = " << minPtForNoIso_ ;
594  }
595 
596  // We did error checking in the constructor, so this is safe.
597  if ( storeRawSumPt_ ) {
598  return totalPt;
599  } else if ( storeRawPUsumPt_ ) {
600  if ( applyDeltaBeta_ ) return puPt;
601  else if ( applyRhoCorrection_ ) return rhoThisEvent_;
602  else return 0.;
603  } else if ( storeRawOccupancy_ ) {
604  return nOccupants;
605  } else if ( storeRawFootprintCorrection_ ) {
606  return footprintCorrection_value;
607  } else if ( storeRawPhotonSumPt_outsideSignalCone_ ) {
608  return photonSumPt_outsideSignalCone;
609  } else {
610  return (fails ? 0. : 1.);
611  }
612 }
613 
#define LogDebug(id)
PFRecoTauDiscriminationByIsolation(const edm::ParameterSet &pset)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
selection
main part
Definition: corrVsCorr.py:98
void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup) override
bool exists(std::string const &parameterName) const
checks if a parameter exists
double weightedSum(const std::vector< PFCandidatePtr > &inColl_, double eta, double phi) const
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
std::vector< std::unique_ptr< FootprintCorrection > > footprintCorrections_
edm::EDGetTokenT< reco::PFCandidateCollection > pfCand_token
FootprintCorrection(const std::string &selection, const std::string &offset)
def move
Definition: eostools.py:510
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
std::vector< reco::PFCandidatePtr > chargedPFCandidatesInEvent_
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
T min(T a, T b)
Definition: MathUtil.h:58
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
double discriminate(const PFTauRef &pfTau) const override
#define LogTrace(id)
std::auto_ptr< tau::RecoTauQualityCuts > qcuts_
std::auto_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
ParameterSet const & getParameterSet(std::string const &) const
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
Geom::Phi< T > phi() const
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
std::auto_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
tuple cout
Definition: gather_cfg.py:145
moduleLabel_(iConfig.getParameter< string >("@module_label"))
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::EDGetTokenT< reco::VertexCollection > vertex_token