972 inputs.flat<
float>().setZero();
974 const auto&
get = [&](
int var_index) ->
float& {
975 return inputs.tensor<
float,4>()(0, 0, 0, var_index);
978 const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
979 const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
982 if(!cell_map.empty()){
988 if(valid_index_pf_ele){
989 size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
991 get(dnn::pfCand_ele_valid) = valid_index_pf_ele;
992 get(dnn::pfCand_ele_rel_pt) =
getValueNorm(pfCands.at(index_pf_ele).polarP4().pt() /
tau.polarP4().pt(),
993 is_inner ? 0.9792f : 0.304f, is_inner ? 0.5383f : 1.845f);
994 get(dnn::pfCand_ele_deta) =
getValueLinear(pfCands.at(index_pf_ele).polarP4().eta() -
tau.polarP4().eta(),
995 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
997 is_inner ? -0.1
f : -0.5
f, is_inner ? 0.1
f : 0.5
f,
false);
998 get(dnn::pfCand_ele_pvAssociationQuality) = getValueLinear<int>(pfCands.at(index_pf_ele).pvAssociationQuality(), 0, 7,
true);
999 get(dnn::pfCand_ele_puppiWeight) =
getValue(pfCands.at(index_pf_ele).puppiWeight());
1000 get(dnn::pfCand_ele_charge) =
getValue(pfCands.at(index_pf_ele).charge());
1001 get(dnn::pfCand_ele_lostInnerHits) = getValue<int>(pfCands.at(index_pf_ele).lostInnerHits());
1002 get(dnn::pfCand_ele_numberOfPixelHits) =
getValueLinear(pfCands.at(index_pf_ele).numberOfPixelHits(), 0, 10,
true);
1003 get(dnn::pfCand_ele_vertex_dx) =
getValueNorm(pfCands.at(index_pf_ele).vertex().x() - pv.
position().x(), 0.f, 0.1221f);
1004 get(dnn::pfCand_ele_vertex_dy) =
getValueNorm(pfCands.at(index_pf_ele).vertex().y() - pv.
position().y(), 0.f, 0.1226f);
1005 get(dnn::pfCand_ele_vertex_dz) =
getValueNorm(pfCands.at(index_pf_ele).vertex().z() - pv.
position().z(), 0.001f, 1.024f);
1006 get(dnn::pfCand_ele_vertex_dx_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().x() -
1007 pv.
position().x() -
tau.flightLength().x(), 0.f, 0.3411f);
1008 get(dnn::pfCand_ele_vertex_dy_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().y() -
1009 pv.
position().y() -
tau.flightLength().y(), 0.0003f, 0.3385f);
1010 get(dnn::pfCand_ele_vertex_dz_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().z() -
1011 pv.
position().z() -
tau.flightLength().z(), 0.f, 1.307f);
1013 const bool hasTrackDetails = pfCands.at(index_pf_ele).hasTrackDetails();
1014 if(hasTrackDetails){
1015 get(dnn::pfCand_ele_hasTrackDetails) = hasTrackDetails;
1016 get(dnn::pfCand_ele_dxy) =
getValueNorm(pfCands.at(index_pf_ele).dxy(), 0.f, 0.171f);
1018 pfCands.at(index_pf_ele).dxyError(), 1.634f, 6.45f);
1019 get(dnn::pfCand_ele_dz) =
getValueNorm(pfCands.at(index_pf_ele).dz(), 0.001f, 1.02f);
1021 pfCands.at(index_pf_ele).dzError(), 24.56f, 210.4f);
1022 get(dnn::pfCand_ele_track_chi2_ndof) =
getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().chi2() /
1023 pfCands.at(index_pf_ele).pseudoTrack().ndof(), 2.272f, 8.439f);
1024 get(dnn::pfCand_ele_track_ndof) =
getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().ndof(), 15.18f, 3.203f);
1027 if(valid_index_pf_gamma){
1028 size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
1029 get(dnn::pfCand_gamma_valid) = valid_index_pf_gamma;
1030 get(dnn::pfCand_gamma_rel_pt) =
getValueNorm(pfCands.at(index_pf_gamma).polarP4().pt() /
tau.polarP4().pt(),
1031 is_inner ? 0.6048f : 0.02576f, is_inner ? 1.669f : 0.3833f);
1032 get(dnn::pfCand_gamma_deta) =
getValueLinear(pfCands.at(index_pf_gamma).polarP4().eta() -
tau.polarP4().eta(),
1033 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1034 get(dnn::pfCand_gamma_dphi) =
getValueLinear(
dPhi(
tau.polarP4(), pfCands.at(index_pf_gamma).polarP4()),
1035 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1036 get(dnn::pfCand_gamma_pvAssociationQuality) =
1037 getValueLinear<int>(pfCands.at(index_pf_gamma).pvAssociationQuality(), 0, 7,
true);
1038 get(dnn::pfCand_gamma_fromPV) = getValueLinear<int>(pfCands.at(index_pf_gamma).fromPV(), 0, 3,
true);
1039 get(dnn::pfCand_gamma_puppiWeight) =
getValue(pfCands.at(index_pf_gamma).puppiWeight());
1040 get(dnn::pfCand_gamma_puppiWeightNoLep) =
getValue(pfCands.at(index_pf_gamma).puppiWeightNoLep());
1041 get(dnn::pfCand_gamma_lostInnerHits) = getValue<int>(pfCands.at(index_pf_gamma).lostInnerHits());
1042 get(dnn::pfCand_gamma_numberOfPixelHits) =
getValueLinear(pfCands.at(index_pf_gamma).numberOfPixelHits(), 0, 7,
true);
1043 get(dnn::pfCand_gamma_vertex_dx) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().x() - pv.
position().x(), 0.f, 0.0067f);
1044 get(dnn::pfCand_gamma_vertex_dy) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().y() - pv.
position().y(), 0.f, 0.0069f);
1045 get(dnn::pfCand_gamma_vertex_dz) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().z() - pv.
position().z(), 0.f, 0.0578f);
1046 get(dnn::pfCand_gamma_vertex_dx_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().x() -
1047 pv.
position().x() -
tau.flightLength().x(), 0.001f, 0.9565f);
1048 get(dnn::pfCand_gamma_vertex_dy_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().y() -
1049 pv.
position().y() -
tau.flightLength().y(), 0.0008f, 0.9592f);
1050 get(dnn::pfCand_gamma_vertex_dz_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().z() -
1051 pv.
position().z() -
tau.flightLength().z(), 0.0038f, 2.154f);
1053 const bool hasTrackDetails = pfCands.at(index_pf_gamma).hasTrackDetails();
1054 if(hasTrackDetails){
1055 get(dnn::pfCand_gamma_hasTrackDetails) = hasTrackDetails;
1056 get(dnn::pfCand_gamma_dxy) =
getValueNorm(pfCands.at(index_pf_gamma).dxy(), 0.0004f, 0.882f);
1058 pfCands.at(index_pf_gamma).dxyError(), 4.271f, 63.78f);
1059 get(dnn::pfCand_gamma_dz) =
getValueNorm(pfCands.at(index_pf_gamma).dz(), 0.0071f, 5.285f);
1061 pfCands.at(index_pf_gamma).dzError(), 162.1f, 622.4f);
1062 get(dnn::pfCand_gamma_track_chi2_ndof) = pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0 ?
1063 getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().chi2() /
1064 pfCands.at(index_pf_gamma).pseudoTrack().ndof(), 4.268f, 15.47f) : 0;
1065 get(dnn::pfCand_gamma_track_ndof) = pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0 ?
1066 getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().ndof(), 12.25f, 4.774f) : 0;
1069 if(valid_index_ele){
1072 get(dnn::ele_valid) = valid_index_ele;
1074 is_inner ? 1.067f : 0.5111f, is_inner ? 1.521f : 2.765f);
1076 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1078 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1080 float cc_ele_energy, cc_gamma_energy;
1084 get(dnn::ele_cc_valid) = cc_valid;
1085 get(dnn::ele_cc_ele_rel_energy) =
getValueNorm(cc_ele_energy /
electrons.at(index_ele).polarP4().pt(), 1.729f, 1.644f);
1086 get(dnn::ele_cc_gamma_rel_energy) =
getValueNorm(cc_gamma_energy / cc_ele_energy, 0.1439f, 0.3284f);
1087 get(dnn::ele_cc_n_gamma) =
getValueNorm(cc_n_gamma, 1.794f, 2.079f);
1089 get(dnn::ele_rel_trackMomentumAtVtx) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtVtx().R() /
1090 electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1091 get(dnn::ele_rel_trackMomentumAtCalo) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtCalo().R() /
1092 electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1094 electrons.at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
1095 get(dnn::ele_rel_trackMomentumAtEleClus) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtEleClus().R() /
1096 electrons.at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
1097 get(dnn::ele_rel_trackMomentumAtVtxWithConstraint) =
1099 electrons.at(index_ele).polarP4().pt(), 1.625f, 1.581f);
1101 electrons.at(index_ele).polarP4().pt(), 1.993f, 1.308f);
1103 electrons.at(index_ele).ecalEnergyError(), 70.25f, 58.16f);
1104 get(dnn::ele_eSuperClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSuperClusterOverP(), 2.432f, 15.13f);
1105 get(dnn::ele_eSeedClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverP(), 2.034f, 13.96f);
1106 get(dnn::ele_eSeedClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverPout(), 6.64f, 36.8f);
1107 get(dnn::ele_eEleClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eEleClusterOverPout(), 4.183f, 20.63f);
1108 get(dnn::ele_deltaEtaSuperClusterTrackAtVtx) =
1110 get(dnn::ele_deltaEtaSeedClusterTrackAtCalo) =
1112 get(dnn::ele_deltaEtaEleClusterTrackAtCalo) =
1114 get(dnn::ele_deltaPhiEleClusterTrackAtCalo) =
1116 get(dnn::ele_deltaPhiSuperClusterTrackAtVtx) =
1118 get(dnn::ele_deltaPhiSeedClusterTrackAtCalo) =
1120 get(dnn::ele_mvaInput_earlyBrem) =
getValue(
electrons.at(index_ele).mvaInput().earlyBrem);
1121 get(dnn::ele_mvaInput_lateBrem) =
getValue(
electrons.at(index_ele).mvaInput().lateBrem);
1122 get(dnn::ele_mvaInput_sigmaEtaEta) =
getValueNorm(
electrons.at(index_ele).mvaInput().sigmaEtaEta,0.0008f, 0.0052f);
1123 get(dnn::ele_mvaInput_hadEnergy) =
getValueNorm(
electrons.at(index_ele).mvaInput().hadEnergy, 14.04f, 69.48f);
1124 get(dnn::ele_mvaInput_deltaEta) =
getValueNorm(
electrons.at(index_ele).mvaInput().deltaEta, 0.0099f, 0.0851f);
1126 const auto& gsfTrack =
electrons.at(index_ele).gsfTrack();
1127 if(gsfTrack.isNonnull()){
1128 get(dnn::ele_gsfTrack_normalizedChi2) =
getValueNorm(gsfTrack->normalizedChi2(), 3.049f, 10.39f);
1129 get(dnn::ele_gsfTrack_numberOfValidHits) =
getValueNorm(gsfTrack->numberOfValidHits(), 16.52f, 2.806f);
1130 get(dnn::ele_rel_gsfTrack_pt) =
getValueNorm(gsfTrack->pt() /
electrons.at(index_ele).polarP4().pt(), 1.355f, 16.81f);
1131 get(dnn::ele_gsfTrack_pt_sig) =
getValueNorm(gsfTrack->pt() / gsfTrack->ptError(), 5.046f, 3.119f);
1133 const auto& closestCtfTrack =
electrons.at(index_ele).closestCtfTrackRef();
1134 const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
1135 if(has_closestCtfTrack){
1136 get(dnn::ele_has_closestCtfTrack) = has_closestCtfTrack;
1137 get(dnn::ele_closestCtfTrack_normalizedChi2) =
getValueNorm(closestCtfTrack->normalizedChi2(), 2.411f, 6.98f);
1138 get(dnn::ele_closestCtfTrack_numberOfValidHits) =
getValueNorm(closestCtfTrack->numberOfValidHits(), 15.16f, 5.26f);
1141 checkInputs(inputs, is_inner ?
"egamma_inner_block" :
"egamma_outer_block", dnn::NumberOfInputs);
static float getValueLinear(T value, float min_value, float max_value, bool positive)
static bool isInEcalCrack(double eta)
const Point & position() const
position
static float getValue(T value)
static float getValueNorm(T value, float mean, float sigma, float n_sigmas_max=5)
Abs< T >::type abs(const T &t)
std::array< std::shared_ptr< tensorflow::Tensor >, 2 > eGammaTensor_
void checkInputs(const tensorflow::Tensor &inputs, const char *block_name, int n_inputs, int n_eta=1, int n_phi=1) const
static bool calculateElectronClusterVarsV2(const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)