43 <<
" Failed to find File = " << inputFileName <<
" !!\n";
49 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
50 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
52 inputFilesToDelete.push_back(inputFile);
65 namespace reco {
namespace tau {
79 if ( !loadMVAfromDB_ ) {
80 if(cfg.
exists(
"inputFileName")){
82 }
else throw cms::Exception(
"MVA input not defined") <<
"Requested to load tau MVA input from ROOT file but no file provided in cfg file";
95 else throw cms::Exception(
"PFRecoTauDiscriminationByMVAIsolationRun2")
96 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
116 produces<PFTauDiscriminator>(
"category");
198 if ( tau->leadPFChargedHadrCand().
isNull() )
return 0.;
200 int tauDecayMode = tau->decayMode();
203 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10))
206 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11))
220 float decayDistMag =
std::sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
231 float gjAngleDiff = -999;
232 if ( tauDecayMode == 10 ) {
233 double mTau = 1.77682;
234 double mAOne = tau->p4().M();
235 double pAOneMag = tau->p();
236 double argumentThetaGJmax = (
std::pow(mTau,2) -
std::pow(mAOne,2) ) / ( 2 * mTau * pAOneMag );
237 double argumentThetaGJmeasured = ( tau->p4().px() * decayDistX + tau->p4().py() * decayDistY + tau->p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag );
238 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1. ) {
239 double thetaGJmax = std::asin( argumentThetaGJmax );
240 double thetaGJmeasured = std::acos( argumentThetaGJmeasured );
241 gjAngleDiff = thetaGJmeasured - thetaGJmax;
251 mvaInput_[5] = tauDecayMode;
258 mvaInput_[5] = tauDecayMode;
259 mvaInput_[6] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
272 mvaInput_[6] = tauDecayMode;
274 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
275 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
276 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
277 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
278 mvaInput_[12] =
std::min(100.
f, leadingTrackChi2);
280 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
283 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
296 mvaInput_[6] = tauDecayMode;
298 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
299 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
300 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
301 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
302 mvaInput_[12] =
std::min(100.
f, leadingTrackChi2);
304 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
307 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
320 mvaInput_[6] = tauDecayMode;
322 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
323 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
324 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
325 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
327 mvaInput_[13] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
330 mvaInput_[16] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
336 mvaInput_[22] =
std::max(-1.
f, gjAngleDiff);
341 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByMVAIsolationRun2::discriminate>:";
342 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
343 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " <<
puCorrPtSum;
344 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
345 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy() <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
347 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
348 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFTauDiscriminator > FootprintCorrection_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
bool hasSecondaryVertex() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::PFTauDiscriminator > PhotonPtSumOutsideSignalCone_token
const GBRForest * mvaReader_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos
edm::RefProd< TauCollection > TauRefProd
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
edm::Handle< reco::PFTauDiscriminator > footprintCorrection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::Handle< reco::PFTauDiscriminator > puCorrPtSums_
double discriminate(const PFTauRef &) const override
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
PFRecoTauDiscriminationByMVAIsolationRun2(const edm::ParameterSet &cfg)
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
void endEvent(edm::Event &) override
double flightLengthSig() const
edm::Handle< TauCollection > taus_
const Vector & flightLength() const
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
Abs< T >::type abs(const T &t)
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
edm::Handle< reco::PFTauDiscriminator > photonPtSumOutsideSignalCone_
LocationCode location() const
Where was the file found?
std::unique_ptr< PFTauDiscriminator > category_output_
bool isNull() const
Checks for null.
edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > PFTauTIPAssociationByRef
photonPtSumOutsideSignalCone
edm::EDGetTokenT< TauCollection > Tau_token
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
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 beginEvent(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token
std::string fullPath() const
float lead_track_chi2(const reco::PFTau &tau)
return chi2 of the leading track ==> deprecated? <==
edm::FileInPath inputFileName_
double GetClassifier(const float *vector) const
T const * product() const
Power< A, B >::type pow(const A &a, const B &b)
std::vector< TFile * > inputFilesToDelete_
edm::Handle< reco::PFTauDiscriminator > chargedIsoPtSums_
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token