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 | Static 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)
 
const std::map< BasicDiscriminator, size_t > matchDiscriminatorIndices (edm::Event &event, edm::EDGetTokenT< reco::TauDiscriminatorContainer > discriminatorContainerToken, std::vector< BasicDiscriminator > requiredDiscr)
 
- 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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () 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 constexpr float default_value = -999.
 

Private Member Functions

void checkInputs (const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr) const
 
template<typename CandidateCastType , typename TauCastType >
void createConvFeatures (const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const CellGrid &grid, TauFunc tau_funcs, bool is_inner)
 
template<typename CandidateCastType , typename TauCastType >
void createEgammaBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
 
template<typename CandidateCastType , typename TauCastType >
void createHadronsBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
 
template<typename dnn , typename CandidateCastType , typename TauCastType >
tensorflow::Tensor createInputsV1 (const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, TauFunc tau_funcs) const
 
template<typename CandidateCastType , typename TauCastType >
void createMuonBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
 
template<typename CandidateCastType , typename TauCastType >
void createTauBlockInputs (const TauCastType &tau, const size_t &tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, TauFunc tau_funcs)
 
template<typename Collection , typename TauCastType >
void fillGrids (const TauCastType &tau, const Collection &objects, CellGrid &inner_grid, CellGrid &outer_grid)
 
tensorflow::Tensor getPartialPredictions (bool is_inner)
 
tensorflow::Tensor getPredictions (edm::Event &event, edm::Handle< TauCollection > taus) override
 
template<typename CandidateCastType , typename TauCastType >
void getPredictionsV1 (TauCollection::const_reference &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, std::vector< tensorflow::Tensor > &pred_vector, TauFunc tau_funcs)
 
template<typename CandidateCastType , typename TauCastType >
void getPredictionsV2 (TauCollection::const_reference &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const reco::Vertex &pv, double rho, std::vector< tensorflow::Tensor > &pred_vector, TauFunc tau_funcs)
 
void saveInputs (const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr)
 
void setCellConvFeatures (tensorflow::Tensor &convTensor, const tensorflow::Tensor &features, unsigned batch_idx, int eta_index, int phi_index)
 

Static Private Member Functions

static void calculateElectronClusterVars (const pat::Electron *ele, float &elecEe, float &elecEgamma)
 
static bool calculateElectronClusterVarsV2 (const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)
 
template<typename TauCastType >
static bool calculateGottfriedJacksonAngleDifference (const TauCastType &tau, const size_t tau_index, double &gj_diff, TauFunc tau_funcs)
 
template<typename TauCastType >
static float calculateGottfriedJacksonAngleDifference (const TauCastType &tau, const size_t tau_index, TauFunc tau_funcs)
 
template<typename TauCastType >
static const pat::ElectronfindMatchedElectron (const TauCastType &tau, const std::vector< pat::Electron > *electrons, double deltaR)
 
static double getInnerSignalConeRadius (double pt)
 
template<typename T >
static float getValue (T value)
 
template<typename T >
static float getValueLinear (T value, float min_value, float max_value, bool positive)
 
template<typename T >
static float getValueNorm (T value, float mean, float sigma, float n_sigmas_max=5)
 
static bool isAbove (double value, double min)
 
static bool isInEcalCrack (double eta)
 
template<typename CandidateCollection , typename TauCastType >
static void processIsolationPFComponents (const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
 
template<typename CandidateCollection , typename TauCastType >
static void processSignalPFComponents (const TauCastType &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

std::map< BasicDiscriminator, size_t > basicDiscrdR03IndexMap_
 
std::map< BasicDiscriminator, size_t > basicDiscrIndexMap_
 
edm::EDGetTokenT< reco::TauDiscriminatorContainerbasicTauDiscriminators_inputToken_
 
edm::EDGetTokenT< reco::TauDiscriminatorContainerbasicTauDiscriminatorsdR03_inputToken_
 
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > convTensor_
 
const int debug_level
 
const bool disable_CellIndex_workaround_
 
const bool disable_dxy_pca_
 
const bool disable_hcalFraction_workaround_
 
bool discrIndicesMapped_ = false
 
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > eGammaTensor_
 
edm::EDGetTokenT< std::vector< pat::Electron > > electrons_token_
 
int file_counter_
 
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > hadronsTensor_
 
std::string input_layer_
 
bool is_first_block_
 
std::ofstream * json_file_
 
edm::EDGetTokenT< std::vector< pat::Muon > > muons_token_
 
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > muonTensor_
 
std::string output_layer_
 
edm::EDGetTokenT< edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > > pfTauTransverseImpactParameters_token_
 
edm::EDGetTokenT< double > rho_token_
 
const bool save_inputs_
 
std::unique_ptr< tensorflow::Tensor > tauBlockTensor_
 
const unsigned version_
 
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > zeroOutputTensor_
 

Static Private Attributes

static constexpr float pi = M_PI
 

Additional Inherited Members

- Public Types inherited from deep_tau::DeepTauBase
enum  BasicDiscriminator {
  ChargedIsoPtSum, NeutralIsoPtSum, NeutralIsoPtSumWeight, FootprintCorrection,
  PhotonPtSumOutsideSignalCone, PUcorrPtSum
}
 
using CandidateCollection = edm::View< reco::Candidate >
 
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 = edm::View< reco::BaseTau >
 
using TauDiscriminator = reco::TauDiscriminatorContainer
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using WPList = std::vector< 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
 
- Public Attributes inherited from deep_tau::DeepTauBase
uint8_t andPrediscriminants_
 
std::vector< TauDiscInfo< pat::PATTauDiscriminator > > patPrediscriminants_
 
std::vector< TauDiscInfo< reco::PFTauDiscriminator > > recoPrediscriminants_
 
- Protected Attributes inherited from deep_tau::DeepTauBase
const DeepTauCachecache_
 
const bool is_online_
 
OutputCollection outputs_
 
edm::EDGetTokenT< CandidateCollectionpfcandToken_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
edm::EDGetTokenT< reco::VertexCollectionvtxToken_
 
std::map< std::string, WPListworkingPoints_
 
- Static Protected Attributes inherited from deep_tau::DeepTauBase
static const std::vector< BasicDiscriminatorrequiredBasicDiscriminators_
 
static const std::vector< BasicDiscriminatorrequiredBasicDiscriminatorsdR03_
 
static const std::map< BasicDiscriminator, std::string > stringFromDiscriminator_
 

Detailed Description

Definition at line 1101 of file DeepTauId.cc.

Constructor & Destructor Documentation

◆ DeepTauId()

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

Definition at line 1190 of file DeepTauId.cc.

1192  electrons_token_(consumes<std::vector<pat::Electron>>(cfg.getParameter<edm::InputTag>("electrons"))),
1193  muons_token_(consumes<std::vector<pat::Muon>>(cfg.getParameter<edm::InputTag>("muons"))),
1194  rho_token_(consumes<double>(cfg.getParameter<edm::InputTag>("rho"))),
1195  basicTauDiscriminators_inputToken_(consumes<reco::TauDiscriminatorContainer>(
1196  cfg.getUntrackedParameter<edm::InputTag>("basicTauDiscriminators"))),
1197  basicTauDiscriminatorsdR03_inputToken_(consumes<reco::TauDiscriminatorContainer>(
1198  cfg.getUntrackedParameter<edm::InputTag>("basicTauDiscriminatorsdR03"))),
1200  consumes<edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef>>>(
1201  cfg.getParameter<edm::InputTag>("pfTauTransverseImpactParameters"))),
1202  version_(cfg.getParameter<unsigned>("version")),
1203  debug_level(cfg.getParameter<int>("debug_level")),
1204  disable_dxy_pca_(cfg.getParameter<bool>("disable_dxy_pca")),
1205  disable_hcalFraction_workaround_(cfg.getParameter<bool>("disable_hcalFraction_workaround")),
1206  disable_CellIndex_workaround_(cfg.getParameter<bool>("disable_CellIndex_workaround")),
1207  save_inputs_(cfg.getParameter<bool>("save_inputs")),
1208  json_file_(nullptr),
1209  file_counter_(0) {
1210  if (version_ == 1) {
1211  input_layer_ = cache_->getGraph().node(0).name();
1212  output_layer_ = cache_->getGraph().node(cache_->getGraph().node_size() - 1).name();
1213  const auto& shape = cache_->getGraph().node(0).attr().at("shape").shape();
1214  if (shape.dim(1).size() != dnn_inputs_2017v1::NumberOfInputs)
1215  throw cms::Exception("DeepTauId")
1216  << "number of inputs does not match the expected inputs for the given version";
1217  } else if (version_ == 2) {
1218  tauBlockTensor_ = std::make_unique<tensorflow::Tensor>(
1219  tensorflow::DT_FLOAT, tensorflow::TensorShape{1, dnn_inputs_2017_v2::TauBlockInputs::NumberOfInputs});
1220  for (size_t n = 0; n < 2; ++n) {
1221  const bool is_inner = n == 0;
1222  const auto n_cells =
1223  is_inner ? dnn_inputs_2017_v2::number_of_inner_cell : dnn_inputs_2017_v2::number_of_outer_cell;
1224  eGammaTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1225  tensorflow::DT_FLOAT,
1226  tensorflow::TensorShape{1, 1, 1, dnn_inputs_2017_v2::EgammaBlockInputs::NumberOfInputs});
1227  muonTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1228  tensorflow::DT_FLOAT,
1229  tensorflow::TensorShape{1, 1, 1, dnn_inputs_2017_v2::MuonBlockInputs::NumberOfInputs});
1230  hadronsTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1231  tensorflow::DT_FLOAT,
1232  tensorflow::TensorShape{1, 1, 1, dnn_inputs_2017_v2::HadronBlockInputs::NumberOfInputs});
1233  convTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1234  tensorflow::DT_FLOAT,
1235  tensorflow::TensorShape{1, n_cells, n_cells, dnn_inputs_2017_v2::number_of_conv_features});
1236  zeroOutputTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1237  tensorflow::DT_FLOAT, tensorflow::TensorShape{1, 1, 1, dnn_inputs_2017_v2::number_of_conv_features});
1238 
1239  eGammaTensor_[is_inner]->flat<float>().setZero();
1240  muonTensor_[is_inner]->flat<float>().setZero();
1241  hadronsTensor_[is_inner]->flat<float>().setZero();
1242 
1243  setCellConvFeatures(*zeroOutputTensor_[is_inner], getPartialPredictions(is_inner), 0, 0, 0);
1244  }
1245  } else {
1246  throw cms::Exception("DeepTauId") << "version " << version_ << " is not supported.";
1247  }
1248  }

References deep_tau::DeepTauBase::cache_, convTensor_, eGammaTensor_, Exception, deep_tau::DeepTauCache::getGraph(), getPartialPredictions(), hadronsTensor_, input_layer_, muonTensor_, dqmiodumpmetadata::n, Skims_PA_cff::name, output_layer_, setCellConvFeatures(), tauBlockTensor_, version_, and zeroOutputTensor_.

Member Function Documentation

◆ calculateElectronClusterVars()

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

Definition at line 2651 of file DeepTauId.cc.

2651  {
2652  if (ele) {
2653  elecEe = elecEgamma = 0;
2654  auto superCluster = ele->superCluster();
2655  if (superCluster.isNonnull() && superCluster.isAvailable() && superCluster->clusters().isNonnull() &&
2656  superCluster->clusters().isAvailable()) {
2657  for (auto iter = superCluster->clustersBegin(); iter != superCluster->clustersEnd(); ++iter) {
2658  const double energy = (*iter)->energy();
2659  if (iter == superCluster->clustersBegin())
2660  elecEe += energy;
2661  else
2662  elecEgamma += energy;
2663  }
2664  }
2665  } else {
2666  elecEe = elecEgamma = default_value;
2667  }
2668  }

References default_value, HCALHighEnergyHPDFilter_cfi::energy, and pat::Electron::superCluster().

Referenced by createInputsV1().

◆ calculateElectronClusterVarsV2()

static bool DeepTauId::calculateElectronClusterVarsV2 ( const pat::Electron ele,
float &  cc_ele_energy,
float &  cc_gamma_energy,
int &  cc_n_gamma 
)
inlinestaticprivate

Definition at line 1283 of file DeepTauId.cc.

1286  {
1287  cc_ele_energy = cc_gamma_energy = 0;
1288  cc_n_gamma = 0;
1289  const auto& superCluster = ele.superCluster();
1290  if (superCluster.isNonnull() && superCluster.isAvailable() && superCluster->clusters().isNonnull() &&
1291  superCluster->clusters().isAvailable()) {
1292  for (auto iter = superCluster->clustersBegin(); iter != superCluster->clustersEnd(); ++iter) {
1293  const float energy = static_cast<float>((*iter)->energy());
1294  if (iter == superCluster->clustersBegin())
1295  cc_ele_energy += energy;
1296  else {
1297  cc_gamma_energy += energy;
1298  ++cc_n_gamma;
1299  }
1300  }
1301  return true;
1302  } else
1303  return false;
1304  }

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

Referenced by createEgammaBlockInputs().

◆ calculateGottfriedJacksonAngleDifference() [1/2]

template<typename TauCastType >
static bool DeepTauId::calculateGottfriedJacksonAngleDifference ( const TauCastType &  tau,
const size_t  tau_index,
double &  gj_diff,
TauFunc  tau_funcs 
)
inlinestaticprivate

Definition at line 2745 of file DeepTauId.cc.

2748  {
2749  if (tau_funcs.getHasSecondaryVertex(tau, tau_index)) {
2750  static constexpr double mTau = 1.77682;
2751  const double mAOne = tau.p4().M();
2752  const double pAOneMag = tau.p();
2753  const double argumentThetaGJmax = (std::pow(mTau, 2) - std::pow(mAOne, 2)) / (2 * mTau * pAOneMag);
2754  const double argumentThetaGJmeasured = tau.p4().Vect().Dot(tau_funcs.getFlightLength(tau, tau_index)) /
2755  (pAOneMag * tau_funcs.getFlightLength(tau, tau_index).R());
2756  if (std::abs(argumentThetaGJmax) <= 1. && std::abs(argumentThetaGJmeasured) <= 1.) {
2757  double thetaGJmax = std::asin(argumentThetaGJmax);
2758  double thetaGJmeasured = std::acos(argumentThetaGJmeasured);
2759  gj_diff = thetaGJmeasured - thetaGJmax;
2760  return true;
2761  }
2762  }
2763  return false;
2764  }

References funct::abs(), funct::pow(), and metsig::tau.

Referenced by calculateGottfriedJacksonAngleDifference(), createInputsV1(), and createTauBlockInputs().

◆ calculateGottfriedJacksonAngleDifference() [2/2]

template<typename TauCastType >
static float DeepTauId::calculateGottfriedJacksonAngleDifference ( const TauCastType &  tau,
const size_t  tau_index,
TauFunc  tau_funcs 
)
inlinestaticprivate

Definition at line 2767 of file DeepTauId.cc.

2769  {
2770  double gj_diff;
2771  if (calculateGottfriedJacksonAngleDifference(tau, tau_index, gj_diff, tau_funcs))
2772  return static_cast<float>(gj_diff);
2773  return default_value;
2774  }

References calculateGottfriedJacksonAngleDifference(), default_value, and metsig::tau.

◆ checkInputs()

void DeepTauId::checkInputs ( const tensorflow::Tensor &  inputs,
const std::string &  block_name,
int  n_inputs,
const CellGrid *  grid = nullptr 
) const
inlineprivate

Definition at line 1306 of file DeepTauId.cc.

1309  {
1310  if (debug_level >= 1) {
1311  std::cout << "<checkInputs>: block_name = " << block_name << std::endl;
1312  if (block_name == "input_tau") {
1313  for (int input_index = 0; input_index < n_inputs; ++input_index) {
1314  float input = inputs.matrix<float>()(0, input_index);
1315  if (edm::isNotFinite(input)) {
1316  throw cms::Exception("DeepTauId")
1317  << "in the " << block_name
1318  << ", input is not finite, i.e. infinite or NaN, for input_index = " << input_index;
1319  }
1320  if (debug_level >= 2) {
1321  std::cout << block_name << "[var = " << input_index << "] = " << std::setprecision(5) << std::fixed << input
1322  << std::endl;
1323  }
1324  }
1325  } else {
1326  assert(grid);
1327  int n_eta, n_phi;
1328  if (block_name.find("input_inner") != std::string::npos) {
1329  n_eta = 5;
1330  n_phi = 5;
1331  } else if (block_name.find("input_outer") != std::string::npos) {
1332  n_eta = 10;
1333  n_phi = 10;
1334  } else
1335  assert(0);
1336  int eta_phi_index = 0;
1337  for (int eta = -n_eta; eta <= n_eta; ++eta) {
1338  for (int phi = -n_phi; phi <= n_phi; ++phi) {
1339  const CellIndex cell_index{eta, phi};
1340  const auto cell_iter = grid->find(cell_index);
1341  if (cell_iter != grid->end()) {
1342  for (int input_index = 0; input_index < n_inputs; ++input_index) {
1343  float input = inputs.tensor<float, 4>()(eta_phi_index, 0, 0, input_index);
1344  if (edm::isNotFinite(input)) {
1345  throw cms::Exception("DeepTauId")
1346  << "in the " << block_name << ", input is not finite, i.e. infinite or NaN, for eta = " << eta
1347  << ", phi = " << phi << ", input_index = " << input_index;
1348  }
1349  if (debug_level >= 2) {
1350  std::cout << block_name << "[eta = " << eta << "][phi = " << phi << "][var = " << input_index
1351  << "] = " << std::setprecision(5) << std::fixed << input << std::endl;
1352  }
1353  }
1354  eta_phi_index += 1;
1355  }
1356  }
1357  }
1358  }
1359  }
1360  }

References cms::cuda::assert(), gather_cfg::cout, debug_level, PVValHelper::eta, Exception, alignBH_cfg::fixed, dqmMemoryStats::float, getRunAppsInfo::grid, input, PixelMapPlotter::inputs, edm::isNotFinite(), and phi.

Referenced by getPredictionsV2().

◆ createConvFeatures()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::createConvFeatures ( const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
const edm::View< reco::Candidate > &  pfCands,
const CellGrid &  grid,
TauFunc  tau_funcs,
bool  is_inner 
)
inlineprivate

Definition at line 1737 of file DeepTauId.cc.

1747  {
1748  if (debug_level >= 2) {
1749  std::cout << "<DeepTauId::createConvFeatures (is_inner = " << is_inner << ")>:" << std::endl;
1750  }
1751  tensorflow::Tensor& convTensor = *convTensor_.at(is_inner);
1752  eGammaTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1753  tensorflow::DT_FLOAT,
1754  tensorflow::TensorShape{
1755  (long long int)grid.num_valid_cells(), 1, 1, dnn_inputs_2017_v2::EgammaBlockInputs::NumberOfInputs});
1756  muonTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1757  tensorflow::DT_FLOAT,
1758  tensorflow::TensorShape{
1759  (long long int)grid.num_valid_cells(), 1, 1, dnn_inputs_2017_v2::MuonBlockInputs::NumberOfInputs});
1760  hadronsTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1761  tensorflow::DT_FLOAT,
1762  tensorflow::TensorShape{
1763  (long long int)grid.num_valid_cells(), 1, 1, dnn_inputs_2017_v2::HadronBlockInputs::NumberOfInputs});
1764 
1765  eGammaTensor_[is_inner]->flat<float>().setZero();
1766  muonTensor_[is_inner]->flat<float>().setZero();
1767  hadronsTensor_[is_inner]->flat<float>().setZero();
1768 
1769  unsigned idx = 0;
1770  for (int eta = -grid.maxEtaIndex(); eta <= grid.maxEtaIndex(); ++eta) {
1771  for (int phi = -grid.maxPhiIndex(); phi <= grid.maxPhiIndex(); ++phi) {
1772  if (debug_level >= 2) {
1773  std::cout << "processing ( eta = " << eta << ", phi = " << phi << " )" << std::endl;
1774  }
1775  const CellIndex cell_index{eta, phi};
1776  const auto cell_iter = grid.find(cell_index);
1777  if (cell_iter != grid.end()) {
1778  if (debug_level >= 2) {
1779  std::cout << " creating inputs for ( eta = " << eta << ", phi = " << phi << " ): idx = " << idx
1780  << std::endl;
1781  }
1782  const Cell& cell = cell_iter->second;
1783  createEgammaBlockInputs<CandidateCastType>(
1784  idx, tau, tau_index, tau_ref, pv, rho, electrons, pfCands, cell, tau_funcs, is_inner);
1785  createMuonBlockInputs<CandidateCastType>(
1786  idx, tau, tau_index, tau_ref, pv, rho, muons, pfCands, cell, tau_funcs, is_inner);
1787  createHadronsBlockInputs<CandidateCastType>(
1788  idx, tau, tau_index, tau_ref, pv, rho, pfCands, cell, tau_funcs, is_inner);
1789  idx += 1;
1790  } else {
1791  if (debug_level >= 2) {
1792  std::cout << " skipping creation of inputs, because ( eta = " << eta << ", phi = " << phi
1793  << " ) is not in the grid !!" << std::endl;
1794  }
1795  }
1796  }
1797  }
1798 
1799  const auto predTensor = getPartialPredictions(is_inner);
1800  idx = 0;
1801  for (int eta = -grid.maxEtaIndex(); eta <= grid.maxEtaIndex(); ++eta) {
1802  for (int phi = -grid.maxPhiIndex(); phi <= grid.maxPhiIndex(); ++phi) {
1803  const CellIndex cell_index{eta, phi};
1804  const int eta_index = grid.getEtaTensorIndex(cell_index);
1805  const int phi_index = grid.getPhiTensorIndex(cell_index);
1806 
1807  const auto cell_iter = grid.find(cell_index);
1808  if (cell_iter != grid.end()) {
1809  setCellConvFeatures(convTensor, predTensor, idx, eta_index, phi_index);
1810  idx += 1;
1811  } else {
1812  setCellConvFeatures(convTensor, *zeroOutputTensor_[is_inner], 0, eta_index, phi_index);
1813  }
1814  }
1815  }
1816  }

References convTensor_, gather_cfg::cout, debug_level, eGammaTensor_, pwdgSkimBPark_cfi::electrons, PVValHelper::eta, getPartialPredictions(), getRunAppsInfo::grid, hadronsTensor_, heavyIonCSV_trainingSettings::idx, createfilelist::int, PDWG_BPHSkim_cff::muons, muonTensor_, phi, MetAnalyzer::pv(), rho, setCellConvFeatures(), metsig::tau, and zeroOutputTensor_.

◆ createEgammaBlockInputs()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::createEgammaBlockInputs ( unsigned  idx,
const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
const std::vector< pat::Electron > *  electrons,
const edm::View< reco::Candidate > &  pfCands,
const Cell cell_map,
TauFunc  tau_funcs,
bool  is_inner 
)
inlineprivate

Definition at line 1935 of file DeepTauId.cc.

1945  {
1946  namespace dnn = dnn_inputs_2017_v2::EgammaBlockInputs;
1947 
1948  tensorflow::Tensor& inputs = *eGammaTensor_.at(is_inner);
1949 
1950  const auto& get = [&](int var_index) -> float& { return inputs.tensor<float, 4>()(idx, 0, 0, var_index); };
1951 
1952  const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
1953  const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
1954  const bool valid_index_ele = cell_map.count(CellObjectType::Electron);
1955 
1956  if (!cell_map.empty()) {
1957  get(dnn::rho) = getValueNorm(rho, 21.49f, 9.713f);
1958  get(dnn::tau_pt) = getValueLinear(tau.polarP4().pt(), 20.f, 1000.f, true);
1959  get(dnn::tau_eta) = getValueLinear(tau.polarP4().eta(), -2.3f, 2.3f, false);
1960  get(dnn::tau_inside_ecal_crack) = getValue(isInEcalCrack(tau.polarP4().eta()));
1961  }
1962  if (valid_index_pf_ele) {
1963  size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
1964  const auto& ele_cand = dynamic_cast<const CandidateCastType&>(pfCands.at(index_pf_ele));
1965 
1966  get(dnn::pfCand_ele_valid) = valid_index_pf_ele;
1967  get(dnn::pfCand_ele_rel_pt) = getValueNorm(pfCands.at(index_pf_ele).polarP4().pt() / tau.polarP4().pt(),
1968  is_inner ? 0.9792f : 0.304f,
1969  is_inner ? 0.5383f : 1.845f);
1970  get(dnn::pfCand_ele_deta) = getValueLinear(pfCands.at(index_pf_ele).polarP4().eta() - tau.polarP4().eta(),
1971  is_inner ? -0.1f : -0.5f,
1972  is_inner ? 0.1f : 0.5f,
1973  false);
1974  get(dnn::pfCand_ele_dphi) = getValueLinear(dPhi(tau.polarP4(), pfCands.at(index_pf_ele).polarP4()),
1975  is_inner ? -0.1f : -0.5f,
1976  is_inner ? 0.1f : 0.5f,
1977  false);
1978  get(dnn::pfCand_ele_pvAssociationQuality) =
1979  getValueLinear<int>(candFunc::getPvAssocationQuality(ele_cand), 0, 7, true);
1980  get(dnn::pfCand_ele_puppiWeight) = is_inner ? getValue(candFunc::getPuppiWeight(ele_cand, 0.9906834f))
1981  : getValue(candFunc::getPuppiWeight(ele_cand, 0.9669586f));
1982  get(dnn::pfCand_ele_charge) = getValue(ele_cand.charge());
1983  get(dnn::pfCand_ele_lostInnerHits) = getValue<int>(candFunc::getLostInnerHits(ele_cand, 0));
1984  get(dnn::pfCand_ele_numberOfPixelHits) = getValueLinear(candFunc::getNumberOfPixelHits(ele_cand, 0), 0, 10, true);
1985  get(dnn::pfCand_ele_vertex_dx) =
1986  getValueNorm(pfCands.at(index_pf_ele).vertex().x() - pv.position().x(), 0.f, 0.1221f);
1987  get(dnn::pfCand_ele_vertex_dy) =
1988  getValueNorm(pfCands.at(index_pf_ele).vertex().y() - pv.position().y(), 0.f, 0.1226f);
1989  get(dnn::pfCand_ele_vertex_dz) =
1990  getValueNorm(pfCands.at(index_pf_ele).vertex().z() - pv.position().z(), 0.001f, 1.024f);
1991  get(dnn::pfCand_ele_vertex_dx_tauFL) = getValueNorm(
1992  pfCands.at(index_pf_ele).vertex().x() - pv.position().x() - tau_funcs.getFlightLength(tau, tau_index).x(),
1993  0.f,
1994  0.3411f);
1995  get(dnn::pfCand_ele_vertex_dy_tauFL) = getValueNorm(
1996  pfCands.at(index_pf_ele).vertex().y() - pv.position().y() - tau_funcs.getFlightLength(tau, tau_index).y(),
1997  0.0003f,
1998  0.3385f);
1999  get(dnn::pfCand_ele_vertex_dz_tauFL) = getValueNorm(
2000  pfCands.at(index_pf_ele).vertex().z() - pv.position().z() - tau_funcs.getFlightLength(tau, tau_index).z(),
2001  0.f,
2002  1.307f);
2003 
2004  const bool hasTrackDetails = candFunc::getHasTrackDetails(ele_cand);
2005  if (hasTrackDetails) {
2006  get(dnn::pfCand_ele_hasTrackDetails) = hasTrackDetails;
2007  get(dnn::pfCand_ele_dxy) = getValueNorm(candFunc::getTauDxy(ele_cand), 0.f, 0.171f);
2008  get(dnn::pfCand_ele_dxy_sig) =
2009  getValueNorm(std::abs(candFunc::getTauDxy(ele_cand)) / pfCands.at(index_pf_ele).dxyError(), 1.634f, 6.45f);
2010  get(dnn::pfCand_ele_dz) = getValueNorm(candFunc::getTauDz(ele_cand), 0.001f, 1.02f);
2011  get(dnn::pfCand_ele_dz_sig) =
2012  getValueNorm(std::abs(candFunc::getTauDz(ele_cand)) / ele_cand.dzError(), 24.56f, 210.4f);
2013  get(dnn::pfCand_ele_track_chi2_ndof) = getValueNorm(
2014  candFunc::getPseudoTrack(ele_cand).chi2() / candFunc::getPseudoTrack(ele_cand).ndof(), 2.272f, 8.439f);
2015  get(dnn::pfCand_ele_track_ndof) = getValueNorm(candFunc::getPseudoTrack(ele_cand).ndof(), 15.18f, 3.203f);
2016  }
2017  }
2018  if (valid_index_pf_gamma) {
2019  size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
2020  const auto& gamma_cand = dynamic_cast<const CandidateCastType&>(pfCands.at(index_pf_gamma));
2021 
2022  get(dnn::pfCand_gamma_valid) = valid_index_pf_gamma;
2023  get(dnn::pfCand_gamma_rel_pt) = getValueNorm(pfCands.at(index_pf_gamma).polarP4().pt() / tau.polarP4().pt(),
2024  is_inner ? 0.6048f : 0.02576f,
2025  is_inner ? 1.669f : 0.3833f);
2026  get(dnn::pfCand_gamma_deta) = getValueLinear(pfCands.at(index_pf_gamma).polarP4().eta() - tau.polarP4().eta(),
2027  is_inner ? -0.1f : -0.5f,
2028  is_inner ? 0.1f : 0.5f,
2029  false);
2030  get(dnn::pfCand_gamma_dphi) = getValueLinear(dPhi(tau.polarP4(), pfCands.at(index_pf_gamma).polarP4()),
2031  is_inner ? -0.1f : -0.5f,
2032  is_inner ? 0.1f : 0.5f,
2033  false);
2034  get(dnn::pfCand_gamma_pvAssociationQuality) =
2035  getValueLinear<int>(candFunc::getPvAssocationQuality(gamma_cand), 0, 7, true);
2036  get(dnn::pfCand_gamma_fromPV) = getValueLinear<int>(candFunc::getFromPV(gamma_cand), 0, 3, true);
2037  get(dnn::pfCand_gamma_puppiWeight) = is_inner ? getValue(candFunc::getPuppiWeight(gamma_cand, 0.9084110f))
2038  : getValue(candFunc::getPuppiWeight(gamma_cand, 0.4211567f));
2039  get(dnn::pfCand_gamma_puppiWeightNoLep) = is_inner
2040  ? getValue(candFunc::getPuppiWeightNoLep(gamma_cand, 0.8857716f))
2041  : getValue(candFunc::getPuppiWeightNoLep(gamma_cand, 0.3822604f));
2042  get(dnn::pfCand_gamma_lostInnerHits) = getValue<int>(candFunc::getLostInnerHits(gamma_cand, 0));
2043  get(dnn::pfCand_gamma_numberOfPixelHits) =
2044  getValueLinear(candFunc::getNumberOfPixelHits(gamma_cand, 0), 0, 7, true);
2045  get(dnn::pfCand_gamma_vertex_dx) =
2046  getValueNorm(pfCands.at(index_pf_gamma).vertex().x() - pv.position().x(), 0.f, 0.0067f);
2047  get(dnn::pfCand_gamma_vertex_dy) =
2048  getValueNorm(pfCands.at(index_pf_gamma).vertex().y() - pv.position().y(), 0.f, 0.0069f);
2049  get(dnn::pfCand_gamma_vertex_dz) =
2050  getValueNorm(pfCands.at(index_pf_gamma).vertex().z() - pv.position().z(), 0.f, 0.0578f);
2051  get(dnn::pfCand_gamma_vertex_dx_tauFL) = getValueNorm(
2052  pfCands.at(index_pf_gamma).vertex().x() - pv.position().x() - tau_funcs.getFlightLength(tau, tau_index).x(),
2053  0.001f,
2054  0.9565f);
2055  get(dnn::pfCand_gamma_vertex_dy_tauFL) = getValueNorm(
2056  pfCands.at(index_pf_gamma).vertex().y() - pv.position().y() - tau_funcs.getFlightLength(tau, tau_index).y(),
2057  0.0008f,
2058  0.9592f);
2059  get(dnn::pfCand_gamma_vertex_dz_tauFL) = getValueNorm(
2060  pfCands.at(index_pf_gamma).vertex().z() - pv.position().z() - tau_funcs.getFlightLength(tau, tau_index).z(),
2061  0.0038f,
2062  2.154f);
2063  const bool hasTrackDetails = candFunc::getHasTrackDetails(gamma_cand);
2064  if (hasTrackDetails) {
2065  get(dnn::pfCand_gamma_hasTrackDetails) = hasTrackDetails;
2066  get(dnn::pfCand_gamma_dxy) = getValueNorm(candFunc::getTauDxy(gamma_cand), 0.0004f, 0.882f);
2067  get(dnn::pfCand_gamma_dxy_sig) =
2068  getValueNorm(std::abs(candFunc::getTauDxy(gamma_cand)) / gamma_cand.dxyError(), 4.271f, 63.78f);
2069  get(dnn::pfCand_gamma_dz) = getValueNorm(candFunc::getTauDz(gamma_cand), 0.0071f, 5.285f);
2070  get(dnn::pfCand_gamma_dz_sig) =
2071  getValueNorm(std::abs(candFunc::getTauDz(gamma_cand)) / gamma_cand.dzError(), 162.1f, 622.4f);
2072  get(dnn::pfCand_gamma_track_chi2_ndof) = candFunc::getPseudoTrack(gamma_cand).ndof() > 0
2073  ? getValueNorm(candFunc::getPseudoTrack(gamma_cand).chi2() /
2074  candFunc::getPseudoTrack(gamma_cand).ndof(),
2075  4.268f,
2076  15.47f)
2077  : 0;
2078  get(dnn::pfCand_gamma_track_ndof) =
2079  candFunc::getPseudoTrack(gamma_cand).ndof() > 0
2080  ? getValueNorm(candFunc::getPseudoTrack(gamma_cand).ndof(), 12.25f, 4.774f)
2081  : 0;
2082  }
2083  }
2084  if (valid_index_ele) {
2085  size_t index_ele = cell_map.at(CellObjectType::Electron);
2086 
2087  get(dnn::ele_valid) = valid_index_ele;
2088  get(dnn::ele_rel_pt) = getValueNorm(electrons->at(index_ele).polarP4().pt() / tau.polarP4().pt(),
2089  is_inner ? 1.067f : 0.5111f,
2090  is_inner ? 1.521f : 2.765f);
2091  get(dnn::ele_deta) = getValueLinear(electrons->at(index_ele).polarP4().eta() - tau.polarP4().eta(),
2092  is_inner ? -0.1f : -0.5f,
2093  is_inner ? 0.1f : 0.5f,
2094  false);
2095  get(dnn::ele_dphi) = getValueLinear(dPhi(tau.polarP4(), electrons->at(index_ele).polarP4()),
2096  is_inner ? -0.1f : -0.5f,
2097  is_inner ? 0.1f : 0.5f,
2098  false);
2099 
2100  float cc_ele_energy, cc_gamma_energy;
2101  int cc_n_gamma;
2102  const bool cc_valid =
2103  calculateElectronClusterVarsV2(electrons->at(index_ele), cc_ele_energy, cc_gamma_energy, cc_n_gamma);
2104  if (cc_valid) {
2105  get(dnn::ele_cc_valid) = cc_valid;
2106  get(dnn::ele_cc_ele_rel_energy) =
2107  getValueNorm(cc_ele_energy / electrons->at(index_ele).polarP4().pt(), 1.729f, 1.644f);
2108  get(dnn::ele_cc_gamma_rel_energy) = getValueNorm(cc_gamma_energy / cc_ele_energy, 0.1439f, 0.3284f);
2109  get(dnn::ele_cc_n_gamma) = getValueNorm(cc_n_gamma, 1.794f, 2.079f);
2110  }
2111  get(dnn::ele_rel_trackMomentumAtVtx) = getValueNorm(
2112  electrons->at(index_ele).trackMomentumAtVtx().R() / electrons->at(index_ele).polarP4().pt(), 1.531f, 1.424f);
2113  get(dnn::ele_rel_trackMomentumAtCalo) = getValueNorm(
2114  electrons->at(index_ele).trackMomentumAtCalo().R() / electrons->at(index_ele).polarP4().pt(), 1.531f, 1.424f);
2115  get(dnn::ele_rel_trackMomentumOut) = getValueNorm(
2116  electrons->at(index_ele).trackMomentumOut().R() / electrons->at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
2117  get(dnn::ele_rel_trackMomentumAtEleClus) =
2118  getValueNorm(electrons->at(index_ele).trackMomentumAtEleClus().R() / electrons->at(index_ele).polarP4().pt(),
2119  0.7735f,
2120  0.935f);
2121  get(dnn::ele_rel_trackMomentumAtVtxWithConstraint) = getValueNorm(
2122  electrons->at(index_ele).trackMomentumAtVtxWithConstraint().R() / electrons->at(index_ele).polarP4().pt(),
2123  1.625f,
2124  1.581f);
2125  get(dnn::ele_rel_ecalEnergy) =
2126  getValueNorm(electrons->at(index_ele).ecalEnergy() / electrons->at(index_ele).polarP4().pt(), 1.993f, 1.308f);
2127  get(dnn::ele_ecalEnergy_sig) = getValueNorm(
2128  electrons->at(index_ele).ecalEnergy() / electrons->at(index_ele).ecalEnergyError(), 70.25f, 58.16f);
2129  get(dnn::ele_eSuperClusterOverP) = getValueNorm(electrons->at(index_ele).eSuperClusterOverP(), 2.432f, 15.13f);
2130  get(dnn::ele_eSeedClusterOverP) = getValueNorm(electrons->at(index_ele).eSeedClusterOverP(), 2.034f, 13.96f);
2131  get(dnn::ele_eSeedClusterOverPout) = getValueNorm(electrons->at(index_ele).eSeedClusterOverPout(), 6.64f, 36.8f);
2132  get(dnn::ele_eEleClusterOverPout) = getValueNorm(electrons->at(index_ele).eEleClusterOverPout(), 4.183f, 20.63f);
2133  get(dnn::ele_deltaEtaSuperClusterTrackAtVtx) =
2134  getValueNorm(electrons->at(index_ele).deltaEtaSuperClusterTrackAtVtx(), 0.f, 0.0363f);
2135  get(dnn::ele_deltaEtaSeedClusterTrackAtCalo) =
2136  getValueNorm(electrons->at(index_ele).deltaEtaSeedClusterTrackAtCalo(), -0.0001f, 0.0512f);
2137  get(dnn::ele_deltaEtaEleClusterTrackAtCalo) =
2138  getValueNorm(electrons->at(index_ele).deltaEtaEleClusterTrackAtCalo(), -0.0001f, 0.0541f);
2139  get(dnn::ele_deltaPhiEleClusterTrackAtCalo) =
2140  getValueNorm(electrons->at(index_ele).deltaPhiEleClusterTrackAtCalo(), 0.0002f, 0.0553f);
2141  get(dnn::ele_deltaPhiSuperClusterTrackAtVtx) =
2142  getValueNorm(electrons->at(index_ele).deltaPhiSuperClusterTrackAtVtx(), 0.0001f, 0.0523f);
2143  get(dnn::ele_deltaPhiSeedClusterTrackAtCalo) =
2144  getValueNorm(electrons->at(index_ele).deltaPhiSeedClusterTrackAtCalo(), 0.0004f, 0.0777f);
2145  get(dnn::ele_mvaInput_earlyBrem) = getValue(electrons->at(index_ele).mvaInput().earlyBrem);
2146  get(dnn::ele_mvaInput_lateBrem) = getValue(electrons->at(index_ele).mvaInput().lateBrem);
2147  get(dnn::ele_mvaInput_sigmaEtaEta) =
2148  getValueNorm(electrons->at(index_ele).mvaInput().sigmaEtaEta, 0.0008f, 0.0052f);
2149  get(dnn::ele_mvaInput_hadEnergy) = getValueNorm(electrons->at(index_ele).mvaInput().hadEnergy, 14.04f, 69.48f);
2150  get(dnn::ele_mvaInput_deltaEta) = getValueNorm(electrons->at(index_ele).mvaInput().deltaEta, 0.0099f, 0.0851f);
2151  const auto& gsfTrack = electrons->at(index_ele).gsfTrack();
2152  if (gsfTrack.isNonnull()) {
2153  get(dnn::ele_gsfTrack_normalizedChi2) = getValueNorm(gsfTrack->normalizedChi2(), 3.049f, 10.39f);
2154  get(dnn::ele_gsfTrack_numberOfValidHits) = getValueNorm(gsfTrack->numberOfValidHits(), 16.52f, 2.806f);
2155  get(dnn::ele_rel_gsfTrack_pt) =
2156  getValueNorm(gsfTrack->pt() / electrons->at(index_ele).polarP4().pt(), 1.355f, 16.81f);
2157  get(dnn::ele_gsfTrack_pt_sig) = getValueNorm(gsfTrack->pt() / gsfTrack->ptError(), 5.046f, 3.119f);
2158  }
2159  const auto& closestCtfTrack = electrons->at(index_ele).closestCtfTrackRef();
2160  const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
2161  if (has_closestCtfTrack) {
2162  get(dnn::ele_has_closestCtfTrack) = has_closestCtfTrack;
2163  get(dnn::ele_closestCtfTrack_normalizedChi2) = getValueNorm(closestCtfTrack->normalizedChi2(), 2.411f, 6.98f);
2164  get(dnn::ele_closestCtfTrack_numberOfValidHits) =
2165  getValueNorm(closestCtfTrack->numberOfValidHits(), 15.16f, 5.26f);
2166  }
2167  }
2168  }

References funct::abs(), edm::View< T >::at(), calculateElectronClusterVarsV2(), hltPixelTracks_cff::chi2, HLT_FULL_cff::dPhi, eGammaTensor_, nanoDQM_cff::Electron, pwdgSkimBPark_cfi::electrons, f, dqmMemoryStats::float, get, getValue(), getValueLinear(), getValueNorm(), heavyIonCSV_trainingSettings::idx, PixelMapPlotter::inputs, isInEcalCrack(), ndof, MetAnalyzer::pv(), rho, ZElectronSkim_cff::rho, metsig::tau, runTauDisplay::tau_eta, and runTauDisplay::tau_pt.

◆ createHadronsBlockInputs()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::createHadronsBlockInputs ( unsigned  idx,
const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
const edm::View< reco::Candidate > &  pfCands,
const Cell cell_map,
TauFunc  tau_funcs,
bool  is_inner 
)
inlineprivate

Definition at line 2322 of file DeepTauId.cc.

2331  {
2332  namespace dnn = dnn_inputs_2017_v2::HadronBlockInputs;
2333 
2334  tensorflow::Tensor& inputs = *hadronsTensor_.at(is_inner);
2335 
2336  const auto& get = [&](int var_index) -> float& { return inputs.tensor<float, 4>()(idx, 0, 0, var_index); };
2337 
2338  const bool valid_chH = cell_map.count(CellObjectType::PfCand_chargedHadron);
2339  const bool valid_nH = cell_map.count(CellObjectType::PfCand_neutralHadron);
2340 
2341  if (!cell_map.empty()) {
2342  get(dnn::rho) = getValueNorm(rho, 21.49f, 9.713f);
2343  get(dnn::tau_pt) = getValueLinear(tau.polarP4().pt(), 20.f, 1000.f, true);
2344  get(dnn::tau_eta) = getValueLinear(tau.polarP4().eta(), -2.3f, 2.3f, false);
2345  get(dnn::tau_inside_ecal_crack) = getValue(isInEcalCrack(tau.polarP4().eta()));
2346  }
2347  if (valid_chH) {
2348  size_t index_chH = cell_map.at(CellObjectType::PfCand_chargedHadron);
2349  const auto& chH_cand = dynamic_cast<const CandidateCastType&>(pfCands.at(index_chH));
2350 
2351  get(dnn::pfCand_chHad_valid) = valid_chH;
2352  get(dnn::pfCand_chHad_rel_pt) = getValueNorm(pfCands.at(index_chH).polarP4().pt() / tau.polarP4().pt(),
2353  is_inner ? 0.2564f : 0.0194f,
2354  is_inner ? 0.8607f : 0.1865f);
2355  get(dnn::pfCand_chHad_deta) = getValueLinear(pfCands.at(index_chH).polarP4().eta() - tau.polarP4().eta(),
2356  is_inner ? -0.1f : -0.5f,
2357  is_inner ? 0.1f : 0.5f,
2358  false);
2359  get(dnn::pfCand_chHad_dphi) = getValueLinear(dPhi(tau.polarP4(), pfCands.at(index_chH).polarP4()),
2360  is_inner ? -0.1f : -0.5f,
2361  is_inner ? 0.1f : 0.5f,
2362  false);
2363  get(dnn::pfCand_chHad_leadChargedHadrCand) =
2364  getValue(&chH_cand == dynamic_cast<const CandidateCastType*>(tau.leadChargedHadrCand().get()));
2365  get(dnn::pfCand_chHad_pvAssociationQuality) =
2366  getValueLinear<int>(candFunc::getPvAssocationQuality(chH_cand), 0, 7, true);
2367  get(dnn::pfCand_chHad_fromPV) = getValueLinear<int>(candFunc::getFromPV(chH_cand), 0, 3, true);
2368  const float default_chH_pw_inner = 0.7614090f;
2369  const float default_chH_pw_outer = 0.1974930f;
2370  get(dnn::pfCand_chHad_puppiWeight) = is_inner
2371  ? getValue(candFunc::getPuppiWeight(chH_cand, default_chH_pw_inner))
2372  : getValue(candFunc::getPuppiWeight(chH_cand, default_chH_pw_outer));
2373  get(dnn::pfCand_chHad_puppiWeightNoLep) =
2374  is_inner ? getValue(candFunc::getPuppiWeightNoLep(chH_cand, default_chH_pw_inner))
2375  : getValue(candFunc::getPuppiWeightNoLep(chH_cand, default_chH_pw_outer));
2376  get(dnn::pfCand_chHad_charge) = getValue(chH_cand.charge());
2377  get(dnn::pfCand_chHad_lostInnerHits) = getValue<int>(candFunc::getLostInnerHits(chH_cand, 0));
2378  get(dnn::pfCand_chHad_numberOfPixelHits) =
2379  getValueLinear(candFunc::getNumberOfPixelHits(chH_cand, 0), 0, 12, true);
2380  get(dnn::pfCand_chHad_vertex_dx) =
2381  getValueNorm(pfCands.at(index_chH).vertex().x() - pv.position().x(), 0.0005f, 1.735f);
2382  get(dnn::pfCand_chHad_vertex_dy) =
2383  getValueNorm(pfCands.at(index_chH).vertex().y() - pv.position().y(), -0.0008f, 1.752f);
2384  get(dnn::pfCand_chHad_vertex_dz) =
2385  getValueNorm(pfCands.at(index_chH).vertex().z() - pv.position().z(), -0.0201f, 8.333f);
2386  get(dnn::pfCand_chHad_vertex_dx_tauFL) = getValueNorm(
2387  pfCands.at(index_chH).vertex().x() - pv.position().x() - tau_funcs.getFlightLength(tau, tau_index).x(),
2388  -0.0014f,
2389  1.93f);
2390  get(dnn::pfCand_chHad_vertex_dy_tauFL) = getValueNorm(
2391  pfCands.at(index_chH).vertex().y() - pv.position().y() - tau_funcs.getFlightLength(tau, tau_index).y(),
2392  0.0022f,
2393  1.948f);
2394  get(dnn::pfCand_chHad_vertex_dz_tauFL) = getValueNorm(
2395  pfCands.at(index_chH).vertex().z() - pv.position().z() - tau_funcs.getFlightLength(tau, tau_index).z(),
2396  -0.0138f,
2397  8.622f);
2398 
2399  const bool hasTrackDetails = candFunc::getHasTrackDetails(chH_cand);
2400  if (hasTrackDetails) {
2401  get(dnn::pfCand_chHad_hasTrackDetails) = hasTrackDetails;
2402  get(dnn::pfCand_chHad_dxy) = getValueNorm(candFunc::getTauDxy(chH_cand), -0.012f, 2.386f);
2403  get(dnn::pfCand_chHad_dxy_sig) =
2404  getValueNorm(std::abs(candFunc::getTauDxy(chH_cand)) / chH_cand.dxyError(), 6.417f, 36.28f);
2405  get(dnn::pfCand_chHad_dz) = getValueNorm(candFunc::getTauDz(chH_cand), -0.0246f, 7.618f);
2406  get(dnn::pfCand_chHad_dz_sig) =
2407  getValueNorm(std::abs(candFunc::getTauDz(chH_cand)) / chH_cand.dzError(), 301.3f, 491.1f);
2408  get(dnn::pfCand_chHad_track_chi2_ndof) =
2409  candFunc::getPseudoTrack(chH_cand).ndof() > 0
2410  ? getValueNorm(candFunc::getPseudoTrack(chH_cand).chi2() / candFunc::getPseudoTrack(chH_cand).ndof(),
2411  0.7876f,
2412  3.694f)
2413  : 0;
2414  get(dnn::pfCand_chHad_track_ndof) =
2415  candFunc::getPseudoTrack(chH_cand).ndof() > 0
2416  ? getValueNorm(candFunc::getPseudoTrack(chH_cand).ndof(), 13.92f, 6.581f)
2417  : 0;
2418  }
2419  float hcal_fraction = candFunc::getHCalFraction(chH_cand, disable_hcalFraction_workaround_);
2420  get(dnn::pfCand_chHad_hcalFraction) = getValue(hcal_fraction);
2421  get(dnn::pfCand_chHad_rawCaloFraction) = getValueLinear(candFunc::getRawCaloFraction(chH_cand), 0.f, 2.6f, true);
2422  }
2423  if (valid_nH) {
2424  size_t index_nH = cell_map.at(CellObjectType::PfCand_neutralHadron);
2425  const auto& nH_cand = dynamic_cast<const CandidateCastType&>(pfCands.at(index_nH));
2426 
2427  get(dnn::pfCand_nHad_valid) = valid_nH;
2428  get(dnn::pfCand_nHad_rel_pt) = getValueNorm(pfCands.at(index_nH).polarP4().pt() / tau.polarP4().pt(),
2429  is_inner ? 0.3163f : 0.0502f,
2430  is_inner ? 0.2769f : 0.4266f);
2431  get(dnn::pfCand_nHad_deta) = getValueLinear(pfCands.at(index_nH).polarP4().eta() - tau.polarP4().eta(),
2432  is_inner ? -0.1f : -0.5f,
2433  is_inner ? 0.1f : 0.5f,
2434  false);
2435  get(dnn::pfCand_nHad_dphi) = getValueLinear(
2436  dPhi(tau.polarP4(), pfCands.at(index_nH).polarP4()), is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f, false);
2437  get(dnn::pfCand_nHad_puppiWeight) = is_inner ? getValue(candFunc::getPuppiWeight(nH_cand, 0.9798355f))
2438  : getValue(candFunc::getPuppiWeight(nH_cand, 0.7813260f));
2439  get(dnn::pfCand_nHad_puppiWeightNoLep) = is_inner ? getValue(candFunc::getPuppiWeightNoLep(nH_cand, 0.9046796f))
2440  : getValue(candFunc::getPuppiWeightNoLep(nH_cand, 0.6554860f));
2441  float hcal_fraction = candFunc::getHCalFraction(nH_cand, disable_hcalFraction_workaround_);
2442  get(dnn::pfCand_nHad_hcalFraction) = getValue(hcal_fraction);
2443  }
2444  }

References funct::abs(), edm::View< T >::at(), hltPixelTracks_cff::chi2, disable_hcalFraction_workaround_, HLT_FULL_cff::dPhi, f, dqmMemoryStats::float, get, getValue(), getValueLinear(), getValueNorm(), hadronsTensor_, heavyIonCSV_trainingSettings::idx, PixelMapPlotter::inputs, isInEcalCrack(), ndof, MetAnalyzer::pv(), rho, ZElectronSkim_cff::rho, metsig::tau, runTauDisplay::tau_eta, and runTauDisplay::tau_pt.

◆ createInputsV1()

template<typename dnn , typename CandidateCastType , typename TauCastType >
tensorflow::Tensor DeepTauId::createInputsV1 ( const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
TauFunc  tau_funcs 
) const
inlineprivate

Definition at line 2447 of file DeepTauId.cc.

2452  {
2453  static constexpr bool check_all_set = false;
2454  static constexpr float default_value_for_set_check = -42;
2455 
2456  tensorflow::Tensor inputs(tensorflow::DT_FLOAT, {1, dnn_inputs_2017v1::NumberOfInputs});
2457  const auto& get = [&](int var_index) -> float& { return inputs.matrix<float>()(0, var_index); };
2458  auto leadChargedHadrCand = dynamic_cast<const CandidateCastType*>(tau.leadChargedHadrCand().get());
2459 
2460  if (check_all_set) {
2461  for (int var_index = 0; var_index < dnn::NumberOfInputs; ++var_index) {
2462  get(var_index) = default_value_for_set_check;
2463  }
2464  }
2465 
2466  get(dnn::pt) = tau.p4().pt();
2467  get(dnn::eta) = tau.p4().eta();
2468  get(dnn::mass) = tau.p4().mass();
2469  get(dnn::decayMode) = tau.decayMode();
2470  get(dnn::chargedIsoPtSum) = tau_funcs.getChargedIsoPtSum(tau, tau_ref);
2471  get(dnn::neutralIsoPtSum) = tau_funcs.getNeutralIsoPtSum(tau, tau_ref);
2472  get(dnn::neutralIsoPtSumWeight) = tau_funcs.getNeutralIsoPtSumWeight(tau, tau_ref);
2473  get(dnn::photonPtSumOutsideSignalCone) = tau_funcs.getPhotonPtSumOutsideSignalCone(tau, tau_ref);
2474  get(dnn::puCorrPtSum) = tau_funcs.getPuCorrPtSum(tau, tau_ref);
2475  get(dnn::dxy) = tau_funcs.getdxy(tau, tau_index);
2476  get(dnn::dxy_sig) = tau_funcs.getdxySig(tau, tau_index);
2477  get(dnn::dz) = leadChargedHadrCand ? candFunc::getTauDz(*leadChargedHadrCand) : default_value;
2478  get(dnn::ip3d) = tau_funcs.getip3d(tau, tau_index);
2479  get(dnn::ip3d_sig) = tau_funcs.getip3dSig(tau, tau_index);
2480  get(dnn::hasSecondaryVertex) = tau_funcs.getHasSecondaryVertex(tau, tau_index);
2481  get(dnn::flightLength_r) = tau_funcs.getFlightLength(tau, tau_index).R();
2482  get(dnn::flightLength_dEta) = dEta(tau_funcs.getFlightLength(tau, tau_index), tau.p4());
2483  get(dnn::flightLength_dPhi) = dPhi(tau_funcs.getFlightLength(tau, tau_index), tau.p4());
2484  get(dnn::flightLength_sig) = tau_funcs.getFlightLengthSig(tau, tau_index);
2485  get(dnn::leadChargedHadrCand_pt) = leadChargedHadrCand ? leadChargedHadrCand->p4().Pt() : default_value;
2486  get(dnn::leadChargedHadrCand_dEta) =
2487  leadChargedHadrCand ? dEta(leadChargedHadrCand->p4(), tau.p4()) : default_value;
2488  get(dnn::leadChargedHadrCand_dPhi) =
2489  leadChargedHadrCand ? dPhi(leadChargedHadrCand->p4(), tau.p4()) : default_value;
2490  get(dnn::leadChargedHadrCand_mass) = leadChargedHadrCand ? leadChargedHadrCand->p4().mass() : default_value;
2495  get(dnn::leadingTrackNormChi2) = tau_funcs.getLeadingTrackNormChi2(tau);
2496  get(dnn::e_ratio) = reco::tau::eratio(tau);
2497  get(dnn::gj_angle_diff) = calculateGottfriedJacksonAngleDifference(tau, tau_index, tau_funcs);
2498  get(dnn::n_photons) = reco::tau::n_photons_total(tau);
2499  get(dnn::emFraction) = tau_funcs.getEmFraction(tau);
2500  get(dnn::has_gsf_track) = leadChargedHadrCand && std::abs(leadChargedHadrCand->pdgId()) == 11;
2501  get(dnn::inside_ecal_crack) = isInEcalCrack(tau.p4().Eta());
2502  auto gsf_ele = findMatchedElectron(tau, electrons, 0.3);
2503  get(dnn::gsf_ele_matched) = gsf_ele != nullptr;
2504  get(dnn::gsf_ele_pt) = gsf_ele != nullptr ? gsf_ele->p4().Pt() : default_value;
2505  get(dnn::gsf_ele_dEta) = gsf_ele != nullptr ? dEta(gsf_ele->p4(), tau.p4()) : default_value;
2506  get(dnn::gsf_ele_dPhi) = gsf_ele != nullptr ? dPhi(gsf_ele->p4(), tau.p4()) : default_value;
2507  get(dnn::gsf_ele_mass) = gsf_ele != nullptr ? gsf_ele->p4().mass() : default_value;
2508  calculateElectronClusterVars(gsf_ele, get(dnn::gsf_ele_Ee), get(dnn::gsf_ele_Egamma));
2509  get(dnn::gsf_ele_Pin) = gsf_ele != nullptr ? gsf_ele->trackMomentumAtVtx().R() : default_value;
2510  get(dnn::gsf_ele_Pout) = gsf_ele != nullptr ? gsf_ele->trackMomentumOut().R() : default_value;
2511  get(dnn::gsf_ele_EtotOverPin) = get(dnn::gsf_ele_Pin) > 0
2512  ? (get(dnn::gsf_ele_Ee) + get(dnn::gsf_ele_Egamma)) / get(dnn::gsf_ele_Pin)
2513  : default_value;
2514  get(dnn::gsf_ele_Eecal) = gsf_ele != nullptr ? gsf_ele->ecalEnergy() : default_value;
2515  get(dnn::gsf_ele_dEta_SeedClusterTrackAtCalo) =
2516  gsf_ele != nullptr ? gsf_ele->deltaEtaSeedClusterTrackAtCalo() : default_value;
2517  get(dnn::gsf_ele_dPhi_SeedClusterTrackAtCalo) =
2518  gsf_ele != nullptr ? gsf_ele->deltaPhiSeedClusterTrackAtCalo() : default_value;
2519  get(dnn::gsf_ele_mvaIn_sigmaEtaEta) = gsf_ele != nullptr ? gsf_ele->mvaInput().sigmaEtaEta : default_value;
2520  get(dnn::gsf_ele_mvaIn_hadEnergy) = gsf_ele != nullptr ? gsf_ele->mvaInput().hadEnergy : default_value;
2521  get(dnn::gsf_ele_mvaIn_deltaEta) = gsf_ele != nullptr ? gsf_ele->mvaInput().deltaEta : default_value;
2522 
2523  get(dnn::gsf_ele_Chi2NormGSF) = default_value;
2524  get(dnn::gsf_ele_GSFNumHits) = default_value;
2525  get(dnn::gsf_ele_GSFTrackResol) = default_value;
2526  get(dnn::gsf_ele_GSFTracklnPt) = default_value;
2527  if (gsf_ele != nullptr && gsf_ele->gsfTrack().isNonnull()) {
2528  get(dnn::gsf_ele_Chi2NormGSF) = gsf_ele->gsfTrack()->normalizedChi2();
2529  get(dnn::gsf_ele_GSFNumHits) = gsf_ele->gsfTrack()->numberOfValidHits();
2530  if (gsf_ele->gsfTrack()->pt() > 0) {
2531  get(dnn::gsf_ele_GSFTrackResol) = gsf_ele->gsfTrack()->ptError() / gsf_ele->gsfTrack()->pt();
2532  get(dnn::gsf_ele_GSFTracklnPt) = std::log10(gsf_ele->gsfTrack()->pt());
2533  }
2534  }
2535 
2536  get(dnn::gsf_ele_Chi2NormKF) = default_value;
2537  get(dnn::gsf_ele_KFNumHits) = default_value;
2538  if (gsf_ele != nullptr && gsf_ele->closestCtfTrackRef().isNonnull()) {
2539  get(dnn::gsf_ele_Chi2NormKF) = gsf_ele->closestCtfTrackRef()->normalizedChi2();
2540  get(dnn::gsf_ele_KFNumHits) = gsf_ele->closestCtfTrackRef()->numberOfValidHits();
2541  }
2542  get(dnn::leadChargedCand_etaAtEcalEntrance) = tau_funcs.getEtaAtEcalEntrance(tau);
2543  get(dnn::leadChargedCand_pt) = leadChargedHadrCand->pt();
2544 
2545  get(dnn::leadChargedHadrCand_HoP) = default_value;
2546  get(dnn::leadChargedHadrCand_EoP) = default_value;
2547  if (leadChargedHadrCand->pt() > 0) {
2548  get(dnn::leadChargedHadrCand_HoP) = tau_funcs.getEcalEnergyLeadingChargedHadr(tau) / leadChargedHadrCand->pt();
2549  get(dnn::leadChargedHadrCand_EoP) = tau_funcs.getHcalEnergyLeadingChargedHadr(tau) / leadChargedHadrCand->pt();
2550  }
2551 
2552  MuonHitMatchV1 muon_hit_match;
2553  if (tau.leadPFChargedHadrCand().isNonnull() && tau.leadPFChargedHadrCand()->muonRef().isNonnull())
2554  muon_hit_match.addMatchedMuon(*tau.leadPFChargedHadrCand()->muonRef(), tau);
2555 
2556  auto matched_muons = muon_hit_match.findMatchedMuons(tau, muons, 0.3, 5);
2557  for (auto muon : matched_muons)
2558  muon_hit_match.addMatchedMuon(*muon, tau);
2559  muon_hit_match.fillTensor<dnn>(get, tau, default_value);
2560 
2561  LorentzVectorXYZ signalChargedHadrCands_sumIn, signalChargedHadrCands_sumOut;
2563  tau.signalChargedHadrCands(),
2564  signalChargedHadrCands_sumIn,
2565  signalChargedHadrCands_sumOut,
2566  get(dnn::signalChargedHadrCands_sum_innerSigCone_pt),
2567  get(dnn::signalChargedHadrCands_sum_innerSigCone_dEta),
2568  get(dnn::signalChargedHadrCands_sum_innerSigCone_dPhi),
2569  get(dnn::signalChargedHadrCands_sum_innerSigCone_mass),
2570  get(dnn::signalChargedHadrCands_sum_outerSigCone_pt),
2571  get(dnn::signalChargedHadrCands_sum_outerSigCone_dEta),
2572  get(dnn::signalChargedHadrCands_sum_outerSigCone_dPhi),
2573  get(dnn::signalChargedHadrCands_sum_outerSigCone_mass),
2574  get(dnn::signalChargedHadrCands_nTotal_innerSigCone),
2575  get(dnn::signalChargedHadrCands_nTotal_outerSigCone));
2576 
2577  LorentzVectorXYZ signalNeutrHadrCands_sumIn, signalNeutrHadrCands_sumOut;
2579  tau.signalNeutrHadrCands(),
2580  signalNeutrHadrCands_sumIn,
2581  signalNeutrHadrCands_sumOut,
2582  get(dnn::signalNeutrHadrCands_sum_innerSigCone_pt),
2583  get(dnn::signalNeutrHadrCands_sum_innerSigCone_dEta),
2584  get(dnn::signalNeutrHadrCands_sum_innerSigCone_dPhi),
2585  get(dnn::signalNeutrHadrCands_sum_innerSigCone_mass),
2586  get(dnn::signalNeutrHadrCands_sum_outerSigCone_pt),
2587  get(dnn::signalNeutrHadrCands_sum_outerSigCone_dEta),
2588  get(dnn::signalNeutrHadrCands_sum_outerSigCone_dPhi),
2589  get(dnn::signalNeutrHadrCands_sum_outerSigCone_mass),
2590  get(dnn::signalNeutrHadrCands_nTotal_innerSigCone),
2591  get(dnn::signalNeutrHadrCands_nTotal_outerSigCone));
2592 
2593  LorentzVectorXYZ signalGammaCands_sumIn, signalGammaCands_sumOut;
2595  tau.signalGammaCands(),
2596  signalGammaCands_sumIn,
2597  signalGammaCands_sumOut,
2598  get(dnn::signalGammaCands_sum_innerSigCone_pt),
2599  get(dnn::signalGammaCands_sum_innerSigCone_dEta),
2600  get(dnn::signalGammaCands_sum_innerSigCone_dPhi),
2601  get(dnn::signalGammaCands_sum_innerSigCone_mass),
2602  get(dnn::signalGammaCands_sum_outerSigCone_pt),
2603  get(dnn::signalGammaCands_sum_outerSigCone_dEta),
2604  get(dnn::signalGammaCands_sum_outerSigCone_dPhi),
2605  get(dnn::signalGammaCands_sum_outerSigCone_mass),
2606  get(dnn::signalGammaCands_nTotal_innerSigCone),
2607  get(dnn::signalGammaCands_nTotal_outerSigCone));
2608 
2609  LorentzVectorXYZ isolationChargedHadrCands_sum;
2611  tau.isolationChargedHadrCands(),
2612  isolationChargedHadrCands_sum,
2613  get(dnn::isolationChargedHadrCands_sum_pt),
2614  get(dnn::isolationChargedHadrCands_sum_dEta),
2615  get(dnn::isolationChargedHadrCands_sum_dPhi),
2616  get(dnn::isolationChargedHadrCands_sum_mass),
2617  get(dnn::isolationChargedHadrCands_nTotal));
2618 
2619  LorentzVectorXYZ isolationNeutrHadrCands_sum;
2621  tau.isolationNeutrHadrCands(),
2622  isolationNeutrHadrCands_sum,
2623  get(dnn::isolationNeutrHadrCands_sum_pt),
2624  get(dnn::isolationNeutrHadrCands_sum_dEta),
2625  get(dnn::isolationNeutrHadrCands_sum_dPhi),
2626  get(dnn::isolationNeutrHadrCands_sum_mass),
2627  get(dnn::isolationNeutrHadrCands_nTotal));
2628 
2629  LorentzVectorXYZ isolationGammaCands_sum;
2631  tau.isolationGammaCands(),
2632  isolationGammaCands_sum,
2633  get(dnn::isolationGammaCands_sum_pt),
2634  get(dnn::isolationGammaCands_sum_dEta),
2635  get(dnn::isolationGammaCands_sum_dPhi),
2636  get(dnn::isolationGammaCands_sum_mass),
2637  get(dnn::isolationGammaCands_nTotal));
2638 
2639  get(dnn::tau_visMass_innerSigCone) = (signalGammaCands_sumIn + signalChargedHadrCands_sumIn).mass();
2640 
2641  if (check_all_set) {
2642  for (int var_index = 0; var_index < dnn::NumberOfInputs; ++var_index) {
2643  if (get(var_index) == default_value_for_set_check)
2644  throw cms::Exception("DeepTauId: variable with index = ") << var_index << " is not set.";
2645  }
2646  }
2647 
2648  return inputs;
2649  }

References funct::abs(), calculateElectronClusterVars(), calculateGottfriedJacksonAngleDifference(), taus_cff::decayMode, default_value, HLT_FULL_cff::dEta, HLT_FULL_cff::dPhi, PVValHelper::dxy, PVValHelper::dz, pwdgSkimBPark_cfi::electrons, reco::tau::eratio(), PVValHelper::eta, findMatchedElectron(), get, PixelMapPlotter::inputs, electrons_cff::ip3d, isInEcalCrack(), EgHLTOffHistBins_cfi::mass, PDWG_BPHSkim_cff::muons, reco::tau::n_photons_total(), processIsolationPFComponents(), processSignalPFComponents(), DiDispStaMuonMonitor_cfi::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(), and metsig::tau.

◆ createMuonBlockInputs()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::createMuonBlockInputs ( unsigned  idx,
const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
const std::vector< pat::Muon > *  muons,
const edm::View< reco::Candidate > &  pfCands,
const Cell cell_map,
TauFunc  tau_funcs,
bool  is_inner 
)
inlineprivate

Definition at line 2171 of file DeepTauId.cc.

2181  {
2182  namespace dnn = dnn_inputs_2017_v2::MuonBlockInputs;
2183 
2184  tensorflow::Tensor& inputs = *muonTensor_.at(is_inner);
2185 
2186  const auto& get = [&](int var_index) -> float& { return inputs.tensor<float, 4>()(idx, 0, 0, var_index); };
2187 
2188  const bool valid_index_pf_muon = cell_map.count(CellObjectType::PfCand_muon);
2189  const bool valid_index_muon = cell_map.count(CellObjectType::Muon);
2190 
2191  if (!cell_map.empty()) {
2192  get(dnn::rho) = getValueNorm(rho, 21.49f, 9.713f);
2193  get(dnn::tau_pt) = getValueLinear(tau.polarP4().pt(), 20.f, 1000.f, true);
2194  get(dnn::tau_eta) = getValueLinear(tau.polarP4().eta(), -2.3f, 2.3f, false);
2195  get(dnn::tau_inside_ecal_crack) = getValue(isInEcalCrack(tau.polarP4().eta()));
2196  }
2197  if (valid_index_pf_muon) {
2198  size_t index_pf_muon = cell_map.at(CellObjectType::PfCand_muon);
2199  const auto& muon_cand = dynamic_cast<const CandidateCastType&>(pfCands.at(index_pf_muon));
2200 
2201  get(dnn::pfCand_muon_valid) = valid_index_pf_muon;
2202  get(dnn::pfCand_muon_rel_pt) = getValueNorm(pfCands.at(index_pf_muon).polarP4().pt() / tau.polarP4().pt(),
2203  is_inner ? 0.9509f : 0.0861f,
2204  is_inner ? 0.4294f : 0.4065f);
2205  get(dnn::pfCand_muon_deta) = getValueLinear(pfCands.at(index_pf_muon).polarP4().eta() - tau.polarP4().eta(),
2206  is_inner ? -0.1f : -0.5f,
2207  is_inner ? 0.1f : 0.5f,
2208  false);
2209  get(dnn::pfCand_muon_dphi) = getValueLinear(dPhi(tau.polarP4(), pfCands.at(index_pf_muon).polarP4()),
2210  is_inner ? -0.1f : -0.5f,
2211  is_inner ? 0.1f : 0.5f,
2212  false);
2213  get(dnn::pfCand_muon_pvAssociationQuality) =
2214  getValueLinear<int>(candFunc::getPvAssocationQuality(muon_cand), 0, 7, true);
2215  get(dnn::pfCand_muon_fromPV) = getValueLinear<int>(candFunc::getFromPV(muon_cand), 0, 3, true);
2216  get(dnn::pfCand_muon_puppiWeight) = is_inner ? getValue(candFunc::getPuppiWeight(muon_cand, 0.9786588f))
2217  : getValue(candFunc::getPuppiWeight(muon_cand, 0.8132477f));
2218  get(dnn::pfCand_muon_charge) = getValue(muon_cand.charge());
2219  get(dnn::pfCand_muon_lostInnerHits) = getValue<int>(candFunc::getLostInnerHits(muon_cand, 0));
2220  get(dnn::pfCand_muon_numberOfPixelHits) =
2221  getValueLinear(candFunc::getNumberOfPixelHits(muon_cand, 0), 0, 11, true);
2222  get(dnn::pfCand_muon_vertex_dx) =
2223  getValueNorm(pfCands.at(index_pf_muon).vertex().x() - pv.position().x(), -0.0007f, 0.6869f);
2224  get(dnn::pfCand_muon_vertex_dy) =
2225  getValueNorm(pfCands.at(index_pf_muon).vertex().y() - pv.position().y(), 0.0001f, 0.6784f);
2226  get(dnn::pfCand_muon_vertex_dz) =
2227  getValueNorm(pfCands.at(index_pf_muon).vertex().z() - pv.position().z(), -0.0117f, 4.097f);
2228  get(dnn::pfCand_muon_vertex_dx_tauFL) = getValueNorm(
2229  pfCands.at(index_pf_muon).vertex().x() - pv.position().x() - tau_funcs.getFlightLength(tau, tau_index).x(),
2230  -0.0001f,
2231  0.8642f);
2232  get(dnn::pfCand_muon_vertex_dy_tauFL) = getValueNorm(
2233  pfCands.at(index_pf_muon).vertex().y() - pv.position().y() - tau_funcs.getFlightLength(tau, tau_index).y(),
2234  0.0004f,
2235  0.8561f);
2236  get(dnn::pfCand_muon_vertex_dz_tauFL) = getValueNorm(
2237  pfCands.at(index_pf_muon).vertex().z() - pv.position().z() - tau_funcs.getFlightLength(tau, tau_index).z(),
2238  -0.0118f,
2239  4.405f);
2240 
2241  const bool hasTrackDetails = candFunc::getHasTrackDetails(muon_cand);
2242  if (hasTrackDetails) {
2243  get(dnn::pfCand_muon_hasTrackDetails) = hasTrackDetails;
2244  get(dnn::pfCand_muon_dxy) = getValueNorm(candFunc::getTauDxy(muon_cand), -0.0045f, 0.9655f);
2245  get(dnn::pfCand_muon_dxy_sig) =
2246  getValueNorm(std::abs(candFunc::getTauDxy(muon_cand)) / muon_cand.dxyError(), 4.575f, 42.36f);
2247  get(dnn::pfCand_muon_dz) = getValueNorm(candFunc::getTauDz(muon_cand), -0.0117f, 4.097f);
2248  get(dnn::pfCand_muon_dz_sig) =
2249  getValueNorm(std::abs(candFunc::getTauDz(muon_cand)) / muon_cand.dzError(), 80.37f, 343.3f);
2250  get(dnn::pfCand_muon_track_chi2_ndof) = getValueNorm(
2251  candFunc::getPseudoTrack(muon_cand).chi2() / candFunc::getPseudoTrack(muon_cand).ndof(), 0.69f, 1.711f);
2252  get(dnn::pfCand_muon_track_ndof) = getValueNorm(candFunc::getPseudoTrack(muon_cand).ndof(), 17.5f, 5.11f);
2253  }
2254  }
2255  if (valid_index_muon) {
2256  size_t index_muon = cell_map.at(CellObjectType::Muon);
2257 
2258  get(dnn::muon_valid) = valid_index_muon;
2259  get(dnn::muon_rel_pt) = getValueNorm(muons->at(index_muon).polarP4().pt() / tau.polarP4().pt(),
2260  is_inner ? 0.7966f : 0.2678f,
2261  is_inner ? 3.402f : 3.592f);
2262  get(dnn::muon_deta) = getValueLinear(muons->at(index_muon).polarP4().eta() - tau.polarP4().eta(),
2263  is_inner ? -0.1f : -0.5f,
2264  is_inner ? 0.1f : 0.5f,
2265  false);
2266  get(dnn::muon_dphi) = getValueLinear(dPhi(tau.polarP4(), muons->at(index_muon).polarP4()),
2267  is_inner ? -0.1f : -0.5f,
2268  is_inner ? 0.1f : 0.5f,
2269  false);
2270  get(dnn::muon_dxy) = getValueNorm(muons->at(index_muon).dB(pat::Muon::PV2D), 0.0019f, 1.039f);
2271  get(dnn::muon_dxy_sig) =
2272  getValueNorm(std::abs(muons->at(index_muon).dB(pat::Muon::PV2D)) / muons->at(index_muon).edB(pat::Muon::PV2D),
2273  8.98f,
2274  71.17f);
2275 
2276  const bool normalizedChi2_valid =
2277  muons->at(index_muon).globalTrack().isNonnull() && muons->at(index_muon).normChi2() >= 0;
2278  if (normalizedChi2_valid) {
2279  get(dnn::muon_normalizedChi2_valid) = normalizedChi2_valid;
2280  get(dnn::muon_normalizedChi2) = getValueNorm(muons->at(index_muon).normChi2(), 21.52f, 265.8f);
2281  if (muons->at(index_muon).innerTrack().isNonnull())
2282  get(dnn::muon_numberOfValidHits) = getValueNorm(muons->at(index_muon).numberOfValidHits(), 21.84f, 10.59f);
2283  }
2284  get(dnn::muon_segmentCompatibility) = getValue(muons->at(index_muon).segmentCompatibility());
2285  get(dnn::muon_caloCompatibility) = getValue(muons->at(index_muon).caloCompatibility());
2286 
2287  const bool pfEcalEnergy_valid = muons->at(index_muon).pfEcalEnergy() >= 0;
2288  if (pfEcalEnergy_valid) {
2289  get(dnn::muon_pfEcalEnergy_valid) = pfEcalEnergy_valid;
2290  get(dnn::muon_rel_pfEcalEnergy) =
2291  getValueNorm(muons->at(index_muon).pfEcalEnergy() / muons->at(index_muon).polarP4().pt(), 0.2273f, 0.4865f);
2292  }
2293 
2294  MuonHitMatchV2 hit_match(muons->at(index_muon));
2295  static const std::map<int, std::pair<int, int>> muonMatchHitVars = {
2296  {MuonSubdetId::DT, {dnn::muon_n_matches_DT_1, dnn::muon_n_hits_DT_1}},
2297  {MuonSubdetId::CSC, {dnn::muon_n_matches_CSC_1, dnn::muon_n_hits_CSC_1}},
2298  {MuonSubdetId::RPC, {dnn::muon_n_matches_RPC_1, dnn::muon_n_hits_RPC_1}}};
2299 
2300  static const std::map<int, std::vector<float>> muonMatchVarLimits = {
2301  {MuonSubdetId::DT, {2, 2, 2, 2}}, {MuonSubdetId::CSC, {6, 2, 2, 2}}, {MuonSubdetId::RPC, {7, 6, 4, 4}}};
2302 
2303  static const std::map<int, std::vector<float>> muonHitVarLimits = {{MuonSubdetId::DT, {12, 12, 12, 8}},
2304  {MuonSubdetId::CSC, {24, 12, 12, 12}},
2305  {MuonSubdetId::RPC, {4, 4, 2, 2}}};
2306 
2307  for (int subdet : hit_match.MuonHitMatchV2::consideredSubdets()) {
2308  const auto& matchHitVar = muonMatchHitVars.at(subdet);
2309  const auto& matchLimits = muonMatchVarLimits.at(subdet);
2310  const auto& hitLimits = muonHitVarLimits.at(subdet);
2311  for (int station = MuonHitMatchV2::first_station_id; station <= MuonHitMatchV2::last_station_id; ++station) {
2312  const unsigned n_matches = hit_match.nMatches(subdet, station);
2313  const unsigned n_hits = hit_match.nHits(subdet, station);
2314  get(matchHitVar.first + station - 1) = getValueLinear(n_matches, 0, matchLimits.at(station - 1), true);
2315  get(matchHitVar.second + station - 1) = getValueLinear(n_hits, 0, hitLimits.at(station - 1), true);
2316  }
2317  }
2318  }
2319  }

References funct::abs(), edm::View< T >::at(), hltPixelTracks_cff::chi2, MuonSubdetId::CSC, HLT_FULL_cff::dPhi, MuonSubdetId::DT, f, dqmMemoryStats::float, get, getValue(), getValueLinear(), getValueNorm(), heavyIonCSV_trainingSettings::idx, PixelMapPlotter::inputs, isInEcalCrack(), dumpRecoGeometry_cfg::Muon, PDWG_BPHSkim_cff::muons, muonTensor_, ndof, MetAnalyzer::pv(), pat::Muon::PV2D, rho, ZElectronSkim_cff::rho, MuonSubdetId::RPC, relativeConstraints::station, metsig::tau, runTauDisplay::tau_eta, and runTauDisplay::tau_pt.

◆ createTauBlockInputs()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::createTauBlockInputs ( const TauCastType &  tau,
const size_t &  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
TauFunc  tau_funcs 
)
inlineprivate

Definition at line 1829 of file DeepTauId.cc.

1834  {
1835  namespace dnn = dnn_inputs_2017_v2::TauBlockInputs;
1836 
1837  tensorflow::Tensor& inputs = *tauBlockTensor_;
1838  inputs.flat<float>().setZero();
1839 
1840  const auto& get = [&](int var_index) -> float& { return inputs.matrix<float>()(0, var_index); };
1841 
1842  auto leadChargedHadrCand = dynamic_cast<const CandidateCastType*>(tau.leadChargedHadrCand().get());
1843 
1844  get(dnn::rho) = getValueNorm(rho, 21.49f, 9.713f);
1845  get(dnn::tau_pt) = getValueLinear(tau.polarP4().pt(), 20.f, 1000.f, true);
1846  get(dnn::tau_eta) = getValueLinear(tau.polarP4().eta(), -2.3f, 2.3f, false);
1847  get(dnn::tau_phi) = getValueLinear(tau.polarP4().phi(), -pi, pi, false);
1848  get(dnn::tau_mass) = getValueNorm(tau.polarP4().mass(), 0.6669f, 0.6553f);
1849  get(dnn::tau_E_over_pt) = getValueLinear(tau.p4().energy() / tau.p4().pt(), 1.f, 5.2f, true);
1850  get(dnn::tau_charge) = getValue(tau.charge());
1851  get(dnn::tau_n_charged_prongs) = getValueLinear(tau.decayMode() / 5 + 1, 1, 3, true);
1852  get(dnn::tau_n_neutral_prongs) = getValueLinear(tau.decayMode() % 5, 0, 2, true);
1853  get(dnn::chargedIsoPtSum) = getValueNorm(tau_funcs.getChargedIsoPtSum(tau, tau_ref), 47.78f, 123.5f);
1854  get(dnn::chargedIsoPtSumdR03_over_dR05) =
1855  getValue(tau_funcs.getChargedIsoPtSumdR03(tau, tau_ref) / tau_funcs.getChargedIsoPtSum(tau, tau_ref));
1856  get(dnn::footprintCorrection) = getValueNorm(tau_funcs.getFootprintCorrectiondR03(tau, tau_ref), 9.029f, 26.42f);
1857  get(dnn::neutralIsoPtSum) = getValueNorm(tau_funcs.getNeutralIsoPtSum(tau, tau_ref), 57.59f, 155.3f);
1858  get(dnn::neutralIsoPtSumWeight_over_neutralIsoPtSum) =
1859  getValue(tau_funcs.getNeutralIsoPtSumWeight(tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(tau, tau_ref));
1860  get(dnn::neutralIsoPtSumWeightdR03_over_neutralIsoPtSum) =
1861  getValue(tau_funcs.getNeutralIsoPtSumdR03Weight(tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(tau, tau_ref));
1862  get(dnn::neutralIsoPtSumdR03_over_dR05) =
1863  getValue(tau_funcs.getNeutralIsoPtSumdR03(tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(tau, tau_ref));
1864  get(dnn::photonPtSumOutsideSignalCone) =
1865  getValueNorm(tau_funcs.getPhotonPtSumOutsideSignalCone(tau, tau_ref), 1.731f, 6.846f);
1866  get(dnn::puCorrPtSum) = getValueNorm(tau_funcs.getPuCorrPtSum(tau, tau_ref), 22.38f, 16.34f);
1867  // The global PCA coordinates were used as inputs during the NN training, but it was decided to disable
1868  // them for the inference, because modeling of dxy_PCA in MC poorly describes the data, and x and y coordinates
1869  // in data results outside of the expected 5 std. dev. input validity range. On the other hand,
1870  // these coordinates are strongly era-dependent. Kept as comment to document what NN expects.
1871  if (!disable_dxy_pca_) {
1872  auto const pca = tau_funcs.getdxyPCA(tau, tau_index);
1873  get(dnn::tau_dxy_pca_x) = getValueNorm(pca.x(), -0.0241f, 0.0074f);
1874  get(dnn::tau_dxy_pca_y) = getValueNorm(pca.y(), 0.0675f, 0.0128f);
1875  get(dnn::tau_dxy_pca_z) = getValueNorm(pca.z(), 0.7973f, 3.456f);
1876  } else {
1877  get(dnn::tau_dxy_pca_x) = 0;
1878  get(dnn::tau_dxy_pca_y) = 0;
1879  get(dnn::tau_dxy_pca_z) = 0;
1880  }
1881  const bool tau_dxy_valid =
1882  isAbove(tau_funcs.getdxy(tau, tau_index), -10) && isAbove(tau_funcs.getdxyError(tau, tau_index), 0);
1883  if (tau_dxy_valid) {
1884  get(dnn::tau_dxy_valid) = tau_dxy_valid;
1885  get(dnn::tau_dxy) = getValueNorm(tau_funcs.getdxy(tau, tau_index), 0.0018f, 0.0085f);
1886  get(dnn::tau_dxy_sig) = getValueNorm(
1887  std::abs(tau_funcs.getdxy(tau, tau_index)) / tau_funcs.getdxyError(tau, tau_index), 2.26f, 4.191f);
1888  }
1889  const bool tau_ip3d_valid =
1890  isAbove(tau_funcs.getip3d(tau, tau_index), -10) && isAbove(tau_funcs.getip3dError(tau, tau_index), 0);
1891  if (tau_ip3d_valid) {
1892  get(dnn::tau_ip3d_valid) = tau_ip3d_valid;
1893  get(dnn::tau_ip3d) = getValueNorm(tau_funcs.getip3d(tau, tau_index), 0.0026f, 0.0114f);
1894  get(dnn::tau_ip3d_sig) = getValueNorm(
1895  std::abs(tau_funcs.getip3d(tau, tau_index)) / tau_funcs.getip3dError(tau, tau_index), 2.928f, 4.466f);
1896  }
1897  if (leadChargedHadrCand) {
1898  const bool hasTrackDetails = candFunc::getHasTrackDetails(*leadChargedHadrCand);
1899  const float tau_dz = (is_online_ && !hasTrackDetails) ? 0 : candFunc::getTauDz(*leadChargedHadrCand);
1900  get(dnn::tau_dz) = getValueNorm(tau_dz, 0.f, 0.0190f);
1901  get(dnn::tau_dz_sig_valid) = candFunc::getTauDZSigValid(*leadChargedHadrCand);
1902  const double dzError = hasTrackDetails ? leadChargedHadrCand->dzError() : -999.;
1903  get(dnn::tau_dz_sig) = getValueNorm(std::abs(tau_dz) / dzError, 4.717f, 11.78f);
1904  }
1905  get(dnn::tau_flightLength_x) = getValueNorm(tau_funcs.getFlightLength(tau, tau_index).x(), -0.0003f, 0.7362f);
1906  get(dnn::tau_flightLength_y) = getValueNorm(tau_funcs.getFlightLength(tau, tau_index).y(), -0.0009f, 0.7354f);
1907  get(dnn::tau_flightLength_z) = getValueNorm(tau_funcs.getFlightLength(tau, tau_index).z(), -0.0022f, 1.993f);
1908  get(dnn::tau_flightLength_sig) = 0.55756444; //This value is set due to a bug in the training
1909  get(dnn::tau_pt_weighted_deta_strip) =
1910  getValueLinear(reco::tau::pt_weighted_deta_strip(tau, tau.decayMode()), 0, 1, true);
1911 
1912  get(dnn::tau_pt_weighted_dphi_strip) =
1913  getValueLinear(reco::tau::pt_weighted_dphi_strip(tau, tau.decayMode()), 0, 1, true);
1914  get(dnn::tau_pt_weighted_dr_signal) =
1915  getValueNorm(reco::tau::pt_weighted_dr_signal(tau, tau.decayMode()), 0.0052f, 0.01433f);
1916  get(dnn::tau_pt_weighted_dr_iso) = getValueLinear(reco::tau::pt_weighted_dr_iso(tau, tau.decayMode()), 0, 1, true);
1917  get(dnn::tau_leadingTrackNormChi2) = getValueNorm(tau_funcs.getLeadingTrackNormChi2(tau), 1.538f, 4.401f);
1918  const auto eratio = reco::tau::eratio(tau);
1919  const bool tau_e_ratio_valid = std::isnormal(eratio) && eratio > 0.f;
1920  get(dnn::tau_e_ratio_valid) = tau_e_ratio_valid;
1921  get(dnn::tau_e_ratio) = tau_e_ratio_valid ? getValueLinear(eratio, 0, 1, true) : 0.f;
1922  const double gj_angle_diff = calculateGottfriedJacksonAngleDifference(tau, tau_index, tau_funcs);
1923  const bool tau_gj_angle_diff_valid = (std::isnormal(gj_angle_diff) || gj_angle_diff == 0) && gj_angle_diff >= 0;
1924  get(dnn::tau_gj_angle_diff_valid) = tau_gj_angle_diff_valid;
1925  get(dnn::tau_gj_angle_diff) = tau_gj_angle_diff_valid ? getValueLinear(gj_angle_diff, 0, pi, true) : 0;
1926  get(dnn::tau_n_photons) = getValueNorm(reco::tau::n_photons_total(tau), 2.95f, 3.927f);
1927  get(dnn::tau_emFraction) = getValueLinear(tau_funcs.getEmFraction(tau), -1, 1, false);
1928 
1929  get(dnn::tau_inside_ecal_crack) = getValue(isInEcalCrack(tau.p4().eta()));
1930  get(dnn::leadChargedCand_etaAtEcalEntrance_minus_tau_eta) =
1931  getValueNorm(tau_funcs.getEtaAtEcalEntrance(tau) - tau.p4().eta(), 0.0042f, 0.0323f);
1932  }

References funct::abs(), calculateGottfriedJacksonAngleDifference(), disable_dxy_pca_, reco::tau::eratio(), f, get, getValue(), getValueLinear(), getValueNorm(), PixelMapPlotter::inputs, deep_tau::DeepTauBase::is_online_, isAbove(), isInEcalCrack(), reco::tau::n_photons_total(), pi, reco::tau::pt_weighted_deta_strip(), reco::tau::pt_weighted_dphi_strip(), reco::tau::pt_weighted_dr_iso(), reco::tau::pt_weighted_dr_signal(), rho, ZElectronSkim_cff::rho, metsig::tau, runTauDisplay::tau_eta, runTauDisplay::tau_mass, runTauDisplay::tau_phi, runTauDisplay::tau_pt, and tauBlockTensor_.

◆ fillDescriptions()

static void DeepTauId::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 1147 of file DeepTauId.cc.

1147  {
1149  desc.add<edm::InputTag>("electrons", edm::InputTag("slimmedElectrons"));
1150  desc.add<edm::InputTag>("muons", edm::InputTag("slimmedMuons"));
1151  desc.add<edm::InputTag>("taus", edm::InputTag("slimmedTaus"));
1152  desc.add<edm::InputTag>("pfcands", edm::InputTag("packedPFCandidates"));
1153  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"));
1154  desc.add<edm::InputTag>("rho", edm::InputTag("fixedGridRhoAll"));
1155  desc.add<std::vector<std::string>>("graph_file",
1156  {"RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6.pb"});
1157  desc.add<bool>("mem_mapped", false);
1158  desc.add<unsigned>("version", 2);
1159  desc.add<int>("debug_level", 0);
1160  desc.add<bool>("disable_dxy_pca", false);
1161  desc.add<bool>("disable_hcalFraction_workaround", false);
1162  desc.add<bool>("disable_CellIndex_workaround", false);
1163  desc.add<bool>("save_inputs", false);
1164  desc.add<bool>("is_online", false);
1165 
1166  desc.add<std::vector<std::string>>("VSeWP");
1167  desc.add<std::vector<std::string>>("VSmuWP");
1168  desc.add<std::vector<std::string>>("VSjetWP");
1169 
1170  desc.addUntracked<edm::InputTag>("basicTauDiscriminators", edm::InputTag("basicTauDiscriminators"));
1171  desc.addUntracked<edm::InputTag>("basicTauDiscriminatorsdR03", edm::InputTag("basicTauDiscriminatorsdR03"));
1172  desc.add<edm::InputTag>("pfTauTransverseImpactParameters", edm::InputTag("hpsPFTauTransverseImpactParameters"));
1173 
1174  {
1175  edm::ParameterSetDescription pset_Prediscriminants;
1176  pset_Prediscriminants.add<std::string>("BooleanOperator", "and");
1177  {
1179  psd1.add<double>("cut");
1180  psd1.add<edm::InputTag>("Producer");
1181  pset_Prediscriminants.addOptional<edm::ParameterSetDescription>("decayMode", psd1);
1182  }
1183  desc.add<edm::ParameterSetDescription>("Prediscriminants", pset_Prediscriminants);
1184  }
1185 
1186  descriptions.add("DeepTau", desc);
1187  }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ fillGrids()

template<typename Collection , typename TauCastType >
void DeepTauId::fillGrids ( const TauCastType &  tau,
const Collection &  objects,
CellGrid &  inner_grid,
CellGrid &  outer_grid 
)
inlineprivate

Definition at line 1676 of file DeepTauId.cc.

1676  {
1677  static constexpr double outer_dR2 = 0.25; //0.5^2
1678  const double inner_radius = getInnerSignalConeRadius(tau.polarP4().pt());
1679  const double inner_dR2 = std::pow(inner_radius, 2);
1680 
1681  const auto addObject = [&](size_t n, double deta, double dphi, CellGrid& grid) {
1682  const auto& obj = objects.at(n);
1683  const CellObjectType obj_type = GetCellObjectType(obj);
1684  if (obj_type == CellObjectType::Other)
1685  return;
1686  CellIndex cell_index;
1687  if (grid.tryGetCellIndex(deta, dphi, cell_index)) {
1688  Cell& cell = grid[cell_index];
1689  auto iter = cell.find(obj_type);
1690  if (iter != cell.end()) {
1691  const auto& prev_obj = objects.at(iter->second);
1692  if (obj.polarP4().pt() > prev_obj.polarP4().pt())
1693  iter->second = n;
1694  } else {
1695  cell[obj_type] = n;
1696  }
1697  }
1698  };
1699 
1700  for (size_t n = 0; n < objects.size(); ++n) {
1701  const auto& obj = objects.at(n);
1702  const double deta = obj.polarP4().eta() - tau.polarP4().eta();
1703  const double dphi = reco::deltaPhi(obj.polarP4().phi(), tau.polarP4().phi());
1704  const double dR2 = std::pow(deta, 2) + std::pow(dphi, 2);
1705  if (dR2 < inner_dR2)
1706  addObject(n, deta, dphi, inner_grid);
1707  if (dR2 < outer_dR2)
1708  addObject(n, deta, dphi, outer_grid);
1709  }
1710  }

References reco::deltaPhi(), getInnerSignalConeRadius(), getRunAppsInfo::grid, dqmiodumpmetadata::n, getGTfromDQMFile::obj, funct::pow(), and metsig::tau.

Referenced by getPredictionsV2().

◆ findMatchedElectron()

template<typename TauCastType >
static const pat::Electron* DeepTauId::findMatchedElectron ( const TauCastType &  tau,
const std::vector< pat::Electron > *  electrons,
double  deltaR 
)
inlinestaticprivate

Definition at line 2782 of file DeepTauId.cc.

2784  {
2785  const double dR2 = deltaR * deltaR;
2786  const pat::Electron* matched_ele = nullptr;
2787  for (const auto& ele : *electrons) {
2788  if (reco::deltaR2(tau.p4(), ele.p4()) < dR2 && (!matched_ele || matched_ele->pt() < ele.pt())) {
2789  matched_ele = &ele;
2790  }
2791  }
2792  return matched_ele;
2793  }

References PbPb_ZMuSkimMuonDPG_cff::deltaR, reco::deltaR2(), pwdgSkimBPark_cfi::electrons, reco::LeafCandidate::pt(), and metsig::tau.

Referenced by createInputsV1().

◆ getInnerSignalConeRadius()

static double DeepTauId::getInnerSignalConeRadius ( double  pt)
inlinestaticprivate

Definition at line 2737 of file DeepTauId.cc.

2737  {
2738  static constexpr double min_pt = 30., min_radius = 0.05, cone_opening_coef = 3.;
2739  // This is equivalent of the original formula (std::max(std::min(0.1, 3.0/pt), 0.05)
2740  return std::max(cone_opening_coef / std::max(pt, min_pt), min_radius);
2741  }

References SiStripPI::max, cosmictrackSelector_cfi::min_pt, and DiDispStaMuonMonitor_cfi::pt.

Referenced by fillGrids(), and processSignalPFComponents().

◆ GetOutputs()

static const OutputCollection& DeepTauId::GetOutputs ( )
inlinestatic

Definition at line 1105 of file DeepTauId.cc.

1105  {
1106  static constexpr size_t e_index = 0, mu_index = 1, tau_index = 2, jet_index = 3;
1107  static const OutputCollection outputs_ = {
1108  {"VSe", Output({tau_index}, {e_index, tau_index})},
1109  {"VSmu", Output({tau_index}, {mu_index, tau_index})},
1110  {"VSjet", Output({tau_index}, {jet_index, tau_index})},
1111  };
1112  return outputs_;
1113  }

References GetRecoTauVFromDQM_MC_cff::Output, and deep_tau::DeepTauBase::outputs_.

◆ getPartialPredictions()

tensorflow::Tensor DeepTauId::getPartialPredictions ( bool  is_inner)
inlineprivate

Definition at line 1712 of file DeepTauId.cc.

1712  {
1713  std::vector<tensorflow::Tensor> pred_vector;
1714  if (is_inner) {
1715  tensorflow::run(&(cache_->getSession("inner")),
1716  {
1717  {"input_inner_egamma", *eGammaTensor_.at(is_inner)},
1718  {"input_inner_muon", *muonTensor_.at(is_inner)},
1719  {"input_inner_hadrons", *hadronsTensor_.at(is_inner)},
1720  },
1721  {"inner_all_dropout_4/Identity"},
1722  &pred_vector);
1723  } else {
1724  tensorflow::run(&(cache_->getSession("outer")),
1725  {
1726  {"input_outer_egamma", *eGammaTensor_.at(is_inner)},
1727  {"input_outer_muon", *muonTensor_.at(is_inner)},
1728  {"input_outer_hadrons", *hadronsTensor_.at(is_inner)},
1729  },
1730  {"outer_all_dropout_4/Identity"},
1731  &pred_vector);
1732  }
1733  return pred_vector.at(0);
1734  }

References deep_tau::DeepTauBase::cache_, eGammaTensor_, deep_tau::DeepTauCache::getSession(), hadronsTensor_, muonTensor_, and tensorflow::run().

Referenced by createConvFeatures(), and DeepTauId().

◆ getPredictions()

tensorflow::Tensor DeepTauId::getPredictions ( edm::Event event,
edm::Handle< TauCollection taus 
)
inlineoverrideprivatevirtual

Implements deep_tau::DeepTauBase.

Definition at line 1423 of file DeepTauId.cc.

1423  {
1424  // Empty dummy vectors
1425  const std::vector<pat::Electron> electron_collection_default;
1426  const std::vector<pat::Muon> muon_collection_default;
1427  const reco::TauDiscriminatorContainer basicTauDiscriminators_default;
1428  const reco::TauDiscriminatorContainer basicTauDiscriminatorsdR03_default;
1430  pfTauTransverseImpactParameters_default;
1431 
1432  const std::vector<pat::Electron>* electron_collection;
1433  const std::vector<pat::Muon>* muon_collection;
1434  const reco::TauDiscriminatorContainer* basicTauDiscriminators;
1435  const reco::TauDiscriminatorContainer* basicTauDiscriminatorsdR03;
1437  pfTauTransverseImpactParameters;
1438 
1439  if (!is_online_) {
1440  electron_collection = &event.get(electrons_token_);
1441  muon_collection = &event.get(muons_token_);
1442  pfTauTransverseImpactParameters = &pfTauTransverseImpactParameters_default;
1443  basicTauDiscriminators = &basicTauDiscriminators_default;
1444  basicTauDiscriminatorsdR03 = &basicTauDiscriminatorsdR03_default;
1445  } else {
1446  electron_collection = &electron_collection_default;
1447  muon_collection = &muon_collection_default;
1448  pfTauTransverseImpactParameters = &event.get(pfTauTransverseImpactParameters_token_);
1449  basicTauDiscriminators = &event.get(basicTauDiscriminators_inputToken_);
1450  basicTauDiscriminatorsdR03 = &event.get(basicTauDiscriminatorsdR03_inputToken_);
1451 
1452  // Get indices for discriminators
1453  if (!discrIndicesMapped_) {
1458  discrIndicesMapped_ = true;
1459  }
1460  }
1461 
1462  TauFunc tauIDs = {basicTauDiscriminators,
1463  basicTauDiscriminatorsdR03,
1464  pfTauTransverseImpactParameters,
1467 
1469  event.getByToken(pfcandToken_, pfCands);
1470 
1472  event.getByToken(vtxToken_, vertices);
1473 
1475  event.getByToken(rho_token_, rho);
1476 
1477  tensorflow::Tensor predictions(tensorflow::DT_FLOAT, {static_cast<int>(taus->size()), deep_tau::NumberOfOutputs});
1478 
1479  for (size_t tau_index = 0; tau_index < taus->size(); ++tau_index) {
1480  const edm::RefToBase<reco::BaseTau> tauRef = taus->refAt(tau_index);
1481 
1482  std::vector<tensorflow::Tensor> pred_vector;
1483 
1484  bool passesPrediscriminants;
1485  if (is_online_) {
1486  passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<reco::PFTauDiscriminator>>>(
1488  } else {
1489  passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<pat::PATTauDiscriminator>>>(
1491  }
1492 
1493  if (passesPrediscriminants) {
1494  if (version_ == 1) {
1495  if (is_online_)
1496  getPredictionsV1<reco::PFCandidate, reco::PFTau>(
1497  taus->at(tau_index), tau_index, tauRef, electron_collection, muon_collection, pred_vector, tauIDs);
1498  else
1499  getPredictionsV1<pat::PackedCandidate, pat::Tau>(
1500  taus->at(tau_index), tau_index, tauRef, electron_collection, muon_collection, pred_vector, tauIDs);
1501  } else if (version_ == 2) {
1502  if (is_online_) {
1503  getPredictionsV2<reco::PFCandidate, reco::PFTau>(taus->at(tau_index),
1504  tau_index,
1505  tauRef,
1506  electron_collection,
1507  muon_collection,
1508  *pfCands,
1509  vertices->at(0),
1510  *rho,
1511  pred_vector,
1512  tauIDs);
1513  } else
1514  getPredictionsV2<pat::PackedCandidate, pat::Tau>(taus->at(tau_index),
1515  tau_index,
1516  tauRef,
1517  electron_collection,
1518  muon_collection,
1519  *pfCands,
1520  vertices->at(0),
1521  *rho,
1522  pred_vector,
1523  tauIDs);
1524  } else {
1525  throw cms::Exception("DeepTauId") << "version " << version_ << " is not supported.";
1526  }
1527 
1528  for (int k = 0; k < deep_tau::NumberOfOutputs; ++k) {
1529  const float pred = pred_vector[0].flat<float>()(k);
1530  if (!(pred >= 0 && pred <= 1))
1531  throw cms::Exception("DeepTauId")
1532  << "invalid prediction = " << pred << " for tau_index = " << tau_index << ", pred_index = " << k;
1533  predictions.matrix<float>()(tau_index, k) = pred;
1534  }
1535  }
1536  }
1537  return predictions;
1538  }

References deep_tau::DeepTauBase::andPrediscriminants_, basicDiscrdR03IndexMap_, basicDiscrIndexMap_, basicTauDiscriminators_inputToken_, basicTauDiscriminatorsdR03_inputToken_, discrIndicesMapped_, electrons_token_, Exception, edm::ValueMap< T >::get(), deep_tau::DeepTauBase::is_online_, dqmdumpme::k, matchDiscriminatorIndices(), muons_token_, deep_tau::NumberOfOutputs, deep_tau::DeepTauBase::patPrediscriminants_, deep_tau::DeepTauBase::pfcandToken_, pfTauTransverseImpactParameters_token_, deep_tau::DeepTauBase::recoPrediscriminants_, deep_tau::DeepTauBase::requiredBasicDiscriminators_, deep_tau::DeepTauBase::requiredBasicDiscriminatorsdR03_, rho, rho_token_, Tau3MuMonitor_cff::taus, version_, pwdgSkimBPark_cfi::vertices, and deep_tau::DeepTauBase::vtxToken_.

◆ getPredictionsV1()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::getPredictionsV1 ( TauCollection::const_reference tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
std::vector< tensorflow::Tensor > &  pred_vector,
TauFunc  tau_funcs 
)
inlineprivate

Definition at line 1541 of file DeepTauId.cc.

1547  {
1548  const tensorflow::Tensor& inputs = createInputsV1<dnn_inputs_2017v1, const CandidateCastType>(
1549  dynamic_cast<const TauCastType&>(tau), tau_index, tau_ref, electrons, muons, tau_funcs);
1550  tensorflow::run(&(cache_->getSession()), {{input_layer_, inputs}}, {output_layer_}, &pred_vector);
1551  }

References deep_tau::DeepTauBase::cache_, pwdgSkimBPark_cfi::electrons, deep_tau::DeepTauCache::getSession(), input_layer_, PixelMapPlotter::inputs, PDWG_BPHSkim_cff::muons, output_layer_, tensorflow::run(), and metsig::tau.

◆ getPredictionsV2()

template<typename CandidateCastType , typename TauCastType >
void DeepTauId::getPredictionsV2 ( TauCollection::const_reference tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
const edm::View< reco::Candidate > &  pfCands,
const reco::Vertex pv,
double  rho,
std::vector< tensorflow::Tensor > &  pred_vector,
TauFunc  tau_funcs 
)
inlineprivate

Definition at line 1554 of file DeepTauId.cc.

1563  {
1564  if (debug_level >= 2) {
1565  std::cout << "<DeepTauId::getPredictionsV2 (moduleLabel = " << moduleDescription().moduleLabel()
1566  << ")>:" << std::endl;
1567  std::cout << " tau: pT = " << tau.pt() << ", eta = " << tau.eta() << ", phi = " << tau.phi() << std::endl;
1568  }
1569  CellGrid inner_grid(dnn_inputs_2017_v2::number_of_inner_cell,
1570  dnn_inputs_2017_v2::number_of_inner_cell,
1571  0.02,
1572  0.02,
1574  CellGrid outer_grid(dnn_inputs_2017_v2::number_of_outer_cell,
1575  dnn_inputs_2017_v2::number_of_outer_cell,
1576  0.05,
1577  0.05,
1579  fillGrids(dynamic_cast<const TauCastType&>(tau), *electrons, inner_grid, outer_grid);
1580  fillGrids(dynamic_cast<const TauCastType&>(tau), *muons, inner_grid, outer_grid);
1581  fillGrids(dynamic_cast<const TauCastType&>(tau), pfCands, inner_grid, outer_grid);
1582 
1583  createTauBlockInputs<CandidateCastType>(
1584  dynamic_cast<const TauCastType&>(tau), tau_index, tau_ref, pv, rho, tau_funcs);
1585  using namespace dnn_inputs_2017_v2;
1586  checkInputs(*tauBlockTensor_, "input_tau", TauBlockInputs::NumberOfInputs);
1587  createConvFeatures<CandidateCastType>(dynamic_cast<const TauCastType&>(tau),
1588  tau_index,
1589  tau_ref,
1590  pv,
1591  rho,
1592  electrons,
1593  muons,
1594  pfCands,
1595  inner_grid,
1596  tau_funcs,
1597  true);
1598  checkInputs(*eGammaTensor_[true], "input_inner_egamma", EgammaBlockInputs::NumberOfInputs, &inner_grid);
1599  checkInputs(*muonTensor_[true], "input_inner_muon", MuonBlockInputs::NumberOfInputs, &inner_grid);
1600  checkInputs(*hadronsTensor_[true], "input_inner_hadrons", HadronBlockInputs::NumberOfInputs, &inner_grid);
1601  createConvFeatures<CandidateCastType>(dynamic_cast<const TauCastType&>(tau),
1602  tau_index,
1603  tau_ref,
1604  pv,
1605  rho,
1606  electrons,
1607  muons,
1608  pfCands,
1609  outer_grid,
1610  tau_funcs,
1611  false);
1612  checkInputs(*eGammaTensor_[false], "input_outer_egamma", EgammaBlockInputs::NumberOfInputs, &outer_grid);
1613  checkInputs(*muonTensor_[false], "input_outer_muon", MuonBlockInputs::NumberOfInputs, &outer_grid);
1614  checkInputs(*hadronsTensor_[false], "input_outer_hadrons", HadronBlockInputs::NumberOfInputs, &outer_grid);
1615 
1616  if (save_inputs_) {
1617  std::string json_file_name = "DeepTauId_" + std::to_string(file_counter_) + ".json";
1618  json_file_ = new std::ofstream(json_file_name.data());
1619  is_first_block_ = true;
1620  (*json_file_) << "{";
1621  saveInputs(*tauBlockTensor_, "input_tau", dnn_inputs_2017_v2::TauBlockInputs::NumberOfInputs);
1622  saveInputs(*eGammaTensor_[true],
1623  "input_inner_egamma",
1624  dnn_inputs_2017_v2::EgammaBlockInputs::NumberOfInputs,
1625  &inner_grid);
1626  saveInputs(
1627  *muonTensor_[true], "input_inner_muon", dnn_inputs_2017_v2::MuonBlockInputs::NumberOfInputs, &inner_grid);
1628  saveInputs(*hadronsTensor_[true],
1629  "input_inner_hadrons",
1630  dnn_inputs_2017_v2::HadronBlockInputs::NumberOfInputs,
1631  &inner_grid);
1632  saveInputs(*eGammaTensor_[false],
1633  "input_outer_egamma",
1634  dnn_inputs_2017_v2::EgammaBlockInputs::NumberOfInputs,
1635  &outer_grid);
1636  saveInputs(
1637  *muonTensor_[false], "input_outer_muon", dnn_inputs_2017_v2::MuonBlockInputs::NumberOfInputs, &outer_grid);
1638  saveInputs(*hadronsTensor_[false],
1639  "input_outer_hadrons",
1640  dnn_inputs_2017_v2::HadronBlockInputs::NumberOfInputs,
1641  &outer_grid);
1642  (*json_file_) << "}";
1643  delete json_file_;
1644  ++file_counter_;
1645  }
1646 
1647  tensorflow::run(&(cache_->getSession("core")),
1648  {{"input_tau", *tauBlockTensor_},
1649  {"input_inner", *convTensor_.at(true)},
1650  {"input_outer", *convTensor_.at(false)}},
1651  {"main_output/Softmax"},
1652  &pred_vector);
1653  if (debug_level >= 1) {
1654  std::cout << "output = { ";
1655  for (int idx = 0; idx < deep_tau::NumberOfOutputs; ++idx) {
1656  if (idx > 0)
1657  std::cout << ", ";
1659  if (idx == 0)
1660  label = "e";
1661  else if (idx == 1)
1662  label = "mu";
1663  else if (idx == 2)
1664  label = "tau";
1665  else if (idx == 3)
1666  label = "jet";
1667  else
1668  assert(0);
1669  std::cout << label << " = " << pred_vector[0].flat<float>()(idx);
1670  }
1671  std::cout << " }" << std::endl;
1672  }
1673  }

References cms::cuda::assert(), deep_tau::DeepTauBase::cache_, checkInputs(), convTensor_, gather_cfg::cout, debug_level, disable_CellIndex_workaround_, eGammaTensor_, pwdgSkimBPark_cfi::electrons, file_counter_, fillGrids(), deep_tau::DeepTauCache::getSession(), hadronsTensor_, heavyIonCSV_trainingSettings::idx, is_first_block_, json_file_, label, PDWG_BPHSkim_cff::muons, muonTensor_, deep_tau::NumberOfOutputs, MetAnalyzer::pv(), rho, tensorflow::run(), save_inputs_, saveInputs(), AlCaHLTBitMon_QueryRunRegistry::string, metsig::tau, and tauBlockTensor_.

◆ getValue()

template<typename T >
static float DeepTauId::getValue ( T  value)
inlinestaticprivate

Definition at line 1260 of file DeepTauId.cc.

1260  {
1261  return std::isnormal(value) ? static_cast<float>(value) : 0.f;
1262  }

Referenced by createEgammaBlockInputs(), createHadronsBlockInputs(), createMuonBlockInputs(), createTauBlockInputs(), getValueLinear(), and getValueNorm().

◆ getValueLinear()

template<typename T >
static float DeepTauId::getValueLinear ( T  value,
float  min_value,
float  max_value,
bool  positive 
)
inlinestaticprivate

Definition at line 1265 of file DeepTauId.cc.

1265  {
1266  const float fixed_value = getValue(value);
1267  const float clamped_value = std::clamp(fixed_value, min_value, max_value);
1268  float transformed_value = (clamped_value - min_value) / (max_value - min_value);
1269  if (!positive)
1270  transformed_value = transformed_value * 2 - 1;
1271  return transformed_value;
1272  }

References getValue(), hcaldqm::quantity::max_value, and hcaldqm::quantity::min_value.

Referenced by createEgammaBlockInputs(), createHadronsBlockInputs(), createMuonBlockInputs(), and createTauBlockInputs().

◆ getValueNorm()

template<typename T >
static float DeepTauId::getValueNorm ( T  value,
float  mean,
float  sigma,
float  n_sigmas_max = 5 
)
inlinestaticprivate

Definition at line 1275 of file DeepTauId.cc.

1275  {
1276  const float fixed_value = getValue(value);
1277  const float norm_value = (fixed_value - mean) / sigma;
1278  return std::clamp(norm_value, -n_sigmas_max, n_sigmas_max);
1279  }

References getValue(), and SiStripPI::mean.

Referenced by createEgammaBlockInputs(), createHadronsBlockInputs(), createMuonBlockInputs(), and createTauBlockInputs().

◆ globalEndJob()

static void DeepTauId::globalEndJob ( const deep_tau::DeepTauCache cache_)
inlinestatic

Definition at line 1254 of file DeepTauId.cc.

1254 { return DeepTauBase::globalEndJob(cache_); }

References deep_tau::DeepTauBase::cache_.

◆ initializeGlobalCache()

static std::unique_ptr<deep_tau::DeepTauCache> DeepTauId::initializeGlobalCache ( const edm::ParameterSet cfg)
inlinestatic

Definition at line 1250 of file DeepTauId.cc.

1250  {
1251  return DeepTauBase::initializeGlobalCache(cfg);
1252  }

References looper::cfg.

◆ isAbove()

static bool DeepTauId::isAbove ( double  value,
double  min 
)
inlinestaticprivate

Definition at line 1281 of file DeepTauId.cc.

1281 { return std::isnormal(value) && value > min; }

References min().

Referenced by createTauBlockInputs().

◆ isInEcalCrack()

static bool DeepTauId::isInEcalCrack ( double  eta)
inlinestaticprivate

Definition at line 2776 of file DeepTauId.cc.

2776  {
2777  const double abs_eta = std::abs(eta);
2778  return abs_eta > 1.46 && abs_eta < 1.558;
2779  }

References funct::abs(), and PVValHelper::eta.

Referenced by createEgammaBlockInputs(), createHadronsBlockInputs(), createInputsV1(), createMuonBlockInputs(), and createTauBlockInputs().

◆ matchDiscriminatorIndices()

const std::map<BasicDiscriminator, size_t> DeepTauId::matchDiscriminatorIndices ( edm::Event event,
edm::EDGetTokenT< reco::TauDiscriminatorContainer discriminatorContainerToken,
std::vector< BasicDiscriminator requiredDiscr 
)
inline

Definition at line 1115 of file DeepTauId.cc.

1118  {
1119  std::map<std::string, size_t> discrIndexMapStr;
1120  auto const aHandle = event.getHandle(discriminatorContainerToken);
1121  auto const aProv = aHandle.provenance();
1122  if (aProv == nullptr)
1123  aHandle.whyFailed()->raise();
1124  const auto& psetsFromProvenance = edm::parameterSet(aProv->stable(), event.processHistory());
1125  auto const idlist = psetsFromProvenance.getParameter<std::vector<edm::ParameterSet>>("IDdefinitions");
1126  for (size_t j = 0; j < idlist.size(); ++j) {
1127  std::string idname = idlist[j].getParameter<std::string>("IDname");
1128  if (discrIndexMapStr.count(idname)) {
1129  throw cms::Exception("DeepTauId")
1130  << "basic discriminator " << idname << " appears more than once in the input.";
1131  }
1132  discrIndexMapStr[idname] = j;
1133  }
1134 
1135  //translate to a map of <BasicDiscriminator, index> and check if all discriminators are present
1136  std::map<BasicDiscriminator, size_t> discrIndexMap;
1137  for (size_t i = 0; i < requiredDiscr.size(); i++) {
1138  if (discrIndexMapStr.find(stringFromDiscriminator_.at(requiredDiscr[i])) == discrIndexMapStr.end())
1139  throw cms::Exception("DeepTauId") << "Basic Discriminator " << stringFromDiscriminator_.at(requiredDiscr[i])
1140  << " was not provided in the config file.";
1141  else
1142  discrIndexMap[requiredDiscr[i]] = discrIndexMapStr[stringFromDiscriminator_.at(requiredDiscr[i])];
1143  }
1144  return discrIndexMap;
1145  }

References Exception, edm::ParameterSet::getParameter(), mps_fire::i, dqmiolumiharvest::j, edm::parameterSet(), AlCaHLTBitMon_QueryRunRegistry::string, and deep_tau::DeepTauBase::stringFromDiscriminator_.

Referenced by getPredictions().

◆ processIsolationPFComponents()

template<typename CandidateCollection , typename TauCastType >
static void DeepTauId::processIsolationPFComponents ( const TauCastType &  tau,
const CandidateCollection candidates,
LorentzVectorXYZ p4,
float &  pt,
float &  d_eta,
float &  d_phi,
float &  m,
float &  n 
)
inlinestaticprivate

Definition at line 2715 of file DeepTauId.cc.

2722  {
2723  p4 = LorentzVectorXYZ(0, 0, 0, 0);
2724  n = 0;
2725 
2726  for (const auto& cand : candidates) {
2727  p4 += cand->p4();
2728  ++n;
2729  }
2730 
2731  pt = n != 0 ? p4.Pt() : default_value;
2732  d_eta = n != 0 ? dEta(p4, tau.p4()) : default_value;
2733  d_phi = n != 0 ? dPhi(p4, tau.p4()) : default_value;
2734  m = n != 0 ? p4.mass() : default_value;
2735  }

References HLT_FULL_cff::candidates, default_value, HLT_FULL_cff::dEta, HLT_FULL_cff::dPhi, visualization-live-secondInstance_cfg::m, dqmiodumpmetadata::n, p4, DiDispStaMuonMonitor_cfi::pt, and metsig::tau.

Referenced by createInputsV1().

◆ processSignalPFComponents()

template<typename CandidateCollection , typename TauCastType >
static void DeepTauId::processSignalPFComponents ( const TauCastType &  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 2671 of file DeepTauId.cc.

2684  {
2685  p4_inner = LorentzVectorXYZ(0, 0, 0, 0);
2686  p4_outer = LorentzVectorXYZ(0, 0, 0, 0);
2687  n_inner = 0;
2688  n_outer = 0;
2689 
2690  const double innerSigCone_radius = getInnerSignalConeRadius(tau.pt());
2691  for (const auto& cand : candidates) {
2692  const double dR = reco::deltaR(cand->p4(), tau.leadChargedHadrCand()->p4());
2693  const bool isInside_innerSigCone = dR < innerSigCone_radius;
2694  if (isInside_innerSigCone) {
2695  p4_inner += cand->p4();
2696  ++n_inner;
2697  } else {
2698  p4_outer += cand->p4();
2699  ++n_outer;
2700  }
2701  }
2702 
2703  pt_inner = n_inner != 0 ? p4_inner.Pt() : default_value;
2704  dEta_inner = n_inner != 0 ? dEta(p4_inner, tau.p4()) : default_value;
2705  dPhi_inner = n_inner != 0 ? dPhi(p4_inner, tau.p4()) : default_value;
2706  m_inner = n_inner != 0 ? p4_inner.mass() : default_value;
2707 
2708  pt_outer = n_outer != 0 ? p4_outer.Pt() : default_value;
2709  dEta_outer = n_outer != 0 ? dEta(p4_outer, tau.p4()) : default_value;
2710  dPhi_outer = n_outer != 0 ? dPhi(p4_outer, tau.p4()) : default_value;
2711  m_outer = n_outer != 0 ? p4_outer.mass() : default_value;
2712  }

References HLT_FULL_cff::candidates, default_value, reco::deltaR(), HLT_FULL_cff::dEta, HLT_FULL_cff::dPhi, HGC3DClusterGenMatchSelector_cfi::dR, getInnerSignalConeRadius(), and metsig::tau.

Referenced by createInputsV1().

◆ saveInputs()

void DeepTauId::saveInputs ( const tensorflow::Tensor &  inputs,
const std::string &  block_name,
int  n_inputs,
const CellGrid *  grid = nullptr 
)
inlineprivate

Definition at line 1362 of file DeepTauId.cc.

1365  {
1366  if (debug_level >= 1) {
1367  std::cout << "<saveInputs>: block_name = " << block_name << std::endl;
1368  }
1369  if (!is_first_block_)
1370  (*json_file_) << ", ";
1371  (*json_file_) << "\"" << block_name << "\": [";
1372  if (block_name == "input_tau") {
1373  for (int input_index = 0; input_index < n_inputs; ++input_index) {
1374  float input = inputs.matrix<float>()(0, input_index);
1375  if (input_index != 0)
1376  (*json_file_) << ", ";
1377  (*json_file_) << input;
1378  }
1379  } else {
1380  assert(grid);
1381  int n_eta, n_phi;
1382  if (block_name.find("input_inner") != std::string::npos) {
1383  n_eta = 5;
1384  n_phi = 5;
1385  } else if (block_name.find("input_outer") != std::string::npos) {
1386  n_eta = 10;
1387  n_phi = 10;
1388  } else
1389  assert(0);
1390  int eta_phi_index = 0;
1391  for (int eta = -n_eta; eta <= n_eta; ++eta) {
1392  if (eta != -n_eta)
1393  (*json_file_) << ", ";
1394  (*json_file_) << "[";
1395  for (int phi = -n_phi; phi <= n_phi; ++phi) {
1396  if (phi != -n_phi)
1397  (*json_file_) << ", ";
1398  (*json_file_) << "[";
1399  const CellIndex cell_index{eta, phi};
1400  const auto cell_iter = grid->find(cell_index);
1401  for (int input_index = 0; input_index < n_inputs; ++input_index) {
1402  float input = 0.;
1403  if (cell_iter != grid->end()) {
1404  input = inputs.tensor<float, 4>()(eta_phi_index, 0, 0, input_index);
1405  }
1406  if (input_index != 0)
1407  (*json_file_) << ", ";
1408  (*json_file_) << input;
1409  }
1410  if (cell_iter != grid->end()) {
1411  eta_phi_index += 1;
1412  }
1413  (*json_file_) << "]";
1414  }
1415  (*json_file_) << "]";
1416  }
1417  }
1418  (*json_file_) << "]";
1419  is_first_block_ = false;
1420  }

References cms::cuda::assert(), gather_cfg::cout, debug_level, PVValHelper::eta, dqmMemoryStats::float, getRunAppsInfo::grid, input, PixelMapPlotter::inputs, is_first_block_, and phi.

Referenced by getPredictionsV2().

◆ setCellConvFeatures()

void DeepTauId::setCellConvFeatures ( tensorflow::Tensor &  convTensor,
const tensorflow::Tensor &  features,
unsigned  batch_idx,
int  eta_index,
int  phi_index 
)
inlineprivate

Definition at line 1818 of file DeepTauId.cc.

1822  {
1823  for (int n = 0; n < dnn_inputs_2017_v2::number_of_conv_features; ++n) {
1824  convTensor.tensor<float, 4>()(0, eta_index, phi_index, n) = features.tensor<float, 4>()(batch_idx, 0, 0, n);
1825  }
1826  }

References postprocess-scan-build::features, dqmMemoryStats::float, and dqmiodumpmetadata::n.

Referenced by createConvFeatures(), and DeepTauId().

Member Data Documentation

◆ basicDiscrdR03IndexMap_

std::map<BasicDiscriminator, size_t> DeepTauId::basicDiscrdR03IndexMap_
private

Definition at line 2820 of file DeepTauId.cc.

Referenced by getPredictions().

◆ basicDiscrIndexMap_

std::map<BasicDiscriminator, size_t> DeepTauId::basicDiscrIndexMap_
private

Definition at line 2819 of file DeepTauId.cc.

Referenced by getPredictions().

◆ basicTauDiscriminators_inputToken_

edm::EDGetTokenT<reco::TauDiscriminatorContainer> DeepTauId::basicTauDiscriminators_inputToken_
private

Definition at line 2799 of file DeepTauId.cc.

Referenced by getPredictions().

◆ basicTauDiscriminatorsdR03_inputToken_

edm::EDGetTokenT<reco::TauDiscriminatorContainer> DeepTauId::basicTauDiscriminatorsdR03_inputToken_
private

Definition at line 2800 of file DeepTauId.cc.

Referenced by getPredictions().

◆ convTensor_

std::array<std::unique_ptr<tensorflow::Tensor>, 2> DeepTauId::convTensor_
private

Definition at line 2810 of file DeepTauId.cc.

Referenced by createConvFeatures(), DeepTauId(), and getPredictionsV2().

◆ debug_level

const int DeepTauId::debug_level
private

Definition at line 2805 of file DeepTauId.cc.

Referenced by checkInputs(), createConvFeatures(), getPredictionsV2(), and saveInputs().

◆ default_value

constexpr float DeepTauId::default_value = -999.
staticconstexpr

◆ disable_CellIndex_workaround_

const bool DeepTauId::disable_CellIndex_workaround_
private

Definition at line 2808 of file DeepTauId.cc.

Referenced by getPredictionsV2().

◆ disable_dxy_pca_

const bool DeepTauId::disable_dxy_pca_
private

Definition at line 2806 of file DeepTauId.cc.

Referenced by createTauBlockInputs().

◆ disable_hcalFraction_workaround_

const bool DeepTauId::disable_hcalFraction_workaround_
private

Definition at line 2807 of file DeepTauId.cc.

Referenced by createHadronsBlockInputs().

◆ discrIndicesMapped_

bool DeepTauId::discrIndicesMapped_ = false
private

Definition at line 2818 of file DeepTauId.cc.

Referenced by getPredictions().

◆ eGammaTensor_

std::array<std::unique_ptr<tensorflow::Tensor>, 2> DeepTauId::eGammaTensor_
private

◆ electrons_token_

edm::EDGetTokenT<std::vector<pat::Electron> > DeepTauId::electrons_token_
private

Definition at line 2796 of file DeepTauId.cc.

Referenced by getPredictions().

◆ file_counter_

int DeepTauId::file_counter_
private

Definition at line 2815 of file DeepTauId.cc.

Referenced by getPredictionsV2().

◆ hadronsTensor_

std::array<std::unique_ptr<tensorflow::Tensor>, 2> DeepTauId::hadronsTensor_
private

◆ input_layer_

std::string DeepTauId::input_layer_
private

Definition at line 2803 of file DeepTauId.cc.

Referenced by DeepTauId(), and getPredictionsV1().

◆ is_first_block_

bool DeepTauId::is_first_block_
private

Definition at line 2814 of file DeepTauId.cc.

Referenced by getPredictionsV2(), and saveInputs().

◆ json_file_

std::ofstream* DeepTauId::json_file_
private

Definition at line 2813 of file DeepTauId.cc.

Referenced by getPredictionsV2().

◆ muons_token_

edm::EDGetTokenT<std::vector<pat::Muon> > DeepTauId::muons_token_
private

Definition at line 2797 of file DeepTauId.cc.

Referenced by getPredictions().

◆ muonTensor_

std::array<std::unique_ptr<tensorflow::Tensor>, 2> DeepTauId::muonTensor_
private

◆ output_layer_

std::string DeepTauId::output_layer_
private

Definition at line 2803 of file DeepTauId.cc.

Referenced by DeepTauId(), and getPredictionsV1().

◆ pfTauTransverseImpactParameters_token_

edm::EDGetTokenT<edm::AssociationVector<reco::PFTauRefProd, std::vector<reco::PFTauTransverseImpactParameterRef> > > DeepTauId::pfTauTransverseImpactParameters_token_
private

Definition at line 2802 of file DeepTauId.cc.

Referenced by getPredictions().

◆ pi

constexpr float DeepTauId::pi = M_PI
staticconstexprprivate

Definition at line 1257 of file DeepTauId.cc.

Referenced by createTauBlockInputs().

◆ rho_token_

edm::EDGetTokenT<double> DeepTauId::rho_token_
private

Definition at line 2798 of file DeepTauId.cc.

Referenced by getPredictions().

◆ save_inputs_

const bool DeepTauId::save_inputs_
private

Definition at line 2812 of file DeepTauId.cc.

Referenced by getPredictionsV2().

◆ tauBlockTensor_

std::unique_ptr<tensorflow::Tensor> DeepTauId::tauBlockTensor_
private

Definition at line 2809 of file DeepTauId.cc.

Referenced by createTauBlockInputs(), DeepTauId(), and getPredictionsV2().

◆ version_

const unsigned DeepTauId::version_
private

Definition at line 2804 of file DeepTauId.cc.

Referenced by DeepTauId(), and getPredictions().

◆ zeroOutputTensor_

std::array<std::unique_ptr<tensorflow::Tensor>, 2> DeepTauId::zeroOutputTensor_
private

Definition at line 2810 of file DeepTauId.cc.

Referenced by createConvFeatures(), and DeepTauId().

edm::RefProd
Definition: EDProductfwd.h:25
reco::tau::pt_weighted_deta_strip
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
Definition: PFRecoTauClusterVariables.h:36
deep_tau::DeepTauBase::cache_
const DeepTauCache * cache_
Definition: DeepTauBase.h:135
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
deep_tau::DeepTauBase::patPrediscriminants_
std::vector< TauDiscInfo< pat::PATTauDiscriminator > > patPrediscriminants_
Definition: DeepTauBase.h:112
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
DeepTauId::rho_token_
edm::EDGetTokenT< double > rho_token_
Definition: DeepTauId.cc:2798
dnn_inputs_2017_v2
Definition: DeepTauId.cc:159
DeepTauId::calculateElectronClusterVars
static void calculateElectronClusterVars(const pat::Electron *ele, float &elecEe, float &elecEgamma)
Definition: DeepTauId.cc:2651
mps_fire.i
i
Definition: mps_fire.py:428
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
DeepTauId::getInnerSignalConeRadius
static double getInnerSignalConeRadius(double pt)
Definition: DeepTauId.cc:2737
input
static const std::string input
Definition: EdmProvDump.cc:48
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
deep_tau::DeepTauCache::getSession
tensorflow::Session & getSession(const std::string &name="") const
Definition: DeepTauBase.h:57
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
deep_tau::DeepTauBase::pfcandToken_
edm::EDGetTokenT< CandidateCollection > pfcandToken_
Definition: DeepTauBase.h:130
runTauDisplay.tau_eta
tau_eta
Definition: runTauDisplay.py:126
dnn_inputs_2017_v2::MuonBlockInputs
Definition: DeepTauId.cc:308
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
metsig::tau
Definition: SignAlgoResolutions.h:49
muon
Definition: MuonCocktails.h:17
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
DeepTauId::isInEcalCrack
static bool isInEcalCrack(double eta)
Definition: DeepTauId.cc:2776
DeepTauId::pi
static constexpr float pi
Definition: DeepTauId.cc:1257
DeepTauId::getValue
static float getValue(T value)
Definition: DeepTauId.cc:1260
DeepTauId::setCellConvFeatures
void setCellConvFeatures(tensorflow::Tensor &convTensor, const tensorflow::Tensor &features, unsigned batch_idx, int eta_index, int phi_index)
Definition: DeepTauId.cc:1818
DeepTauId::version_
const unsigned version_
Definition: DeepTauId.cc:2804
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
min
T min(T a, T b)
Definition: MathUtil.h:58
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
postprocess-scan-build.features
features
Definition: postprocess-scan-build.py:8
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
relativeConstraints.station
station
Definition: relativeConstraints.py:67
reco::tau::eratio
float eratio(const reco::PFTau &tau)
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
Definition: PFRecoTauClusterVariables.cc:78
deep_tau::DeepTauBase::OutputCollection
std::map< std::string, Output > OutputCollection
Definition: DeepTauBase.h:91
gather_cfg.cout
cout
Definition: gather_cfg.py:144
DeepTauId::matchDiscriminatorIndices
const std::map< BasicDiscriminator, size_t > matchDiscriminatorIndices(edm::Event &event, edm::EDGetTokenT< reco::TauDiscriminatorContainer > discriminatorContainerToken, std::vector< BasicDiscriminator > requiredDiscr)
Definition: DeepTauId.cc:1115
objects
Definition: __init__.py:1
ZElectronSkim_cff.rho
rho
Definition: ZElectronSkim_cff.py:38
DeepTauId::hadronsTensor_
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > hadronsTensor_
Definition: DeepTauId.cc:2810
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
DeepTauId::debug_level
const int debug_level
Definition: DeepTauId.cc:2805
deep_tau::DeepTauBase::requiredBasicDiscriminatorsdR03_
static const std::vector< BasicDiscriminator > requiredBasicDiscriminatorsdR03_
Definition: DeepTauBase.h:139
DeepTauId::getValueNorm
static float getValueNorm(T value, float mean, float sigma, float n_sigmas_max=5)
Definition: DeepTauId.cc:1275
getRunAppsInfo.grid
grid
Definition: getRunAppsInfo.py:92
cms::cuda::assert
assert(be >=bs)
deep_tau::DeepTauBase::vtxToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: DeepTauBase.h:131
DeepTauId::muons_token_
edm::EDGetTokenT< std::vector< pat::Muon > > muons_token_
Definition: DeepTauId.cc:2797
deep_tau::DeepTauBase::LorentzVectorXYZ
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > LorentzVectorXYZ
Definition: DeepTauBase.h:75
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13703
DeepTauId::disable_dxy_pca_
const bool disable_dxy_pca_
Definition: DeepTauId.cc:2806
edm::Handle
Definition: AssociativeIterator.h:50
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
DeepTauId::zeroOutputTensor_
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > zeroOutputTensor_
Definition: DeepTauId.cc:2810
DeepTauId::basicDiscrIndexMap_
std::map< BasicDiscriminator, size_t > basicDiscrIndexMap_
Definition: DeepTauId.cc:2819
deep_tau::NumberOfOutputs
constexpr int NumberOfOutputs
Definition: DeepTauId.cc:19
cosmictrackSelector_cfi.min_pt
min_pt
Definition: cosmictrackSelector_cfi.py:18
GetRecoTauVFromDQM_MC_cff.Output
Output
Definition: GetRecoTauVFromDQM_MC_cff.py:12
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
DeepTauId::default_value
static constexpr float default_value
Definition: DeepTauId.cc:1103
ndof
Definition: HIMultiTrackSelector.h:49
DeepTauId::json_file_
std::ofstream * json_file_
Definition: DeepTauId.cc:2813
deep_tau::DeepTauBase::DeepTauBase
DeepTauBase(const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
Definition: DeepTauBase.cc:86
reco::tau::pt_weighted_dphi_strip
float pt_weighted_dphi_strip(const reco::PFTau &tau, int dm)
Definition: PFRecoTauClusterVariables.h:44
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DeepTauId::processIsolationPFComponents
static void processIsolationPFComponents(const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
Definition: DeepTauId.cc:2715
deep_tau::DeepTauBase::requiredBasicDiscriminators_
static const std::vector< BasicDiscriminator > requiredBasicDiscriminators_
Definition: DeepTauBase.h:138
PVValHelper::eta
Definition: PVValidationHelpers.h:70
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DeepTauId::basicTauDiscriminators_inputToken_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_inputToken_
Definition: DeepTauId.cc:2799
dnn_inputs_2017_v2::HadronBlockInputs
Definition: DeepTauId.cc:378
deep_tau::DeepTauBase::is_online_
const bool is_online_
Definition: DeepTauBase.h:133
DeepTauId::checkInputs
void checkInputs(const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr) const
Definition: DeepTauId.cc:1306
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
DeepTauId::getValueLinear
static float getValueLinear(T value, float min_value, float max_value, bool positive)
Definition: DeepTauId.cc:1265
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
DeepTauId::findMatchedElectron
static const pat::Electron * findMatchedElectron(const TauCastType &tau, const std::vector< pat::Electron > *electrons, double deltaR)
Definition: DeepTauId.cc:2782
dqmdumpme.k
k
Definition: dqmdumpme.py:60
hcaldqm::quantity::min_value
const std::map< ValueQuantityType, double > min_value
Definition: ValueQuantity.h:130
DeepTauId::file_counter_
int file_counter_
Definition: DeepTauId.cc:2815
DeepTauId::convTensor_
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > convTensor_
Definition: DeepTauId.cc:2810
DeepTauId::calculateElectronClusterVarsV2
static bool calculateElectronClusterVarsV2(const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)
Definition: DeepTauId.cc:1283
taus_cff.decayMode
decayMode
Definition: taus_cff.py:58
utilities.cache
def cache(function)
Definition: utilities.py:3
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
DeepTauId::disable_hcalFraction_workaround_
const bool disable_hcalFraction_workaround_
Definition: DeepTauId.cc:2807
runTauDisplay.tau_phi
tau_phi
Definition: runTauDisplay.py:127
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::AssociationVector
Definition: AssociationVector.h:67
DeepTauId::basicTauDiscriminatorsdR03_inputToken_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminatorsdR03_inputToken_
Definition: DeepTauId.cc:2800
deep_tau::DeepTauBase::outputs_
OutputCollection outputs_
Definition: DeepTauBase.h:134
edm::View::at
const_reference at(size_type pos) const
DeepTauId::calculateGottfriedJacksonAngleDifference
static bool calculateGottfriedJacksonAngleDifference(const TauCastType &tau, const size_t tau_index, double &gj_diff, TauFunc tau_funcs)
Definition: DeepTauId.cc:2745
DeepTauId::pfTauTransverseImpactParameters_token_
edm::EDGetTokenT< edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > > pfTauTransverseImpactParameters_token_
Definition: DeepTauId.cc:2802
candFunc
Definition: DeepTauId.cc:612
DeepTauId::isAbove
static bool isAbove(double value, double min)
Definition: DeepTauId.cc:1281
DeepTauId::output_layer_
std::string output_layer_
Definition: DeepTauId.cc:2803
Cell
Definition: LogEleMapdb.h:8
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
dnn_inputs_2017_v2::EgammaBlockInputs
Definition: DeepTauId.cc:216
deep_tau::DeepTauBase::stringFromDiscriminator_
static const std::map< BasicDiscriminator, std::string > stringFromDiscriminator_
Definition: DeepTauBase.h:137
reco::tau::n_photons_total
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
Definition: PFRecoTauClusterVariables.cc:163
cand
Definition: decayParser.h:32
electrons_cff.ip3d
ip3d
Definition: electrons_cff.py:357
runTauDisplay.tau_mass
tau_mass
Definition: runTauDisplay.py:128
createfilelist.int
int
Definition: createfilelist.py:10
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
dumpRecoGeometry_cfg.Muon
Muon
Definition: dumpRecoGeometry_cfg.py:190
DeepTauId::disable_CellIndex_workaround_
const bool disable_CellIndex_workaround_
Definition: DeepTauId.cc:2808
p4
double p4[4]
Definition: TauolaWrapper.h:92
value
Definition: value.py:1
pat::Muon::PV2D
Definition: Muon.h:237
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
DeepTauId::GetOutputs
static const OutputCollection & GetOutputs()
Definition: DeepTauId.cc:1105
DeepTauId::eGammaTensor_
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > eGammaTensor_
Definition: DeepTauId.cc:2810
get
#define get
DeepTauId::tauBlockTensor_
std::unique_ptr< tensorflow::Tensor > tauBlockTensor_
Definition: DeepTauId.cc:2809
looper.cfg
cfg
Definition: looper.py:297
nanoDQM_cff.Electron
Electron
Definition: nanoDQM_cff.py:62
DDAxes::phi
edm::ValueMap::get
const_reference_type get(ProductID id, size_t idx) const
Definition: ValueMap.h:144
DeepTauId::is_first_block_
bool is_first_block_
Definition: DeepTauId.cc:2814
DeepTauId::basicDiscrdR03IndexMap_
std::map< BasicDiscriminator, size_t > basicDiscrdR03IndexMap_
Definition: DeepTauId.cc:2820
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
hcaldqm::quantity::max_value
const std::map< ValueQuantityType, double > max_value
Definition: ValueQuantity.h:190
PVValHelper::dxy
Definition: PVValidationHelpers.h:48
pat::Electron::superCluster
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
DeepTauId::muonTensor_
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > muonTensor_
Definition: DeepTauId.cc:2810
DeepTauId::electrons_token_
edm::EDGetTokenT< std::vector< pat::Electron > > electrons_token_
Definition: DeepTauId.cc:2796
PVValHelper::dz
Definition: PVValidationHelpers.h:51
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13702
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
deep_tau::DeepTauBase::recoPrediscriminants_
std::vector< TauDiscInfo< reco::PFTauDiscriminator > > recoPrediscriminants_
Definition: DeepTauBase.h:113
CellObjectType
CellObjectType
Definition: DeepTauId.cc:964
HLT_FULL_cff.candidates
candidates
Definition: HLT_FULL_cff.py:54996
edm::ValueMap
Definition: ValueMap.h:107
runTauDisplay.tau_pt
tau_pt
Definition: runTauDisplay.py:125
Exception
Definition: hltDiff.cc:245
reco::tau::pt_weighted_dr_signal
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
Definition: PFRecoTauClusterVariables.h:32
DeepTauId::saveInputs
void saveInputs(const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr)
Definition: DeepTauId.cc:1362
tensorflow::run
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
Definition: TensorFlow.cc:213
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
DeepTauId::input_layer_
std::string input_layer_
Definition: DeepTauId.cc:2803
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
reco::tau::pt_weighted_dr_iso
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
Definition: PFRecoTauClusterVariables.h:52
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
edm::RefToBase
Definition: AssociativeIterator.h:54
DeepTauId::fillGrids
void fillGrids(const TauCastType &tau, const Collection &objects, CellGrid &inner_grid, CellGrid &outer_grid)
Definition: DeepTauId.cc:1676
DeepTauId::save_inputs_
const bool save_inputs_
Definition: DeepTauId.cc:2812
deep_tau::DeepTauBase::andPrediscriminants_
uint8_t andPrediscriminants_
Definition: DeepTauBase.h:111
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
cms::Exception
Definition: Exception.h:70
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
dnn_inputs_2017_v2::TauBlockInputs
Definition: DeepTauId.cc:163
edm::InputTag
Definition: InputTag.h:15
DeepTauId::getPartialPredictions
tensorflow::Tensor getPartialPredictions(bool is_inner)
Definition: DeepTauId.cc:1712
label
const char * label
Definition: PFTauDecayModeTools.cc:11
deep_tau::DeepTauCache::getGraph
const tensorflow::GraphDef & getGraph(const std::string &name="") const
Definition: DeepTauBase.h:58
DeepTauId::discrIndicesMapped_
bool discrIndicesMapped_
Definition: DeepTauId.cc:2818
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
DeepTauId::processSignalPFComponents
static void processSignalPFComponents(const TauCastType &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:2671