983 inputs.flat<
float>().setZero();
985 const auto&
get = [&](
int var_index) ->
float& {
986 return inputs.tensor<
float,4>()(0, 0, 0, var_index);
989 const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
990 const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
993 if(!cell_map.empty()){
999 if(valid_index_pf_ele){
1000 size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
1002 get(dnn::pfCand_ele_valid) = valid_index_pf_ele;
1003 get(dnn::pfCand_ele_rel_pt) =
getValueNorm(pfCands.at(index_pf_ele).polarP4().pt() /
tau.polarP4().pt(),
1004 is_inner ? 0.9792f : 0.304f, is_inner ? 0.5383f : 1.845f);
1005 get(dnn::pfCand_ele_deta) =
getValueLinear(pfCands.at(index_pf_ele).polarP4().eta() -
tau.polarP4().eta(),
1006 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1008 is_inner ? -0.1
f : -0.5
f, is_inner ? 0.1
f : 0.5
f,
false);
1009 get(dnn::pfCand_ele_pvAssociationQuality) = getValueLinear<int>(pfCands.at(index_pf_ele).pvAssociationQuality(), 0, 7,
true);
1010 get(dnn::pfCand_ele_puppiWeight) =
getValue(pfCands.at(index_pf_ele).puppiWeight());
1011 get(dnn::pfCand_ele_charge) =
getValue(pfCands.at(index_pf_ele).charge());
1012 get(dnn::pfCand_ele_lostInnerHits) = getValue<int>(pfCands.at(index_pf_ele).lostInnerHits());
1013 get(dnn::pfCand_ele_numberOfPixelHits) =
getValueLinear(pfCands.at(index_pf_ele).numberOfPixelHits(), 0, 10,
true);
1014 get(dnn::pfCand_ele_vertex_dx) =
getValueNorm(pfCands.at(index_pf_ele).vertex().x() - pv.
position().x(), 0.f, 0.1221f);
1015 get(dnn::pfCand_ele_vertex_dy) =
getValueNorm(pfCands.at(index_pf_ele).vertex().y() - pv.
position().y(), 0.f, 0.1226f);
1016 get(dnn::pfCand_ele_vertex_dz) =
getValueNorm(pfCands.at(index_pf_ele).vertex().z() - pv.
position().z(), 0.001f, 1.024f);
1017 get(dnn::pfCand_ele_vertex_dx_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().x() -
1018 pv.
position().x() -
tau.flightLength().x(), 0.f, 0.3411f);
1019 get(dnn::pfCand_ele_vertex_dy_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().y() -
1020 pv.
position().y() -
tau.flightLength().y(), 0.0003f, 0.3385f);
1021 get(dnn::pfCand_ele_vertex_dz_tauFL) =
getValueNorm(pfCands.at(index_pf_ele).vertex().z() -
1022 pv.
position().z() -
tau.flightLength().z(), 0.f, 1.307f);
1024 const bool hasTrackDetails = pfCands.at(index_pf_ele).hasTrackDetails();
1025 if(hasTrackDetails){
1026 get(dnn::pfCand_ele_hasTrackDetails) = hasTrackDetails;
1027 get(dnn::pfCand_ele_dxy) =
getValueNorm(pfCands.at(index_pf_ele).dxy(), 0.f, 0.171f);
1029 pfCands.at(index_pf_ele).dxyError(), 1.634f, 6.45f);
1030 get(dnn::pfCand_ele_dz) =
getValueNorm(pfCands.at(index_pf_ele).dz(), 0.001f, 1.02f);
1032 pfCands.at(index_pf_ele).dzError(), 24.56f, 210.4f);
1033 get(dnn::pfCand_ele_track_chi2_ndof) =
getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().chi2() /
1034 pfCands.at(index_pf_ele).pseudoTrack().ndof(), 2.272f, 8.439f);
1035 get(dnn::pfCand_ele_track_ndof) =
getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().ndof(), 15.18f, 3.203f);
1038 if(valid_index_pf_gamma){
1039 size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
1040 get(dnn::pfCand_gamma_valid) = valid_index_pf_gamma;
1041 get(dnn::pfCand_gamma_rel_pt) =
getValueNorm(pfCands.at(index_pf_gamma).polarP4().pt() /
tau.polarP4().pt(),
1042 is_inner ? 0.6048f : 0.02576f, is_inner ? 1.669f : 0.3833f);
1043 get(dnn::pfCand_gamma_deta) =
getValueLinear(pfCands.at(index_pf_gamma).polarP4().eta() -
tau.polarP4().eta(),
1044 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1045 get(dnn::pfCand_gamma_dphi) =
getValueLinear(
dPhi(
tau.polarP4(), pfCands.at(index_pf_gamma).polarP4()),
1046 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1047 get(dnn::pfCand_gamma_pvAssociationQuality) =
1048 getValueLinear<int>(pfCands.at(index_pf_gamma).pvAssociationQuality(), 0, 7,
true);
1049 get(dnn::pfCand_gamma_fromPV) = getValueLinear<int>(pfCands.at(index_pf_gamma).fromPV(), 0, 3,
true);
1050 get(dnn::pfCand_gamma_puppiWeight) =
getValue(pfCands.at(index_pf_gamma).puppiWeight());
1051 get(dnn::pfCand_gamma_puppiWeightNoLep) =
getValue(pfCands.at(index_pf_gamma).puppiWeightNoLep());
1052 get(dnn::pfCand_gamma_lostInnerHits) = getValue<int>(pfCands.at(index_pf_gamma).lostInnerHits());
1053 get(dnn::pfCand_gamma_numberOfPixelHits) =
getValueLinear(pfCands.at(index_pf_gamma).numberOfPixelHits(), 0, 7,
true);
1054 get(dnn::pfCand_gamma_vertex_dx) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().x() - pv.
position().x(), 0.f, 0.0067f);
1055 get(dnn::pfCand_gamma_vertex_dy) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().y() - pv.
position().y(), 0.f, 0.0069f);
1056 get(dnn::pfCand_gamma_vertex_dz) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().z() - pv.
position().z(), 0.f, 0.0578f);
1057 get(dnn::pfCand_gamma_vertex_dx_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().x() -
1058 pv.
position().x() -
tau.flightLength().x(), 0.001f, 0.9565f);
1059 get(dnn::pfCand_gamma_vertex_dy_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().y() -
1060 pv.
position().y() -
tau.flightLength().y(), 0.0008f, 0.9592f);
1061 get(dnn::pfCand_gamma_vertex_dz_tauFL) =
getValueNorm(pfCands.at(index_pf_gamma).vertex().z() -
1062 pv.
position().z() -
tau.flightLength().z(), 0.0038f, 2.154f);
1064 const bool hasTrackDetails = pfCands.at(index_pf_gamma).hasTrackDetails();
1065 if(hasTrackDetails){
1066 get(dnn::pfCand_gamma_hasTrackDetails) = hasTrackDetails;
1067 get(dnn::pfCand_gamma_dxy) =
getValueNorm(pfCands.at(index_pf_gamma).dxy(), 0.0004f, 0.882f);
1069 pfCands.at(index_pf_gamma).dxyError(), 4.271f, 63.78f);
1070 get(dnn::pfCand_gamma_dz) =
getValueNorm(pfCands.at(index_pf_gamma).dz(), 0.0071f, 5.285f);
1072 pfCands.at(index_pf_gamma).dzError(), 162.1f, 622.4f);
1073 get(dnn::pfCand_gamma_track_chi2_ndof) = pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0 ?
1074 getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().chi2() /
1075 pfCands.at(index_pf_gamma).pseudoTrack().ndof(), 4.268f, 15.47f) : 0;
1076 get(dnn::pfCand_gamma_track_ndof) = pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0 ?
1077 getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().ndof(), 12.25f, 4.774f) : 0;
1080 if(valid_index_ele){
1083 get(dnn::ele_valid) = valid_index_ele;
1085 is_inner ? 1.067f : 0.5111f, is_inner ? 1.521f : 2.765f);
1087 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1089 is_inner ? -0.1f : -0.5f, is_inner ? 0.1f : 0.5f,
false);
1091 float cc_ele_energy, cc_gamma_energy;
1095 get(dnn::ele_cc_valid) = cc_valid;
1096 get(dnn::ele_cc_ele_rel_energy) =
getValueNorm(cc_ele_energy /
electrons.at(index_ele).polarP4().pt(), 1.729f, 1.644f);
1097 get(dnn::ele_cc_gamma_rel_energy) =
getValueNorm(cc_gamma_energy / cc_ele_energy, 0.1439f, 0.3284f);
1098 get(dnn::ele_cc_n_gamma) =
getValueNorm(cc_n_gamma, 1.794f, 2.079f);
1100 get(dnn::ele_rel_trackMomentumAtVtx) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtVtx().R() /
1101 electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1102 get(dnn::ele_rel_trackMomentumAtCalo) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtCalo().R() /
1103 electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1105 electrons.at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
1106 get(dnn::ele_rel_trackMomentumAtEleClus) =
getValueNorm(
electrons.at(index_ele).trackMomentumAtEleClus().R() /
1107 electrons.at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
1108 get(dnn::ele_rel_trackMomentumAtVtxWithConstraint) =
1110 electrons.at(index_ele).polarP4().pt(), 1.625f, 1.581f);
1112 electrons.at(index_ele).polarP4().pt(), 1.993f, 1.308f);
1114 electrons.at(index_ele).ecalEnergyError(), 70.25f, 58.16f);
1115 get(dnn::ele_eSuperClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSuperClusterOverP(), 2.432f, 15.13f);
1116 get(dnn::ele_eSeedClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverP(), 2.034f, 13.96f);
1117 get(dnn::ele_eSeedClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverPout(), 6.64f, 36.8f);
1118 get(dnn::ele_eEleClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eEleClusterOverPout(), 4.183f, 20.63f);
1119 get(dnn::ele_deltaEtaSuperClusterTrackAtVtx) =
1121 get(dnn::ele_deltaEtaSeedClusterTrackAtCalo) =
1123 get(dnn::ele_deltaEtaEleClusterTrackAtCalo) =
1125 get(dnn::ele_deltaPhiEleClusterTrackAtCalo) =
1127 get(dnn::ele_deltaPhiSuperClusterTrackAtVtx) =
1129 get(dnn::ele_deltaPhiSeedClusterTrackAtCalo) =
1131 get(dnn::ele_mvaInput_earlyBrem) =
getValue(
electrons.at(index_ele).mvaInput().earlyBrem);
1132 get(dnn::ele_mvaInput_lateBrem) =
getValue(
electrons.at(index_ele).mvaInput().lateBrem);
1133 get(dnn::ele_mvaInput_sigmaEtaEta) =
getValueNorm(
electrons.at(index_ele).mvaInput().sigmaEtaEta,0.0008f, 0.0052f);
1134 get(dnn::ele_mvaInput_hadEnergy) =
getValueNorm(
electrons.at(index_ele).mvaInput().hadEnergy, 14.04f, 69.48f);
1135 get(dnn::ele_mvaInput_deltaEta) =
getValueNorm(
electrons.at(index_ele).mvaInput().deltaEta, 0.0099f, 0.0851f);
1137 const auto& gsfTrack =
electrons.at(index_ele).gsfTrack();
1138 if(gsfTrack.isNonnull()){
1139 get(dnn::ele_gsfTrack_normalizedChi2) =
getValueNorm(gsfTrack->normalizedChi2(), 3.049f, 10.39f);
1140 get(dnn::ele_gsfTrack_numberOfValidHits) =
getValueNorm(gsfTrack->numberOfValidHits(), 16.52f, 2.806f);
1141 get(dnn::ele_rel_gsfTrack_pt) =
getValueNorm(gsfTrack->pt() /
electrons.at(index_ele).polarP4().pt(), 1.355f, 16.81f);
1142 get(dnn::ele_gsfTrack_pt_sig) =
getValueNorm(gsfTrack->pt() / gsfTrack->ptError(), 5.046f, 3.119f);
1144 const auto& closestCtfTrack =
electrons.at(index_ele).closestCtfTrackRef();
1145 const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
1146 if(has_closestCtfTrack){
1147 get(dnn::ele_has_closestCtfTrack) = has_closestCtfTrack;
1148 get(dnn::ele_closestCtfTrack_normalizedChi2) =
getValueNorm(closestCtfTrack->normalizedChi2(), 2.411f, 6.98f);
1149 get(dnn::ele_closestCtfTrack_numberOfValidHits) =
getValueNorm(closestCtfTrack->numberOfValidHits(), 15.16f, 5.26f);
1152 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)