CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
DeepTauId Class Reference
Inheritance diagram for DeepTauId:
deep_tau::DeepTauBase edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >

Public Member Functions

 DeepTauId (const edm::ParameterSet &cfg, const deep_tau::DeepTauCache *cache)
 
- Public Member Functions inherited from deep_tau::DeepTauBase
 DeepTauBase (const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
 
void produce (edm::Event &event, const edm::EventSetup &es) override
 
 ~DeepTauBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static const OutputCollectionGetOutputs ()
 
static void globalEndJob (const deep_tau::DeepTauCache *cache_)
 
static std::unique_ptr< deep_tau::DeepTauCacheinitializeGlobalCache (const edm::ParameterSet &cfg)
 
- Static Public Member Functions inherited from deep_tau::DeepTauBase
static void globalEndJob (const DeepTauCache *cache)
 
static std::unique_ptr< DeepTauCacheinitializeGlobalCache (const edm::ParameterSet &cfg)
 

Static Public Attributes

static float default_value = -999.
 

Private Member Functions

template<typename dnn >
tensorflow::Tensor createInputs (const TauType &tau, const ElectronCollection &electrons, const MuonCollection &muons) const
 
tensorflow::Tensor getPredictions (edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus) override
 

Static Private Member Functions

static void calculateElectronClusterVars (const pat::Electron *ele, float &elecEe, float &elecEgamma)
 
static float calculateGottfriedJacksonAngleDifference (const pat::Tau &tau)
 
static const pat::ElectronfindMatchedElectron (const pat::Tau &tau, const pat::ElectronCollection &electrons, double deltaR)
 
static double getInnerSignalConeRadius (double pt)
 
static bool isInEcalCrack (double eta)
 
template<typename CandidateCollection >
static void processIsolationPFComponents (const pat::Tau &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
 
template<typename CandidateCollection >
static void processSignalPFComponents (const pat::Tau &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4_inner, LorentzVectorXYZ &p4_outer, float &pt_inner, float &dEta_inner, float &dPhi_inner, float &m_inner, float &pt_outer, float &dEta_outer, float &dPhi_outer, float &m_outer, float &n_inner, float &n_outer)
 

Private Attributes

edm::EDGetTokenT< ElectronCollectionelectrons_token
 
std::string input_layer
 
edm::EDGetTokenT< MuonCollectionmuons_token
 
std::string output_layer
 

Additional Inherited Members

- Public Types inherited from deep_tau::DeepTauBase
using Cutter = TauWPThreshold
 
using CutterPtr = std::unique_ptr< Cutter >
 
using ElectronCollection = pat::ElectronCollection
 
using LorentzVectorXYZ = ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >>
 
using MuonCollection = pat::MuonCollection
 
using OutputCollection = std::map< std::string, Output >
 
using TauCollection = std::vector< TauType >
 
using TauDiscriminator = pat::PATTauDiscriminator
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using TauType = pat::Tau
 
using WPMap = std::map< std::string, CutterPtr >
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Protected Attributes inherited from deep_tau::DeepTauBase
const DeepTauCachecache_
 
OutputCollection outputs_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
std::map< std::string, WPMapworkingPoints_
 

Detailed Description

Definition at line 230 of file DeepTauId.cc.

Constructor & Destructor Documentation

DeepTauId::DeepTauId ( const edm::ParameterSet cfg,
const deep_tau::DeepTauCache cache 
)
inlineexplicit

Definition at line 272 of file DeepTauId.cc.

272  :
273  DeepTauBase(cfg, GetOutputs(), cache),
274  electrons_token(consumes<ElectronCollection>(cfg.getParameter<edm::InputTag>("electrons"))),
275  muons_token(consumes<MuonCollection>(cfg.getParameter<edm::InputTag>("muons"))),
276  input_layer(cache_->getGraph().node(0).name()),
277  output_layer(cache_->getGraph().node(cache_->getGraph().node_size() - 1).name())
278  {
279  const auto& shape = cache_->getGraph().node(0).attr().at("shape").shape();
280  if(shape.dim(1).size() != dnn_inputs_2017v1::NumberOfInputs)
281  throw cms::Exception("DeepTauId") << "number of inputs does not match the expected inputs for the given version";
282 
283  }
T getParameter(std::string const &) const
const tensorflow::GraphDef & getGraph() const
Definition: DeepTauBase.h:50
const DeepTauCache * cache_
Definition: DeepTauBase.h:101
edm::EDGetTokenT< ElectronCollection > electrons_token
Definition: DeepTauId.cc:631
static const OutputCollection & GetOutputs()
Definition: DeepTauId.cc:235
DeepTauBase(const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
Definition: DeepTauBase.cc:79
std::string input_layer
Definition: DeepTauId.cc:633
edm::EDGetTokenT< MuonCollection > muons_token
Definition: DeepTauId.cc:632
std::string output_layer
Definition: DeepTauId.cc:633

Member Function Documentation

static void DeepTauId::calculateElectronClusterVars ( const pat::Electron ele,
float &  elecEe,
float &  elecEgamma 
)
inlinestaticprivate

Definition at line 512 of file DeepTauId.cc.

References randomXiThetaGunProducer_cfi::energy, and pat::Electron::superCluster().

513  {
514  if(ele) {
515  elecEe = elecEgamma = 0;
516  auto superCluster = ele->superCluster();
517  if(superCluster.isNonnull() && superCluster.isAvailable() && superCluster->clusters().isNonnull()
518  && superCluster->clusters().isAvailable()) {
519  for(auto iter = superCluster->clustersBegin(); iter != superCluster->clustersEnd(); ++iter) {
520  const double energy = (*iter)->energy();
521  if(iter == superCluster->clustersBegin()) elecEe += energy;
522  else elecEgamma += energy;
523  }
524  }
525  } else {
526  elecEe = elecEgamma = default_value;
527  }
528  }
static float default_value
Definition: DeepTauId.cc:233
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
static float DeepTauId::calculateGottfriedJacksonAngleDifference ( const pat::Tau tau)
inlinestaticprivate

Definition at line 593 of file DeepTauId.cc.

References funct::abs(), constexpr, pat::Tau::decayMode(), pat::Tau::flightLength(), reco::LeafCandidate::p(), reco::LeafCandidate::p4(), and funct::pow().

594  {
595  if(tau.decayMode() == 10) {
596  static constexpr double mTau = 1.77682;
597  const double mAOne = tau.p4().M();
598  const double pAOneMag = tau.p();
599  const double argumentThetaGJmax = (std::pow(mTau,2) - std::pow(mAOne,2) ) / ( 2 * mTau * pAOneMag );
600  const double argumentThetaGJmeasured = tau.p4().Vect().Dot(tau.flightLength())
601  / ( pAOneMag * tau.flightLength().R() );
602  if ( std::abs(argumentThetaGJmax) <= 1. && std::abs(argumentThetaGJmeasured) <= 1. ) {
603  double thetaGJmax = std::asin( argumentThetaGJmax );
604  double thetaGJmeasured = std::acos( argumentThetaGJmeasured );
605  return thetaGJmeasured - thetaGJmax;
606  }
607  }
608  return default_value;
609  }
const pat::tau::TauPFEssential::Vector & flightLength() const
Definition: Tau.h:322
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
double p() const final
magnitude of momentum vector
int decayMode() const
reconstructed tau decay mode (specific to PFTau)
Definition: Tau.h:366
static float default_value
Definition: DeepTauId.cc:233
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
#define constexpr
template<typename dnn >
tensorflow::Tensor DeepTauId::createInputs ( const TauType tau,
const ElectronCollection electrons,
const MuonCollection muons 
) const
inlineprivate

Definition at line 318 of file DeepTauId.cc.

References funct::abs(), tauProducer_cfi::chargedIsoPtSum, constexpr, taus_cff::decayMode, pat::Tau::decayMode(), particleFlow_cfi::dEta, particleFlow_cfi::dPhi, PVValHelper::dxy, pat::Tau::dxy(), pat::Tau::dxy_Sig(), PVValHelper::dz, pat::Tau::ecalEnergyLeadChargedHadrCand(), pat::Tau::emFraction_MVA(), reco::tau::eratio(), PVValHelper::eta, pat::Tau::etaAtEcalEntranceLeadChargedCand(), Exception, pat::Tau::flightLength(), pat::Tau::flightLengthSig(), edm::Ptr< T >::get(), pat::Tau::hasSecondaryVertex(), pat::Tau::hcalEnergyLeadChargedHadrCand(), PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, electrons_cff::ip3d, pat::Tau::ip3d(), pat::Tau::ip3d_Sig(), edm::Ptr< T >::isNonnull(), pat::Tau::leadChargedHadrCand(), pat::Tau::leadingTrackNormChi2(), pat::Tau::leadPFChargedHadrCand(), ResonanceBuilder::mass, reco::tau::n_photons_total(), tauProducer_cfi::neutralIsoPtSum, tauProducer_cfi::neutralIsoPtSumWeight, reco::LeafCandidate::p4(), tauProducer_cfi::photonPtSumOutsideSignalCone, EnergyCorrector::pt, reco::tau::pt_weighted_deta_strip(), reco::tau::pt_weighted_dphi_strip(), reco::tau::pt_weighted_dr_iso(), reco::tau::pt_weighted_dr_signal(), pat::Tau::ptLeadChargedCand(), tauProducer_cfi::puCorrPtSum, metsig::tau, and pat::Tau::tauID().

320  {
321  static constexpr bool check_all_set = false;
322  static constexpr float default_value_for_set_check = -42;
323 
324  tensorflow::Tensor inputs(tensorflow::DT_FLOAT, { 1, dnn_inputs_2017v1::NumberOfInputs});
325  const auto& get = [&](int var_index) -> float& { return inputs.matrix<float>()(0, var_index); };
326  auto leadChargedHadrCand = dynamic_cast<const pat::PackedCandidate*>(tau.leadChargedHadrCand().get());
327 
328  if(check_all_set) {
329  for(int var_index = 0; var_index < dnn::NumberOfInputs; ++var_index) {
330  get(var_index) = default_value_for_set_check;
331  }
332  }
333 
334  get(dnn::pt) = tau.p4().pt();
335  get(dnn::eta) = tau.p4().eta();
336  get(dnn::mass) = tau.p4().mass();
337  get(dnn::decayMode) = tau.decayMode();
338  get(dnn::chargedIsoPtSum) = tau.tauID("chargedIsoPtSum");
339  get(dnn::neutralIsoPtSum) = tau.tauID("neutralIsoPtSum");
340  get(dnn::neutralIsoPtSumWeight) = tau.tauID("neutralIsoPtSumWeight");
341  get(dnn::photonPtSumOutsideSignalCone) = tau.tauID("photonPtSumOutsideSignalCone");
342  get(dnn::puCorrPtSum) = tau.tauID("puCorrPtSum");
343  get(dnn::dxy) = tau.dxy();
344  get(dnn::dxy_sig) = tau.dxy_Sig();
345  get(dnn::dz) = leadChargedHadrCand ? leadChargedHadrCand->dz() : default_value;
346  get(dnn::ip3d) = tau.ip3d();
347  get(dnn::ip3d_sig) = tau.ip3d_Sig();
348  get(dnn::hasSecondaryVertex) = tau.hasSecondaryVertex();
349  get(dnn::flightLength_r) = tau.flightLength().R();
350  get(dnn::flightLength_dEta) = dEta(tau.flightLength(), tau.p4());
351  get(dnn::flightLength_dPhi) = dPhi(tau.flightLength(), tau.p4());
352  get(dnn::flightLength_sig) = tau.flightLengthSig();
353  get(dnn::leadChargedHadrCand_pt) = leadChargedHadrCand ? leadChargedHadrCand->p4().Pt() : default_value;
354  get(dnn::leadChargedHadrCand_dEta) = leadChargedHadrCand
355  ? dEta(leadChargedHadrCand->p4(), tau.p4()) : default_value;
356  get(dnn::leadChargedHadrCand_dPhi) = leadChargedHadrCand
357  ? dPhi(leadChargedHadrCand->p4(), tau.p4()) : default_value;
358  get(dnn::leadChargedHadrCand_mass) = leadChargedHadrCand
359  ? leadChargedHadrCand->p4().mass() : default_value;
364  get(dnn::leadingTrackNormChi2) = tau.leadingTrackNormChi2();
365  get(dnn::e_ratio) = reco::tau::eratio(tau);
366  get(dnn::gj_angle_diff) = calculateGottfriedJacksonAngleDifference(tau);
367  get(dnn::n_photons) = reco::tau::n_photons_total(tau);
368  get(dnn::emFraction) = tau.emFraction_MVA();
369  get(dnn::has_gsf_track) = leadChargedHadrCand && std::abs(leadChargedHadrCand->pdgId()) == 11;
370  get(dnn::inside_ecal_crack) = isInEcalCrack(tau.p4().Eta());
371  auto gsf_ele = findMatchedElectron(tau, electrons, 0.3);
372  get(dnn::gsf_ele_matched) = gsf_ele != nullptr;
373  get(dnn::gsf_ele_pt) = gsf_ele != nullptr ? gsf_ele->p4().Pt() : default_value;
374  get(dnn::gsf_ele_dEta) = gsf_ele != nullptr ? dEta(gsf_ele->p4(), tau.p4()) : default_value;
375  get(dnn::gsf_ele_dPhi) = gsf_ele != nullptr ? dPhi(gsf_ele->p4(), tau.p4()) : default_value;
376  get(dnn::gsf_ele_mass) = gsf_ele != nullptr ? gsf_ele->p4().mass() : default_value;
377  calculateElectronClusterVars(gsf_ele, get(dnn::gsf_ele_Ee), get(dnn::gsf_ele_Egamma));
378  get(dnn::gsf_ele_Pin) = gsf_ele != nullptr ? gsf_ele->trackMomentumAtVtx().R() : default_value;
379  get(dnn::gsf_ele_Pout) = gsf_ele != nullptr ? gsf_ele->trackMomentumOut().R() : default_value;
380  get(dnn::gsf_ele_EtotOverPin) = get(dnn::gsf_ele_Pin) > 0
381  ? (get(dnn::gsf_ele_Ee) + get(dnn::gsf_ele_Egamma)) / get(dnn::gsf_ele_Pin)
382  : default_value;
383  get(dnn::gsf_ele_Eecal) = gsf_ele != nullptr ? gsf_ele->ecalEnergy() : default_value;
384  get(dnn::gsf_ele_dEta_SeedClusterTrackAtCalo) = gsf_ele != nullptr
385  ? gsf_ele->deltaEtaSeedClusterTrackAtCalo() : default_value;
386  get(dnn::gsf_ele_dPhi_SeedClusterTrackAtCalo) = gsf_ele != nullptr
387  ? gsf_ele->deltaPhiSeedClusterTrackAtCalo() : default_value;
388  get(dnn::gsf_ele_mvaIn_sigmaEtaEta) = gsf_ele != nullptr
389  ? gsf_ele->mvaInput().sigmaEtaEta : default_value;
390  get(dnn::gsf_ele_mvaIn_hadEnergy) = gsf_ele != nullptr ? gsf_ele->mvaInput().hadEnergy : default_value;
391  get(dnn::gsf_ele_mvaIn_deltaEta) = gsf_ele != nullptr ? gsf_ele->mvaInput().deltaEta : default_value;
392 
393  get(dnn::gsf_ele_Chi2NormGSF) = default_value;
394  get(dnn::gsf_ele_GSFNumHits) = default_value;
395  get(dnn::gsf_ele_GSFTrackResol) = default_value;
396  get(dnn::gsf_ele_GSFTracklnPt) = default_value;
397  if(gsf_ele != nullptr && gsf_ele->gsfTrack().isNonnull()) {
398  get(dnn::gsf_ele_Chi2NormGSF) = gsf_ele->gsfTrack()->normalizedChi2();
399  get(dnn::gsf_ele_GSFNumHits) = gsf_ele->gsfTrack()->numberOfValidHits();
400  if(gsf_ele->gsfTrack()->pt() > 0) {
401  get(dnn::gsf_ele_GSFTrackResol) = gsf_ele->gsfTrack()->ptError() / gsf_ele->gsfTrack()->pt();
402  get(dnn::gsf_ele_GSFTracklnPt) = std::log10(gsf_ele->gsfTrack()->pt());
403  }
404  }
405 
406  get(dnn::gsf_ele_Chi2NormKF) = default_value;
407  get(dnn::gsf_ele_KFNumHits) = default_value;
408  if(gsf_ele != nullptr && gsf_ele->closestCtfTrackRef().isNonnull()) {
409  get(dnn::gsf_ele_Chi2NormKF) = gsf_ele->closestCtfTrackRef()->normalizedChi2();
410  get(dnn::gsf_ele_KFNumHits) = gsf_ele->closestCtfTrackRef()->numberOfValidHits();
411  }
412  get(dnn::leadChargedCand_etaAtEcalEntrance) = tau.etaAtEcalEntranceLeadChargedCand();
413  get(dnn::leadChargedCand_pt) = tau.ptLeadChargedCand();
414 
415  get(dnn::leadChargedHadrCand_HoP) = default_value;
416  get(dnn::leadChargedHadrCand_EoP) = default_value;
417  if(tau.leadChargedHadrCand()->pt() > 0) {
418  get(dnn::leadChargedHadrCand_HoP) = tau.hcalEnergyLeadChargedHadrCand()
419  / tau.leadChargedHadrCand()->pt();
420  get(dnn::leadChargedHadrCand_EoP) = tau.ecalEnergyLeadChargedHadrCand()
421  / tau.leadChargedHadrCand()->pt();
422  }
423 
424  MuonHitMatch muon_hit_match;
425  if(tau.leadPFChargedHadrCand().isNonnull() && tau.leadPFChargedHadrCand()->muonRef().isNonnull())
426  muon_hit_match.addMatchedMuon(*tau.leadPFChargedHadrCand()->muonRef(), tau);
427 
428  auto matched_muons = muon_hit_match.findMatchedMuons(tau, muons, 0.3, 5);
429  for(auto muon : matched_muons)
430  muon_hit_match.addMatchedMuon(*muon, tau);
431  muon_hit_match.fillTensor<dnn>(get, tau, default_value);
432 
433  LorentzVectorXYZ signalChargedHadrCands_sumIn, signalChargedHadrCands_sumOut;
434  processSignalPFComponents(tau, tau.signalChargedHadrCands(),
435  signalChargedHadrCands_sumIn, signalChargedHadrCands_sumOut,
436  get(dnn::signalChargedHadrCands_sum_innerSigCone_pt),
437  get(dnn::signalChargedHadrCands_sum_innerSigCone_dEta),
438  get(dnn::signalChargedHadrCands_sum_innerSigCone_dPhi),
439  get(dnn::signalChargedHadrCands_sum_innerSigCone_mass),
440  get(dnn::signalChargedHadrCands_sum_outerSigCone_pt),
441  get(dnn::signalChargedHadrCands_sum_outerSigCone_dEta),
442  get(dnn::signalChargedHadrCands_sum_outerSigCone_dPhi),
443  get(dnn::signalChargedHadrCands_sum_outerSigCone_mass),
444  get(dnn::signalChargedHadrCands_nTotal_innerSigCone),
445  get(dnn::signalChargedHadrCands_nTotal_outerSigCone));
446 
447  LorentzVectorXYZ signalNeutrHadrCands_sumIn, signalNeutrHadrCands_sumOut;
448  processSignalPFComponents(tau, tau.signalNeutrHadrCands(),
449  signalNeutrHadrCands_sumIn, signalNeutrHadrCands_sumOut,
450  get(dnn::signalNeutrHadrCands_sum_innerSigCone_pt),
451  get(dnn::signalNeutrHadrCands_sum_innerSigCone_dEta),
452  get(dnn::signalNeutrHadrCands_sum_innerSigCone_dPhi),
453  get(dnn::signalNeutrHadrCands_sum_innerSigCone_mass),
454  get(dnn::signalNeutrHadrCands_sum_outerSigCone_pt),
455  get(dnn::signalNeutrHadrCands_sum_outerSigCone_dEta),
456  get(dnn::signalNeutrHadrCands_sum_outerSigCone_dPhi),
457  get(dnn::signalNeutrHadrCands_sum_outerSigCone_mass),
458  get(dnn::signalNeutrHadrCands_nTotal_innerSigCone),
459  get(dnn::signalNeutrHadrCands_nTotal_outerSigCone));
460 
461 
462  LorentzVectorXYZ signalGammaCands_sumIn, signalGammaCands_sumOut;
463  processSignalPFComponents(tau, tau.signalGammaCands(),
464  signalGammaCands_sumIn, signalGammaCands_sumOut,
465  get(dnn::signalGammaCands_sum_innerSigCone_pt),
466  get(dnn::signalGammaCands_sum_innerSigCone_dEta),
467  get(dnn::signalGammaCands_sum_innerSigCone_dPhi),
468  get(dnn::signalGammaCands_sum_innerSigCone_mass),
469  get(dnn::signalGammaCands_sum_outerSigCone_pt),
470  get(dnn::signalGammaCands_sum_outerSigCone_dEta),
471  get(dnn::signalGammaCands_sum_outerSigCone_dPhi),
472  get(dnn::signalGammaCands_sum_outerSigCone_mass),
473  get(dnn::signalGammaCands_nTotal_innerSigCone),
474  get(dnn::signalGammaCands_nTotal_outerSigCone));
475 
476  LorentzVectorXYZ isolationChargedHadrCands_sum;
477  processIsolationPFComponents(tau, tau.isolationChargedHadrCands(), isolationChargedHadrCands_sum,
478  get(dnn::isolationChargedHadrCands_sum_pt),
479  get(dnn::isolationChargedHadrCands_sum_dEta),
480  get(dnn::isolationChargedHadrCands_sum_dPhi),
481  get(dnn::isolationChargedHadrCands_sum_mass),
482  get(dnn::isolationChargedHadrCands_nTotal));
483 
484  LorentzVectorXYZ isolationNeutrHadrCands_sum;
485  processIsolationPFComponents(tau, tau.isolationNeutrHadrCands(), isolationNeutrHadrCands_sum,
486  get(dnn::isolationNeutrHadrCands_sum_pt),
487  get(dnn::isolationNeutrHadrCands_sum_dEta),
488  get(dnn::isolationNeutrHadrCands_sum_dPhi),
489  get(dnn::isolationNeutrHadrCands_sum_mass),
490  get(dnn::isolationNeutrHadrCands_nTotal));
491 
492  LorentzVectorXYZ isolationGammaCands_sum;
493  processIsolationPFComponents(tau, tau.isolationGammaCands(), isolationGammaCands_sum,
494  get(dnn::isolationGammaCands_sum_pt),
495  get(dnn::isolationGammaCands_sum_dEta),
496  get(dnn::isolationGammaCands_sum_dPhi),
497  get(dnn::isolationGammaCands_sum_mass),
498  get(dnn::isolationGammaCands_nTotal));
499 
500  get(dnn::tau_visMass_innerSigCone) = (signalGammaCands_sumIn + signalChargedHadrCands_sumIn).mass();
501 
502  if(check_all_set) {
503  for(int var_index = 0; var_index < dnn::NumberOfInputs; ++var_index) {
504  if(get(var_index) == default_value_for_set_check)
505  throw cms::Exception("DeepTauId: variable with index = ") << var_index << " is not set.";
506  }
507  }
508 
509  return inputs;
510  }
unsigned int n_photons_total(const reco::PFTau &tau)
return total number of pf photon candidates with pT>500 MeV, which are associated to signal ...
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
static bool isInEcalCrack(double eta)
Definition: DeepTauId.cc:611
static void processIsolationPFComponents(const pat::Tau &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
Definition: DeepTauId.cc:567
static float calculateGottfriedJacksonAngleDifference(const pat::Tau &tau)
Definition: DeepTauId.cc:593
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
float pt_weighted_dphi_strip(const reco::PFTau &tau, int dm)
float eratio(const reco::PFTau &tau)
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
static void processSignalPFComponents(const pat::Tau &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4_inner, LorentzVectorXYZ &p4_outer, float &pt_inner, float &dEta_inner, float &dPhi_inner, float &m_inner, float &pt_outer, float &dEta_outer, float &dPhi_outer, float &m_outer, float &n_inner, float &n_outer)
Definition: DeepTauId.cc:531
static const pat::Electron * findMatchedElectron(const pat::Tau &tau, const pat::ElectronCollection &electrons, double deltaR)
Definition: DeepTauId.cc:617
static float default_value
Definition: DeepTauId.cc:233
static void calculateElectronClusterVars(const pat::Electron *ele, float &elecEe, float &elecEgamma)
Definition: DeepTauId.cc:512
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >> LorentzVectorXYZ
Definition: DeepTauBase.h:67
#define constexpr
static void DeepTauId::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 246 of file DeepTauId.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

247  {
249  desc.add<edm::InputTag>("electrons", edm::InputTag("slimmedElectrons"));
250  desc.add<edm::InputTag>("muons", edm::InputTag("slimmedMuons"));
251  desc.add<edm::InputTag>("taus", edm::InputTag("slimmedTaus"));
252  desc.add<std::string>("graph_file", "RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v1_20L1024N_quantized.pb");
253  desc.add<bool>("mem_mapped", false);
254 
256  descWP.add<std::string>("VVVLoose", "0");
257  descWP.add<std::string>("VVLoose", "0");
258  descWP.add<std::string>("VLoose", "0");
259  descWP.add<std::string>("Loose", "0");
260  descWP.add<std::string>("Medium", "0");
261  descWP.add<std::string>("Tight", "0");
262  descWP.add<std::string>("VTight", "0");
263  descWP.add<std::string>("VVTight", "0");
264  descWP.add<std::string>("VVVTight", "0");
265  desc.add<edm::ParameterSetDescription>("VSeWP", descWP);
266  desc.add<edm::ParameterSetDescription>("VSmuWP", descWP);
267  desc.add<edm::ParameterSetDescription>("VSjetWP", descWP);
268  descriptions.add("DeepTau2017v1", desc);
269  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const pat::Electron* DeepTauId::findMatchedElectron ( const pat::Tau tau,
const pat::ElectronCollection electrons,
double  deltaR 
)
inlinestaticprivate

Definition at line 617 of file DeepTauId.cc.

References boostedElectronIsolation_cff::deltaR, reco::deltaR2(), reco::LeafCandidate::p4(), and reco::LeafCandidate::pt().

619  {
620  const double dR2 = deltaR*deltaR;
621  const pat::Electron* matched_ele = nullptr;
622  for(const auto& ele : electrons) {
623  if(reco::deltaR2(tau.p4(), ele.p4()) < dR2 && (!matched_ele || matched_ele->pt() < ele.pt())) {
624  matched_ele = &ele;
625  }
626  }
627  return matched_ele;
628  }
double pt() const final
transverse momentum
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
Analysis-level electron class.
Definition: Electron.h:52
static double DeepTauId::getInnerSignalConeRadius ( double  pt)
inlinestaticprivate

Definition at line 585 of file DeepTauId.cc.

References constexpr, SiStripPI::max, and cosmictrackSelector_cfi::min_pt.

586  {
587  static constexpr double min_pt = 30., min_radius = 0.05, cone_opening_coef = 3.;
588  // This is equivalent of the original formula (std::max(std::min(0.1, 3.0/pt), 0.05)
589  return std::max(cone_opening_coef / std::max(pt, min_pt), min_radius);
590  }
#define constexpr
static const OutputCollection& DeepTauId::GetOutputs ( )
inlinestatic

Definition at line 235 of file DeepTauId.cc.

References constexpr, and Output.

236  {
237  static constexpr size_t e_index = 0, mu_index = 1, tau_index = 2, jet_index = 3;
238  static const OutputCollection outputs_ = {
239  { "VSe", Output({tau_index}, {e_index, tau_index}) },
240  { "VSmu", Output({tau_index}, {mu_index, tau_index}) },
241  { "VSjet", Output({tau_index}, {jet_index, tau_index}) },
242  };
243  return outputs_;
244  }
std::map< std::string, Output > OutputCollection
Definition: DeepTauBase.h:82
OutputCollection outputs_
Definition: DeepTauBase.h:100
#define Output(cl)
Definition: vmac.h:194
#define constexpr
tensorflow::Tensor DeepTauId::getPredictions ( edm::Event event,
const edm::EventSetup es,
edm::Handle< TauCollection taus 
)
inlineoverrideprivatevirtual

Implements deep_tau::DeepTauBase.

Definition at line 296 of file DeepTauId.cc.

References nano_cff::electrons, PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, gen::k, extraflags_cff::muons, and tensorflow::run().

298  {
300  event.getByToken(electrons_token, electrons);
301 
303  event.getByToken(muons_token, muons);
304 
305  tensorflow::Tensor predictions(tensorflow::DT_FLOAT, { static_cast<int>(taus->size()),
306  dnn_inputs_2017v1::NumberOfOutputs});
307  for(size_t tau_index = 0; tau_index < taus->size(); ++tau_index) {
308  const tensorflow::Tensor& inputs = createInputs<dnn_inputs_2017v1>(taus->at(tau_index), *electrons, *muons);
309  std::vector<tensorflow::Tensor> pred_vector;
310  tensorflow::run(&(cache_->getSession()), { { input_layer, inputs } }, { output_layer }, &pred_vector);
311  for(int k = 0; k < dnn_inputs_2017v1::NumberOfOutputs; ++k)
312  predictions.matrix<float>()(tau_index, k) = pred_vector[0].flat<float>()(k);
313  }
314  return predictions;
315  }
tensorflow::Session & getSession() const
Definition: DeepTauBase.h:49
const DeepTauCache * cache_
Definition: DeepTauBase.h:101
edm::EDGetTokenT< ElectronCollection > electrons_token
Definition: DeepTauId.cc:631
int k[5][pyjets_maxn]
std::string input_layer
Definition: DeepTauId.cc:633
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, const std::vector< std::string > &targetNodes, std::vector< Tensor > *outputs)
Definition: TensorFlow.cc:210
edm::EDGetTokenT< MuonCollection > muons_token
Definition: DeepTauId.cc:632
std::string output_layer
Definition: DeepTauId.cc:633
static void DeepTauId::globalEndJob ( const deep_tau::DeepTauCache cache_)
inlinestatic

Definition at line 290 of file DeepTauId.cc.

291  {
292  return DeepTauBase::globalEndJob(cache_);
293  }
static std::unique_ptr<deep_tau::DeepTauCache> DeepTauId::initializeGlobalCache ( const edm::ParameterSet cfg)
inlinestatic

Definition at line 285 of file DeepTauId.cc.

286  {
287  return DeepTauBase::initializeGlobalCache(cfg);
288  }
static bool DeepTauId::isInEcalCrack ( double  eta)
inlinestaticprivate

Definition at line 611 of file DeepTauId.cc.

References funct::abs().

612  {
613  const double abs_eta = std::abs(eta);
614  return abs_eta > 1.46 && abs_eta < 1.558;
615  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
template<typename CandidateCollection >
static void DeepTauId::processIsolationPFComponents ( const pat::Tau tau,
const CandidateCollection &  candidates,
LorentzVectorXYZ p4,
float &  pt,
float &  d_eta,
float &  d_phi,
float &  m,
float &  n 
)
inlinestaticprivate

Definition at line 567 of file DeepTauId.cc.

References particleFlow_cfi::dEta, particleFlow_cfi::dPhi, gen::n, and reco::LeafCandidate::p4().

570  {
571  p4 = LorentzVectorXYZ(0, 0, 0, 0);
572  n = 0;
573 
574  for(const auto& cand : candidates) {
575  p4 += cand->p4();
576  ++n;
577  }
578 
579  pt = n != 0 ? p4.Pt() : default_value;
580  d_eta = n != 0 ? dEta(p4, tau.p4()) : default_value;
581  d_phi = n != 0 ? dPhi(p4, tau.p4()) : default_value;
582  m = n != 0 ? p4.mass() : default_value;
583  }
double p4[4]
Definition: TauolaWrapper.h:92
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
static float default_value
Definition: DeepTauId.cc:233
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >> LorentzVectorXYZ
Definition: DeepTauBase.h:67
template<typename CandidateCollection >
static void DeepTauId::processSignalPFComponents ( const pat::Tau tau,
const CandidateCollection &  candidates,
LorentzVectorXYZ p4_inner,
LorentzVectorXYZ p4_outer,
float &  pt_inner,
float &  dEta_inner,
float &  dPhi_inner,
float &  m_inner,
float &  pt_outer,
float &  dEta_outer,
float &  dPhi_outer,
float &  m_outer,
float &  n_inner,
float &  n_outer 
)
inlinestaticprivate

Definition at line 531 of file DeepTauId.cc.

References reco::deltaR(), particleFlow_cfi::dEta, particleFlow_cfi::dPhi, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, pat::Tau::leadChargedHadrCand(), reco::LeafCandidate::p4(), and reco::LeafCandidate::pt().

536  {
537  p4_inner = LorentzVectorXYZ(0, 0, 0, 0);
538  p4_outer = LorentzVectorXYZ(0, 0, 0, 0);
539  n_inner = 0;
540  n_outer = 0;
541 
542  const double innerSigCone_radius = getInnerSignalConeRadius(tau.pt());
543  for(const auto& cand : candidates) {
544  const double dR = reco::deltaR(cand->p4(), tau.leadChargedHadrCand()->p4());
545  const bool isInside_innerSigCone = dR < innerSigCone_radius;
546  if(isInside_innerSigCone) {
547  p4_inner += cand->p4();
548  ++n_inner;
549  } else {
550  p4_outer += cand->p4();
551  ++n_outer;
552  }
553  }
554 
555  pt_inner = n_inner != 0 ? p4_inner.Pt() : default_value;
556  dEta_inner = n_inner != 0 ? dEta(p4_inner, tau.p4()) : default_value;
557  dPhi_inner = n_inner != 0 ? dPhi(p4_inner, tau.p4()) : default_value;
558  m_inner = n_inner != 0 ? p4_inner.mass() : default_value;
559 
560  pt_outer = n_outer != 0 ? p4_outer.Pt() : default_value;
561  dEta_outer = n_outer != 0 ? dEta(p4_outer, tau.p4()) : default_value;
562  dPhi_outer = n_outer != 0 ? dPhi(p4_outer, tau.p4()) : default_value;
563  m_outer = n_outer != 0 ? p4_outer.mass() : default_value;
564  }
static double getInnerSignalConeRadius(double pt)
Definition: DeepTauId.cc:585
double pt() const final
transverse momentum
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
const reco::CandidatePtr leadChargedHadrCand() const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
static float default_value
Definition: DeepTauId.cc:233
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >> LorentzVectorXYZ
Definition: DeepTauBase.h:67

Member Data Documentation

float DeepTauId::default_value = -999.
static

Definition at line 233 of file DeepTauId.cc.

edm::EDGetTokenT<ElectronCollection> DeepTauId::electrons_token
private

Definition at line 631 of file DeepTauId.cc.

std::string DeepTauId::input_layer
private

Definition at line 633 of file DeepTauId.cc.

edm::EDGetTokenT<MuonCollection> DeepTauId::muons_token
private

Definition at line 632 of file DeepTauId.cc.

std::string DeepTauId::output_layer
private

Definition at line 633 of file DeepTauId.cc.