CMS 3D CMS Logo

PFRecoTauDiscriminationByIsolation.cc
Go to the documentation of this file.
1 #include <functional>
2 #include <memory>
3 
14 
15 #include "TMath.h"
16 #include "TFormula.h"
17 
18 /* class PFRecoTauDiscriminationByIsolation
19  * created : Jul 23 2007,
20  * revised : Thu Aug 13 14:44:40 PDT 2009
21  * contributors : Ludovic Houchu (IPHC, Strasbourg),
22  * Christian Veelken (UC Davis),
23  * Evan K. Friis (UC Davis)
24  * Michalis Bachtis (UW Madison)
25  */
26 
27 using namespace reco;
28 using namespace std;
29 
31 public:
34  moduleLabel_(pset.getParameter<std::string>("@module_label")),
35  qualityCutsPSet_(pset.getParameter<edm::ParameterSet>("qualityCuts")) {
36  includeTracks_ = pset.getParameter<bool>("ApplyDiscriminationByTrackerIsolation");
37  includeGammas_ = pset.getParameter<bool>("ApplyDiscriminationByECALIsolation");
38 
39  calculateWeights_ = pset.getParameter<bool>("ApplyDiscriminationByWeightedECALIsolation");
40 
41  // RIC: multiply neutral isolation by a flat factor.
42  // Useful, for instance, to combine charged and neutral isolations
43  // with different relative weights
44  weightGammas_ = pset.getParameter<double>("WeightECALIsolation");
45 
46  // RIC: allow to relax the isolation completely beyond a given tau pt
47  minPtForNoIso_ = pset.getParameter<double>("minTauPtForNoIso");
48 
49  applyOccupancyCut_ = pset.getParameter<bool>("applyOccupancyCut");
50  maximumOccupancy_ = pset.getParameter<uint32_t>("maximumOccupancy");
51 
52  applySumPtCut_ = pset.getParameter<bool>("applySumPtCut");
53  maximumSumPt_ = pset.getParameter<double>("maximumSumPtCut");
54 
55  applyRelativeSumPtCut_ = pset.getParameter<bool>("applyRelativeSumPtCut");
56  maximumRelativeSumPt_ = pset.getParameter<double>("relativeSumPtCut");
57  offsetRelativeSumPt_ = pset.getParameter<double>("relativeSumPtOffset");
58 
59  storeRawOccupancy_ = pset.getParameter<bool>("storeRawOccupancy");
60  storeRawSumPt_ = pset.getParameter<bool>("storeRawSumPt");
61  storeRawPUsumPt_ = pset.getParameter<bool>("storeRawPUsumPt");
62  storeRawFootprintCorrection_ = pset.getParameter<bool>("storeRawFootprintCorrection");
63  storeRawPhotonSumPt_outsideSignalCone_ = pset.getParameter<bool>("storeRawPhotonSumPt_outsideSignalCone");
64 
65  // Sanity check on requested options. We can't apply cuts and store the
66  // raw output at the same time
67  if (applySumPtCut_ || applyOccupancyCut_ || applyRelativeSumPtCut_) {
68  if (storeRawSumPt_ || storeRawOccupancy_ || storeRawPUsumPt_) {
69  throw cms::Exception("BadIsoConfig") << "A 'store raw' and a 'apply cut' option have been set to true "
70  << "simultaneously. These options are mutually exclusive.";
71  }
72  }
73 
74  // sanity check2 - can't use weighted and unweighted iso at the same time
75  if (includeGammas_ && calculateWeights_) {
76  throw cms::Exception("BasIsoConfig")
77  << "Both 'ApplyDiscriminationByECALIsolation' and 'ApplyDiscriminationByWeightedECALIsolation' "
78  << "have been set to true. These options are mutually exclusive.";
79  }
80 
81  // Can only store one type
82  int numStoreOptions = 0;
83  if (storeRawSumPt_)
84  ++numStoreOptions;
85  if (storeRawOccupancy_)
86  ++numStoreOptions;
87  if (storeRawPUsumPt_)
88  ++numStoreOptions;
89  if (storeRawFootprintCorrection_)
90  ++numStoreOptions;
91  if (storeRawPhotonSumPt_outsideSignalCone_)
92  ++numStoreOptions;
93  if (numStoreOptions > 1) {
94  throw cms::Exception("BadIsoConfig") << "Multiple 'store sum pt' and/or 'store occupancy' options are set."
95  << " These options are mutually exclusive.";
96  }
97 
98  customIsoCone_ = pset.getParameter<double>("customOuterCone");
99 
100  applyPhotonPtSumOutsideSignalConeCut_ = pset.getParameter<bool>("applyPhotonPtSumOutsideSignalConeCut");
101  if (applyPhotonPtSumOutsideSignalConeCut_) {
102  maxAbsPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxAbsPhotonSumPt_outsideSignalCone");
103  maxRelPhotonSumPt_outsideSignalCone_ = pset.getParameter<double>("maxRelPhotonSumPt_outsideSignalCone");
104  }
105 
106  applyFootprintCorrection_ = pset.getParameter<bool>("applyFootprintCorrection");
107  if (applyFootprintCorrection_ || storeRawFootprintCorrection_) {
108  edm::VParameterSet cfgFootprintCorrections = pset.getParameter<edm::VParameterSet>("footprintCorrections");
109  for (edm::VParameterSet::const_iterator cfgFootprintCorrection = cfgFootprintCorrections.begin();
110  cfgFootprintCorrection != cfgFootprintCorrections.end();
111  ++cfgFootprintCorrection) {
112  std::string selection = cfgFootprintCorrection->getParameter<std::string>("selection");
113  std::string offset = cfgFootprintCorrection->getParameter<std::string>("offset");
114  std::unique_ptr<FootprintCorrection> footprintCorrection(new FootprintCorrection(selection, offset));
115  footprintCorrections_.push_back(std::move(footprintCorrection));
116  }
117  }
118 
119  // Get the quality cuts specific to the isolation region
120  edm::ParameterSet isolationQCuts = qualityCutsPSet_.getParameterSet("isolationQualityCuts");
121 
122  qcuts_ = std::make_unique<tau::RecoTauQualityCuts>(isolationQCuts);
123 
124  vertexAssociator_ = std::make_unique<tau::RecoTauVertexAssociator>(qualityCutsPSet_, consumesCollector());
125 
126  applyDeltaBeta_ = pset.getParameter<bool>("applyDeltaBetaCorrection");
127 
128  if (applyDeltaBeta_ || calculateWeights_) {
129  // Factorize the isolation QCuts into those that are used to
130  // select PU and those that are not.
131  std::pair<edm::ParameterSet, edm::ParameterSet> puFactorizedIsoQCuts =
132  reco::tau::factorizePUQCuts(isolationQCuts);
133 
134  // Determine the pt threshold for the PU tracks
135  // First check if the user specifies explicitly the cut.
136  // For that the user has to provide a >= 0 value for the PtCutOverride.
137  bool deltaBetaPUTrackPtCutOverride = pset.getParameter<bool>("deltaBetaPUTrackPtCutOverride");
139  double deltaBetaPUTrackPtCutOverride_val = pset.getParameter<double>("deltaBetaPUTrackPtCutOverride_val");
140  puFactorizedIsoQCuts.second.addParameter<double>("minTrackPt", deltaBetaPUTrackPtCutOverride_val);
141  } else {
142  // Secondly take it from the minGammaEt
143  puFactorizedIsoQCuts.second.addParameter<double>("minTrackPt",
144  isolationQCuts.getParameter<double>("minGammaEt"));
145  }
146 
147  pileupQcutsPUTrackSelection_ = std::make_unique<tau::RecoTauQualityCuts>(puFactorizedIsoQCuts.first);
148 
149  pileupQcutsGeneralQCuts_ = std::make_unique<tau::RecoTauQualityCuts>(puFactorizedIsoQCuts.second);
150 
151  pfCandSrc_ = pset.getParameter<edm::InputTag>("particleFlowSrc");
152  pfCand_token = consumes<edm::View<reco::Candidate> >(pfCandSrc_);
153  vertexSrc_ = pset.getParameter<edm::InputTag>("vertexSrc");
154  vertex_token = consumes<reco::VertexCollection>(vertexSrc_);
155  deltaBetaCollectionCone_ = pset.getParameter<double>("isoConeSizeForDeltaBeta");
156  std::string deltaBetaFactorFormula = pset.getParameter<string>("deltaBetaFactor");
157  deltaBetaFormula_ = std::make_unique<TFormula>("DB_corr", deltaBetaFactorFormula.c_str());
158  }
159 
160  applyRhoCorrection_ = pset.getParameter<bool>("applyRhoCorrection");
161  if (applyRhoCorrection_) {
162  rhoProducer_ = pset.getParameter<edm::InputTag>("rhoProducer");
163  rho_token = consumes<double>(rhoProducer_);
164  rhoConeSize_ = pset.getParameter<double>("rhoConeSize");
165  rhoUEOffsetCorrection_ = pset.getParameter<double>("rhoUEOffsetCorrection");
166  }
167  useAllPFCands_ = pset.getParameter<bool>("UseAllPFCandsForWeights");
168 
169  verbosity_ = pset.getParameter<int>("verbosity");
170  }
171 
173 
174  void beginEvent(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
175  double discriminate(const PFTauRef& pfTau) const override;
176 
177  inline double weightedSum(const std::vector<CandidatePtr>& inColl_, double eta, double phi) const {
178  double out = 1.0;
179  for (auto const& inObj_ : inColl_) {
180  double sum = (inObj_->pt() * inObj_->pt()) / (deltaR2(eta, phi, inObj_->eta(), inObj_->phi()));
181  if (sum > 1.0)
182  out *= sum;
183  }
184  return out;
185  }
186 
187  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
188 
189 private:
191 
193  std::unique_ptr<tau::RecoTauQualityCuts> qcuts_;
194 
195  // Inverted QCut which selects tracks with bad DZ/trackWeight
196  std::unique_ptr<tau::RecoTauQualityCuts> pileupQcutsPUTrackSelection_;
197  std::unique_ptr<tau::RecoTauQualityCuts> pileupQcutsGeneralQCuts_;
198 
199  std::unique_ptr<tau::RecoTauVertexAssociator> vertexAssociator_;
200 
213  // RIC:
215 
219 
223  : selection_(selection), offset_(offset) {}
227  };
228  std::vector<std::unique_ptr<FootprintCorrection> > footprintCorrections_;
229 
230  // Options to store the raw value in the discriminator instead of boolean pass/fail flag
236 
237  /* **********************************************************************
238  **** Pileup Subtraction Parameters ***********************************
239  **********************************************************************/
240 
241  // Delta Beta correction
245  // Keep track of how many vertices are in the event
248  std::vector<reco::CandidatePtr> chargedPFCandidatesInEvent_;
249  // Size of cone used to collect PU tracks
251  std::unique_ptr<TFormula> deltaBetaFormula_;
253 
254  // Rho correction
259  double rhoConeSize_;
263 
264  // Flag to enable/disable debug output
266 };
267 
269  // NB: The use of the PV in this context is necessitated by its use in
270  // applying quality cuts to the different objects in the isolation cone
271  // The vertex associator contains the logic to select the appropriate vertex
272  // We need to pass it the event so it can load the vertices.
273  vertexAssociator_->setEvent(event);
274 
275  // If we are applying the delta beta correction, we need to get the PF
276  // candidates from the event so we can find the PU tracks.
277  if (applyDeltaBeta_ || calculateWeights_) {
278  // Collect all the PF pile up tracks
280  event.getByToken(pfCand_token, pfCandidates);
281  chargedPFCandidatesInEvent_.clear();
282  chargedPFCandidatesInEvent_.reserve(pfCandidates->size());
283  size_t numPFCandidates = pfCandidates->size();
284  for (size_t i = 0; i < numPFCandidates; ++i) {
285  reco::CandidatePtr pfCandidate(pfCandidates, i);
286  if (pfCandidate->charge() != 0) {
287  chargedPFCandidatesInEvent_.push_back(pfCandidate);
288  }
289  }
290  // Count all the vertices in the event, to parameterize the DB
291  // correction factor
293  event.getByToken(vertex_token, vertices);
294  size_t nVtxThisEvent = vertices->size();
295  deltaBetaFactorThisEvent_ = deltaBetaFormula_->Eval(nVtxThisEvent);
296  }
297 
298  if (applyRhoCorrection_) {
299  edm::Handle<double> rhoHandle_;
300  event.getByToken(rho_token, rhoHandle_);
301  rhoThisEvent_ = (*rhoHandle_ - rhoUEOffsetCorrection_) * (3.14159) * rhoConeSize_ * rhoConeSize_;
302  }
303 }
304 
306  LogDebug("discriminate") << " tau: Pt = " << pfTau->pt() << ", eta = " << pfTau->eta() << ", phi = " << pfTau->phi();
307  LogDebug("discriminate") << *pfTau;
308 
309  // collect the objects we are working with (ie tracks, tracks+gammas, etc)
310  std::vector<CandidatePtr> isoCharged_;
311  std::vector<CandidatePtr> isoNeutral_;
312  std::vector<CandidatePtr> isoPU_;
313  CandidateCollection isoNeutralWeight_;
314  std::vector<CandidatePtr> chPV_;
315  isoCharged_.reserve(pfTau->isolationChargedHadrCands().size());
316  isoNeutral_.reserve(pfTau->isolationGammaCands().size());
317  isoPU_.reserve(std::min(100UL, chargedPFCandidatesInEvent_.size()));
318  isoNeutralWeight_.reserve(pfTau->isolationGammaCands().size());
319 
320  chPV_.reserve(std::min(50UL, chargedPFCandidatesInEvent_.size()));
321 
322  // Get the primary vertex associated to this tau
323  reco::VertexRef pv = vertexAssociator_->associatedVertex(*pfTau);
324  // Let the quality cuts know which the vertex to use when applying selections
325  // on dz, etc.
326  if (verbosity_) {
327  if (pv.isNonnull()) {
328  LogTrace("discriminate") << "pv: x = " << pv->position().x() << ", y = " << pv->position().y()
329  << ", z = " << pv->position().z();
330  } else {
331  LogTrace("discriminate") << "pv: N/A";
332  }
333  if (pfTau->leadChargedHadrCand().isNonnull()) {
334  LogTrace("discriminate") << "leadPFChargedHadron:"
335  << " Pt = " << pfTau->leadChargedHadrCand()->pt() << ","
336  << " eta = " << pfTau->leadChargedHadrCand()->eta() << ","
337  << " phi = " << pfTau->leadChargedHadrCand()->phi();
338  } else {
339  LogTrace("discriminate") << "leadPFChargedHadron: N/A";
340  }
341  }
342 
343  // CV: isolation is not well defined in case primary vertex or leading charged hadron do not exist
344  if (!(pv.isNonnull() && pfTau->leadChargedHadrCand().isNonnull()))
345  return 0.;
346 
347  qcuts_->setPV(pv);
348  qcuts_->setLeadTrack(*pfTau->leadChargedHadrCand());
349 
350  if (applyDeltaBeta_ || calculateWeights_) {
351  pileupQcutsGeneralQCuts_->setPV(pv);
352  pileupQcutsGeneralQCuts_->setLeadTrack(*pfTau->leadChargedHadrCand());
353  pileupQcutsPUTrackSelection_->setPV(pv);
354  pileupQcutsPUTrackSelection_->setLeadTrack(*pfTau->leadChargedHadrCand());
355  }
356 
357  // Load the tracks if they are being used.
358  if (includeTracks_) {
359  for (auto const& cand : pfTau->isolationChargedHadrCands()) {
360  if (qcuts_->filterCandRef(cand)) {
361  LogTrace("discriminate") << "adding charged iso cand with pt " << cand->pt();
362  isoCharged_.push_back(cand);
363  }
364  }
365  }
366  if (includeGammas_ || calculateWeights_) {
367  for (auto const& cand : pfTau->isolationGammaCands()) {
368  if (qcuts_->filterCandRef(cand)) {
369  LogTrace("discriminate") << "adding neutral iso cand with pt " << cand->pt();
370  isoNeutral_.push_back(cand);
371  }
372  }
373  }
374 
377 
378  // If desired, get PU tracks.
379  if (applyDeltaBeta_ || calculateWeights_) {
380  // First select by inverted the DZ/track weight cuts. True = invert
381  if (verbosity_) {
382  std::cout << "Initial PFCands: " << chargedPFCandidatesInEvent_.size() << std::endl;
383  }
384 
385  std::vector<CandidatePtr> allPU = pileupQcutsPUTrackSelection_->filterCandRefs(chargedPFCandidatesInEvent_, true);
386 
387  std::vector<CandidatePtr> allNPU = pileupQcutsPUTrackSelection_->filterCandRefs(chargedPFCandidatesInEvent_);
388  LogTrace("discriminate") << "After track cuts: " << allPU.size();
389 
390  // Now apply the rest of the cuts, like pt, and TIP, tracker hits, etc
391  if (!useAllPFCands_) {
392  std::vector<CandidatePtr> cleanPU = pileupQcutsGeneralQCuts_->filterCandRefs(allPU);
393 
394  std::vector<CandidatePtr> cleanNPU = pileupQcutsGeneralQCuts_->filterCandRefs(allNPU);
395 
396  LogTrace("discriminate") << "After cleaning cuts: " << cleanPU.size();
397 
398  // Only select PU tracks inside the isolation cone.
399  DRFilter deltaBetaFilter(pfTau->p4(), 0, deltaBetaCollectionCone_);
400  for (auto const& cand : cleanPU) {
401  if (deltaBetaFilter(cand))
402  isoPU_.push_back(cand);
403  }
404 
405  for (auto const& cand : cleanNPU) {
406  if (deltaBetaFilter(cand))
407  chPV_.push_back(cand);
408  }
409  LogTrace("discriminate") << "After cone cuts: " << isoPU_.size() << " " << chPV_.size();
410  } else {
411  isoPU_ = std::move(allPU);
412  chPV_ = std::move(allNPU);
413  }
414  }
415 
416  if (calculateWeights_) {
417  for (auto const& isoObject : isoNeutral_) {
418  if (isoObject->charge() != 0) {
419  // weight only neutral objects
420  isoNeutralWeight_.push_back(*isoObject);
421  continue;
422  }
423 
424  double eta = isoObject->eta();
425  double phi = isoObject->phi();
426  double sumNPU = 0.5 * log(weightedSum(chPV_, eta, phi));
427 
428  double sumPU = 0.5 * log(weightedSum(isoPU_, eta, phi));
429  LeafCandidate neutral(*isoObject);
430  if ((sumNPU + sumPU) > 0)
431  neutral.setP4(((sumNPU) / (sumNPU + sumPU)) * neutral.p4());
432 
433  isoNeutralWeight_.push_back(neutral);
434  }
435  }
436 
437  // Check if we want a custom iso cone
438  if (customIsoCone_ >= 0.) {
439  DRFilter filter(pfTau->p4(), 0, customIsoCone_);
440  DRFilter2 filter2(pfTau->p4(), 0, customIsoCone_);
441  std::vector<CandidatePtr> isoCharged_filter;
442  std::vector<CandidatePtr> isoNeutral_filter;
443  CandidateCollection isoNeutralWeight_filter;
444  // Remove all the objects not in our iso cone
445  for (auto const& isoObject : isoCharged_) {
446  if (filter(isoObject))
447  isoCharged_filter.push_back(isoObject);
448  }
449  if (!calculateWeights_) {
450  for (auto const& isoObject : isoNeutral_) {
451  if (filter(isoObject))
452  isoNeutral_filter.push_back(isoObject);
453  }
454  isoNeutral_ = isoNeutral_filter;
455  } else {
456  for (auto const& isoObject : isoNeutralWeight_) {
457  if (filter2(isoObject))
458  isoNeutralWeight_filter.push_back(isoObject);
459  }
460  isoNeutralWeight_ = isoNeutralWeight_filter;
461  }
462  isoCharged_ = isoCharged_filter;
463  }
464 
465  bool failsOccupancyCut = false;
466  bool failsSumPtCut = false;
467  bool failsRelativeSumPtCut = false;
468 
469  //--- nObjects requirement
470  int neutrals = isoNeutral_.size();
471 
472  if (applyDeltaBeta_) {
473  neutrals -= TMath::Nint(deltaBetaFactorThisEvent_ * isoPU_.size());
474  }
475  if (neutrals < 0) {
476  neutrals = 0;
477  }
478 
479  size_t nOccupants = isoCharged_.size() + neutrals;
480 
481  failsOccupancyCut = (nOccupants > maximumOccupancy_);
482 
483  double footprintCorrection_value = 0.;
484  if (applyFootprintCorrection_ || storeRawFootprintCorrection_) {
485  for (std::vector<std::unique_ptr<FootprintCorrection> >::const_iterator footprintCorrection =
486  footprintCorrections_.begin();
487  footprintCorrection != footprintCorrections_.end();
488  ++footprintCorrection) {
489  if ((*footprintCorrection)->selection_(*pfTau)) {
490  footprintCorrection_value = (*footprintCorrection)->offset_(*pfTau);
491  }
492  }
493  }
494 
495  double totalPt = 0.;
496  double puPt = 0.;
497  //--- Sum PT requirement
498  if (applySumPtCut_ || applyRelativeSumPtCut_ || storeRawSumPt_ || storeRawPUsumPt_) {
499  double chargedPt = 0.;
500  double neutralPt = 0.;
501  double weightedNeutralPt = 0.;
502  for (auto const& isoObject : isoCharged_) {
503  chargedPt += isoObject->pt();
504  }
505  if (!calculateWeights_) {
506  for (auto const& isoObject : isoNeutral_) {
507  neutralPt += isoObject->pt();
508  }
509  } else {
510  for (auto const& isoObject : isoNeutralWeight_) {
511  weightedNeutralPt += isoObject.pt();
512  }
513  }
514  for (auto const& isoObject : isoPU_) {
515  puPt += isoObject->pt();
516  }
517  LogTrace("discriminate") << "chargedPt = " << chargedPt;
518  LogTrace("discriminate") << "neutralPt = " << neutralPt;
519  LogTrace("discriminate") << "weighted neutral Pt = " << weightedNeutralPt;
520  LogTrace("discriminate") << "puPt = " << puPt << " (delta-beta corr. = " << (deltaBetaFactorThisEvent_ * puPt)
521  << ")";
522 
523  if (calculateWeights_) {
524  neutralPt = weightedNeutralPt;
525  }
526 
527  if (applyDeltaBeta_) {
528  neutralPt -= (deltaBetaFactorThisEvent_ * puPt);
529  }
530 
531  if (applyFootprintCorrection_) {
532  neutralPt -= footprintCorrection_value;
533  }
534 
535  if (applyRhoCorrection_) {
536  neutralPt -= rhoThisEvent_;
537  }
538 
539  if (neutralPt < 0.) {
540  neutralPt = 0.;
541  }
542 
543  totalPt = chargedPt + weightGammas_ * neutralPt;
544  LogTrace("discriminate") << "totalPt = " << totalPt << " (cut = " << maximumSumPt_ << ")";
545 
546  failsSumPtCut = (totalPt > maximumSumPt_);
547 
548  //--- Relative Sum PT requirement
549  failsRelativeSumPtCut = (totalPt > ((pfTau->pt() - offsetRelativeSumPt_) * maximumRelativeSumPt_));
550  }
551 
552  bool failsPhotonPtSumOutsideSignalConeCut = false;
553  double photonSumPt_outsideSignalCone = 0.;
554  if (applyPhotonPtSumOutsideSignalConeCut_ || storeRawPhotonSumPt_outsideSignalCone_) {
555  const std::vector<reco::CandidatePtr>& signalGammas = pfTau->signalGammaCands();
556  for (std::vector<reco::CandidatePtr>::const_iterator signalGamma = signalGammas.begin();
557  signalGamma != signalGammas.end();
558  ++signalGamma) {
559  double dR = deltaR(pfTau->eta(), pfTau->phi(), (*signalGamma)->eta(), (*signalGamma)->phi());
560  if (dR > pfTau->signalConeSize())
561  photonSumPt_outsideSignalCone += (*signalGamma)->pt();
562  }
563  if (photonSumPt_outsideSignalCone > maxAbsPhotonSumPt_outsideSignalCone_ ||
564  photonSumPt_outsideSignalCone > (maxRelPhotonSumPt_outsideSignalCone_ * pfTau->pt())) {
565  failsPhotonPtSumOutsideSignalConeCut = true;
566  }
567  }
568 
569  bool fails = (applyOccupancyCut_ && failsOccupancyCut) || (applySumPtCut_ && failsSumPtCut) ||
570  (applyRelativeSumPtCut_ && failsRelativeSumPtCut) ||
571  (applyPhotonPtSumOutsideSignalConeCut_ && failsPhotonPtSumOutsideSignalConeCut);
572 
573  if (pfTau->pt() > minPtForNoIso_ && minPtForNoIso_ > 0.) {
574  return 1.;
575  LogDebug("discriminate") << "tau pt = " << pfTau->pt() << "\t min cutoff pt = " << minPtForNoIso_;
576  }
577 
578  // We did error checking in the constructor, so this is safe.
579  if (storeRawSumPt_) {
580  return totalPt;
581  } else if (storeRawPUsumPt_) {
582  if (applyDeltaBeta_)
583  return puPt;
584  else if (applyRhoCorrection_)
585  return rhoThisEvent_;
586  else
587  return 0.;
588  } else if (storeRawOccupancy_) {
589  return nOccupants;
590  } else if (storeRawFootprintCorrection_) {
591  return footprintCorrection_value;
592  } else if (storeRawPhotonSumPt_outsideSignalCone_) {
593  return photonSumPt_outsideSignalCone;
594  } else {
595  return (fails ? 0. : 1.);
596  }
597 }
598 
600  // pfRecoTauDiscriminationByIsolation
602  desc.add<bool>("storeRawFootprintCorrection", false);
603  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
604  desc.add<bool>("storeRawOccupancy", false);
605  desc.add<double>("maximumSumPtCut", 6.0);
606 
607  edm::ParameterSetDescription desc_qualityCuts;
609  desc.add<edm::ParameterSetDescription>("qualityCuts", desc_qualityCuts);
610 
611  desc.add<double>("minTauPtForNoIso", -99.0);
612  desc.add<double>("maxAbsPhotonSumPt_outsideSignalCone", 1000000000.0);
613  desc.add<edm::InputTag>("vertexSrc", edm::InputTag("offlinePrimaryVertices"));
614  desc.add<bool>("applySumPtCut", false);
615  desc.add<double>("rhoConeSize", 0.5);
616  desc.add<bool>("ApplyDiscriminationByTrackerIsolation", true);
617  desc.add<bool>("storeRawPhotonSumPt_outsideSignalCone", false);
618  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAll"));
619 
620  {
622  vpsd1.add<std::string>("selection");
623  vpsd1.add<std::string>("offset");
624  desc.addVPSet("footprintCorrections", vpsd1, {});
625  }
626 
627  desc.add<std::string>("deltaBetaFactor", "0.38");
628  desc.add<bool>("applyFootprintCorrection", false);
629  desc.add<bool>("UseAllPFCandsForWeights", false);
630  desc.add<double>("relativeSumPtCut", 0.0);
631  {
632  edm::ParameterSetDescription pset_Prediscriminants;
633  pset_Prediscriminants.add<std::string>("BooleanOperator", "and");
634  {
636  psd1.add<double>("cut");
637  psd1.add<edm::InputTag>("Producer");
638  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
639  }
640  {
641  // encountered this at
642  // RecoTauTag/Configuration/python/HPSPFTaus_cff.py
643  // Prediscriminants = requireDecayMode.clone(),
644  // requireDecayMode = cms.PSet(
645  // BooleanOperator = cms.string("and"),
646  // decayMode = cms.PSet(
647  // Producer = cms.InputTag('hpsPFTauDiscriminationByDecayModeFindingNewDMs'),
648  // cut = cms.double(0.5)
649  // )
650  // )
652  psd1.add<double>("cut");
653  psd1.add<edm::InputTag>("Producer");
654  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("decayMode", psd1);
655  }
656  {
657  // encountered this at
658  // RecoTauTag/Configuration/python/HPSPFTaus_cff.py
659  // Prediscriminants = requireDecayMode.clone(),
660  // hpsPFTauDiscriminationByLooseIsolation.Prediscriminants.preIso = cms.PSet(
661  // Producer = cms.InputTag("hpsPFTauDiscriminationByLooseChargedIsolation"),
662  // cut = cms.double(0.5)
663  // )
665  psd1.add<double>("cut");
666  psd1.add<edm::InputTag>("Producer");
667  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("preIso", psd1);
668  }
669  desc.add<edm::ParameterSetDescription>("Prediscriminants", pset_Prediscriminants);
670  }
671 
672  desc.add<unsigned int>("maximumOccupancy", 0);
673  desc.add<int>("verbosity", 0);
674 
675  desc.add<bool>("applyOccupancyCut", true);
676  desc.add<bool>("applyDeltaBetaCorrection", false);
677  desc.add<bool>("applyRelativeSumPtCut", false);
678  desc.add<bool>("storeRawPUsumPt", false);
679  desc.add<bool>("applyPhotonPtSumOutsideSignalConeCut", false);
680  desc.add<bool>("deltaBetaPUTrackPtCutOverride", false);
681  desc.add<bool>("ApplyDiscriminationByWeightedECALIsolation", false);
682  desc.add<bool>("storeRawSumPt", false);
683  desc.add<bool>("ApplyDiscriminationByECALIsolation", true);
684  desc.add<bool>("applyRhoCorrection", false);
685 
686  desc.add<double>("WeightECALIsolation", 1.0);
687  desc.add<double>("rhoUEOffsetCorrection", 1.0);
688  desc.add<double>("maxRelPhotonSumPt_outsideSignalCone", 0.1);
689  desc.add<double>("deltaBetaPUTrackPtCutOverride_val", -1.5);
690  desc.add<double>("isoConeSizeForDeltaBeta", 0.5);
691  desc.add<double>("relativeSumPtOffset", 0.0);
692  desc.add<double>("customOuterCone", -1.0);
693  desc.add<edm::InputTag>("particleFlowSrc", edm::InputTag("particleFlow"));
694 
695  descriptions.add("pfRecoTauDiscriminationByIsolation", desc);
696 }
697 
ConfigurationDescriptions.h
PFRecoTauDiscriminationByIsolation::FootprintCorrection
Definition: PFRecoTauDiscriminationByIsolation.cc:221
PFRecoTauDiscriminationByIsolation::discriminate
double discriminate(const PFTauRef &pfTau) const override
Definition: PFRecoTauDiscriminationByIsolation.cc:305
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
PFRecoTauDiscriminationByIsolation::FootprintCorrection::offset_
StringObjectFunction< PFTau > offset_
Definition: PFRecoTauDiscriminationByIsolation.cc:226
mps_fire.i
i
Definition: mps_fire.py:428
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
StringObjectFunction< PFTau >
TauDiscriminationProducerBase.h
PFRecoTauDiscriminationByIsolation::storeRawFootprintCorrection_
bool storeRawFootprintCorrection_
Definition: PFRecoTauDiscriminationByIsolation.cc:234
PFRecoTauDiscriminationByIsolation::deltaBetaCollectionCone_
double deltaBetaCollectionCone_
Definition: PFRecoTauDiscriminationByIsolation.cc:250
PFRecoTauDiscriminationByIsolation::includeGammas_
bool includeGammas_
Definition: PFRecoTauDiscriminationByIsolation.cc:202
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
PFRecoTauDiscriminationByIsolation::maximumOccupancy_
uint32_t maximumOccupancy_
Definition: PFRecoTauDiscriminationByIsolation.cc:206
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFRecoTauDiscriminationByIsolation::chargedPFCandidatesInEvent_
std::vector< reco::CandidatePtr > chargedPFCandidatesInEvent_
Definition: PFRecoTauDiscriminationByIsolation.cc:248
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
PFRecoTauDiscriminationByIsolation::moduleLabel_
std::string moduleLabel_
Definition: PFRecoTauDiscriminationByIsolation.cc:190
PFRecoTauDiscriminationByIsolation::weightedSum
double weightedSum(const std::vector< CandidatePtr > &inColl_, double eta, double phi) const
Definition: PFRecoTauDiscriminationByIsolation.cc:177
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
ConeTools.h
PFRecoTauDiscriminationByIsolation::useAllPFCands_
bool useAllPFCands_
Definition: PFRecoTauDiscriminationByIsolation.cc:256
edm::Handle
Definition: AssociativeIterator.h:50
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
PFRecoTauDiscriminationByIsolation::pileupQcutsPUTrackSelection_
std::unique_ptr< tau::RecoTauQualityCuts > pileupQcutsPUTrackSelection_
Definition: PFRecoTauDiscriminationByIsolation.cc:196
PFRecoTauDiscriminationByIsolation::rhoProducer_
edm::InputTag rhoProducer_
Definition: PFRecoTauDiscriminationByIsolation.cc:257
RecoTauVertexAssociator.h
edm::Ref< PFTauCollection >
PFRecoTauDiscriminationByIsolation::maxAbsPhotonSumPt_outsideSignalCone_
double maxAbsPhotonSumPt_outsideSignalCone_
Definition: PFRecoTauDiscriminationByIsolation.cc:217
PFRecoTauDiscriminationByIsolation::maxRelPhotonSumPt_outsideSignalCone_
double maxRelPhotonSumPt_outsideSignalCone_
Definition: PFRecoTauDiscriminationByIsolation.cc:218
PFRecoTauDiscriminationByIsolation::FootprintCorrection::selection_
StringCutObjectSelector< PFTau > selection_
Definition: PFRecoTauDiscriminationByIsolation.cc:225
PFRecoTauDiscriminationByIsolation::qualityCutsPSet_
edm::ParameterSet qualityCutsPSet_
Definition: PFRecoTauDiscriminationByIsolation.cc:192
PFRecoTauDiscriminationByIsolation::verbosity_
int verbosity_
Definition: PFRecoTauDiscriminationByIsolation.cc:265
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFRecoTauDiscriminationByIsolation::rhoThisEvent_
double rhoThisEvent_
Definition: PFRecoTauDiscriminationByIsolation.cc:262
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
reco::Candidate::charge
virtual int charge() const =0
electric charge
PFRecoTauDiscriminationByIsolation::FootprintCorrection::~FootprintCorrection
~FootprintCorrection()
Definition: PFRecoTauDiscriminationByIsolation.cc:224
PFRecoTauDiscriminationByIsolation::storeRawPhotonSumPt_outsideSignalCone_
bool storeRawPhotonSumPt_outsideSignalCone_
Definition: PFRecoTauDiscriminationByIsolation.cc:235
PVValHelper::eta
Definition: PVValidationHelpers.h:69
PFRecoTauDiscriminationByIsolation::vertexAssociator_
std::unique_ptr< tau::RecoTauVertexAssociator > vertexAssociator_
Definition: PFRecoTauDiscriminationByIsolation.cc:199
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
LeafCandidate.h
TauDiscriminationProducerBase
Definition: TauDiscriminationProducerBase.h:55
HLT_FULL_cff.deltaBetaPUTrackPtCutOverride
deltaBetaPUTrackPtCutOverride
Definition: HLT_FULL_cff.py:32948
ParameterSetDescription.h
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
PFRecoTauDiscriminationByIsolation::qcuts_
std::unique_ptr< tau::RecoTauQualityCuts > qcuts_
Definition: PFRecoTauDiscriminationByIsolation.cc:193
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Vertex.h
RecoTauQualityCuts.h
PFRecoTauDiscriminationByIsolation::applyOccupancyCut_
bool applyOccupancyCut_
Definition: PFRecoTauDiscriminationByIsolation.cc:205
edm::OwnVector::reserve
void reserve(size_t)
Definition: OwnVector.h:320
PFRecoTauDiscriminationByIsolation::vertex_token
edm::EDGetTokenT< reco::VertexCollection > vertex_token
Definition: PFRecoTauDiscriminationByIsolation.cc:247
PFRecoTauDiscriminationByIsolation::applyDeltaBeta_
bool applyDeltaBeta_
Definition: PFRecoTauDiscriminationByIsolation.cc:242
PFRecoTauDiscriminationByIsolation::maximumSumPt_
double maximumSumPt_
Definition: PFRecoTauDiscriminationByIsolation.cc:208
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
PFRecoTauDiscriminationByIsolation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFRecoTauDiscriminationByIsolation.cc:599
reco::tau::cone::DeltaRPtrFilter
Definition: ConeTools.h:33
PFRecoTauDiscriminationByIsolation::rhoConeSize_
double rhoConeSize_
Definition: PFRecoTauDiscriminationByIsolation.cc:259
PFRecoTauDiscriminationByIsolation::storeRawOccupancy_
bool storeRawOccupancy_
Definition: PFRecoTauDiscriminationByIsolation.cc:231
ParameterSet
Definition: Functions.h:16
PFRecoTauDiscriminationByIsolation::PFRecoTauDiscriminationByIsolation
PFRecoTauDiscriminationByIsolation(const edm::ParameterSet &pset)
Definition: PFRecoTauDiscriminationByIsolation.cc:32
PFRecoTauDiscriminationByIsolation::calculateWeights_
bool calculateWeights_
Definition: PFRecoTauDiscriminationByIsolation.cc:203
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
PFRecoTauDiscriminationByIsolation::minPtForNoIso_
double minPtForNoIso_
Definition: PFRecoTauDiscriminationByIsolation.cc:214
reco::tau::cone::DeltaRFilter
Definition: ConeTools.h:15
PFRecoTauDiscriminationByIsolation::applyPhotonPtSumOutsideSignalConeCut_
bool applyPhotonPtSumOutsideSignalConeCut_
Definition: PFRecoTauDiscriminationByIsolation.cc:216
PFRecoTauDiscriminationByIsolation::pileupQcutsGeneralQCuts_
std::unique_ptr< tau::RecoTauQualityCuts > pileupQcutsGeneralQCuts_
Definition: PFRecoTauDiscriminationByIsolation.cc:197
PFRecoTauDiscriminationByIsolation::storeRawSumPt_
bool storeRawSumPt_
Definition: PFRecoTauDiscriminationByIsolation.cc:232
cand
Definition: decayParser.h:32
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
PFRecoTauDiscriminationByIsolation::rho_token
edm::EDGetTokenT< double > rho_token
Definition: PFRecoTauDiscriminationByIsolation.cc:258
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
reco::tau::RecoTauQualityCuts::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &descriptions)
Declare all parameters read from python config file.
Definition: RecoTauQualityCuts.cc:346
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:57
reco::tau::factorizePUQCuts
std::pair< edm::ParameterSet, edm::ParameterSet > factorizePUQCuts(const edm::ParameterSet &inputSet)
Definition: RecoTauQualityCuts.cc:167
PFRecoTauDiscriminationByIsolation::storeRawPUsumPt_
bool storeRawPUsumPt_
Definition: PFRecoTauDiscriminationByIsolation.cc:233
PFRecoTauDiscriminationByIsolation
Definition: PFRecoTauDiscriminationByIsolation.cc:30
edm::Ptr< Candidate >
PFRecoTauDiscriminationByIsolation::applySumPtCut_
bool applySumPtCut_
Definition: PFRecoTauDiscriminationByIsolation.cc:207
PFRecoTauDiscriminationByIsolation::vertexSrc_
edm::InputTag vertexSrc_
Definition: PFRecoTauDiscriminationByIsolation.cc:246
PFRecoTauDiscriminationByIsolation::pfCand_token
edm::EDGetTokenT< edm::View< reco::Candidate > > pfCand_token
Definition: PFRecoTauDiscriminationByIsolation.cc:244
PFRecoTauDiscriminationByIsolation::includeTracks_
bool includeTracks_
Definition: PFRecoTauDiscriminationByIsolation.cc:201
PFRecoTauDiscriminationByIsolation::deltaBetaFormula_
std::unique_ptr< TFormula > deltaBetaFormula_
Definition: PFRecoTauDiscriminationByIsolation.cc:251
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
PFRecoTauDiscriminationByIsolation::maximumRelativeSumPt_
double maximumRelativeSumPt_
Definition: PFRecoTauDiscriminationByIsolation.cc:210
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PFRecoTauDiscriminationByIsolation::beginEvent
void beginEvent(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Definition: PFRecoTauDiscriminationByIsolation.cc:268
StringCutObjectSelector.h
PFRecoTauDiscriminationByIsolation::rhoUEOffsetCorrection_
double rhoUEOffsetCorrection_
Definition: PFRecoTauDiscriminationByIsolation.cc:260
PFRecoTauDiscriminationByIsolation::applyRelativeSumPtCut_
bool applyRelativeSumPtCut_
Definition: PFRecoTauDiscriminationByIsolation.cc:209
PFRecoTauDiscriminationByIsolation::~PFRecoTauDiscriminationByIsolation
~PFRecoTauDiscriminationByIsolation() override
Definition: PFRecoTauDiscriminationByIsolation.cc:172
StringCutObjectSelector< PFTau >
Exception
Definition: hltDiff.cc:246
PFRecoTauDiscriminationByIsolation::deltaBetaFactorThisEvent_
double deltaBetaFactorThisEvent_
Definition: PFRecoTauDiscriminationByIsolation.cc:252
PFRecoTauDiscriminationByIsolation::offsetRelativeSumPt_
double offsetRelativeSumPt_
Definition: PFRecoTauDiscriminationByIsolation.cc:211
PFRecoTauDiscriminationByIsolation::applyFootprintCorrection_
bool applyFootprintCorrection_
Definition: PFRecoTauDiscriminationByIsolation.cc:220
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PFRecoTauDiscriminationByIsolation::footprintCorrections_
std::vector< std::unique_ptr< FootprintCorrection > > footprintCorrections_
Definition: PFRecoTauDiscriminationByIsolation.cc:228
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
HLT_FULL_cff.deltaBetaPUTrackPtCutOverride_val
deltaBetaPUTrackPtCutOverride_val
Definition: HLT_FULL_cff.py:32968
PFRecoTauDiscriminationByIsolation::applyRhoCorrection_
bool applyRhoCorrection_
Definition: PFRecoTauDiscriminationByIsolation.cc:255
PFRecoTauDiscriminationByIsolation::weightGammas_
double weightGammas_
Definition: PFRecoTauDiscriminationByIsolation.cc:204
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
reco::LeafCandidate
Definition: LeafCandidate.h:16
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
PFRecoTauDiscriminationByIsolation::pfCandSrc_
edm::InputTag pfCandSrc_
Definition: PFRecoTauDiscriminationByIsolation.cc:243
PFRecoTauDiscriminationByIsolation::rhoCorrectionThisEvent_
double rhoCorrectionThisEvent_
Definition: PFRecoTauDiscriminationByIsolation.cc:261
event
Definition: event.py:1
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::Event
Definition: Event.h:73
StringObjectFunction.h
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
edm::InputTag
Definition: InputTag.h:15
PFRecoTauDiscriminationByIsolation::FootprintCorrection::FootprintCorrection
FootprintCorrection(const std::string &selection, const std::string &offset)
Definition: PFRecoTauDiscriminationByIsolation.cc:222
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::OwnVector
Definition: OwnVector.h:24
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
PFRecoTauDiscriminationByIsolation::customIsoCone_
double customIsoCone_
Definition: PFRecoTauDiscriminationByIsolation.cc:212