Skip to content

Commit

Permalink
made handling of hcalFraction issue
Browse files Browse the repository at this point in the history
  cms-tau-pog/TauMLTools#24
configurable via python config
  • Loading branch information
Christian Veelken committed Aug 27, 2020
1 parent a747a23 commit 3094f04
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions RecoTauTag/RecoTau/plugins/DeepTauId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Tau identification using Deep NN.
*
* \author Konstantin Androsov, INFN Pisa
* Christian Veelken, Tallinn
*/

#include "RecoTauTag/RecoTau/interface/DeepTauBase.h"
Expand Down Expand Up @@ -859,6 +860,7 @@ class DeepTauId : public deep_tau::DeepTauBase {
desc.add<unsigned>("version", 2);
desc.add<int>("debug_level", 0);
desc.add<bool>("disable_dxy_pca", false);
desc.add<bool>("disable_hcalFraction_workaround", false);
desc.add<bool>("save_inputs", false);

desc.add<std::vector<std::string>>("VSeWP");
Expand All @@ -877,6 +879,7 @@ class DeepTauId : public deep_tau::DeepTauBase {
version(cfg.getParameter<unsigned>("version")),
debug_level(cfg.getParameter<int>("debug_level")),
disable_dxy_pca_(cfg.getParameter<bool>("disable_dxy_pca")),
disable_hcalFraction_workaround_(cfg.getParameter<bool>("disable_hcalFraction_workaround")),
inner_grid(nullptr),
outer_grid(nullptr),
save_inputs(cfg.getParameter<bool>("save_inputs")),
Expand Down Expand Up @@ -1887,14 +1890,18 @@ class DeepTauId : public deep_tau::DeepTauBase {
: 0;
}
float hcal_fraction = 0.;
//if (pfCands.at(index_chH).pdgId() == 1 || pfCands.at(index_chH).pdgId() == 130) {
// hcal_fraction = pfCands.at(index_chH).hcalFraction();
//} else if (pfCands.at(index_chH).isIsolatedChargedHadron()) {
// hcal_fraction = pfCands.at(index_chH).rawHcalFraction();
//}
// CV: use consistent definition for pfCand_chHad_hcalFraction
// in DeepTauId.cc code and in TauMLTools/Production/plugins/TauTupleProducer.cc
hcal_fraction = pfCands.at(index_chH).hcalFraction();
if ( disable_hcalFraction_workaround_ ) {
// CV: use consistent definition for pfCand_chHad_hcalFraction
// in DeepTauId.cc code and in TauMLTools/Production/plugins/TauTupleProducer.cc
hcal_fraction = pfCands.at(index_chH).hcalFraction();
} else {
// CV: backwards compatibility with DeepTau training v2p1 used during Run 2
if (pfCands.at(index_chH).pdgId() == 1 || pfCands.at(index_chH).pdgId() == 130) {
hcal_fraction = pfCands.at(index_chH).hcalFraction();
} else if (pfCands.at(index_chH).isIsolatedChargedHadron()) {
hcal_fraction = pfCands.at(index_chH).rawHcalFraction();
}
}
get(dnn::pfCand_chHad_hcalFraction) = getValue(hcal_fraction);
get(dnn::pfCand_chHad_rawCaloFraction) = getValueLinear(pfCands.at(index_chH).rawCaloFraction(), 0.f, 2.6f, true);
}
Expand All @@ -1914,14 +1921,18 @@ class DeepTauId : public deep_tau::DeepTauBase {
get(dnn::pfCand_nHad_puppiWeight) = getValue(pfCands.at(index_nH).puppiWeight());
get(dnn::pfCand_nHad_puppiWeightNoLep) = getValue(pfCands.at(index_nH).puppiWeightNoLep());
float hcal_fraction = 0.;
//if (pfCands.at(index_nH).pdgId() == 1 || pfCands.at(index_nH).pdgId() == 130) {
// hcal_fraction = pfCands.at(index_nH).hcalFraction();
//} else if (pfCands.at(index_nH).isIsolatedChargedHadron()) {
// hcal_fraction = pfCands.at(index_nH).rawHcalFraction();
//}
// CV: use consistent definition for pfCand_chHad_hcalFraction
// in DeepTauId.cc code and in TauMLTools/Production/plugins/TauTupleProducer.cc
hcal_fraction = pfCands.at(index_nH).hcalFraction();
if ( disable_hcalFraction_workaround_ ) {
// CV: use consistent definition for pfCand_chHad_hcalFraction
// in DeepTauId.cc code and in TauMLTools/Production/plugins/TauTupleProducer.cc
hcal_fraction = pfCands.at(index_nH).hcalFraction();
} else {
// CV: backwards compatibility with DeepTau training v2p1 used during Run 2
if (pfCands.at(index_nH).pdgId() == 1 || pfCands.at(index_nH).pdgId() == 130) {
hcal_fraction = pfCands.at(index_nH).hcalFraction();
} else if (pfCands.at(index_nH).isIsolatedChargedHadron()) {
hcal_fraction = pfCands.at(index_nH).rawHcalFraction();
}
}
get(dnn::pfCand_nHad_hcalFraction) = getValue(hcal_fraction);
}
}
Expand Down Expand Up @@ -2272,6 +2283,7 @@ class DeepTauId : public deep_tau::DeepTauBase {
const unsigned version;
const int debug_level;
const bool disable_dxy_pca_;
const bool disable_hcalFraction_workaround_;
std::unique_ptr<tensorflow::Tensor> tauBlockTensor_;
std::array<std::unique_ptr<tensorflow::Tensor>, 2> eGammaTensor_, muonTensor_, hadronsTensor_, convTensor_,
zeroOutputTensor_;
Expand Down

0 comments on commit 3094f04

Please sign in to comment.