17 #include "oneapi/tbb/concurrent_unordered_set.h" 26 constexpr
int number_of_inner_cell = 11;
27 constexpr
int number_of_outer_cell = 21;
28 constexpr
int number_of_conv_features = 64;
29 namespace TauBlockInputs {
41 chargedIsoPtSumdR03_over_dR05,
44 neutralIsoPtSumWeight_over_neutralIsoPtSum,
45 neutralIsoPtSumWeightdR03_over_neutralIsoPtSum,
46 neutralIsoPtSumdR03_over_dR05,
47 photonPtSumOutsideSignalCone,
65 tau_pt_weighted_deta_strip,
66 tau_pt_weighted_dphi_strip,
67 tau_pt_weighted_dr_signal,
68 tau_pt_weighted_dr_iso,
69 tau_leadingTrackNormChi2,
72 tau_gj_angle_diff_valid,
76 tau_inside_ecal_crack,
77 leadChargedCand_etaAtEcalEntrance_minus_tau_eta,
80 std::vector<int> varsToDrop = {
81 tau_phi, tau_dxy_pca_x, tau_dxy_pca_y, tau_dxy_pca_z};
84 namespace EgammaBlockInputs {
89 tau_inside_ecal_crack,
94 pfCand_ele_pvAssociationQuality,
95 pfCand_ele_puppiWeight,
97 pfCand_ele_lostInnerHits,
98 pfCand_ele_numberOfPixelHits,
100 pfCand_ele_vertex_dy,
101 pfCand_ele_vertex_dz,
102 pfCand_ele_vertex_dx_tauFL,
103 pfCand_ele_vertex_dy_tauFL,
104 pfCand_ele_vertex_dz_tauFL,
105 pfCand_ele_hasTrackDetails,
110 pfCand_ele_track_chi2_ndof,
111 pfCand_ele_track_ndof,
117 ele_cc_ele_rel_energy,
118 ele_cc_gamma_rel_energy,
120 ele_rel_trackMomentumAtVtx,
121 ele_rel_trackMomentumAtCalo,
122 ele_rel_trackMomentumOut,
123 ele_rel_trackMomentumAtEleClus,
124 ele_rel_trackMomentumAtVtxWithConstraint,
127 ele_eSuperClusterOverP,
128 ele_eSeedClusterOverP,
129 ele_eSeedClusterOverPout,
130 ele_eEleClusterOverPout,
131 ele_deltaEtaSuperClusterTrackAtVtx,
132 ele_deltaEtaSeedClusterTrackAtCalo,
133 ele_deltaEtaEleClusterTrackAtCalo,
134 ele_deltaPhiEleClusterTrackAtCalo,
135 ele_deltaPhiSuperClusterTrackAtVtx,
136 ele_deltaPhiSeedClusterTrackAtCalo,
137 ele_mvaInput_earlyBrem,
138 ele_mvaInput_lateBrem,
139 ele_mvaInput_sigmaEtaEta,
140 ele_mvaInput_hadEnergy,
141 ele_mvaInput_deltaEta,
142 ele_gsfTrack_normalizedChi2,
143 ele_gsfTrack_numberOfValidHits,
146 ele_has_closestCtfTrack,
147 ele_closestCtfTrack_normalizedChi2,
148 ele_closestCtfTrack_numberOfValidHits,
153 pfCand_gamma_pvAssociationQuality,
155 pfCand_gamma_puppiWeight,
156 pfCand_gamma_puppiWeightNoLep,
157 pfCand_gamma_lostInnerHits,
158 pfCand_gamma_numberOfPixelHits,
159 pfCand_gamma_vertex_dx,
160 pfCand_gamma_vertex_dy,
161 pfCand_gamma_vertex_dz,
162 pfCand_gamma_vertex_dx_tauFL,
163 pfCand_gamma_vertex_dy_tauFL,
164 pfCand_gamma_vertex_dz_tauFL,
165 pfCand_gamma_hasTrackDetails,
167 pfCand_gamma_dxy_sig,
170 pfCand_gamma_track_chi2_ndof,
171 pfCand_gamma_track_ndof,
176 namespace MuonBlockInputs {
181 tau_inside_ecal_crack,
186 pfCand_muon_pvAssociationQuality,
188 pfCand_muon_puppiWeight,
190 pfCand_muon_lostInnerHits,
191 pfCand_muon_numberOfPixelHits,
192 pfCand_muon_vertex_dx,
193 pfCand_muon_vertex_dy,
194 pfCand_muon_vertex_dz,
195 pfCand_muon_vertex_dx_tauFL,
196 pfCand_muon_vertex_dy_tauFL,
197 pfCand_muon_vertex_dz_tauFL,
198 pfCand_muon_hasTrackDetails,
203 pfCand_muon_track_chi2_ndof,
204 pfCand_muon_track_ndof,
211 muon_normalizedChi2_valid,
213 muon_numberOfValidHits,
214 muon_segmentCompatibility,
215 muon_caloCompatibility,
216 muon_pfEcalEnergy_valid,
217 muon_rel_pfEcalEnergy,
222 muon_n_matches_CSC_1,
223 muon_n_matches_CSC_2,
224 muon_n_matches_CSC_3,
225 muon_n_matches_CSC_4,
226 muon_n_matches_RPC_1,
227 muon_n_matches_RPC_2,
228 muon_n_matches_RPC_3,
229 muon_n_matches_RPC_4,
246 namespace HadronBlockInputs {
251 tau_inside_ecal_crack,
256 pfCand_chHad_leadChargedHadrCand,
257 pfCand_chHad_pvAssociationQuality,
259 pfCand_chHad_puppiWeight,
260 pfCand_chHad_puppiWeightNoLep,
262 pfCand_chHad_lostInnerHits,
263 pfCand_chHad_numberOfPixelHits,
264 pfCand_chHad_vertex_dx,
265 pfCand_chHad_vertex_dy,
266 pfCand_chHad_vertex_dz,
267 pfCand_chHad_vertex_dx_tauFL,
268 pfCand_chHad_vertex_dy_tauFL,
269 pfCand_chHad_vertex_dz_tauFL,
270 pfCand_chHad_hasTrackDetails,
272 pfCand_chHad_dxy_sig,
275 pfCand_chHad_track_chi2_ndof,
276 pfCand_chHad_track_ndof,
277 pfCand_chHad_hcalFraction,
278 pfCand_chHad_rawCaloFraction,
283 pfCand_nHad_puppiWeight,
284 pfCand_nHad_puppiWeightNoLep,
285 pfCand_nHad_hcalFraction,
292 static tbb::concurrent_unordered_set<std::string> isFirstWarning;
298 <<
"Exception in <getTauID>: No tauID '" <<
tauID <<
"' available in pat::Tau given as function argument.";
300 if (isFirstWarning.insert(
tauID).second) {
302 <<
"' available in pat::Tau given as function argument." 303 <<
" Using default_value = " << default_value <<
" instead." << std::endl;
305 return default_value;
316 std::map<BasicDiscr, size_t> indexMap;
317 std::map<BasicDiscr, size_t> indexMapdR03;
320 return (*basicTauDiscriminatorCollection)[tau_ref].rawValues.at(indexMap.at(BasicDiscr::ChargedIsoPtSum));
323 return getTauID(
tau,
"chargedIsoPtSum");
326 return (*basicTauDiscriminatordR03Collection)[tau_ref].rawValues.at(indexMapdR03.at(BasicDiscr::ChargedIsoPtSum));
329 return getTauID(
tau,
"chargedIsoPtSumdR03");
332 return (*basicTauDiscriminatordR03Collection)[tau_ref].rawValues.at(
333 indexMapdR03.at(BasicDiscr::FootprintCorrection));
336 return getTauID(
tau,
"footprintCorrectiondR03");
339 return getTauID(
tau,
"footprintCorrection");
342 return (*basicTauDiscriminatorCollection)[tau_ref].rawValues.at(indexMap.at(BasicDiscr::NeutralIsoPtSum));
345 return getTauID(
tau,
"neutralIsoPtSum");
348 return (*basicTauDiscriminatordR03Collection)[tau_ref].rawValues.at(indexMapdR03.at(BasicDiscr::NeutralIsoPtSum));
351 return getTauID(
tau,
"neutralIsoPtSumdR03");
354 return (*basicTauDiscriminatorCollection)[tau_ref].rawValues.at(indexMap.at(BasicDiscr::NeutralIsoPtSumWeight));
357 return getTauID(
tau,
"neutralIsoPtSumWeight");
361 return (*basicTauDiscriminatordR03Collection)[tau_ref].rawValues.at(
362 indexMapdR03.at(BasicDiscr::NeutralIsoPtSumWeight));
365 return getTauID(
tau,
"neutralIsoPtSumWeightdR03");
367 const float getPhotonPtSumOutsideSignalCone(
const reco::PFTau&
tau,
369 return (*basicTauDiscriminatorCollection)[tau_ref].rawValues.at(
370 indexMap.at(BasicDiscr::PhotonPtSumOutsideSignalCone));
372 const float getPhotonPtSumOutsideSignalCone(
const pat::Tau&
tau,
374 return getTauID(
tau,
"photonPtSumOutsideSignalCone");
376 const float getPhotonPtSumOutsideSignalConedR03(
const reco::PFTau&
tau,
378 return (*basicTauDiscriminatordR03Collection)[tau_ref].rawValues.at(
379 indexMapdR03.at(BasicDiscr::PhotonPtSumOutsideSignalCone));
381 const float getPhotonPtSumOutsideSignalConedR03(
const pat::Tau&
tau,
383 return getTauID(
tau,
"photonPtSumOutsideSignalConedR03");
386 return (*basicTauDiscriminatorCollection)[tau_ref].rawValues.at(indexMap.at(BasicDiscr::PUcorrPtSum));
389 return getTauID(
tau,
"puCorrPtSum");
392 auto getdxyPCA(
const reco::PFTau&
tau,
const size_t tau_index)
const {
395 auto getdxyPCA(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.dxy_PCA(); }
396 auto getdxy(
const reco::PFTau&
tau,
const size_t tau_index)
const {
399 auto getdxy(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.dxy(); }
400 auto getdxyError(
const reco::PFTau&
tau,
const size_t tau_index)
const {
403 auto getdxyError(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.dxy_error(); }
404 auto getdxySig(
const reco::PFTau&
tau,
const size_t tau_index)
const {
407 auto getdxySig(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.dxy_Sig(); }
408 auto getip3d(
const reco::PFTau&
tau,
const size_t tau_index)
const {
411 auto getip3d(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.ip3d(); }
412 auto getip3dError(
const reco::PFTau&
tau,
const size_t tau_index)
const {
415 auto getip3dError(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.ip3d_error(); }
416 auto getip3dSig(
const reco::PFTau&
tau,
const size_t tau_index)
const {
419 auto getip3dSig(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.ip3d_Sig(); }
420 auto getHasSecondaryVertex(
const reco::PFTau&
tau,
const size_t tau_index)
const {
423 auto getHasSecondaryVertex(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.hasSecondaryVertex(); }
424 auto getFlightLength(
const reco::PFTau&
tau,
const size_t tau_index)
const {
427 auto getFlightLength(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.flightLength(); }
428 auto getFlightLengthSig(
const reco::PFTau&
tau,
const size_t tau_index)
const {
431 auto getFlightLengthSig(
const pat::Tau&
tau,
const size_t tau_index)
const {
return tau.flightLengthSig(); }
434 auto getLeadingTrackNormChi2(
const pat::Tau&
tau) {
return tau.leadingTrackNormChi2(); }
435 auto getEmFraction(
const pat::Tau&
tau) {
return tau.emFraction_MVA(); }
437 auto getEtaAtEcalEntrance(
const pat::Tau&
tau) {
return tau.etaAtEcalEntranceLeadChargedCand(); }
439 return tau.leadPFChargedHadrCand()->positionAtECALEntrance().eta();
441 auto getEcalEnergyLeadingChargedHadr(
const reco::PFTau&
tau) {
return tau.leadPFChargedHadrCand()->ecalEnergy(); }
442 auto getEcalEnergyLeadingChargedHadr(
const pat::Tau&
tau) {
return tau.ecalEnergyLeadChargedHadrCand(); }
443 auto getHcalEnergyLeadingChargedHadr(
const reco::PFTau&
tau) {
return tau.leadPFChargedHadrCand()->hcalEnergy(); }
444 auto getHcalEnergyLeadingChargedHadr(
const pat::Tau&
tau) {
return tau.hcalEnergyLeadChargedHadrCand(); }
446 template <
typename PreDiscrType>
447 bool passPrediscriminants(
const PreDiscrType prediscriminants,
448 const size_t andPrediscriminants,
450 bool passesPrediscriminants = (andPrediscriminants ? 1 : 0);
452 size_t nPrediscriminants = prediscriminants.size();
453 for (
size_t iDisc = 0; iDisc < nPrediscriminants; ++iDisc) {
455 double discResult = (*prediscriminants[iDisc].handle)[tau_ref];
456 uint8_t thisPasses = (discResult > prediscriminants[iDisc].cut) ? 1 : 0;
473 if (thisPasses ^ andPrediscriminants)
475 passesPrediscriminants = (andPrediscriminants ? 0 : 1);
479 return passesPrediscriminants;
487 return cand.bestTrack() !=
nullptr && std::isnormal(
cand.bestTrack()->dz()) && std::isnormal(
cand.dzError()) &&
491 return cand.hasTrackDetails() && std::isnormal(
cand.dz()) && std::isnormal(
cand.dzError()) &&
cand.dzError() > 0;
501 return cand.puppiWeightNoLep();
504 return cand.bestTrack() !=
nullptr 510 return cand.bestTrack() !=
nullptr 515 return cand.numberOfPixelHits();
524 return cand.rawHcalEnergy() / (
cand.rawHcalEnergy() +
cand.rawEcalEnergy());
527 float hcal_fraction = 0.;
531 hcal_fraction =
cand.hcalFraction();
534 if (
cand.pdgId() == 1 ||
cand.pdgId() == 130) {
535 hcal_fraction =
cand.hcalFraction();
536 }
else if (
cand.isIsolatedChargedHadron()) {
537 hcal_fraction =
cand.rawHcalFraction();
540 return hcal_fraction;
543 return (
cand.rawEcalEnergy() +
cand.rawHcalEnergy()) /
cand.energy();
548 template <
typename LVector1,
typename LVector2>
549 float dEta(
const LVector1& p4,
const LVector2& tau_p4) {
550 return static_cast<float>(p4.eta() - tau_p4.eta());
553 template <
typename LVector1,
typename LVector2>
554 float dPhi(
const LVector1& p4_1,
const LVector2& p4_2) {
555 return static_cast<float>(
reco::deltaPhi(p4_2.phi(), p4_1.phi()));
558 struct MuonHitMatchV2 {
559 static constexpr
size_t n_muon_stations = 4;
560 static constexpr
int first_station_id = 1;
561 static constexpr
int last_station_id = first_station_id + n_muon_stations - 1;
562 using CountArray = std::array<unsigned, n_muon_stations>;
563 using CountMap = std::map<int, CountArray>;
565 const std::vector<int>& consideredSubdets() {
571 static const std::map<int, std::string> subdet_names = {
573 if (!subdet_names.count(subdet))
574 throw cms::Exception(
"MuonHitMatch") <<
"Subdet name for subdet id " << subdet <<
" not found.";
575 return subdet_names.at(subdet);
578 size_t getStationIndex(
int station,
bool throw_exception)
const {
579 if (station < first_station_id || station > last_station_id) {
581 throw cms::Exception(
"MuonHitMatch") <<
"Station id is out of range";
584 return static_cast<size_t>(
station - 1);
588 for (
int subdet : consideredSubdets()) {
589 n_matches[subdet].fill(0);
590 n_hits[subdet].fill(0);
598 for (
const auto& segment :
muon.matches()) {
599 if (segment.segmentMatches.empty() && segment.rpcMatches.empty())
601 if (n_matches.count(segment.detector())) {
602 const size_t station_index = getStationIndex(segment.station(),
true);
603 ++n_matches.at(segment.detector()).at(station_index);
609 if (
muon.outerTrack().isNonnull()) {
610 const auto& hit_pattern =
muon.outerTrack()->hitPattern();
617 const size_t station_index = getStationIndex(hit_pattern.getMuonStation(hit_id),
false);
618 if (station_index < n_muon_stations) {
619 CountArray* muon_n_hits =
nullptr;
620 if (hit_pattern.muonDTHitFilter(hit_id))
622 else if (hit_pattern.muonCSCHitFilter(hit_id))
624 else if (hit_pattern.muonRPCHitFilter(hit_id))
628 ++muon_n_hits->at(station_index);
635 unsigned nMatches(
int subdet,
int station)
const {
636 if (!n_matches.count(subdet))
637 throw cms::Exception(
"MuonHitMatch") <<
"Subdet " << subdet <<
" not found.";
638 const size_t station_index = getStationIndex(
station,
true);
639 return n_matches.at(subdet).at(station_index);
643 if (!n_hits.count(subdet))
644 throw cms::Exception(
"MuonHitMatch") <<
"Subdet " << subdet <<
" not found.";
645 const size_t station_index = getStationIndex(
station,
true);
646 return n_hits.at(subdet).at(station_index);
649 unsigned countMuonStationsWithMatches(
int first_station,
int last_station)
const {
650 static const std::map<int, std::vector<bool>> masks = {
655 const size_t first_station_index = getStationIndex(first_station,
true);
656 const size_t last_station_index = getStationIndex(last_station,
true);
658 for (
size_t n = first_station_index;
n <= last_station_index; ++
n) {
659 for (
const auto&
match : n_matches) {
660 if (!masks.at(
match.first).at(
n) &&
match.second.at(
n) > 0)
667 unsigned countMuonStationsWithHits(
int first_station,
int last_station)
const {
668 static const std::map<int, std::vector<bool>> masks = {
674 const size_t first_station_index = getStationIndex(first_station,
true);
675 const size_t last_station_index = getStationIndex(last_station,
true);
677 for (
size_t n = first_station_index;
n <= last_station_index; ++
n) {
678 for (
const auto&
hit : n_hits) {
679 if (!masks.at(
hit.first).at(
n) &&
hit.second.at(
n) > 0)
687 CountMap n_matches, n_hits;
693 PfCand_chargedHadron,
694 PfCand_neutralHadron,
701 template <
typename Object>
714 static const std::map<int, CellObjectType> obj_types = {{11, CellObjectType::PfCand_electron},
715 {13, CellObjectType::PfCand_muon},
716 {22, CellObjectType::PfCand_gamma},
717 {130, CellObjectType::PfCand_neutralHadron},
718 {211, CellObjectType::PfCand_chargedHadron}};
721 if (iter == obj_types.end())
722 return CellObjectType::Other;
726 using Cell = std::map<CellObjectType, size_t>;
739 using Map = std::map<CellIndex, Cell>;
740 using const_iterator = Map::const_iterator;
742 CellGrid(
unsigned n_cells_eta,
743 unsigned n_cells_phi,
744 double cell_size_eta,
745 double cell_size_phi,
747 : nCellsEta(n_cells_eta),
748 nCellsPhi(n_cells_phi),
749 nTotal(nCellsEta * nCellsPhi),
750 cellSizeEta(cell_size_eta),
751 cellSizePhi(cell_size_phi),
753 if (nCellsEta % 2 != 1 || nCellsEta < 1)
754 throw cms::Exception(
"DeepTauId") <<
"Invalid number of eta cells.";
755 if (nCellsPhi % 2 != 1 || nCellsPhi < 1)
756 throw cms::Exception(
"DeepTauId") <<
"Invalid number of phi cells.";
757 if (cellSizeEta <= 0 || cellSizePhi <= 0)
761 int maxEtaIndex()
const {
return static_cast<int>((nCellsEta - 1) / 2); }
762 int maxPhiIndex()
const {
return static_cast<int>((nCellsPhi - 1) / 2); }
763 double maxDeltaEta()
const {
return cellSizeEta * (0.5 + maxEtaIndex()); }
764 double maxDeltaPhi()
const {
return cellSizePhi * (0.5 + maxPhiIndex()); }
765 int getEtaTensorIndex(
const CellIndex& cellIndex)
const {
return cellIndex.eta + maxEtaIndex(); }
766 int getPhiTensorIndex(
const CellIndex& cellIndex)
const {
return cellIndex.phi + maxPhiIndex(); }
768 bool tryGetCellIndex(
double deltaEta,
double deltaPhi, CellIndex& cellIndex)
const {
769 const auto getCellIndex = [
this](
double x,
double maxX,
double size,
int&
index) {
774 if (disable_CellIndex_workaround_) {
777 absIndex = std::floor(absX /
size + 0.5);
782 index =
static_cast<int>(std::copysign(absIndex,
x));
790 size_t num_valid_cells()
const {
return cells.size(); }
792 const Cell& at(
const CellIndex& cellIndex)
const {
return cells.at(cellIndex); }
793 size_t count(
const CellIndex& cellIndex)
const {
return cells.count(cellIndex); }
794 const_iterator
find(
const CellIndex& cellIndex)
const {
return cells.find(cellIndex); }
795 const_iterator begin()
const {
return cells.begin(); }
796 const_iterator
end()
const {
return cells.end(); }
799 const unsigned nCellsEta, nCellsPhi, nTotal;
800 const double cellSizeEta, cellSizePhi;
803 std::map<CellIndex, Cell>
cells;
804 const bool disable_CellIndex_workaround_;
810 {bd::ChargedIsoPtSum,
"ChargedIsoPtSum"},
811 {bd::NeutralIsoPtSum,
"NeutralIsoPtSum"},
812 {bd::NeutralIsoPtSumWeight,
"NeutralIsoPtSumWeight"},
813 {bd::FootprintCorrection,
"TauFootprintCorrection"},
814 {bd::PhotonPtSumOutsideSignalCone,
"PhotonPtSumOutsideSignalCone"},
815 {bd::PUcorrPtSum,
"PUcorrPtSum"}};
818 bd::NeutralIsoPtSumWeight,
819 bd::PhotonPtSumOutsideSignalCone,
823 bd::NeutralIsoPtSumWeight,
824 bd::PhotonPtSumOutsideSignalCone,
825 bd::FootprintCorrection};
832 static constexpr
size_t e_index = 0, mu_index = 1, tau_index = 2, jet_index = 3;
834 {
"VSe",
Output({tau_index}, {e_index, tau_index})},
835 {
"VSmu",
Output({tau_index}, {mu_index, tau_index})},
836 {
"VSjet",
Output({tau_index}, {jet_index, tau_index})},
844 std::vector<BasicDiscriminator> requiredDiscr) {
845 std::map<std::string, size_t> discrIndexMapStr;
846 auto const aHandle =
event.getHandle(discriminatorContainerToken);
847 auto const aProv = aHandle.provenance();
848 if (aProv ==
nullptr)
849 aHandle.whyFailed()->raise();
850 const auto& psetsFromProvenance =
edm::parameterSet(aProv->stable(),
event.processHistory());
851 auto const idlist = psetsFromProvenance.
getParameter<std::vector<edm::ParameterSet>>(
"IDdefinitions");
852 for (
size_t j = 0;
j < idlist.size(); ++
j) {
854 if (discrIndexMapStr.count(idname)) {
856 <<
"basic discriminator " << idname <<
" appears more than once in the input.";
858 discrIndexMapStr[idname] =
j;
862 std::map<BasicDiscriminator, size_t> discrIndexMap;
863 for (
size_t i = 0;
i < requiredDiscr.size();
i++) {
866 <<
" was not provided in the config file.";
870 return discrIndexMap;
881 desc.add<std::vector<std::string>>(
"graph_file",
882 {
"RecoTauTag/TrainingFiles/data/DeepTauId/deepTau_2017v2p6_e6.pb"});
883 desc.add<
bool>(
"mem_mapped",
false);
884 desc.add<
unsigned>(
"version", 2);
885 desc.add<
unsigned>(
"sub_version", 1);
886 desc.add<
int>(
"debug_level", 0);
887 desc.add<
bool>(
"disable_dxy_pca",
false);
888 desc.add<
bool>(
"disable_hcalFraction_workaround",
false);
889 desc.add<
bool>(
"disable_CellIndex_workaround",
false);
890 desc.add<
bool>(
"save_inputs",
false);
891 desc.add<
bool>(
"is_online",
false);
893 desc.add<std::vector<std::string>>(
"VSeWP", {
"-1."});
894 desc.add<std::vector<std::string>>(
"VSmuWP", {
"-1."});
895 desc.add<std::vector<std::string>>(
"VSjetWP", {
"-1."});
906 psd1.
add<
double>(
"cut");
913 descriptions.
add(
"DeepTau",
desc);
923 cfg.getUntrackedParameter<
edm::
InputTag>(
"basicTauDiscriminators"))),
925 cfg.getUntrackedParameter<
edm::
InputTag>(
"basicTauDiscriminatorsdR03"))),
928 cfg.getParameter<
edm::
InputTag>(
"pfTauTransverseImpactParameters"))),
946 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, TauBlockInputs::NumberOfInputs});
949 std::sort(TauBlockInputs::varsToDrop.begin(), TauBlockInputs::varsToDrop.
end());
950 for (
auto v : TauBlockInputs::varsToDrop) {
952 for (std::size_t
i =
v + 1;
i < TauBlockInputs::NumberOfInputs; ++
i)
956 tensorflow::DT_FLOAT,
957 tensorflow::TensorShape{1,
958 static_cast<int>(TauBlockInputs::NumberOfInputs) -
959 static_cast<int>(TauBlockInputs::varsToDrop.
size())});
964 std::map<std::vector<bool>, std::vector<sc::FeatureT>> GridFeatureTypes_map = {
965 {{
false}, {sc::FeatureT::TauFlat, sc::FeatureT::GridGlobal}},
967 {sc::FeatureT::PfCand_electron,
968 sc::FeatureT::PfCand_muon,
969 sc::FeatureT::PfCand_chHad,
970 sc::FeatureT::PfCand_nHad,
971 sc::FeatureT::PfCand_gamma,
976 for (
const auto&
p : GridFeatureTypes_map) {
977 for (
auto is_inner :
p.first) {
978 for (
auto featureType :
p.second) {
979 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(featureType, is_inner));
980 if (!(sp.mean_.size() == sp.std_.size() && sp.mean_.size() == sp.lim_min_.size() &&
981 sp.mean_.size() == sp.lim_max_.size()))
982 throw cms::Exception(
"DeepTauId") <<
"sizes of scaling parameter vectors do not match between each other";
987 for (
size_t n = 0;
n < 2; ++
n) {
988 const bool is_inner =
n == 0;
989 const auto n_cells = is_inner ? number_of_inner_cell : number_of_outer_cell;
990 eGammaTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
991 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, 1, 1, EgammaBlockInputs::NumberOfInputs});
992 muonTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
993 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, 1, 1, MuonBlockInputs::NumberOfInputs});
995 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, 1, 1, HadronBlockInputs::NumberOfInputs});
996 convTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
997 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, n_cells, n_cells, number_of_conv_features});
999 tensorflow::DT_FLOAT, tensorflow::TensorShape{1, 1, 1, number_of_conv_features});
1013 return DeepTauBase::initializeGlobalCache(
cfg);
1021 template <
typename T>
1023 return std::isnormal(
value) ?
static_cast<float>(
value) : 0.
f;
1026 template <
typename T>
1032 transformed_value = transformed_value * 2 - 1;
1033 return transformed_value;
1036 template <
typename T>
1039 const float norm_value = (fixed_value -
mean) / sigma;
1040 return std::clamp(norm_value, -n_sigmas_max, n_sigmas_max);
1046 float& cc_ele_energy,
1047 float& cc_gamma_energy,
1049 cc_ele_energy = cc_gamma_energy = 0;
1052 if (superCluster.isNonnull() && superCluster.isAvailable() && superCluster->clusters().isNonnull() &&
1053 superCluster->clusters().isAvailable()) {
1054 for (
auto iter = superCluster->clustersBegin(); iter != superCluster->clustersEnd(); ++iter) {
1055 const float energy =
static_cast<float>((*iter)->energy());
1056 if (iter == superCluster->clustersBegin())
1059 cc_gamma_energy +=
energy;
1071 const CellGrid*
grid =
nullptr)
const {
1073 std::cout <<
"<checkInputs>: block_name = " << block_name << std::endl;
1074 if (block_name ==
"input_tau") {
1075 for (
int input_index = 0; input_index < n_inputs; ++input_index) {
1076 float input =
inputs.matrix<
float>()(0, input_index);
1079 <<
"in the " << block_name
1080 <<
", input is not finite, i.e. infinite or NaN, for input_index = " << input_index;
1090 if (block_name.find(
"input_inner") != std::string::npos) {
1093 }
else if (block_name.find(
"input_outer") != std::string::npos) {
1098 int eta_phi_index = 0;
1099 for (
int eta = -n_eta;
eta <= n_eta; ++
eta) {
1100 for (
int phi = -n_phi;
phi <= n_phi; ++
phi) {
1101 const CellIndex cell_index{
eta,
phi};
1102 const auto cell_iter =
grid->find(cell_index);
1103 if (cell_iter !=
grid->end()) {
1104 for (
int input_index = 0; input_index < n_inputs; ++input_index) {
1108 <<
"in the " << block_name <<
", input is not finite, i.e. infinite or NaN, for eta = " <<
eta 1109 <<
", phi = " <<
phi <<
", input_index = " << input_index;
1112 std::cout << block_name <<
"[eta = " <<
eta <<
"][phi = " <<
phi <<
"][var = " << input_index
1113 <<
"] = " << std::setprecision(5) <<
std::fixed <<
input << std::endl;
1127 const CellGrid*
grid =
nullptr) {
1129 std::cout <<
"<saveInputs>: block_name = " << block_name << std::endl;
1132 (*json_file_) <<
", ";
1133 (*json_file_) <<
"\"" << block_name <<
"\": [";
1134 if (block_name ==
"input_tau") {
1135 for (
int input_index = 0; input_index < n_inputs; ++input_index) {
1136 float input =
inputs.matrix<
float>()(0, input_index);
1137 if (input_index != 0)
1138 (*json_file_) <<
", ";
1139 (*json_file_) <<
input;
1144 if (block_name.find(
"input_inner") != std::string::npos) {
1147 }
else if (block_name.find(
"input_outer") != std::string::npos) {
1152 int eta_phi_index = 0;
1153 for (
int eta = -n_eta;
eta <= n_eta; ++
eta) {
1155 (*json_file_) <<
", ";
1156 (*json_file_) <<
"[";
1157 for (
int phi = -n_phi;
phi <= n_phi; ++
phi) {
1159 (*json_file_) <<
", ";
1160 (*json_file_) <<
"[";
1161 const CellIndex cell_index{
eta,
phi};
1162 const auto cell_iter =
grid->find(cell_index);
1163 for (
int input_index = 0; input_index < n_inputs; ++input_index) {
1165 if (cell_iter !=
grid->end()) {
1168 if (input_index != 0)
1169 (*json_file_) <<
", ";
1170 (*json_file_) <<
input;
1172 if (cell_iter !=
grid->end()) {
1175 (*json_file_) <<
"]";
1177 (*json_file_) <<
"]";
1180 (*json_file_) <<
"]";
1187 const std::vector<pat::Electron> electron_collection_default;
1188 const std::vector<pat::Muon> muon_collection_default;
1192 pfTauTransverseImpactParameters_default;
1194 const std::vector<pat::Electron>* electron_collection;
1195 const std::vector<pat::Muon>* muon_collection;
1208 electron_collection = &electron_collection_default;
1209 muon_collection = &muon_collection_default;
1241 for (
size_t tau_index = 0; tau_index <
taus->size(); ++tau_index) {
1244 std::vector<tensorflow::Tensor> pred_vector;
1246 bool passesPrediscriminants;
1248 passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<reco::PFTauDiscriminator>>>(
1251 passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<pat::PATTauDiscriminator>>>(
1255 if (passesPrediscriminants) {
1258 getPredictionsV2<reco::PFCandidate, reco::PFTau>(
taus->at(tau_index),
1261 electron_collection,
1269 getPredictionsV2<pat::PackedCandidate, pat::Tau>(
taus->at(tau_index),
1272 electron_collection,
1284 const float pred = pred_vector[0].flat<
float>()(
k);
1285 if (!(pred >= 0 && pred <= 1))
1287 <<
"invalid prediction = " << pred <<
" for tau_index = " << tau_index <<
", pred_index = " <<
k;
1288 predictions.matrix<
float>()(tau_index,
k) = pred;
1297 predictions.matrix<
float>()(tau_index,
k) = (
k == 2) ? -1.
f : 2.
f;
1304 template <
typename Cand
idateCastType,
typename TauCastType>
1306 const size_t tau_index,
1308 const std::vector<pat::Electron>*
electrons,
1309 const std::vector<pat::Muon>*
muons,
1313 std::vector<tensorflow::Tensor>& pred_vector,
1314 TauFunc tau_funcs) {
1317 std::cout <<
"<DeepTauId::getPredictionsV2 (moduleLabel = " << moduleDescription().moduleLabel()
1318 <<
")>:" << std::endl;
1319 std::cout <<
" tau: pT = " <<
tau.pt() <<
", eta = " <<
tau.eta() <<
", phi = " <<
tau.phi() << std::endl;
1324 fillGrids(dynamic_cast<const TauCastType&>(
tau), *
muons, inner_grid, outer_grid);
1325 fillGrids(dynamic_cast<const TauCastType&>(
tau), pfCands, inner_grid, outer_grid);
1327 createTauBlockInputs<CandidateCastType>(
1328 dynamic_cast<const TauCastType&
>(
tau), tau_index, tau_ref,
pv,
rho, tau_funcs);
1330 createConvFeatures<CandidateCastType>(
dynamic_cast<const TauCastType&
>(
tau),
1344 createConvFeatures<CandidateCastType>(
dynamic_cast<const TauCastType&
>(
tau),
1361 json_file_ =
new std::ofstream(json_file_name.data());
1363 (*json_file_) <<
"{";
1366 *
eGammaTensor_[
true],
"input_inner_egamma", dnn_inputs_v2::EgammaBlockInputs::NumberOfInputs, &inner_grid);
1367 saveInputs(*
muonTensor_[
true],
"input_inner_muon", dnn_inputs_v2::MuonBlockInputs::NumberOfInputs, &inner_grid);
1369 *
hadronsTensor_[
true],
"input_inner_hadrons", dnn_inputs_v2::HadronBlockInputs::NumberOfInputs, &inner_grid);
1371 *
eGammaTensor_[
false],
"input_outer_egamma", dnn_inputs_v2::EgammaBlockInputs::NumberOfInputs, &outer_grid);
1372 saveInputs(*
muonTensor_[
false],
"input_outer_muon", dnn_inputs_v2::MuonBlockInputs::NumberOfInputs, &outer_grid);
1374 *
hadronsTensor_[
false],
"input_outer_hadrons", dnn_inputs_v2::HadronBlockInputs::NumberOfInputs, &outer_grid);
1375 (*json_file_) <<
"}";
1384 {
"main_output/Softmax"},
1408 template <
typename Collection,
typename TauCastType>
1409 void fillGrids(
const TauCastType&
tau,
const Collection&
objects, CellGrid& inner_grid, CellGrid& outer_grid) {
1410 static constexpr
double outer_dR2 = 0.25;
1412 const double inner_dR2 =
std::pow(inner_radius, 2);
1414 const auto addObject = [&](
size_t n,
double deta,
double dphi, CellGrid&
grid) {
1417 if (obj_type == CellObjectType::Other)
1419 CellIndex cell_index;
1420 if (
grid.tryGetCellIndex(deta, dphi, cell_index)) {
1422 auto iter = cell.find(obj_type);
1423 if (iter != cell.end()) {
1424 const auto& prev_obj =
objects.at(iter->second);
1425 if (
obj.polarP4().pt() > prev_obj.polarP4().pt())
1433 for (
size_t n = 0;
n <
objects.size(); ++
n) {
1435 const double deta =
obj.polarP4().eta() -
tau.polarP4().eta();
1438 if (dR2 < inner_dR2)
1439 addObject(
n, deta, dphi, inner_grid);
1440 if (dR2 < outer_dR2)
1441 addObject(
n, deta, dphi, outer_grid);
1446 std::vector<tensorflow::Tensor> pred_vector;
1454 {
"inner_all_dropout_4/Identity"},
1463 {
"outer_all_dropout_4/Identity"},
1466 return pred_vector.at(0);
1469 template <
typename Cand
idateCastType,
typename TauCastType>
1471 const size_t tau_index,
1475 const std::vector<pat::Electron>*
electrons,
1476 const std::vector<pat::Muon>*
muons,
1478 const CellGrid&
grid,
1482 std::cout <<
"<DeepTauId::createConvFeatures (is_inner = " << is_inner <<
")>:" << std::endl;
1484 tensorflow::Tensor& convTensor = *
convTensor_.at(is_inner);
1485 eGammaTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1486 tensorflow::DT_FLOAT,
1487 tensorflow::TensorShape{
1488 (
long long int)
grid.num_valid_cells(), 1, 1, dnn_inputs_v2::EgammaBlockInputs::NumberOfInputs});
1489 muonTensor_[is_inner] = std::make_unique<tensorflow::Tensor>(
1490 tensorflow::DT_FLOAT,
1491 tensorflow::TensorShape{
1492 (
long long int)
grid.num_valid_cells(), 1, 1, dnn_inputs_v2::MuonBlockInputs::NumberOfInputs});
1494 tensorflow::DT_FLOAT,
1495 tensorflow::TensorShape{
1496 (
long long int)
grid.num_valid_cells(), 1, 1, dnn_inputs_v2::HadronBlockInputs::NumberOfInputs});
1506 std::cout <<
"processing ( eta = " <<
eta <<
", phi = " <<
phi <<
" )" << std::endl;
1508 const CellIndex cell_index{
eta,
phi};
1509 const auto cell_iter =
grid.find(cell_index);
1510 if (cell_iter !=
grid.end()) {
1512 std::cout <<
" creating inputs for ( eta = " <<
eta <<
", phi = " <<
phi <<
" ): idx = " <<
idx 1515 const Cell& cell = cell_iter->second;
1516 createEgammaBlockInputs<CandidateCastType>(
1517 idx,
tau, tau_index, tau_ref,
pv,
rho,
electrons, pfCands, cell, tau_funcs, is_inner);
1518 createMuonBlockInputs<CandidateCastType>(
1519 idx,
tau, tau_index, tau_ref,
pv,
rho,
muons, pfCands, cell, tau_funcs, is_inner);
1520 createHadronsBlockInputs<CandidateCastType>(
1521 idx,
tau, tau_index, tau_ref,
pv,
rho, pfCands, cell, tau_funcs, is_inner);
1525 std::cout <<
" skipping creation of inputs, because ( eta = " <<
eta <<
", phi = " <<
phi 1526 <<
" ) is not in the grid !!" << std::endl;
1536 const CellIndex cell_index{
eta,
phi};
1537 const int eta_index =
grid.getEtaTensorIndex(cell_index);
1538 const int phi_index =
grid.getPhiTensorIndex(cell_index);
1540 const auto cell_iter =
grid.find(cell_index);
1541 if (cell_iter !=
grid.end()) {
1552 const tensorflow::Tensor&
features,
1556 for (
int n = 0;
n < dnn_inputs_v2::number_of_conv_features; ++
n) {
1557 convTensor.tensor<
float, 4>()(0, eta_index, phi_index,
n) =
features.tensor<
float, 4>()(batch_idx, 0, 0,
n);
1561 template <
typename Cand
idateCastType,
typename TauCastType>
1563 const size_t& tau_index,
1567 TauFunc tau_funcs) {
1574 inputs.flat<
float>().setZero();
1576 const auto&
get = [&](
int var_index) ->
float& {
1580 auto leadChargedHadrCand =
dynamic_cast<const CandidateCastType*
>(
tau.leadChargedHadrCand().get());
1591 get(dnn::tau_n_charged_prongs) = sp.scale(
tau.decayMode() / 5 + 1,
tauInputs_indices_[dnn::tau_n_charged_prongs]);
1592 get(dnn::tau_n_neutral_prongs) = sp.scale(
tau.decayMode() % 5,
tauInputs_indices_[dnn::tau_n_neutral_prongs]);
1593 get(dnn::chargedIsoPtSum) =
1595 get(dnn::chargedIsoPtSumdR03_over_dR05) =
1596 sp.scale(tau_funcs.getChargedIsoPtSumdR03(
tau, tau_ref) / tau_funcs.getChargedIsoPtSum(
tau, tau_ref),
1599 get(dnn::footprintCorrection) =
1600 sp.scale(tau_funcs.getFootprintCorrectiondR03(
tau, tau_ref),
tauInputs_indices_[dnn::footprintCorrection]);
1602 get(dnn::footprintCorrection) =
1603 sp.scale(tau_funcs.getFootprintCorrection(
tau, tau_ref),
tauInputs_indices_[dnn::footprintCorrection]);
1605 get(dnn::neutralIsoPtSum) =
1607 get(dnn::neutralIsoPtSumWeight_over_neutralIsoPtSum) =
1608 sp.scale(tau_funcs.getNeutralIsoPtSumWeight(
tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(
tau, tau_ref),
1610 get(dnn::neutralIsoPtSumWeightdR03_over_neutralIsoPtSum) =
1611 sp.scale(tau_funcs.getNeutralIsoPtSumdR03Weight(
tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(
tau, tau_ref),
1613 get(dnn::neutralIsoPtSumdR03_over_dR05) =
1614 sp.scale(tau_funcs.getNeutralIsoPtSumdR03(
tau, tau_ref) / tau_funcs.getNeutralIsoPtSum(
tau, tau_ref),
1616 get(dnn::photonPtSumOutsideSignalCone) = sp.scale(tau_funcs.getPhotonPtSumOutsideSignalCone(
tau, tau_ref),
1618 get(dnn::puCorrPtSum) = sp.scale(tau_funcs.getPuCorrPtSum(
tau, tau_ref),
tauInputs_indices_[dnn::puCorrPtSum]);
1625 auto const pca = tau_funcs.getdxyPCA(
tau, tau_index);
1630 get(dnn::tau_dxy_pca_x) = 0;
1631 get(dnn::tau_dxy_pca_y) = 0;
1632 get(dnn::tau_dxy_pca_z) = 0;
1636 const bool tau_dxy_valid =
1637 isAbove(tau_funcs.getdxy(
tau, tau_index), -10) &&
isAbove(tau_funcs.getdxyError(
tau, tau_index), 0);
1638 if (tau_dxy_valid) {
1639 get(dnn::tau_dxy_valid) = sp.scale(tau_dxy_valid,
tauInputs_indices_[dnn::tau_dxy_valid]);
1641 get(dnn::tau_dxy_sig) =
1642 sp.scale(
std::abs(tau_funcs.getdxy(
tau, tau_index)) / tau_funcs.getdxyError(
tau, tau_index),
1645 const bool tau_ip3d_valid =
1646 isAbove(tau_funcs.getip3d(
tau, tau_index), -10) &&
isAbove(tau_funcs.getip3dError(
tau, tau_index), 0);
1647 if (tau_ip3d_valid) {
1648 get(dnn::tau_ip3d_valid) = sp.scale(tau_ip3d_valid,
tauInputs_indices_[dnn::tau_ip3d_valid]);
1649 get(dnn::tau_ip3d) = sp.scale(tau_funcs.getip3d(
tau, tau_index),
tauInputs_indices_[dnn::tau_ip3d]);
1650 get(dnn::tau_ip3d_sig) =
1651 sp.scale(
std::abs(tau_funcs.getip3d(
tau, tau_index)) / tau_funcs.getip3dError(
tau, tau_index),
1654 if (leadChargedHadrCand) {
1655 const bool hasTrackDetails = candFunc::getHasTrackDetails(*leadChargedHadrCand);
1656 const float tau_dz = (
is_online_ && !hasTrackDetails) ? 0 : candFunc::getTauDz(*leadChargedHadrCand);
1658 get(dnn::tau_dz_sig_valid) =
1659 sp.scale(candFunc::getTauDZSigValid(*leadChargedHadrCand),
tauInputs_indices_[dnn::tau_dz_sig_valid]);
1660 const double dzError = hasTrackDetails ? leadChargedHadrCand->dzError() : -999.;
1663 get(dnn::tau_flightLength_x) =
1664 sp.scale(tau_funcs.getFlightLength(
tau, tau_index).x(),
tauInputs_indices_[dnn::tau_flightLength_x]);
1665 get(dnn::tau_flightLength_y) =
1666 sp.scale(tau_funcs.getFlightLength(
tau, tau_index).y(),
tauInputs_indices_[dnn::tau_flightLength_y]);
1667 get(dnn::tau_flightLength_z) =
1668 sp.scale(tau_funcs.getFlightLength(
tau, tau_index).z(),
tauInputs_indices_[dnn::tau_flightLength_z]);
1670 get(dnn::tau_flightLength_sig) = 0.55756444;
1672 get(dnn::tau_flightLength_sig) =
1673 sp.scale(tau_funcs.getFlightLengthSig(
tau, tau_index),
tauInputs_indices_[dnn::tau_flightLength_sig]);
1682 get(dnn::tau_pt_weighted_dr_iso) =
1684 get(dnn::tau_leadingTrackNormChi2) =
1685 sp.scale(tau_funcs.getLeadingTrackNormChi2(
tau),
tauInputs_indices_[dnn::tau_leadingTrackNormChi2]);
1687 const bool tau_e_ratio_valid = std::isnormal(
eratio) &&
eratio > 0.f;
1688 get(dnn::tau_e_ratio_valid) = sp.scale(tau_e_ratio_valid,
tauInputs_indices_[dnn::tau_e_ratio_valid]);
1691 const bool tau_gj_angle_diff_valid = (std::isnormal(gj_angle_diff) || gj_angle_diff == 0) && gj_angle_diff >= 0;
1692 get(dnn::tau_gj_angle_diff_valid) =
1694 get(dnn::tau_gj_angle_diff) =
1695 tau_gj_angle_diff_valid ? sp.scale(gj_angle_diff,
tauInputs_indices_[dnn::tau_gj_angle_diff]) : 0;
1697 get(dnn::tau_emFraction) = sp.scale(tau_funcs.getEmFraction(
tau),
tauInputs_indices_[dnn::tau_emFraction]);
1699 get(dnn::tau_inside_ecal_crack) =
1701 get(dnn::leadChargedCand_etaAtEcalEntrance_minus_tau_eta) =
1702 sp.scale(tau_funcs.getEtaAtEcalEntrance(
tau) -
tau.p4().eta(),
1706 template <
typename Cand
idateCastType,
typename TauCastType>
1708 const TauCastType&
tau,
1709 const size_t tau_index,
1713 const std::vector<pat::Electron>*
electrons,
1715 const Cell& cell_map,
1726 int PFe_index_offset =
scalingParamsMap_->at(std::make_pair(ft_global,
false)).mean_.size();
1727 int e_index_offset = PFe_index_offset +
scalingParamsMap_->at(std::make_pair(ft_PFe,
false)).mean_.size();
1728 int PFg_index_offset = e_index_offset +
scalingParamsMap_->at(std::make_pair(ft_e,
false)).mean_.size();
1731 int fill_index_offset_e = 0;
1732 int fill_index_offset_PFg = 0;
1734 fill_index_offset_e =
1736 fill_index_offset_PFg =
1742 const auto&
get = [&](
int var_index) ->
float& {
return inputs.tensor<
float, 4>()(
idx, 0, 0, var_index); };
1744 const bool valid_index_pf_ele = cell_map.count(CellObjectType::PfCand_electron);
1745 const bool valid_index_pf_gamma = cell_map.count(CellObjectType::PfCand_gamma);
1748 if (!cell_map.empty()) {
1749 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_global,
false));
1753 get(dnn::tau_inside_ecal_crack) = sp.scale(
isInEcalCrack(
tau.polarP4().eta()), dnn::tau_inside_ecal_crack);
1755 if (valid_index_pf_ele) {
1756 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFe, is_inner));
1757 size_t index_pf_ele = cell_map.at(CellObjectType::PfCand_electron);
1758 const auto& ele_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_pf_ele));
1760 get(dnn::pfCand_ele_valid) = sp.scale(valid_index_pf_ele, dnn::pfCand_ele_valid - PFe_index_offset);
1761 get(dnn::pfCand_ele_rel_pt) =
1762 sp.scale(ele_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_ele_rel_pt - PFe_index_offset);
1763 get(dnn::pfCand_ele_deta) =
1764 sp.scale(ele_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_ele_deta - PFe_index_offset);
1765 get(dnn::pfCand_ele_dphi) =
1766 sp.scale(
dPhi(
tau.polarP4(), ele_cand.polarP4()), dnn::pfCand_ele_dphi - PFe_index_offset);
1767 get(dnn::pfCand_ele_pvAssociationQuality) = sp.scale<
int>(
1768 candFunc::getPvAssocationQuality(ele_cand), dnn::pfCand_ele_pvAssociationQuality - PFe_index_offset);
1769 get(dnn::pfCand_ele_puppiWeight) = is_inner ? sp.scale(candFunc::getPuppiWeight(ele_cand, 0.9906834f),
1770 dnn::pfCand_ele_puppiWeight - PFe_index_offset)
1771 : sp.scale(candFunc::getPuppiWeight(ele_cand, 0.9669586
f),
1772 dnn::pfCand_ele_puppiWeight - PFe_index_offset);
1773 get(dnn::pfCand_ele_charge) = sp.scale(ele_cand.charge(), dnn::pfCand_ele_charge - PFe_index_offset);
1774 get(dnn::pfCand_ele_lostInnerHits) =
1775 sp.scale<
int>(candFunc::getLostInnerHits(ele_cand, 0), dnn::pfCand_ele_lostInnerHits - PFe_index_offset);
1776 get(dnn::pfCand_ele_numberOfPixelHits) =
1777 sp.scale(candFunc::getNumberOfPixelHits(ele_cand, 0), dnn::pfCand_ele_numberOfPixelHits - PFe_index_offset);
1778 get(dnn::pfCand_ele_vertex_dx) =
1779 sp.scale(ele_cand.vertex().x() -
pv.position().x(), dnn::pfCand_ele_vertex_dx - PFe_index_offset);
1780 get(dnn::pfCand_ele_vertex_dy) =
1781 sp.scale(ele_cand.vertex().y() -
pv.position().y(), dnn::pfCand_ele_vertex_dy - PFe_index_offset);
1782 get(dnn::pfCand_ele_vertex_dz) =
1783 sp.scale(ele_cand.vertex().z() -
pv.position().z(), dnn::pfCand_ele_vertex_dz - PFe_index_offset);
1784 get(dnn::pfCand_ele_vertex_dx_tauFL) =
1785 sp.scale(ele_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
1786 dnn::pfCand_ele_vertex_dx_tauFL - PFe_index_offset);
1787 get(dnn::pfCand_ele_vertex_dy_tauFL) =
1788 sp.scale(ele_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
1789 dnn::pfCand_ele_vertex_dy_tauFL - PFe_index_offset);
1790 get(dnn::pfCand_ele_vertex_dz_tauFL) =
1791 sp.scale(ele_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
1792 dnn::pfCand_ele_vertex_dz_tauFL - PFe_index_offset);
1794 const bool hasTrackDetails = candFunc::getHasTrackDetails(ele_cand);
1795 if (hasTrackDetails) {
1796 get(dnn::pfCand_ele_hasTrackDetails) =
1797 sp.scale(hasTrackDetails, dnn::pfCand_ele_hasTrackDetails - PFe_index_offset);
1798 get(dnn::pfCand_ele_dxy) = sp.scale(candFunc::getTauDxy(ele_cand), dnn::pfCand_ele_dxy - PFe_index_offset);
1799 get(dnn::pfCand_ele_dxy_sig) = sp.scale(
std::abs(candFunc::getTauDxy(ele_cand)) / ele_cand.dxyError(),
1800 dnn::pfCand_ele_dxy_sig - PFe_index_offset);
1801 get(dnn::pfCand_ele_dz) = sp.scale(candFunc::getTauDz(ele_cand), dnn::pfCand_ele_dz - PFe_index_offset);
1802 get(dnn::pfCand_ele_dz_sig) = sp.scale(
std::abs(candFunc::getTauDz(ele_cand)) / ele_cand.dzError(),
1803 dnn::pfCand_ele_dz_sig - PFe_index_offset);
1804 get(dnn::pfCand_ele_track_chi2_ndof) =
1805 candFunc::getPseudoTrack(ele_cand).ndof() > 0
1806 ? sp.scale(candFunc::getPseudoTrack(ele_cand).
chi2() / candFunc::getPseudoTrack(ele_cand).
ndof(),
1807 dnn::pfCand_ele_track_chi2_ndof - PFe_index_offset)
1809 get(dnn::pfCand_ele_track_ndof) =
1810 candFunc::getPseudoTrack(ele_cand).ndof() > 0
1811 ? sp.scale(candFunc::getPseudoTrack(ele_cand).
ndof(), dnn::pfCand_ele_track_ndof - PFe_index_offset)
1815 if (valid_index_pf_gamma) {
1816 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFg, is_inner));
1817 size_t index_pf_gamma = cell_map.at(CellObjectType::PfCand_gamma);
1818 const auto& gamma_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_pf_gamma));
1820 get(dnn::pfCand_gamma_valid + fill_index_offset_PFg) =
1821 sp.scale(valid_index_pf_gamma, dnn::pfCand_gamma_valid - PFg_index_offset);
1822 get(dnn::pfCand_gamma_rel_pt + fill_index_offset_PFg) =
1823 sp.scale(gamma_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_gamma_rel_pt - PFg_index_offset);
1824 get(dnn::pfCand_gamma_deta + fill_index_offset_PFg) =
1825 sp.scale(gamma_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_gamma_deta - PFg_index_offset);
1826 get(dnn::pfCand_gamma_dphi + fill_index_offset_PFg) =
1827 sp.scale(
dPhi(
tau.polarP4(), gamma_cand.polarP4()), dnn::pfCand_gamma_dphi - PFg_index_offset);
1828 get(dnn::pfCand_gamma_pvAssociationQuality + fill_index_offset_PFg) = sp.scale<
int>(
1829 candFunc::getPvAssocationQuality(gamma_cand), dnn::pfCand_gamma_pvAssociationQuality - PFg_index_offset);
1830 get(dnn::pfCand_gamma_fromPV + fill_index_offset_PFg) =
1831 sp.scale<
int>(candFunc::getFromPV(gamma_cand), dnn::pfCand_gamma_fromPV - PFg_index_offset);
1832 get(dnn::pfCand_gamma_puppiWeight + fill_index_offset_PFg) =
1833 is_inner ? sp.scale(candFunc::getPuppiWeight(gamma_cand, 0.9084110f),
1834 dnn::pfCand_gamma_puppiWeight - PFg_index_offset)
1835 : sp.scale(candFunc::getPuppiWeight(gamma_cand, 0.4211567
f),
1836 dnn::pfCand_gamma_puppiWeight - PFg_index_offset);
1837 get(dnn::pfCand_gamma_puppiWeightNoLep + fill_index_offset_PFg) =
1838 is_inner ? sp.scale(candFunc::getPuppiWeightNoLep(gamma_cand, 0.8857716f),
1839 dnn::pfCand_gamma_puppiWeightNoLep - PFg_index_offset)
1840 : sp.scale(candFunc::getPuppiWeightNoLep(gamma_cand, 0.3822604
f),
1841 dnn::pfCand_gamma_puppiWeightNoLep - PFg_index_offset);
1842 get(dnn::pfCand_gamma_lostInnerHits + fill_index_offset_PFg) =
1843 sp.scale<
int>(candFunc::getLostInnerHits(gamma_cand, 0), dnn::pfCand_gamma_lostInnerHits - PFg_index_offset);
1844 get(dnn::pfCand_gamma_numberOfPixelHits + fill_index_offset_PFg) = sp.scale(
1845 candFunc::getNumberOfPixelHits(gamma_cand, 0), dnn::pfCand_gamma_numberOfPixelHits - PFg_index_offset);
1846 get(dnn::pfCand_gamma_vertex_dx + fill_index_offset_PFg) =
1847 sp.scale(gamma_cand.vertex().x() -
pv.position().x(), dnn::pfCand_gamma_vertex_dx - PFg_index_offset);
1848 get(dnn::pfCand_gamma_vertex_dy + fill_index_offset_PFg) =
1849 sp.scale(gamma_cand.vertex().y() -
pv.position().y(), dnn::pfCand_gamma_vertex_dy - PFg_index_offset);
1850 get(dnn::pfCand_gamma_vertex_dz + fill_index_offset_PFg) =
1851 sp.scale(gamma_cand.vertex().z() -
pv.position().z(), dnn::pfCand_gamma_vertex_dz - PFg_index_offset);
1852 get(dnn::pfCand_gamma_vertex_dx_tauFL + fill_index_offset_PFg) =
1853 sp.scale(gamma_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
1854 dnn::pfCand_gamma_vertex_dx_tauFL - PFg_index_offset);
1855 get(dnn::pfCand_gamma_vertex_dy_tauFL + fill_index_offset_PFg) =
1856 sp.scale(gamma_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
1857 dnn::pfCand_gamma_vertex_dy_tauFL - PFg_index_offset);
1858 get(dnn::pfCand_gamma_vertex_dz_tauFL + fill_index_offset_PFg) =
1859 sp.scale(gamma_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
1860 dnn::pfCand_gamma_vertex_dz_tauFL - PFg_index_offset);
1861 const bool hasTrackDetails = candFunc::getHasTrackDetails(gamma_cand);
1862 if (hasTrackDetails) {
1863 get(dnn::pfCand_gamma_hasTrackDetails + fill_index_offset_PFg) =
1864 sp.scale(hasTrackDetails, dnn::pfCand_gamma_hasTrackDetails - PFg_index_offset);
1865 get(dnn::pfCand_gamma_dxy + fill_index_offset_PFg) =
1866 sp.scale(candFunc::getTauDxy(gamma_cand), dnn::pfCand_gamma_dxy - PFg_index_offset);
1867 get(dnn::pfCand_gamma_dxy_sig + fill_index_offset_PFg) =
1868 sp.scale(
std::abs(candFunc::getTauDxy(gamma_cand)) / gamma_cand.dxyError(),
1869 dnn::pfCand_gamma_dxy_sig - PFg_index_offset);
1870 get(dnn::pfCand_gamma_dz + fill_index_offset_PFg) =
1871 sp.scale(candFunc::getTauDz(gamma_cand), dnn::pfCand_gamma_dz - PFg_index_offset);
1872 get(dnn::pfCand_gamma_dz_sig + fill_index_offset_PFg) =
1873 sp.scale(
std::abs(candFunc::getTauDz(gamma_cand)) / gamma_cand.dzError(),
1874 dnn::pfCand_gamma_dz_sig - PFg_index_offset);
1875 get(dnn::pfCand_gamma_track_chi2_ndof + fill_index_offset_PFg) =
1876 candFunc::getPseudoTrack(gamma_cand).ndof() > 0
1877 ? sp.scale(candFunc::getPseudoTrack(gamma_cand).
chi2() / candFunc::getPseudoTrack(gamma_cand).
ndof(),
1878 dnn::pfCand_gamma_track_chi2_ndof - PFg_index_offset)
1880 get(dnn::pfCand_gamma_track_ndof + fill_index_offset_PFg) =
1881 candFunc::getPseudoTrack(gamma_cand).ndof() > 0
1882 ? sp.scale(candFunc::getPseudoTrack(gamma_cand).
ndof(), dnn::pfCand_gamma_track_ndof - PFg_index_offset)
1886 if (valid_index_ele) {
1887 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_e, is_inner));
1889 const auto& ele =
electrons->at(index_ele);
1891 get(dnn::ele_valid + fill_index_offset_e) = sp.scale(valid_index_ele, dnn::ele_valid - e_index_offset);
1892 get(dnn::ele_rel_pt + fill_index_offset_e) =
1893 sp.scale(ele.polarP4().pt() /
tau.polarP4().pt(), dnn::ele_rel_pt - e_index_offset);
1894 get(dnn::ele_deta + fill_index_offset_e) =
1895 sp.scale(ele.polarP4().eta() -
tau.polarP4().eta(), dnn::ele_deta - e_index_offset);
1896 get(dnn::ele_dphi + fill_index_offset_e) =
1897 sp.scale(
dPhi(
tau.polarP4(), ele.polarP4()), dnn::ele_dphi - e_index_offset);
1899 float cc_ele_energy, cc_gamma_energy;
1903 get(dnn::ele_cc_valid + fill_index_offset_e) = sp.scale(cc_valid, dnn::ele_cc_valid - e_index_offset);
1904 get(dnn::ele_cc_ele_rel_energy + fill_index_offset_e) =
1905 sp.scale(cc_ele_energy / ele.polarP4().pt(), dnn::ele_cc_ele_rel_energy - e_index_offset);
1906 get(dnn::ele_cc_gamma_rel_energy + fill_index_offset_e) =
1907 sp.scale(cc_gamma_energy / cc_ele_energy, dnn::ele_cc_gamma_rel_energy - e_index_offset);
1908 get(dnn::ele_cc_n_gamma + fill_index_offset_e) = sp.scale(cc_n_gamma, dnn::ele_cc_n_gamma - e_index_offset);
1910 get(dnn::ele_rel_trackMomentumAtVtx + fill_index_offset_e) =
1911 sp.scale(ele.trackMomentumAtVtx().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtVtx - e_index_offset);
1912 get(dnn::ele_rel_trackMomentumAtCalo + fill_index_offset_e) = sp.scale(
1913 ele.trackMomentumAtCalo().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtCalo - e_index_offset);
1914 get(dnn::ele_rel_trackMomentumOut + fill_index_offset_e) =
1915 sp.scale(ele.trackMomentumOut().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumOut - e_index_offset);
1916 get(dnn::ele_rel_trackMomentumAtEleClus + fill_index_offset_e) = sp.scale(
1917 ele.trackMomentumAtEleClus().R() / ele.polarP4().pt(), dnn::ele_rel_trackMomentumAtEleClus - e_index_offset);
1918 get(dnn::ele_rel_trackMomentumAtVtxWithConstraint + fill_index_offset_e) =
1919 sp.scale(ele.trackMomentumAtVtxWithConstraint().R() / ele.polarP4().pt(),
1920 dnn::ele_rel_trackMomentumAtVtxWithConstraint - e_index_offset);
1921 get(dnn::ele_rel_ecalEnergy + fill_index_offset_e) =
1922 sp.scale(ele.ecalEnergy() / ele.polarP4().pt(), dnn::ele_rel_ecalEnergy - e_index_offset);
1923 get(dnn::ele_ecalEnergy_sig + fill_index_offset_e) =
1924 sp.scale(ele.ecalEnergy() / ele.ecalEnergyError(), dnn::ele_ecalEnergy_sig - e_index_offset);
1925 get(dnn::ele_eSuperClusterOverP + fill_index_offset_e) =
1926 sp.scale(ele.eSuperClusterOverP(), dnn::ele_eSuperClusterOverP - e_index_offset);
1927 get(dnn::ele_eSeedClusterOverP + fill_index_offset_e) =
1928 sp.scale(ele.eSeedClusterOverP(), dnn::ele_eSeedClusterOverP - e_index_offset);
1929 get(dnn::ele_eSeedClusterOverPout + fill_index_offset_e) =
1930 sp.scale(ele.eSeedClusterOverPout(), dnn::ele_eSeedClusterOverPout - e_index_offset);
1931 get(dnn::ele_eEleClusterOverPout + fill_index_offset_e) =
1932 sp.scale(ele.eEleClusterOverPout(), dnn::ele_eEleClusterOverPout - e_index_offset);
1933 get(dnn::ele_deltaEtaSuperClusterTrackAtVtx + fill_index_offset_e) =
1934 sp.scale(ele.deltaEtaSuperClusterTrackAtVtx(), dnn::ele_deltaEtaSuperClusterTrackAtVtx - e_index_offset);
1935 get(dnn::ele_deltaEtaSeedClusterTrackAtCalo + fill_index_offset_e) =
1936 sp.scale(ele.deltaEtaSeedClusterTrackAtCalo(), dnn::ele_deltaEtaSeedClusterTrackAtCalo - e_index_offset);
1937 get(dnn::ele_deltaEtaEleClusterTrackAtCalo + fill_index_offset_e) =
1938 sp.scale(ele.deltaEtaEleClusterTrackAtCalo(), dnn::ele_deltaEtaEleClusterTrackAtCalo - e_index_offset);
1939 get(dnn::ele_deltaPhiEleClusterTrackAtCalo + fill_index_offset_e) =
1940 sp.scale(ele.deltaPhiEleClusterTrackAtCalo(), dnn::ele_deltaPhiEleClusterTrackAtCalo - e_index_offset);
1941 get(dnn::ele_deltaPhiSuperClusterTrackAtVtx + fill_index_offset_e) =
1942 sp.scale(ele.deltaPhiSuperClusterTrackAtVtx(), dnn::ele_deltaPhiSuperClusterTrackAtVtx - e_index_offset);
1943 get(dnn::ele_deltaPhiSeedClusterTrackAtCalo + fill_index_offset_e) =
1944 sp.scale(ele.deltaPhiSeedClusterTrackAtCalo(), dnn::ele_deltaPhiSeedClusterTrackAtCalo - e_index_offset);
1945 get(dnn::ele_mvaInput_earlyBrem + fill_index_offset_e) =
1946 sp.scale(ele.mvaInput().earlyBrem, dnn::ele_mvaInput_earlyBrem - e_index_offset);
1947 get(dnn::ele_mvaInput_lateBrem + fill_index_offset_e) =
1948 sp.scale(ele.mvaInput().lateBrem, dnn::ele_mvaInput_lateBrem - e_index_offset);
1949 get(dnn::ele_mvaInput_sigmaEtaEta + fill_index_offset_e) =
1950 sp.scale(ele.mvaInput().sigmaEtaEta, dnn::ele_mvaInput_sigmaEtaEta - e_index_offset);
1951 get(dnn::ele_mvaInput_hadEnergy + fill_index_offset_e) =
1952 sp.scale(ele.mvaInput().hadEnergy, dnn::ele_mvaInput_hadEnergy - e_index_offset);
1953 get(dnn::ele_mvaInput_deltaEta + fill_index_offset_e) =
1954 sp.scale(ele.mvaInput().deltaEta, dnn::ele_mvaInput_deltaEta - e_index_offset);
1955 const auto& gsfTrack = ele.gsfTrack();
1956 if (gsfTrack.isNonnull()) {
1957 get(dnn::ele_gsfTrack_normalizedChi2 + fill_index_offset_e) =
1958 sp.scale(gsfTrack->normalizedChi2(), dnn::ele_gsfTrack_normalizedChi2 - e_index_offset);
1959 get(dnn::ele_gsfTrack_numberOfValidHits + fill_index_offset_e) =
1960 sp.scale(gsfTrack->numberOfValidHits(), dnn::ele_gsfTrack_numberOfValidHits - e_index_offset);
1961 get(dnn::ele_rel_gsfTrack_pt + fill_index_offset_e) =
1962 sp.scale(gsfTrack->pt() / ele.polarP4().pt(), dnn::ele_rel_gsfTrack_pt - e_index_offset);
1963 get(dnn::ele_gsfTrack_pt_sig + fill_index_offset_e) =
1964 sp.scale(gsfTrack->pt() / gsfTrack->ptError(), dnn::ele_gsfTrack_pt_sig - e_index_offset);
1966 const auto& closestCtfTrack = ele.closestCtfTrackRef();
1967 const bool has_closestCtfTrack = closestCtfTrack.isNonnull();
1968 if (has_closestCtfTrack) {
1969 get(dnn::ele_has_closestCtfTrack + fill_index_offset_e) =
1970 sp.scale(has_closestCtfTrack, dnn::ele_has_closestCtfTrack - e_index_offset);
1971 get(dnn::ele_closestCtfTrack_normalizedChi2 + fill_index_offset_e) =
1972 sp.scale(closestCtfTrack->normalizedChi2(), dnn::ele_closestCtfTrack_normalizedChi2 - e_index_offset);
1973 get(dnn::ele_closestCtfTrack_numberOfValidHits + fill_index_offset_e) =
1974 sp.scale(closestCtfTrack->numberOfValidHits(), dnn::ele_closestCtfTrack_numberOfValidHits - e_index_offset);
1979 template <
typename Cand
idateCastType,
typename TauCastType>
1981 const TauCastType&
tau,
1982 const size_t tau_index,
1986 const std::vector<pat::Muon>*
muons,
1988 const Cell& cell_map,
1998 int PFmu_index_offset =
scalingParamsMap_->at(std::make_pair(ft_global,
false)).mean_.size();
1999 int mu_index_offset = PFmu_index_offset +
scalingParamsMap_->at(std::make_pair(ft_PFmu,
false)).mean_.size();
2003 const auto&
get = [&](
int var_index) ->
float& {
return inputs.tensor<
float, 4>()(
idx, 0, 0, var_index); };
2005 const bool valid_index_pf_muon = cell_map.count(CellObjectType::PfCand_muon);
2008 if (!cell_map.empty()) {
2009 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_global,
false));
2013 get(dnn::tau_inside_ecal_crack) = sp.scale(
isInEcalCrack(
tau.polarP4().eta()), dnn::tau_inside_ecal_crack);
2015 if (valid_index_pf_muon) {
2016 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFmu, is_inner));
2017 size_t index_pf_muon = cell_map.at(CellObjectType::PfCand_muon);
2018 const auto& muon_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_pf_muon));
2020 get(dnn::pfCand_muon_valid) = sp.scale(valid_index_pf_muon, dnn::pfCand_muon_valid - PFmu_index_offset);
2021 get(dnn::pfCand_muon_rel_pt) =
2022 sp.scale(muon_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_muon_rel_pt - PFmu_index_offset);
2023 get(dnn::pfCand_muon_deta) =
2024 sp.scale(muon_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_muon_deta - PFmu_index_offset);
2025 get(dnn::pfCand_muon_dphi) =
2026 sp.scale(
dPhi(
tau.polarP4(), muon_cand.polarP4()), dnn::pfCand_muon_dphi - PFmu_index_offset);
2027 get(dnn::pfCand_muon_pvAssociationQuality) = sp.scale<
int>(
2028 candFunc::getPvAssocationQuality(muon_cand), dnn::pfCand_muon_pvAssociationQuality - PFmu_index_offset);
2029 get(dnn::pfCand_muon_fromPV) =
2030 sp.scale<
int>(candFunc::getFromPV(muon_cand), dnn::pfCand_muon_fromPV - PFmu_index_offset);
2031 get(dnn::pfCand_muon_puppiWeight) = is_inner ? sp.scale(candFunc::getPuppiWeight(muon_cand, 0.9786588f),
2032 dnn::pfCand_muon_puppiWeight - PFmu_index_offset)
2033 : sp.scale(candFunc::getPuppiWeight(muon_cand, 0.8132477
f),
2034 dnn::pfCand_muon_puppiWeight - PFmu_index_offset);
2035 get(dnn::pfCand_muon_charge) = sp.scale(muon_cand.charge(), dnn::pfCand_muon_charge - PFmu_index_offset);
2036 get(dnn::pfCand_muon_lostInnerHits) =
2037 sp.scale<
int>(candFunc::getLostInnerHits(muon_cand, 0), dnn::pfCand_muon_lostInnerHits - PFmu_index_offset);
2038 get(dnn::pfCand_muon_numberOfPixelHits) = sp.scale(candFunc::getNumberOfPixelHits(muon_cand, 0),
2039 dnn::pfCand_muon_numberOfPixelHits - PFmu_index_offset);
2040 get(dnn::pfCand_muon_vertex_dx) =
2041 sp.scale(muon_cand.vertex().x() -
pv.position().x(), dnn::pfCand_muon_vertex_dx - PFmu_index_offset);
2042 get(dnn::pfCand_muon_vertex_dy) =
2043 sp.scale(muon_cand.vertex().y() -
pv.position().y(), dnn::pfCand_muon_vertex_dy - PFmu_index_offset);
2044 get(dnn::pfCand_muon_vertex_dz) =
2045 sp.scale(muon_cand.vertex().z() -
pv.position().z(), dnn::pfCand_muon_vertex_dz - PFmu_index_offset);
2046 get(dnn::pfCand_muon_vertex_dx_tauFL) =
2047 sp.scale(muon_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
2048 dnn::pfCand_muon_vertex_dx_tauFL - PFmu_index_offset);
2049 get(dnn::pfCand_muon_vertex_dy_tauFL) =
2050 sp.scale(muon_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
2051 dnn::pfCand_muon_vertex_dy_tauFL - PFmu_index_offset);
2052 get(dnn::pfCand_muon_vertex_dz_tauFL) =
2053 sp.scale(muon_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
2054 dnn::pfCand_muon_vertex_dz_tauFL - PFmu_index_offset);
2056 const bool hasTrackDetails = candFunc::getHasTrackDetails(muon_cand);
2057 if (hasTrackDetails) {
2058 get(dnn::pfCand_muon_hasTrackDetails) =
2059 sp.scale(hasTrackDetails, dnn::pfCand_muon_hasTrackDetails - PFmu_index_offset);
2060 get(dnn::pfCand_muon_dxy) = sp.scale(candFunc::getTauDxy(muon_cand), dnn::pfCand_muon_dxy - PFmu_index_offset);
2061 get(dnn::pfCand_muon_dxy_sig) = sp.scale(
std::abs(candFunc::getTauDxy(muon_cand)) / muon_cand.dxyError(),
2062 dnn::pfCand_muon_dxy_sig - PFmu_index_offset);
2063 get(dnn::pfCand_muon_dz) = sp.scale(candFunc::getTauDz(muon_cand), dnn::pfCand_muon_dz - PFmu_index_offset);
2064 get(dnn::pfCand_muon_dz_sig) = sp.scale(
std::abs(candFunc::getTauDz(muon_cand)) / muon_cand.dzError(),
2065 dnn::pfCand_muon_dz_sig - PFmu_index_offset);
2066 get(dnn::pfCand_muon_track_chi2_ndof) =
2067 candFunc::getPseudoTrack(muon_cand).ndof() > 0
2068 ? sp.scale(candFunc::getPseudoTrack(muon_cand).
chi2() / candFunc::getPseudoTrack(muon_cand).
ndof(),
2069 dnn::pfCand_muon_track_chi2_ndof - PFmu_index_offset)
2071 get(dnn::pfCand_muon_track_ndof) =
2072 candFunc::getPseudoTrack(muon_cand).ndof() > 0
2073 ? sp.scale(candFunc::getPseudoTrack(muon_cand).
ndof(), dnn::pfCand_muon_track_ndof - PFmu_index_offset)
2077 if (valid_index_muon) {
2078 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_mu, is_inner));
2080 const auto&
muon =
muons->at(index_muon);
2082 get(dnn::muon_valid) = sp.scale(valid_index_muon, dnn::muon_valid - mu_index_offset);
2083 get(dnn::muon_rel_pt) = sp.scale(
muon.polarP4().pt() /
tau.polarP4().pt(), dnn::muon_rel_pt - mu_index_offset);
2084 get(dnn::muon_deta) = sp.scale(
muon.polarP4().eta() -
tau.polarP4().eta(), dnn::muon_deta - mu_index_offset);
2085 get(dnn::muon_dphi) = sp.scale(
dPhi(
tau.polarP4(),
muon.polarP4()), dnn::muon_dphi - mu_index_offset);
2087 get(dnn::muon_dxy_sig) =
2090 const bool normalizedChi2_valid =
muon.globalTrack().isNonnull() &&
muon.normChi2() >= 0;
2091 if (normalizedChi2_valid) {
2092 get(dnn::muon_normalizedChi2_valid) =
2093 sp.scale(normalizedChi2_valid, dnn::muon_normalizedChi2_valid - mu_index_offset);
2094 get(dnn::muon_normalizedChi2) = sp.scale(
muon.normChi2(), dnn::muon_normalizedChi2 - mu_index_offset);
2095 if (
muon.innerTrack().isNonnull())
2096 get(dnn::muon_numberOfValidHits) =
2097 sp.scale(
muon.numberOfValidHits(), dnn::muon_numberOfValidHits - mu_index_offset);
2099 get(dnn::muon_segmentCompatibility) =
2100 sp.scale(
muon.segmentCompatibility(), dnn::muon_segmentCompatibility - mu_index_offset);
2101 get(dnn::muon_caloCompatibility) =
2102 sp.scale(
muon.caloCompatibility(), dnn::muon_caloCompatibility - mu_index_offset);
2104 const bool pfEcalEnergy_valid =
muon.pfEcalEnergy() >= 0;
2105 if (pfEcalEnergy_valid) {
2106 get(dnn::muon_pfEcalEnergy_valid) =
2107 sp.scale(pfEcalEnergy_valid, dnn::muon_pfEcalEnergy_valid - mu_index_offset);
2108 get(dnn::muon_rel_pfEcalEnergy) =
2109 sp.scale(
muon.pfEcalEnergy() /
muon.polarP4().pt(), dnn::muon_rel_pfEcalEnergy - mu_index_offset);
2112 MuonHitMatchV2 hit_match(
muon);
2113 static const std::map<int, std::pair<int, int>> muonMatchHitVars = {
2118 for (
int subdet : hit_match.MuonHitMatchV2::consideredSubdets()) {
2119 const auto& matchHitVar = muonMatchHitVars.at(subdet);
2120 for (
int station = MuonHitMatchV2::first_station_id;
station <= MuonHitMatchV2::last_station_id; ++
station) {
2121 const unsigned n_matches = hit_match.nMatches(subdet,
station);
2122 const unsigned n_hits = hit_match.nHits(subdet,
station);
2123 get(matchHitVar.first +
station - 1) = sp.scale(n_matches, matchHitVar.first +
station - 1 - mu_index_offset);
2124 get(matchHitVar.second +
station - 1) = sp.scale(n_hits, matchHitVar.second +
station - 1 - mu_index_offset);
2130 template <
typename Cand
idateCastType,
typename TauCastType>
2132 const TauCastType&
tau,
2133 const size_t tau_index,
2138 const Cell& cell_map,
2148 int PFchH_index_offset =
scalingParamsMap_->at(std::make_pair(ft_global,
false)).mean_.size();
2149 int PFnH_index_offset = PFchH_index_offset +
scalingParamsMap_->at(std::make_pair(ft_PFchH,
false)).mean_.size();
2153 const auto&
get = [&](
int var_index) ->
float& {
return inputs.tensor<
float, 4>()(
idx, 0, 0, var_index); };
2155 const bool valid_chH = cell_map.count(CellObjectType::PfCand_chargedHadron);
2156 const bool valid_nH = cell_map.count(CellObjectType::PfCand_neutralHadron);
2158 if (!cell_map.empty()) {
2159 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_global,
false));
2163 get(dnn::tau_inside_ecal_crack) = sp.scale(
isInEcalCrack(
tau.polarP4().eta()), dnn::tau_inside_ecal_crack);
2166 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFchH, is_inner));
2167 size_t index_chH = cell_map.at(CellObjectType::PfCand_chargedHadron);
2168 const auto& chH_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_chH));
2170 get(dnn::pfCand_chHad_valid) = sp.scale(valid_chH, dnn::pfCand_chHad_valid - PFchH_index_offset);
2171 get(dnn::pfCand_chHad_rel_pt) =
2172 sp.scale(chH_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_chHad_rel_pt - PFchH_index_offset);
2173 get(dnn::pfCand_chHad_deta) =
2174 sp.scale(chH_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_chHad_deta - PFchH_index_offset);
2175 get(dnn::pfCand_chHad_dphi) =
2176 sp.scale(
dPhi(
tau.polarP4(), chH_cand.polarP4()), dnn::pfCand_chHad_dphi - PFchH_index_offset);
2177 get(dnn::pfCand_chHad_leadChargedHadrCand) =
2178 sp.scale(&chH_cand == dynamic_cast<const CandidateCastType*>(
tau.leadChargedHadrCand().get()),
2179 dnn::pfCand_chHad_leadChargedHadrCand - PFchH_index_offset);
2180 get(dnn::pfCand_chHad_pvAssociationQuality) = sp.scale<
int>(
2181 candFunc::getPvAssocationQuality(chH_cand), dnn::pfCand_chHad_pvAssociationQuality - PFchH_index_offset);
2182 get(dnn::pfCand_chHad_fromPV) =
2183 sp.scale<
int>(candFunc::getFromPV(chH_cand), dnn::pfCand_chHad_fromPV - PFchH_index_offset);
2184 const float default_chH_pw_inner = 0.7614090f;
2185 const float default_chH_pw_outer = 0.1974930f;
2186 get(dnn::pfCand_chHad_puppiWeight) = is_inner ? sp.scale(candFunc::getPuppiWeight(chH_cand, default_chH_pw_inner),
2187 dnn::pfCand_chHad_puppiWeight - PFchH_index_offset)
2188 : sp.scale(candFunc::getPuppiWeight(chH_cand, default_chH_pw_outer),
2189 dnn::pfCand_chHad_puppiWeight - PFchH_index_offset);
2190 get(dnn::pfCand_chHad_puppiWeightNoLep) =
2191 is_inner ? sp.scale(candFunc::getPuppiWeightNoLep(chH_cand, default_chH_pw_inner),
2192 dnn::pfCand_chHad_puppiWeightNoLep - PFchH_index_offset)
2193 : sp.scale(candFunc::getPuppiWeightNoLep(chH_cand, default_chH_pw_outer),
2194 dnn::pfCand_chHad_puppiWeightNoLep - PFchH_index_offset);
2195 get(dnn::pfCand_chHad_charge) = sp.scale(chH_cand.charge(), dnn::pfCand_chHad_charge - PFchH_index_offset);
2196 get(dnn::pfCand_chHad_lostInnerHits) =
2197 sp.scale<
int>(candFunc::getLostInnerHits(chH_cand, 0), dnn::pfCand_chHad_lostInnerHits - PFchH_index_offset);
2198 get(dnn::pfCand_chHad_numberOfPixelHits) = sp.scale(candFunc::getNumberOfPixelHits(chH_cand, 0),
2199 dnn::pfCand_chHad_numberOfPixelHits - PFchH_index_offset);
2200 get(dnn::pfCand_chHad_vertex_dx) =
2201 sp.scale(chH_cand.vertex().x() -
pv.position().x(), dnn::pfCand_chHad_vertex_dx - PFchH_index_offset);
2202 get(dnn::pfCand_chHad_vertex_dy) =
2203 sp.scale(chH_cand.vertex().y() -
pv.position().y(), dnn::pfCand_chHad_vertex_dy - PFchH_index_offset);
2204 get(dnn::pfCand_chHad_vertex_dz) =
2205 sp.scale(chH_cand.vertex().z() -
pv.position().z(), dnn::pfCand_chHad_vertex_dz - PFchH_index_offset);
2206 get(dnn::pfCand_chHad_vertex_dx_tauFL) =
2207 sp.scale(chH_cand.vertex().x() -
pv.position().x() - tau_funcs.getFlightLength(
tau, tau_index).x(),
2208 dnn::pfCand_chHad_vertex_dx_tauFL - PFchH_index_offset);
2209 get(dnn::pfCand_chHad_vertex_dy_tauFL) =
2210 sp.scale(chH_cand.vertex().y() -
pv.position().y() - tau_funcs.getFlightLength(
tau, tau_index).y(),
2211 dnn::pfCand_chHad_vertex_dy_tauFL - PFchH_index_offset);
2212 get(dnn::pfCand_chHad_vertex_dz_tauFL) =
2213 sp.scale(chH_cand.vertex().z() -
pv.position().z() - tau_funcs.getFlightLength(
tau, tau_index).z(),
2214 dnn::pfCand_chHad_vertex_dz_tauFL - PFchH_index_offset);
2216 const bool hasTrackDetails = candFunc::getHasTrackDetails(chH_cand);
2217 if (hasTrackDetails) {
2218 get(dnn::pfCand_chHad_hasTrackDetails) =
2219 sp.scale(hasTrackDetails, dnn::pfCand_chHad_hasTrackDetails - PFchH_index_offset);
2220 get(dnn::pfCand_chHad_dxy) =
2221 sp.scale(candFunc::getTauDxy(chH_cand), dnn::pfCand_chHad_dxy - PFchH_index_offset);
2222 get(dnn::pfCand_chHad_dxy_sig) = sp.scale(
std::abs(candFunc::getTauDxy(chH_cand)) / chH_cand.dxyError(),
2223 dnn::pfCand_chHad_dxy_sig - PFchH_index_offset);
2224 get(dnn::pfCand_chHad_dz) = sp.scale(candFunc::getTauDz(chH_cand), dnn::pfCand_chHad_dz - PFchH_index_offset);
2225 get(dnn::pfCand_chHad_dz_sig) = sp.scale(
std::abs(candFunc::getTauDz(chH_cand)) / chH_cand.dzError(),
2226 dnn::pfCand_chHad_dz_sig - PFchH_index_offset);
2227 get(dnn::pfCand_chHad_track_chi2_ndof) =
2228 candFunc::getPseudoTrack(chH_cand).ndof() > 0
2229 ? sp.scale(candFunc::getPseudoTrack(chH_cand).
chi2() / candFunc::getPseudoTrack(chH_cand).
ndof(),
2230 dnn::pfCand_chHad_track_chi2_ndof - PFchH_index_offset)
2232 get(dnn::pfCand_chHad_track_ndof) =
2233 candFunc::getPseudoTrack(chH_cand).ndof() > 0
2234 ? sp.scale(candFunc::getPseudoTrack(chH_cand).
ndof(), dnn::pfCand_chHad_track_ndof - PFchH_index_offset)
2238 get(dnn::pfCand_chHad_hcalFraction) =
2239 sp.scale(hcal_fraction, dnn::pfCand_chHad_hcalFraction - PFchH_index_offset);
2240 get(dnn::pfCand_chHad_rawCaloFraction) =
2241 sp.scale(candFunc::getRawCaloFraction(chH_cand), dnn::pfCand_chHad_rawCaloFraction - PFchH_index_offset);
2244 const sc::ScalingParams& sp =
scalingParamsMap_->at(std::make_pair(ft_PFnH, is_inner));
2245 size_t index_nH = cell_map.at(CellObjectType::PfCand_neutralHadron);
2246 const auto& nH_cand =
dynamic_cast<const CandidateCastType&
>(pfCands.
at(index_nH));
2248 get(dnn::pfCand_nHad_valid) = sp.scale(valid_nH, dnn::pfCand_nHad_valid - PFnH_index_offset);
2249 get(dnn::pfCand_nHad_rel_pt) =
2250 sp.scale(nH_cand.polarP4().pt() /
tau.polarP4().pt(), dnn::pfCand_nHad_rel_pt - PFnH_index_offset);
2251 get(dnn::pfCand_nHad_deta) =
2252 sp.scale(nH_cand.polarP4().eta() -
tau.polarP4().eta(), dnn::pfCand_nHad_deta - PFnH_index_offset);
2253 get(dnn::pfCand_nHad_dphi) =
2254 sp.scale(
dPhi(
tau.polarP4(), nH_cand.polarP4()), dnn::pfCand_nHad_dphi - PFnH_index_offset);
2255 get(dnn::pfCand_nHad_puppiWeight) = is_inner ? sp.scale(candFunc::getPuppiWeight(nH_cand, 0.9798355f),
2256 dnn::pfCand_nHad_puppiWeight - PFnH_index_offset)
2257 : sp.scale(candFunc::getPuppiWeight(nH_cand, 0.7813260
f),
2258 dnn::pfCand_nHad_puppiWeight - PFnH_index_offset);
2259 get(dnn::pfCand_nHad_puppiWeightNoLep) = is_inner
2260 ? sp.scale(candFunc::getPuppiWeightNoLep(nH_cand, 0.9046796f),
2261 dnn::pfCand_nHad_puppiWeightNoLep - PFnH_index_offset)
2262 : sp.scale(candFunc::getPuppiWeightNoLep(nH_cand, 0.6554860
f),
2263 dnn::pfCand_nHad_puppiWeightNoLep - PFnH_index_offset);
2265 get(dnn::pfCand_nHad_hcalFraction) = sp.scale(hcal_fraction, dnn::pfCand_nHad_hcalFraction - PFnH_index_offset);
2271 elecEe = elecEgamma = 0;
2273 if (superCluster.isNonnull() && superCluster.isAvailable() && superCluster->clusters().isNonnull() &&
2274 superCluster->clusters().isAvailable()) {
2275 for (
auto iter = superCluster->clustersBegin(); iter != superCluster->clustersEnd(); ++iter) {
2276 const double energy = (*iter)->energy();
2277 if (iter == superCluster->clustersBegin())
2288 template <
typename Cand
idateCollection,
typename TauCastType>
2311 const bool isInside_innerSigCone =
dR < innerSigCone_radius;
2312 if (isInside_innerSigCone) {
2313 p4_inner +=
cand->p4();
2316 p4_outer +=
cand->p4();
2332 template <
typename Cand
idateCollection,
typename TauCastType>
2356 static constexpr
double min_pt = 30., min_radius = 0.05, cone_opening_coef = 3.;
2362 template <
typename TauCastType>
2364 const size_t tau_index,
2366 TauFunc tau_funcs) {
2367 if (tau_funcs.getHasSecondaryVertex(
tau, tau_index)) {
2368 static constexpr
double mTau = 1.77682;
2369 const double mAOne =
tau.p4().M();
2370 const double pAOneMag =
tau.p();
2371 const double argumentThetaGJmax = (
std::pow(mTau, 2) -
std::pow(mAOne, 2)) / (2 * mTau * pAOneMag);
2372 const double argumentThetaGJmeasured =
tau.p4().Vect().Dot(tau_funcs.getFlightLength(
tau, tau_index)) /
2373 (pAOneMag * tau_funcs.getFlightLength(
tau, tau_index).R());
2374 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1.) {
2375 double thetaGJmax = std::asin(argumentThetaGJmax);
2376 double thetaGJmeasured = std::acos(argumentThetaGJmeasured);
2377 gj_diff = thetaGJmeasured - thetaGJmax;
2384 template <
typename TauCastType>
2386 const size_t tau_index,
2387 TauFunc tau_funcs) {
2390 return static_cast<float>(gj_diff);
2396 return abs_eta > 1.46 && abs_eta < 1.558;
2399 template <
typename TauCastType>
2401 const std::vector<pat::Electron>*
electrons,
2406 if (
reco::deltaR2(
tau.p4(), ele.p4()) < dR2 && (!matched_ele || matched_ele->
pt() < ele.pt())) {
void createConvFeatures(const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const CellGrid &grid, TauFunc tau_funcs, bool is_inner)
static constexpr float default_value
constexpr double deltaPhi(double phi1, double phi2)
void createMuonBlockInputs(unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > LorentzVectorXYZ
unsigned int n_photons_total(const reco::PFTau &tau)
return total number of pf photon candidates with pT>500 MeV, which are associated to signal ...
T getParameter(std::string const &) const
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > hadronsTensor_
std::map< BasicDiscriminator, size_t > basicDiscrdR03IndexMap_
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static void processIsolationPFComponents(const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
static std::unique_ptr< deep_tau::DeepTauCache > initializeGlobalCache(const edm::ParameterSet &cfg)
double pt() const final
transverse momentum
static void processSignalPFComponents(const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4_inner, LorentzVectorXYZ &p4_outer, float &pt_inner, float &dEta_inner, float &dPhi_inner, float &m_inner, float &pt_outer, float &dEta_outer, float &dPhi_outer, float &m_outer, float &n_inner, float &n_outer)
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
const bool disable_dxy_pca_
static float getValueLinear(T value, float min_value, float max_value, bool positive)
static const pat::Electron * findMatchedElectron(const TauCastType &tau, const std::vector< pat::Electron > *electrons, double deltaR)
constexpr bool isNotFinite(T x)
void createHadronsBlockInputs(unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
void fillGrids(const TauCastType &tau, const Collection &objects, CellGrid &inner_grid, CellGrid &outer_grid)
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > zeroOutputTensor_
std::map< BasicDiscriminator, size_t > basicDiscrIndexMap_
#define DEFINE_FWK_MODULE(type)
const DeepTauCache * cache_
static double getInnerSignalConeRadius(double pt)
std::ofstream * json_file_
static bool isAbove(double value, double min)
static bool isInEcalCrack(double eta)
std::string to_string(const V &value)
void setCellConvFeatures(tensorflow::Tensor &convTensor, const tensorflow::Tensor &features, unsigned batch_idx, int eta_index, int phi_index)
const unsigned sub_version_
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
void countMatches(const reco::Muon &muon, std::vector< int > &numMatchesDT, std::vector< int > &numMatchesCSC, std::vector< int > &numMatchesRPC)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
const std::map< ValueQuantityType, double > min_value
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
std::map< std::string, Output > OutputCollection
static const double deltaEta
const std::map< std::pair< deep_tau::Scaling::FeatureT, bool >, deep_tau::Scaling::ScalingParams > * scalingParamsMap_
static const OutputCollection & GetOutputs()
static std::string const input
static const std::vector< BasicDiscriminator > requiredBasicDiscriminatorsdR03_
pfTauTransverseImpactParameters
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > convTensor_
DeepTauId(const edm::ParameterSet &cfg, const deep_tau::DeepTauCache *cache)
const std::map< std::pair< FeatureT, bool >, ScalingParams > scalingParamsMap_v2p5
OutputCollection outputs_
std::string output_layer_
static constexpr float pi
static float getValue(T value)
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
std::vector< float > features(const reco::PreId &ecal, const reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
const std::map< BasicDiscriminator, size_t > matchDiscriminatorIndices(edm::Event &event, edm::EDGetTokenT< reco::TauDiscriminatorContainer > discriminatorContainerToken, std::vector< BasicDiscriminator > requiredDiscr)
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, std::vector< Tensor > *outputs, const thread::ThreadPoolOptions &threadPoolOptions)
void saveInputs(const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr)
const bool disable_CellIndex_workaround_
static float getValueNorm(T value, float mean, float sigma, float n_sigmas_max=5)
Abs< T >::type abs(const T &t)
disable_hcalFraction_workaround
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
void createEgammaBlockInputs(unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner)
static void globalEndJob(const deep_tau::DeepTauCache *cache_)
static const std::vector< BasicDiscriminator > requiredBasicDiscriminators_
DeepTauBase(const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void checkInputs(const tensorflow::Tensor &inputs, const std::string &block_name, int n_inputs, const CellGrid *grid=nullptr) const
tensorflow::Session & getSession(const std::string &name="") const
const_reference at(size_type pos) const
Analysis-level tau class.
const std::map< std::pair< FeatureT, bool >, ScalingParams > scalingParamsMap_v2p1
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
tensorflow::Tensor getPredictions(edm::Event &event, edm::Handle< TauCollection > taus) override
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ cells
tensorflow::Tensor getPartialPredictions(bool is_inner)
static bool calculateGottfriedJacksonAngleDifference(const TauCastType &tau, const size_t tau_index, double &gj_diff, TauFunc tau_funcs)
edm::EDGetTokenT< edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > > pfTauTransverseImpactParameters_token_
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
edm::ValueMap< SingleTauDiscriminatorContainer > TauDiscriminatorContainer
void createTauBlockInputs(const TauCastType &tau, const size_t &tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, TauFunc tau_funcs)
float pt_weighted_dphi_strip(const reco::PFTau &tau, int dm)
void getPredictionsV2(TauCollection::const_reference &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const reco::Vertex &pv, double rho, std::vector< tensorflow::Tensor > &pred_vector, TauFunc tau_funcs)
float eratio(const reco::PFTau &tau)
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
uint8_t andPrediscriminants_
Analysis-level electron class.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
edm::Ref< PFTauTransverseImpactParameterCollection > PFTauTransverseImpactParameterRef
presistent reference to a PFTauTransverseImpactParameter
static const std::map< BasicDiscriminator, std::string > stringFromDiscriminator_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_inputToken_
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
static float calculateGottfriedJacksonAngleDifference(const TauCastType &tau, const size_t tau_index, TauFunc tau_funcs)
static bool calculateElectronClusterVarsV2(const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)
Particle reconstructed by the particle flow algorithm.
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > eGammaTensor_
const bool disable_hcalFraction_workaround_
disable_CellIndex_workaround
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminatorsdR03_inputToken_
const std::map< ValueQuantityType, double > max_value
std::vector< int > tauInputs_indices_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
basicTauDiscriminatorsdR03
float lead_track_chi2(const reco::PFTau &tau)
return chi2 of the leading track ==> deprecated? <==
std::vector< TauDiscInfo< pat::PATTauDiscriminator > > patPrediscriminants_
Log< level::Warning, false > LogWarning
std::array< std::unique_ptr< tensorflow::Tensor >, 2 > muonTensor_
edm::EDGetTokenT< std::vector< pat::Electron > > electrons_token_
edm::EDGetTokenT< std::vector< pat::Muon > > muons_token_
T operator[](int i) const
edm::EDGetTokenT< double > rho_token_
static void calculateElectronClusterVars(const pat::Electron *ele, float &elecEe, float &elecEgamma)
T const & const_reference
static const std::string subdets[7]
edm::EDGetTokenT< CandidateCollection > pfcandToken_
Analysis-level muon class.
std::vector< TauDiscInfo< reco::PFTauDiscriminator > > recoPrediscriminants_
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)
Power< A, B >::type pow(const A &a, const B &b)
constexpr int NumberOfOutputs
std::unique_ptr< tensorflow::Tensor > tauBlockTensor_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_