1432 int PFe_index_offset =
scalingParamsMap_->at(std::make_pair(ft_global,
false)).mean_.size();
1433 int e_index_offset = PFe_index_offset +
scalingParamsMap_->at(std::make_pair(ft_PFe,
false)).mean_.size();
1434 int PFg_index_offset = e_index_offset +
scalingParamsMap_->at(std::make_pair(ft_e,
false)).mean_.size();
1437 int fill_index_offset_e = 0;
1438 int fill_index_offset_PFg = 0;
1440 fill_index_offset_e =
1442 fill_index_offset_PFg =
1446 const auto&
get = [&](
int var_index) ->
float& {
1447 if constexpr (std::is_same_v<EgammaBlockType, std::vector<float>::iterator>) {
1448 return *(egammaBlockInputs + var_index);
1450 return ((tensorflow::Tensor)egammaBlockInputs).tensor<float, 4>()(
idx, 0, 0, var_index);
1454 const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
1455 const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
1458 if (!cell_map.empty()) {
1459 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_global,
false));
1463 get(dnn::tau_inside_ecal_crack) = sp.scale(
isInEcalCrack(
tau.polarP4().eta()), dnn::tau_inside_ecal_crack);
1465 if (valid_index_pf_ele) {
1466 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFe, is_inner));
1467 size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
1468 const auto& ele_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_pf_ele));
1470 get(dnn::pfCand_ele_valid) = sp.scale(valid_index_pf_ele, dnn::pfCand_ele_valid - PFe_index_offset);
1471 get(dnn::pfCand_ele_rel_pt) =
1472 sp.scale(ele_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_ele_rel_pt - PFe_index_offset);
1473 get(dnn::pfCand_ele_deta) =
1474 sp.scale(ele_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_ele_deta - PFe_index_offset);
1475 get(dnn::pfCand_ele_dphi) =
1476 sp.scale(
dPhi(
tau.polarP4(), ele_cand.polarP4()), dnn::pfCand_ele_dphi - PFe_index_offset);
1477 get(dnn::pfCand_ele_pvAssociationQuality) = sp.scale<
int>(
1478 candFunc::getPvAssocationQuality(ele_cand), dnn::pfCand_ele_pvAssociationQuality - PFe_index_offset);
1479 get(dnn::pfCand_ele_puppiWeight) = is_inner ? sp.scale(candFunc::getPuppiWeight(ele_cand, 0.9906834f),
1480 dnn::pfCand_ele_puppiWeight - PFe_index_offset)
1481 : sp.scale(candFunc::getPuppiWeight(ele_cand, 0.9669586
f),
1482 dnn::pfCand_ele_puppiWeight - PFe_index_offset);
1483 get(dnn::pfCand_ele_charge) = sp.scale(ele_cand.charge(), dnn::pfCand_ele_charge - PFe_index_offset);
1484 get(dnn::pfCand_ele_lostInnerHits) =
1485 sp.scale<
int>(candFunc::getLostInnerHits(ele_cand, 0), dnn::pfCand_ele_lostInnerHits - PFe_index_offset);
1486 get(dnn::pfCand_ele_numberOfPixelHits) =
1487 sp.scale(candFunc::getNumberOfPixelHits(ele_cand, 0), dnn::pfCand_ele_numberOfPixelHits - PFe_index_offset);
1488 get(dnn::pfCand_ele_vertex_dx) =
1489 sp.scale(ele_cand.vertex().x() -
pv.position().x(), dnn::pfCand_ele_vertex_dx - PFe_index_offset);
1490 get(dnn::pfCand_ele_vertex_dy) =
1491 sp.scale(ele_cand.vertex().y() -
pv.position().y(), dnn::pfCand_ele_vertex_dy - PFe_index_offset);
1492 get(dnn::pfCand_ele_vertex_dz) =
1493 sp.scale(ele_cand.vertex().z() -
pv.position().z(), dnn::pfCand_ele_vertex_dz - PFe_index_offset);
1494 get(dnn::pfCand_ele_vertex_dx_tauFL) =
1495 sp.scale(ele_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
1496 dnn::pfCand_ele_vertex_dx_tauFL - PFe_index_offset);
1497 get(dnn::pfCand_ele_vertex_dy_tauFL) =
1498 sp.scale(ele_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
1499 dnn::pfCand_ele_vertex_dy_tauFL - PFe_index_offset);
1500 get(dnn::pfCand_ele_vertex_dz_tauFL) =
1501 sp.scale(ele_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
1502 dnn::pfCand_ele_vertex_dz_tauFL - PFe_index_offset);
1504 const bool hasTrackDetails = candFunc::getHasTrackDetails(ele_cand);
1505 if (hasTrackDetails) {
1506 get(dnn::pfCand_ele_hasTrackDetails) =
1507 sp.scale(hasTrackDetails, dnn::pfCand_ele_hasTrackDetails - PFe_index_offset);
1508 get(dnn::pfCand_ele_dxy) = sp.scale(candFunc::getTauDxy(ele_cand), dnn::pfCand_ele_dxy - PFe_index_offset);
1509 get(dnn::pfCand_ele_dxy_sig) = sp.scale(
std::abs(candFunc::getTauDxy(ele_cand)) / ele_cand.dxyError(),
1510 dnn::pfCand_ele_dxy_sig - PFe_index_offset);
1511 get(dnn::pfCand_ele_dz) = sp.scale(candFunc::getTauDz(ele_cand), dnn::pfCand_ele_dz - PFe_index_offset);
1512 get(dnn::pfCand_ele_dz_sig) = sp.scale(
std::abs(candFunc::getTauDz(ele_cand)) / ele_cand.dzError(),
1513 dnn::pfCand_ele_dz_sig - PFe_index_offset);
1514 get(dnn::pfCand_ele_track_chi2_ndof) =
1515 candFunc::getPseudoTrack(ele_cand).ndof() > 0
1516 ? sp.scale(candFunc::getPseudoTrack(ele_cand).
chi2() / candFunc::getPseudoTrack(ele_cand).
ndof(),
1517 dnn::pfCand_ele_track_chi2_ndof - PFe_index_offset)
1519 get(dnn::pfCand_ele_track_ndof) =
1520 candFunc::getPseudoTrack(ele_cand).ndof() > 0
1521 ? sp.scale(candFunc::getPseudoTrack(ele_cand).
ndof(), dnn::pfCand_ele_track_ndof - PFe_index_offset)
1525 if (valid_index_pf_gamma) {
1526 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFg, is_inner));
1527 size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
1528 const auto& gamma_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_pf_gamma));
1530 get(dnn::pfCand_gamma_valid + fill_index_offset_PFg) =
1531 sp.scale(valid_index_pf_gamma, dnn::pfCand_gamma_valid - PFg_index_offset);
1532 get(dnn::pfCand_gamma_rel_pt + fill_index_offset_PFg) =
1533 sp.scale(gamma_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_gamma_rel_pt - PFg_index_offset);
1534 get(dnn::pfCand_gamma_deta + fill_index_offset_PFg) =
1535 sp.scale(gamma_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_gamma_deta - PFg_index_offset);
1536 get(dnn::pfCand_gamma_dphi + fill_index_offset_PFg) =
1537 sp.scale(
dPhi(
tau.polarP4(), gamma_cand.polarP4()), dnn::pfCand_gamma_dphi - PFg_index_offset);
1538 get(dnn::pfCand_gamma_pvAssociationQuality + fill_index_offset_PFg) = sp.scale<
int>(
1539 candFunc::getPvAssocationQuality(gamma_cand), dnn::pfCand_gamma_pvAssociationQuality - PFg_index_offset);
1540 get(dnn::pfCand_gamma_fromPV + fill_index_offset_PFg) =
1541 sp.scale<
int>(candFunc::getFromPV(gamma_cand), dnn::pfCand_gamma_fromPV - PFg_index_offset);
1542 get(dnn::pfCand_gamma_puppiWeight + fill_index_offset_PFg) =
1543 is_inner ? sp.scale(candFunc::getPuppiWeight(gamma_cand, 0.9084110f),
1544 dnn::pfCand_gamma_puppiWeight - PFg_index_offset)
1545 : sp.scale(candFunc::getPuppiWeight(gamma_cand, 0.4211567
f),
1546 dnn::pfCand_gamma_puppiWeight - PFg_index_offset);
1547 get(dnn::pfCand_gamma_puppiWeightNoLep + fill_index_offset_PFg) =
1548 is_inner ? sp.scale(candFunc::getPuppiWeightNoLep(gamma_cand, 0.8857716f),
1549 dnn::pfCand_gamma_puppiWeightNoLep - PFg_index_offset)
1550 : sp.scale(candFunc::getPuppiWeightNoLep(gamma_cand, 0.3822604
f),
1551 dnn::pfCand_gamma_puppiWeightNoLep - PFg_index_offset);
1552 get(dnn::pfCand_gamma_lostInnerHits + fill_index_offset_PFg) =
1553 sp.scale<
int>(candFunc::getLostInnerHits(gamma_cand, 0), dnn::pfCand_gamma_lostInnerHits - PFg_index_offset);
1554 get(dnn::pfCand_gamma_numberOfPixelHits + fill_index_offset_PFg) = sp.scale(
1555 candFunc::getNumberOfPixelHits(gamma_cand, 0), dnn::pfCand_gamma_numberOfPixelHits - PFg_index_offset);
1556 get(dnn::pfCand_gamma_vertex_dx + fill_index_offset_PFg) =
1557 sp.scale(gamma_cand.vertex().x() -
pv.position().x(), dnn::pfCand_gamma_vertex_dx - PFg_index_offset);
1558 get(dnn::pfCand_gamma_vertex_dy + fill_index_offset_PFg) =
1559 sp.scale(gamma_cand.vertex().y() -
pv.position().y(), dnn::pfCand_gamma_vertex_dy - PFg_index_offset);
1560 get(dnn::pfCand_gamma_vertex_dz + fill_index_offset_PFg) =
1561 sp.scale(gamma_cand.vertex().z() -
pv.position().z(), dnn::pfCand_gamma_vertex_dz - PFg_index_offset);
1562 get(dnn::pfCand_gamma_vertex_dx_tauFL + fill_index_offset_PFg) =
1563 sp.scale(gamma_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
1564 dnn::pfCand_gamma_vertex_dx_tauFL - PFg_index_offset);
1565 get(dnn::pfCand_gamma_vertex_dy_tauFL + fill_index_offset_PFg) =
1566 sp.scale(gamma_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
1567 dnn::pfCand_gamma_vertex_dy_tauFL - PFg_index_offset);
1568 get(dnn::pfCand_gamma_vertex_dz_tauFL + fill_index_offset_PFg) =
1569 sp.scale(gamma_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
1570 dnn::pfCand_gamma_vertex_dz_tauFL - PFg_index_offset);
1571 const bool hasTrackDetails = candFunc::getHasTrackDetails(gamma_cand);
1572 if (hasTrackDetails) {
1573 get(dnn::pfCand_gamma_hasTrackDetails + fill_index_offset_PFg) =
1574 sp.scale(hasTrackDetails, dnn::pfCand_gamma_hasTrackDetails - PFg_index_offset);
1575 get(dnn::pfCand_gamma_dxy + fill_index_offset_PFg) =
1576 sp.scale(candFunc::getTauDxy(gamma_cand), dnn::pfCand_gamma_dxy - PFg_index_offset);
1577 get(dnn::pfCand_gamma_dxy_sig + fill_index_offset_PFg) =
1578 sp.scale(
std::abs(candFunc::getTauDxy(gamma_cand)) / gamma_cand.dxyError(),
1579 dnn::pfCand_gamma_dxy_sig - PFg_index_offset);
1580 get(dnn::pfCand_gamma_dz + fill_index_offset_PFg) =
1581 sp.scale(candFunc::getTauDz(gamma_cand), dnn::pfCand_gamma_dz - PFg_index_offset);
1582 get(dnn::pfCand_gamma_dz_sig + fill_index_offset_PFg) =
1583 sp.scale(
std::abs(candFunc::getTauDz(gamma_cand)) / gamma_cand.dzError(),
1584 dnn::pfCand_gamma_dz_sig - PFg_index_offset);
1585 get(dnn::pfCand_gamma_track_chi2_ndof + fill_index_offset_PFg) =
1586 candFunc::getPseudoTrack(gamma_cand).ndof() > 0
1587 ? sp.scale(candFunc::getPseudoTrack(gamma_cand).
chi2() / candFunc::getPseudoTrack(gamma_cand).
ndof(),
1588 dnn::pfCand_gamma_track_chi2_ndof - PFg_index_offset)
1590 get(dnn::pfCand_gamma_track_ndof + fill_index_offset_PFg) =
1591 candFunc::getPseudoTrack(gamma_cand).ndof() > 0
1592 ? sp.scale(candFunc::getPseudoTrack(gamma_cand).
ndof(), dnn::pfCand_gamma_track_ndof - PFg_index_offset)
1596 if (valid_index_ele) {
1597 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_e, is_inner));
1599 const auto& ele =
electrons->at(index_ele);
1601 get(dnn::ele_valid + fill_index_offset_e) = sp.scale(valid_index_ele, dnn::ele_valid - e_index_offset);
1602 get(dnn::ele_rel_pt + fill_index_offset_e) =
1603 sp.scale(ele.polarP4().pt() /
tau.polarP4().pt(), dnn::ele_rel_pt - e_index_offset);
1604 get(dnn::ele_deta + fill_index_offset_e) =
1605 sp.scale(ele.polarP4().eta() -
tau.polarP4().eta(), dnn::ele_deta - e_index_offset);
1606 get(dnn::ele_dphi + fill_index_offset_e) =
1607 sp.scale(
dPhi(
tau.polarP4(), ele.polarP4()), dnn::ele_dphi - e_index_offset);
1609 float cc_ele_energy, cc_gamma_energy;
1613 get(dnn::ele_cc_valid + fill_index_offset_e) = sp.scale(cc_valid, dnn::ele_cc_valid - e_index_offset);
1614 get(dnn::ele_cc_ele_rel_energy + fill_index_offset_e) =
1615 sp.scale(cc_ele_energy / ele.polarP4().pt(), dnn::ele_cc_ele_rel_energy - e_index_offset);
1616 get(dnn::ele_cc_gamma_rel_energy + fill_index_offset_e) =
1617 sp.scale(cc_gamma_energy / cc_ele_energy, dnn::ele_cc_gamma_rel_energy - e_index_offset);
1618 get(dnn::ele_cc_n_gamma + fill_index_offset_e) = sp.scale(cc_n_gamma, dnn::ele_cc_n_gamma - e_index_offset);
1620 get(dnn::ele_rel_trackMomentumAtVtx + fill_index_offset_e) =
1621 sp.scale(ele.trackMomentumAtVtx().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtVtx - e_index_offset);
1622 get(dnn::ele_rel_trackMomentumAtCalo + fill_index_offset_e) = sp.scale(
1623 ele.trackMomentumAtCalo().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtCalo - e_index_offset);
1624 get(dnn::ele_rel_trackMomentumOut + fill_index_offset_e) =
1625 sp.scale(ele.trackMomentumOut().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumOut - e_index_offset);
1626 get(dnn::ele_rel_trackMomentumAtEleClus + fill_index_offset_e) = sp.scale(
1627 ele.trackMomentumAtEleClus().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtEleClus - e_index_offset);
1628 get(dnn::ele_rel_trackMomentumAtVtxWithConstraint + fill_index_offset_e) =
1629 sp.scale(ele.trackMomentumAtVtxWithConstraint().R() / ele.polarP4().pt(),
1630 dnn::ele_rel_trackMomentumAtVtxWithConstraint - e_index_offset);
1631 get(dnn::ele_rel_ecalEnergy + fill_index_offset_e) =
1632 sp.scale(ele.ecalEnergy() / ele.polarP4().pt(), dnn::ele_rel_ecalEnergy - e_index_offset);
1633 get(dnn::ele_ecalEnergy_sig + fill_index_offset_e) =
1634 sp.scale(ele.ecalEnergy() / ele.ecalEnergyError(), dnn::ele_ecalEnergy_sig - e_index_offset);
1635 get(dnn::ele_eSuperClusterOverP + fill_index_offset_e) =
1636 sp.scale(ele.eSuperClusterOverP(), dnn::ele_eSuperClusterOverP - e_index_offset);
1637 get(dnn::ele_eSeedClusterOverP + fill_index_offset_e) =
1638 sp.scale(ele.eSeedClusterOverP(), dnn::ele_eSeedClusterOverP - e_index_offset);
1639 get(dnn::ele_eSeedClusterOverPout + fill_index_offset_e) =
1640 sp.scale(ele.eSeedClusterOverPout(), dnn::ele_eSeedClusterOverPout - e_index_offset);
1641 get(dnn::ele_eEleClusterOverPout + fill_index_offset_e) =
1642 sp.scale(ele.eEleClusterOverPout(), dnn::ele_eEleClusterOverPout - e_index_offset);
1643 get(dnn::ele_deltaEtaSuperClusterTrackAtVtx + fill_index_offset_e) =
1644 sp.scale(ele.deltaEtaSuperClusterTrackAtVtx(), dnn::ele_deltaEtaSuperClusterTrackAtVtx - e_index_offset);
1645 get(dnn::ele_deltaEtaSeedClusterTrackAtCalo + fill_index_offset_e) =
1646 sp.scale(ele.deltaEtaSeedClusterTrackAtCalo(), dnn::ele_deltaEtaSeedClusterTrackAtCalo - e_index_offset);
1647 get(dnn::ele_deltaEtaEleClusterTrackAtCalo + fill_index_offset_e) =
1648 sp.scale(ele.deltaEtaEleClusterTrackAtCalo(), dnn::ele_deltaEtaEleClusterTrackAtCalo - e_index_offset);
1649 get(dnn::ele_deltaPhiEleClusterTrackAtCalo + fill_index_offset_e) =
1650 sp.scale(ele.deltaPhiEleClusterTrackAtCalo(), dnn::ele_deltaPhiEleClusterTrackAtCalo - e_index_offset);
1651 get(dnn::ele_deltaPhiSuperClusterTrackAtVtx + fill_index_offset_e) =
1652 sp.scale(ele.deltaPhiSuperClusterTrackAtVtx(), dnn::ele_deltaPhiSuperClusterTrackAtVtx - e_index_offset);
1653 get(dnn::ele_deltaPhiSeedClusterTrackAtCalo + fill_index_offset_e) =
1654 sp.scale(ele.deltaPhiSeedClusterTrackAtCalo(), dnn::ele_deltaPhiSeedClusterTrackAtCalo - e_index_offset);
1655 const bool mva_valid =
1656 (ele.mvaInput().earlyBrem > -2) ||
1660 get(dnn::ele_mvaInput_earlyBrem + fill_index_offset_e) =
1661 sp.scale(ele.mvaInput().earlyBrem, dnn::ele_mvaInput_earlyBrem - e_index_offset);
1662 get(dnn::ele_mvaInput_lateBrem + fill_index_offset_e) =
1663 sp.scale(ele.mvaInput().lateBrem, dnn::ele_mvaInput_lateBrem - e_index_offset);
1664 get(dnn::ele_mvaInput_sigmaEtaEta + fill_index_offset_e) =
1665 sp.scale(ele.mvaInput().sigmaEtaEta, dnn::ele_mvaInput_sigmaEtaEta - e_index_offset);
1666 get(dnn::ele_mvaInput_hadEnergy + fill_index_offset_e) =
1667 sp.scale(ele.mvaInput().hadEnergy, dnn::ele_mvaInput_hadEnergy - e_index_offset);
1668 get(dnn::ele_mvaInput_deltaEta + fill_index_offset_e) =
1669 sp.scale(ele.mvaInput().deltaEta, dnn::ele_mvaInput_deltaEta - e_index_offset);
1671 const auto& gsfTrack = ele.gsfTrack();
1672 if (gsfTrack.isNonnull()) {
1673 get(dnn::ele_gsfTrack_normalizedChi2 + fill_index_offset_e) =
1674 sp.scale(gsfTrack->normalizedChi2(), dnn::ele_gsfTrack_normalizedChi2 - e_index_offset);
1675 get(dnn::ele_gsfTrack_numberOfValidHits + fill_index_offset_e) =
1676 sp.scale(gsfTrack->numberOfValidHits(), dnn::ele_gsfTrack_numberOfValidHits - e_index_offset);
1677 get(dnn::ele_rel_gsfTrack_pt + fill_index_offset_e) =
1678 sp.scale(gsfTrack->pt() / ele.polarP4().pt(), dnn::ele_rel_gsfTrack_pt - e_index_offset);
1679 get(dnn::ele_gsfTrack_pt_sig + fill_index_offset_e) =
1680 sp.scale(gsfTrack->pt() / gsfTrack->ptError(), dnn::ele_gsfTrack_pt_sig - e_index_offset);
1682 const auto& closestCtfTrack = ele.closestCtfTrackRef();
1683 const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
1684 if (has_closestCtfTrack) {
1685 get(dnn::ele_has_closestCtfTrack + fill_index_offset_e) =
1686 sp.scale(has_closestCtfTrack, dnn::ele_has_closestCtfTrack - e_index_offset);
1687 get(dnn::ele_closestCtfTrack_normalizedChi2 + fill_index_offset_e) =
1688 sp.scale(closestCtfTrack->normalizedChi2(), dnn::ele_closestCtfTrack_normalizedChi2 - e_index_offset);
1689 get(dnn::ele_closestCtfTrack_numberOfValidHits + fill_index_offset_e) =
1690 sp.scale(closestCtfTrack->numberOfValidHits(), dnn::ele_closestCtfTrack_numberOfValidHits - e_index_offset);
const std::map< std::pair< deep_tau::Scaling::FeatureT, bool >, deep_tau::Scaling::ScalingParams > * scalingParamsMap_
static bool isInEcalCrack(double eta)
static bool calculateElectronClusterVarsV2(const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)
Abs< T >::type abs(const T &t)
const_reference at(size_type pos) const
const unsigned sub_version_