46 <<
" Failed to find File = " << inputFileName <<
" !!\n";
52 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
53 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
55 inputFilesToDelete.push_back(inputFile);
68 namespace reco {
namespace tau {
82 if ( !loadMVAfromDB_ ) {
96 else throw cms::Exception(
"PFRecoTauDiscriminationByMVAIsolationRun2")
97 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
116 produces<PFTauDiscriminator>(
"category");
199 if ( tau->leadChargedHadrCand().
isNull() )
return 0.;
201 int tauDecayMode = tau->decayMode();
204 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10))
207 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11))
221 float decayDistMag =
std::sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
232 float gjAngleDiff = -999;
233 if ( tauDecayMode == 10 ) {
234 double mTau = 1.77682;
235 double mAOne = tau->p4().M();
236 double pAOneMag = tau->p();
237 double argumentThetaGJmax = (
std::pow(mTau,2) -
std::pow(mAOne,2) ) / ( 2 * mTau * pAOneMag );
238 double argumentThetaGJmeasured = ( tau->p4().px() * decayDistX + tau->p4().py() * decayDistY + tau->p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag );
239 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1. ) {
240 double thetaGJmax = std::asin( argumentThetaGJmax );
241 double thetaGJmeasured = std::acos( argumentThetaGJmeasured );
242 gjAngleDiff = thetaGJmeasured - thetaGJmax;
252 mvaInput_[5] = tauDecayMode;
259 mvaInput_[5] = tauDecayMode;
260 mvaInput_[6] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
273 mvaInput_[6] = tauDecayMode;
275 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
276 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
277 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
278 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
279 mvaInput_[12] =
std::min(100.
f, leadingTrackChi2);
281 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
284 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
297 mvaInput_[6] = tauDecayMode;
299 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
300 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
301 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
302 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
303 mvaInput_[12] =
std::min(100.
f, leadingTrackChi2);
305 mvaInput_[14] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
308 mvaInput_[17] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
321 mvaInput_[6] = tauDecayMode;
323 mvaInput_[8] =
std::min(0.5
f, ptWeightedDetaStrip);
324 mvaInput_[9] =
std::min(0.5
f, ptWeightedDphiStrip);
325 mvaInput_[10] =
std::min(0.5
f, ptWeightedDrSignal);
326 mvaInput_[11] =
std::min(0.5
f, ptWeightedDrIsolation);
328 mvaInput_[13] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
dxy());
331 mvaInput_[16] = std::copysign(+1.
f, (
float)tauLifetimeInfo.
ip3d());
337 mvaInput_[22] =
std::max(-1.
f, gjAngleDiff);
342 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByMVAIsolationRun2::discriminate>:";
343 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
344 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " <<
puCorrPtSum;
345 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
346 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy() <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
348 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
349 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
370 desc.
add<
bool>(
"loadMVAfromDB");
382 desc.
add<
int>(
"verbosity", 0);
386 descriptions.
add(
"pfRecoTauDiscriminationByMVAIsolationRun2", desc);
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
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
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
edm::Handle< reco::PFTauDiscriminator > puCorrPtSums_
double discriminate(const PFTauRef &) const override
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
PFRecoTauDiscriminationByMVAIsolationRun2(const edm::ParameterSet &cfg)
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
void endEvent(edm::Event &) override
#define DEFINE_FWK_MODULE(type)
double flightLengthSig() const
static void fillProducerDescriptions(edm::ParameterSetDescription &desc)
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?
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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 add(std::string const &label, ParameterSetDescription const &psetDescription)
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