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