1292 const auto&
get = [&](
int var_index) ->
float& {
return inputs.tensor<
float, 4>()(
idx, 0, 0, var_index); };
1294 const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
1295 const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
1298 if (!cell_map.empty()) {
1304 if (valid_index_pf_ele) {
1305 size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
1307 get(dnn::pfCand_ele_valid) = valid_index_pf_ele;
1308 get(dnn::pfCand_ele_rel_pt) =
getValueNorm(pfCands.at(index_pf_ele).polarP4().pt() /
tau.polarP4().pt(),
1309 is_inner ? 0.9792f : 0.304f,
1310 is_inner ? 0.5383f : 1.845f);
1311 get(dnn::pfCand_ele_deta) =
getValueLinear(pfCands.at(index_pf_ele).polarP4().eta() -
tau.polarP4().eta(),
1312 is_inner ? -0.1f : -0.5f,
1313 is_inner ? 0.1f : 0.5f,
1316 is_inner ? -0.1
f : -0.5
f,
1317 is_inner ? 0.1
f : 0.5
f,
1319 get(dnn::pfCand_ele_pvAssociationQuality) =
1320 getValueLinear<int>(pfCands.at(index_pf_ele).pvAssociationQuality(), 0, 7,
true);
1321 get(dnn::pfCand_ele_puppiWeight) =
getValue(pfCands.at(index_pf_ele).puppiWeight());
1322 get(dnn::pfCand_ele_charge) =
getValue(pfCands.at(index_pf_ele).charge());
1323 get(dnn::pfCand_ele_lostInnerHits) = getValue<int>(pfCands.at(index_pf_ele).lostInnerHits());
1324 get(dnn::pfCand_ele_numberOfPixelHits) =
1325 getValueLinear(pfCands.at(index_pf_ele).numberOfPixelHits(), 0, 10,
true);
1326 get(dnn::pfCand_ele_vertex_dx) =
1328 get(dnn::pfCand_ele_vertex_dy) =
1330 get(dnn::pfCand_ele_vertex_dz) =
1333 pfCands.at(index_pf_ele).vertex().x() - pv.
position().x() -
tau.flightLength().x(), 0.f, 0.3411f);
1335 pfCands.at(index_pf_ele).vertex().y() - pv.
position().y() -
tau.flightLength().y(), 0.0003f, 0.3385f);
1336 get(dnn::pfCand_ele_vertex_dz_tauFL) =
1337 getValueNorm(pfCands.at(index_pf_ele).vertex().z() - pv.
position().z() -
tau.flightLength().z(), 0.f, 1.307f);
1339 const bool hasTrackDetails = pfCands.at(index_pf_ele).hasTrackDetails();
1340 if (hasTrackDetails) {
1341 get(dnn::pfCand_ele_hasTrackDetails) = hasTrackDetails;
1342 get(dnn::pfCand_ele_dxy) =
getValueNorm(pfCands.at(index_pf_ele).dxy(), 0.f, 0.171f);
1343 get(dnn::pfCand_ele_dxy_sig) =
1344 getValueNorm(
std::abs(pfCands.at(index_pf_ele).dxy()) / pfCands.at(index_pf_ele).dxyError(), 1.634f, 6.45f);
1345 get(dnn::pfCand_ele_dz) =
getValueNorm(pfCands.at(index_pf_ele).dz(), 0.001f, 1.02f);
1346 get(dnn::pfCand_ele_dz_sig) =
1347 getValueNorm(
std::abs(pfCands.at(index_pf_ele).dz()) / pfCands.at(index_pf_ele).dzError(), 24.56f, 210.4f);
1348 get(dnn::pfCand_ele_track_chi2_ndof) =
1349 getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().chi2() / pfCands.at(index_pf_ele).pseudoTrack().ndof(),
1352 get(dnn::pfCand_ele_track_ndof) =
getValueNorm(pfCands.at(index_pf_ele).pseudoTrack().ndof(), 15.18f, 3.203f);
1355 if (valid_index_pf_gamma) {
1356 size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
1357 get(dnn::pfCand_gamma_valid) = valid_index_pf_gamma;
1358 get(dnn::pfCand_gamma_rel_pt) =
getValueNorm(pfCands.at(index_pf_gamma).polarP4().pt() /
tau.polarP4().pt(),
1359 is_inner ? 0.6048f : 0.02576f,
1360 is_inner ? 1.669f : 0.3833f);
1361 get(dnn::pfCand_gamma_deta) =
getValueLinear(pfCands.at(index_pf_gamma).polarP4().eta() -
tau.polarP4().eta(),
1362 is_inner ? -0.1f : -0.5f,
1363 is_inner ? 0.1f : 0.5f,
1365 get(dnn::pfCand_gamma_dphi) =
getValueLinear(
dPhi(
tau.polarP4(), pfCands.at(index_pf_gamma).polarP4()),
1366 is_inner ? -0.1f : -0.5f,
1367 is_inner ? 0.1f : 0.5f,
1369 get(dnn::pfCand_gamma_pvAssociationQuality) =
1370 getValueLinear<int>(pfCands.at(index_pf_gamma).pvAssociationQuality(), 0, 7,
true);
1371 get(dnn::pfCand_gamma_fromPV) = getValueLinear<int>(pfCands.at(index_pf_gamma).fromPV(), 0, 3,
true);
1372 get(dnn::pfCand_gamma_puppiWeight) =
getValue(pfCands.at(index_pf_gamma).puppiWeight());
1373 get(dnn::pfCand_gamma_puppiWeightNoLep) =
getValue(pfCands.at(index_pf_gamma).puppiWeightNoLep());
1374 get(dnn::pfCand_gamma_lostInnerHits) = getValue<int>(pfCands.at(index_pf_gamma).lostInnerHits());
1375 get(dnn::pfCand_gamma_numberOfPixelHits) =
1376 getValueLinear(pfCands.at(index_pf_gamma).numberOfPixelHits(), 0, 7,
true);
1377 get(dnn::pfCand_gamma_vertex_dx) =
1379 get(dnn::pfCand_gamma_vertex_dy) =
1381 get(dnn::pfCand_gamma_vertex_dz) =
1384 pfCands.at(index_pf_gamma).vertex().x() - pv.
position().x() -
tau.flightLength().x(), 0.001f, 0.9565f);
1386 pfCands.at(index_pf_gamma).vertex().y() - pv.
position().y() -
tau.flightLength().y(), 0.0008f, 0.9592f);
1388 pfCands.at(index_pf_gamma).vertex().z() - pv.
position().z() -
tau.flightLength().z(), 0.0038f, 2.154f);
1390 const bool hasTrackDetails = pfCands.at(index_pf_gamma).hasTrackDetails();
1391 if (hasTrackDetails) {
1392 get(dnn::pfCand_gamma_hasTrackDetails) = hasTrackDetails;
1393 get(dnn::pfCand_gamma_dxy) =
getValueNorm(pfCands.at(index_pf_gamma).dxy(), 0.0004f, 0.882f);
1395 std::abs(pfCands.at(index_pf_gamma).dxy()) / pfCands.at(index_pf_gamma).dxyError(), 4.271f, 63.78f);
1396 get(dnn::pfCand_gamma_dz) =
getValueNorm(pfCands.at(index_pf_gamma).dz(), 0.0071f, 5.285f);
1398 std::abs(pfCands.at(index_pf_gamma).dz()) / pfCands.at(index_pf_gamma).dzError(), 162.1f, 622.4f);
1399 get(dnn::pfCand_gamma_track_chi2_ndof) = pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0
1400 ?
getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().chi2() /
1401 pfCands.at(index_pf_gamma).pseudoTrack().ndof(),
1405 get(dnn::pfCand_gamma_track_ndof) =
1406 pfCands.at(index_pf_gamma).pseudoTrack().ndof() > 0
1407 ?
getValueNorm(pfCands.at(index_pf_gamma).pseudoTrack().ndof(), 12.25f, 4.774f)
1411 if (valid_index_ele) {
1414 get(dnn::ele_valid) = valid_index_ele;
1416 is_inner ? 1.067f : 0.5111f,
1417 is_inner ? 1.521f : 2.765f);
1419 is_inner ? -0.1f : -0.5f,
1420 is_inner ? 0.1f : 0.5f,
1423 is_inner ? -0.1f : -0.5f,
1424 is_inner ? 0.1f : 0.5f,
1427 float cc_ele_energy, cc_gamma_energy;
1429 const bool cc_valid =
1432 get(dnn::ele_cc_valid) = cc_valid;
1433 get(dnn::ele_cc_ele_rel_energy) =
1435 get(dnn::ele_cc_gamma_rel_energy) =
getValueNorm(cc_gamma_energy / cc_ele_energy, 0.1439f, 0.3284f);
1436 get(dnn::ele_cc_n_gamma) =
getValueNorm(cc_n_gamma, 1.794f, 2.079f);
1439 electrons.at(index_ele).trackMomentumAtVtx().R() /
electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1441 electrons.at(index_ele).trackMomentumAtCalo().R() /
electrons.at(index_ele).polarP4().pt(), 1.531f, 1.424f);
1443 electrons.at(index_ele).trackMomentumOut().R() /
electrons.at(index_ele).polarP4().pt(), 0.7735f, 0.935f);
1444 get(dnn::ele_rel_trackMomentumAtEleClus) =
1448 get(dnn::ele_rel_trackMomentumAtVtxWithConstraint) =
getValueNorm(
1449 electrons.at(index_ele).trackMomentumAtVtxWithConstraint().R() /
electrons.at(index_ele).polarP4().pt(),
1452 get(dnn::ele_rel_ecalEnergy) =
1455 electrons.at(index_ele).ecalEnergy() /
electrons.at(index_ele).ecalEnergyError(), 70.25f, 58.16f);
1456 get(dnn::ele_eSuperClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSuperClusterOverP(), 2.432f, 15.13f);
1457 get(dnn::ele_eSeedClusterOverP) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverP(), 2.034f, 13.96f);
1458 get(dnn::ele_eSeedClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eSeedClusterOverPout(), 6.64f, 36.8f);
1459 get(dnn::ele_eEleClusterOverPout) =
getValueNorm(
electrons.at(index_ele).eEleClusterOverPout(), 4.183f, 20.63f);
1460 get(dnn::ele_deltaEtaSuperClusterTrackAtVtx) =
1462 get(dnn::ele_deltaEtaSeedClusterTrackAtCalo) =
1464 get(dnn::ele_deltaEtaEleClusterTrackAtCalo) =
1466 get(dnn::ele_deltaPhiEleClusterTrackAtCalo) =
1468 get(dnn::ele_deltaPhiSuperClusterTrackAtVtx) =
1470 get(dnn::ele_deltaPhiSeedClusterTrackAtCalo) =
1472 get(dnn::ele_mvaInput_earlyBrem) =
getValue(
electrons.at(index_ele).mvaInput().earlyBrem);
1473 get(dnn::ele_mvaInput_lateBrem) =
getValue(
electrons.at(index_ele).mvaInput().lateBrem);
1474 get(dnn::ele_mvaInput_sigmaEtaEta) =
1476 get(dnn::ele_mvaInput_hadEnergy) =
getValueNorm(
electrons.at(index_ele).mvaInput().hadEnergy, 14.04f, 69.48f);
1477 get(dnn::ele_mvaInput_deltaEta) =
getValueNorm(
electrons.at(index_ele).mvaInput().deltaEta, 0.0099f, 0.0851f);
1479 const auto& gsfTrack =
electrons.at(index_ele).gsfTrack();
1480 if (gsfTrack.isNonnull()) {
1481 get(dnn::ele_gsfTrack_normalizedChi2) =
getValueNorm(gsfTrack->normalizedChi2(), 3.049f, 10.39f);
1482 get(dnn::ele_gsfTrack_numberOfValidHits) =
getValueNorm(gsfTrack->numberOfValidHits(), 16.52f, 2.806f);
1483 get(dnn::ele_rel_gsfTrack_pt) =
1485 get(dnn::ele_gsfTrack_pt_sig) =
getValueNorm(gsfTrack->pt() / gsfTrack->ptError(), 5.046f, 3.119f);
1487 const auto& closestCtfTrack =
electrons.at(index_ele).closestCtfTrackRef();
1488 const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
1489 if (has_closestCtfTrack) {
1490 get(dnn::ele_has_closestCtfTrack) = has_closestCtfTrack;
1491 get(dnn::ele_closestCtfTrack_normalizedChi2) =
getValueNorm(closestCtfTrack->normalizedChi2(), 2.411f, 6.98f);
1492 get(dnn::ele_closestCtfTrack_numberOfValidHits) =
1493 getValueNorm(closestCtfTrack->numberOfValidHits(), 15.16f, 5.26f);
1496 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)
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)
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > eGammaTensor_