44 std::vector<TFile*>& inputFilesToDelete) {
46 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
53 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
54 <<
" Failed to load MVA = " <<
mvaName.data() <<
" from file = " <<
inputFileName.fullPath().data()
73 moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")),
77 loadMVAfromDB_ =
cfg.getParameter<
bool>(
"loadMVAfromDB");
78 if (!loadMVAfromDB_) {
82 if (mvaOpt_string ==
"oldDMwoLT")
84 else if (mvaOpt_string ==
"oldDMwLT")
86 else if (mvaOpt_string ==
"newDMwoLT")
88 else if (mvaOpt_string ==
"newDMwLT")
92 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
95 mvaInput_ =
new float[6];
97 mvaInput_ =
new float[12];
101 tauTransverseImpactParameters_token_ =
102 consumes<PFTauTIPAssociationByRef>(
cfg.getParameter<
edm::InputTag>(
"srcTauTransverseImpactParameters"));
104 basicTauDiscriminators_token_ =
105 consumes<reco::TauDiscriminatorContainer>(
cfg.getParameter<
edm::InputTag>(
"srcBasicTauDiscriminators"));
106 chargedIsoPtSum_index_ =
cfg.getParameter<
int>(
"srcChargedIsoPtSumIndex");
107 neutralIsoPtSum_index_ =
cfg.getParameter<
int>(
"srcNeutralIsoPtSumIndex");
108 pucorrPtSum_index_ =
cfg.getParameter<
int>(
"srcPUcorrPtSumIndex");
110 verbosity_ =
cfg.getParameter<
int>(
"verbosity");
121 for (std::vector<TFile*>::iterator it = inputFilesToDelete_.begin(); it != inputFilesToDelete_.end(); ++it) {
159 if (loadMVAfromDB_) {
162 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
166 evt.
getByToken(tauTransverseImpactParameters_token_, tauLifetimeInfos_);
168 evt.
getByToken(basicTauDiscriminators_token_, basicTauDiscriminators_);
176 result.rawValues = {-1., 0.};
179 if (
tau->leadChargedHadrCand().isNull())
182 int tauDecayMode =
tau->decayMode();
185 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
187 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
188 tauDecayMode == 10))) {
189 double chargedIsoPtSum = (*basicTauDiscriminators_)[
tau].rawValues.at(chargedIsoPtSum_index_);
190 double neutralIsoPtSum = (*basicTauDiscriminators_)[
tau].rawValues.at(neutralIsoPtSum_index_);
191 double puCorrPtSum = (*basicTauDiscriminators_)[
tau].rawValues.at(pucorrPtSum_index_);
198 double decayDistMag = TMath::Sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
201 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(
tau->pt())));
203 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
204 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125 * puCorrPtSum));
205 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
206 mvaInput_[5] = tauDecayMode;
208 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(
tau->pt())));
210 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
211 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125 * puCorrPtSum));
212 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
213 mvaInput_[5] = tauDecayMode;
218 mvaInput_[10] = TMath::Sqrt(decayDistMag);
222 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
224 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:";
225 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " <<
tau->pt() <<
", eta = " <<
tau->eta();
226 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum
227 <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " << puCorrPtSum;
228 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
229 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy()
230 <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
233 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
234 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
236 result.rawValues.at(0) = mvaValue;
246 desc.add<
bool>(
"loadMVAfromDB");
252 desc.add<
int>(
"srcChargedIsoPtSumIndex");
253 desc.add<
int>(
"srcNeutralIsoPtSumIndex");
254 desc.add<
int>(
"srcPUcorrPtSumIndex");
255 desc.add<
int>(
"verbosity", 0);
257 fillProducerDescriptions(
desc);
259 descriptions.
add(
"pfRecoTauDiscriminationByIsolationMVA2",
desc);