45 std::vector<TFile*>& inputFilesToDelete) {
47 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
54 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
55 <<
" Failed to load MVA = " <<
mvaName.data() <<
" from file = " <<
inputFileName.fullPath().data()
82 if (mvaOpt_string ==
"oldDMwoLT")
84 else if (mvaOpt_string ==
"oldDMwLT")
86 else if (mvaOpt_string ==
"newDMwoLT")
88 else if (mvaOpt_string ==
"newDMwLT")
90 else if (mvaOpt_string ==
"DBoldDMwLT")
92 else if (mvaOpt_string ==
"DBnewDMwLT")
94 else if (mvaOpt_string ==
"PWoldDMwLT")
96 else if (mvaOpt_string ==
"PWnewDMwLT")
98 else if (mvaOpt_string ==
"DBoldDMwLTwGJ")
100 else if (mvaOpt_string ==
"DBnewDMwLTwGJ")
104 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
117 consumes<PFTauTIPAssociationByRef>(
cfg.getParameter<
edm::InputTag>(
"srcTauTransverseImpactParameters"));
120 consumes<reco::TauDiscriminatorContainer>(
cfg.getParameter<
edm::InputTag>(
"srcBasicTauDiscriminators"));
194 const std::vector<edm::ParameterSet> psetsFromProvenance =
196 .getParameter<std::vector<edm::ParameterSet>>(
"IDdefinitions");
197 for (
uint i = 0;
i < psetsFromProvenance.size();
i++) {
198 if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
"ChargedIsoPtSum" +
input_id_name_suffix_)
200 else if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
203 else if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
"PUcorrPtSum" +
input_id_name_suffix_)
205 else if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
208 else if (psetsFromProvenance[
i].getParameter<std::string>(
"IDname") ==
221 if (
tau->leadChargedHadrCand().isNull())
224 int tauDecayMode =
tau->decayMode();
228 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
231 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
232 tauDecayMode == 10 || tauDecayMode == 11))) {
233 auto const rawValues = (*basicTauDiscriminators_)[
tau].rawValues;
245 float decayDistMag =
std::sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
256 float gjAngleDiff = -999;
257 if (tauDecayMode == 10) {
258 double mTau = 1.77682;
259 double mAOne =
tau->p4().M();
260 double pAOneMag =
tau->p();
261 double argumentThetaGJmax = (
std::pow(mTau, 2) -
std::pow(mAOne, 2)) / (2 * mTau * pAOneMag);
262 double argumentThetaGJmeasured =
263 (
tau->p4().px() * decayDistX +
tau->p4().py() * decayDistY +
tau->p4().pz() * decayDistZ) /
264 (pAOneMag * decayDistMag);
265 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1.) {
266 double thetaGJmax = std::asin(argumentThetaGJmax);
267 double thetaGJmeasured = std::acos(argumentThetaGJmeasured);
268 gjAngleDiff = thetaGJmeasured - thetaGJmax;
286 mvaInput_[6] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
307 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
310 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
331 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
334 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
354 mvaInput_[13] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
357 mvaInput_[16] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
368 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByMVAIsolationRun2::discriminate>:";
369 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " <<
tau->pt() <<
", eta = " <<
tau->eta();
370 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum
371 <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " << puCorrPtSum;
372 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
373 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy()
374 <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
377 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
378 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
380 result.rawValues.at(0) = mvaValue;
390 desc.add<
bool>(
"loadMVAfromDB",
true);
398 desc.add<
int>(
"verbosity", 0);
402 descriptions.
add(
"pfRecoTauDiscriminationByMVAIsolationRun2",
desc);
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_token
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 ...
~PFRecoTauDiscriminationByMVAIsolationRun2() override
const GBRForest * mvaReader_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
const Vector & flightLength() const
int chargedIsoPtSum_index_
bool hasSecondaryVertex() const
double flightLengthSig() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PFRecoTauDiscriminationByMVAIsolationRun2(const edm::ParameterSet &cfg)
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
edm::Handle< TauCollection > taus_
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
int footprintCorrection_index_
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
Abs< T >::type abs(const T &t)
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
#define DEFINE_FWK_MODULE(type)
int neutralIsoPtSum_index_
Log< level::Warning, true > LogPrint
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > PFTauTIPAssociationByRef
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
edm::Handle< reco::TauDiscriminatorContainer > basicTauDiscriminators_
double GetClassifier(const float *vector) const
float pt_weighted_dphi_strip(const reco::PFTau &tau, int dm)
float eratio(const reco::PFTau &tau)
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< TauCollection > Tau_token
void beginEvent(const edm::Event &, const edm::EventSetup &) override
edm::ProcessHistoryID phID_
float lead_track_chi2(const reco::PFTau &tau)
return chi2 of the leading track ==> deprecated? <==
std::string input_id_name_suffix_
reco::SingleTauDiscriminatorContainer discriminate(const PFTauRef &) const override
int photonPtSumOutsideSignalCone_index_
edm::FileInPath inputFileName_
ProcessHistoryID const & processHistoryID() const
StableProvenance const & stable() const
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_
ProcessHistory const & processHistory() const override
std::vector< TFile * > inputFilesToDelete_