-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparations for future trainings of the MVA tauID #18430
Changes from 4 commits
db62270
bfcbe20
5748327
0526fdc
c4c2d0e
d14f66a
f947030
1a3f320
2076be9
6bfb858
5be50cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,13 +97,16 @@ class PATTauDiscriminationByMVAIsolationRun2 : public PATTauDiscriminationProduc | |
else if ( mvaOpt_string == "DBnewDMwLT" ) mvaOpt_ = kDBnewDMwLT; | ||
else if ( mvaOpt_string == "PWoldDMwLT" ) mvaOpt_ = kPWoldDMwLT; | ||
else if ( mvaOpt_string == "PWnewDMwLT" ) mvaOpt_ = kPWnewDMwLT; | ||
else if ( mvaOpt_string == "DBoldDMwLTwGJ" ) mvaOpt_ = kDBoldDMwLTwGJ; | ||
else if ( mvaOpt_string == "DBnewDMwLTwGJ" ) mvaOpt_ = kDBnewDMwLTwGJ; | ||
else throw cms::Exception("PATTauDiscriminationByMVAIsolationRun2") | ||
<< " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n"; | ||
|
||
if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6]; | ||
else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12]; | ||
else if ( mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kDBnewDMwLT || | ||
mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kPWnewDMwLT) mvaInput_ = new float[23]; | ||
mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kPWnewDMwLT || | ||
mvaOpt_ == kDBoldDMwLTwGJ || mvaOpt_ == kDBnewDMwLTwGJ) mvaInput_ = new float[23]; | ||
else assert(0); | ||
|
||
chargedIsoPtSums_ = cfg.getParameter<std::string>("srcChargedIsoPtSum"); | ||
|
@@ -142,7 +145,7 @@ class PATTauDiscriminationByMVAIsolationRun2 : public PATTauDiscriminationProduc | |
bool loadMVAfromDB_; | ||
edm::FileInPath inputFileName_; | ||
const GBRForest* mvaReader_; | ||
enum { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT, kDBoldDMwLT, kDBnewDMwLT, kPWoldDMwLT, kPWnewDMwLT }; | ||
enum { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT, kDBoldDMwLT, kDBnewDMwLT, kPWoldDMwLT, kPWnewDMwLT, kDBoldDMwLTwGJ, kDBnewDMwLTwGJ }; | ||
int mvaOpt_; | ||
float* mvaInput_; | ||
|
||
|
@@ -185,8 +188,8 @@ double PATTauDiscriminationByMVAIsolationRun2::discriminate(const TauRef& tau) c | |
|
||
int tauDecayMode = tau->decayMode(); | ||
|
||
if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT || mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kPWoldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) || | ||
((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT || mvaOpt_ == kDBnewDMwLT || mvaOpt_ == kPWnewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) { | ||
if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT || mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kDBoldDMwLTwGJ) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) || | ||
((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT || mvaOpt_ == kDBnewDMwLT || mvaOpt_ == kPWnewDMwLT || mvaOpt_ == kDBnewDMwLTwGJ) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11)) ) { | ||
|
||
float chargedIsoPtSum = tau->tauID(chargedIsoPtSums_); | ||
float neutralIsoPtSum = tau->tauID(neutralIsoPtSums_); | ||
|
@@ -209,6 +212,17 @@ double PATTauDiscriminationByMVAIsolationRun2::discriminate(const TauRef& tau) c | |
// --- | ||
float leadingTrackChi2 = tau->leadingTrackNormChi2(); | ||
float eRatio = clusterVariables_.tau_Eratio(*tau); | ||
|
||
// Difference between measured and maximally allowed Gottfried-Jackson angle | ||
float gjAngleDiff = -999; | ||
if ( tauDecayMode == 10 ) { | ||
double mTau = 1.77682; | ||
double mAOne = tau->p4().M(); | ||
double pAOneMag = tau->p(); | ||
double thetaGJmax = TMath::ASin( (TMath::Power(mTau,2) - TMath::Power(mAOne,2) ) / ( 2 * mTau * pAOneMag ) ); | ||
double thetaGJmeasured = TMath::ACos( ( tau->p4().px() * decayDistX + tau->p4().py() * decayDistY + tau->p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please use native c++ methods where available. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm missing what by construction restricts the argument of asin to have an absolute value less or equal 1.0? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dear Slava, the valua of Cheers, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that to happen, the transverse momentum of the tau would have to be below 0.71 GeV. In MiniAOD, only taus with pt greater than 18 GeV are saved. |
||
gjAngleDiff = thetaGJmeasured - thetaGJmax; | ||
} | ||
|
||
if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) { | ||
mvaInput_[0] = std::log(std::max((float)1., (float)tau->pt())); | ||
|
@@ -278,6 +292,30 @@ double PATTauDiscriminationByMVAIsolationRun2::discriminate(const TauRef& tau) c | |
mvaInput_[20] = ( tau->hasSecondaryVertex() ) ? 1. : 0.; | ||
mvaInput_[21] = std::sqrt(decayDistMag); | ||
mvaInput_[22] = std::min((float)10., tau->flightLengthSig()); | ||
} else if ( mvaOpt_ == kDBoldDMwLTwGJ || mvaOpt_ == kDBnewDMwLTwGJ ) { | ||
mvaInput_[0] = std::log(std::max((float)1., (float)tau->pt())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
mvaInput_[1] = std::fabs(tau->eta()); | ||
mvaInput_[2] = std::log(std::max((float)1.e-2, chargedIsoPtSum)); | ||
mvaInput_[3] = std::log(std::max((float)1.e-2, neutralIsoPtSum)); | ||
mvaInput_[4] = std::log(std::max((float)1.e-2, puCorrPtSum)); | ||
mvaInput_[5] = std::log(std::max((float)1.e-2, photonPtSumOutsideSignalCone)); | ||
mvaInput_[6] = tauDecayMode; | ||
mvaInput_[7] = std::min((float)30., nPhoton); | ||
mvaInput_[8] = std::min((float)0.5, ptWeightedDetaStrip); | ||
mvaInput_[9] = std::min((float)0.5, ptWeightedDphiStrip); | ||
mvaInput_[10] = std::min((float)0.5, ptWeightedDrSignal); | ||
mvaInput_[11] = std::min((float)0.5, ptWeightedDrIsolation); | ||
mvaInput_[12] = std::min((float)1., eRatio); | ||
mvaInput_[13] = TMath::Sign((float)+1., tau->dxy()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
mvaInput_[14] = std::sqrt(std::min((float)1., std::fabs(tau->dxy()))); | ||
mvaInput_[15] = std::min((float)10., std::fabs(tau->dxy_Sig())); | ||
mvaInput_[16] = TMath::Sign((float)+1., tau->ip3d()); | ||
mvaInput_[17] = std::sqrt(std::min((float)1., std::fabs(tau->ip3d()))); | ||
mvaInput_[18] = std::min((float)10., std::fabs(tau->ip3d_Sig())); | ||
mvaInput_[19] = ( tau->hasSecondaryVertex() ) ? 1. : 0.; | ||
mvaInput_[20] = std::sqrt(decayDistMag); | ||
mvaInput_[21] = std::min((float)10., tau->flightLengthSig()); | ||
mvaInput_[22] = std::max((float)-1., gjAngleDiff); | ||
} | ||
|
||
double mvaValue = mvaReader_->GetClassifier(mvaInput_); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,13 +89,16 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd | |
else if ( mvaOpt_string == "DBnewDMwLT" ) mvaOpt_ = kDBnewDMwLT; | ||
else if ( mvaOpt_string == "PWoldDMwLT" ) mvaOpt_ = kPWoldDMwLT; | ||
else if ( mvaOpt_string == "PWnewDMwLT" ) mvaOpt_ = kPWnewDMwLT; | ||
else if ( mvaOpt_string == "DBoldDMwLTwGJ" ) mvaOpt_ = kDBoldDMwLTwGJ; | ||
else if ( mvaOpt_string == "DBnewDMwLTwGJ" ) mvaOpt_ = kDBnewDMwLTwGJ; | ||
else throw cms::Exception("PFRecoTauDiscriminationByMVAIsolationRun2") | ||
<< " Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string << " !!\n"; | ||
|
||
if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ = new float[6]; | ||
else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ = new float[12]; | ||
else if ( mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kDBnewDMwLT || | ||
mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kPWnewDMwLT) mvaInput_ = new float[23]; | ||
mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kPWnewDMwLT || | ||
mvaOpt_ == kDBoldDMwLTwGJ || mvaOpt_ == kDBnewDMwLTwGJ) mvaInput_ = new float[23]; | ||
else assert(0); | ||
|
||
TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.getParameter<edm::InputTag>("srcTauTransverseImpactParameters")); | ||
|
@@ -136,7 +139,7 @@ class PFRecoTauDiscriminationByMVAIsolationRun2 : public PFTauDiscriminationProd | |
bool loadMVAfromDB_; | ||
edm::FileInPath inputFileName_; | ||
const GBRForest* mvaReader_; | ||
enum { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT, kDBoldDMwLT, kDBnewDMwLT, kPWoldDMwLT, kPWnewDMwLT }; | ||
enum { kOldDMwoLT, kOldDMwLT, kNewDMwoLT, kNewDMwLT, kDBoldDMwLT, kDBnewDMwLT, kPWoldDMwLT, kPWnewDMwLT, kDBoldDMwLTwGJ, kDBnewDMwLTwGJ }; | ||
int mvaOpt_; | ||
float* mvaInput_; | ||
|
||
|
@@ -197,8 +200,8 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t | |
|
||
int tauDecayMode = tau->decayMode(); | ||
|
||
if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT || mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kPWoldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) || | ||
((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT || mvaOpt_ == kDBnewDMwLT || mvaOpt_ == kPWnewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) { | ||
if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT || mvaOpt_ == kDBoldDMwLT || mvaOpt_ == kPWoldDMwLT || mvaOpt_ == kDBoldDMwLTwGJ) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) || | ||
((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT || mvaOpt_ == kDBnewDMwLT || mvaOpt_ == kPWnewDMwLT || mvaOpt_ == kDBnewDMwLTwGJ) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11)) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a couple of linebreaks here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to be sure: is the decayMode 11 important only in the "new" MVAs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. The decay mode 11 is only available in the "new decay modes" to which the "new" MVA trainings correspond. The "old" MVA trainings in turn correspond to the "old decay modes" (0, 1, 2 and 10). |
||
|
||
float chargedIsoPtSum = (*chargedIsoPtSums_)[tau]; | ||
float neutralIsoPtSum = (*neutralIsoPtSums_)[tau]; | ||
|
@@ -221,6 +224,17 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t | |
float leadingTrackChi2 = clusterVariables_.tau_leadTrackChi2(*tau); | ||
float eRatio = clusterVariables_.tau_Eratio(*tau); | ||
|
||
// Difference between measured and maximally allowed Gottfried-Jackson angle | ||
float gjAngleDiff = -999; | ||
if ( tauDecayMode == 10 ) { | ||
double mTau = 1.77682; | ||
double mAOne = tau->p4().M(); | ||
double pAOneMag = tau->p(); | ||
double thetaGJmax = TMath::ASin( (TMath::Power(mTau,2) - TMath::Power(mAOne,2) ) / ( 2 * mTau * pAOneMag ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments as in PAT tau apply here. |
||
double thetaGJmeasured = TMath::ACos( ( tau->p4().px() * decayDistX + tau->p4().py() * decayDistY + tau->p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag ) ); | ||
gjAngleDiff = thetaGJmeasured - thetaGJmax; | ||
} | ||
|
||
if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) { | ||
mvaInput_[0] = std::log(std::max((float)1., (float)tau->pt())); | ||
mvaInput_[1] = std::fabs((float)tau->eta()); | ||
|
@@ -289,6 +303,30 @@ double PFRecoTauDiscriminationByMVAIsolationRun2::discriminate(const PFTauRef& t | |
mvaInput_[20] = ( tauLifetimeInfo.hasSecondaryVertex() ) ? 1. : 0.; | ||
mvaInput_[21] = std::sqrt(decayDistMag); | ||
mvaInput_[22] = std::min((float)10., (float)tauLifetimeInfo.flightLengthSig()); | ||
} else if ( mvaOpt_ == kDBoldDMwLTwGJ || mvaOpt_ == kDBnewDMwLTwGJ ) { | ||
mvaInput_[0] = std::log(std::max((float)1., (float)tau->pt())); | ||
mvaInput_[1] = std::fabs((float)tau->eta()); | ||
mvaInput_[2] = std::log(std::max((float)1.e-2, chargedIsoPtSum)); | ||
mvaInput_[3] = std::log(std::max((float)1.e-2, neutralIsoPtSum)); | ||
mvaInput_[4] = std::log(std::max((float)1.e-2, puCorrPtSum)); | ||
mvaInput_[5] = std::log(std::max((float)1.e-2, photonPtSumOutsideSignalCone)); | ||
mvaInput_[6] = tauDecayMode; | ||
mvaInput_[7] = std::min((float)30., nPhoton); | ||
mvaInput_[8] = std::min((float)0.5, ptWeightedDetaStrip); | ||
mvaInput_[9] = std::min((float)0.5, ptWeightedDphiStrip); | ||
mvaInput_[10] = std::min((float)0.5, ptWeightedDrSignal); | ||
mvaInput_[11] = std::min((float)0.5, ptWeightedDrIsolation); | ||
mvaInput_[12] = std::min((float)1., eRatio); | ||
mvaInput_[13] = TMath::Sign((float)+1., (float)tauLifetimeInfo.dxy()); | ||
mvaInput_[14] = std::sqrt(std::fabs(std::min((float)1., std::fabs((float)tauLifetimeInfo.dxy())))); | ||
mvaInput_[15] = std::min((float)10., std::fabs((float)tauLifetimeInfo.dxy_Sig())); | ||
mvaInput_[16] = TMath::Sign((float)+1., (float)tauLifetimeInfo.ip3d()); | ||
mvaInput_[17] = std::sqrt(std::fabs(std::min((float)1., std::fabs((float)tauLifetimeInfo.ip3d())))); | ||
mvaInput_[18] = std::min((float)10., std::fabs((float)tauLifetimeInfo.ip3d_Sig())); | ||
mvaInput_[19] = ( tauLifetimeInfo.hasSecondaryVertex() ) ? 1. : 0.; | ||
mvaInput_[20] = std::sqrt(decayDistMag); | ||
mvaInput_[21] = std::min((float)10., (float)tauLifetimeInfo.flightLengthSig()); | ||
mvaInput_[22] = std::max((float)-1., gjAngleDiff); | ||
} | ||
|
||
double mvaValue = mvaReader_->GetClassifier(mvaInput_); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
together with the asin update, it would be nice to add a few linebreaks here to improve readability.