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);
73 moduleLabel_(cfg.getParameter<
std::
string>(
"@module_label")),
79 loadMVAfromDB_ = cfg.
getParameter<
bool>(
"loadMVAfromDB");
80 if ( !loadMVAfromDB_ ) {
84 if ( mvaOpt_string ==
"oldDMwoLT" ) mvaOpt_ =
kOldDMwoLT;
85 else if ( mvaOpt_string ==
"oldDMwLT" ) mvaOpt_ =
kOldDMwLT;
86 else if ( mvaOpt_string ==
"newDMwoLT" ) mvaOpt_ =
kNewDMwoLT;
87 else if ( mvaOpt_string ==
"newDMwLT" ) mvaOpt_ =
kNewDMwLT;
88 else throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2")
89 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
95 TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.
getParameter<
edm::InputTag>(
"srcTauTransverseImpactParameters"));
103 produces<PFTauDiscriminator>(
"category");
108 double discriminate(
const PFTauRef&)
const override;
114 if(!loadMVAfromDB_)
delete mvaReader_;
116 for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
117 it != inputFilesToDelete_.end(); ++it ) {
157 if ( loadMVAfromDB_ ) {
160 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
164 evt.
getByToken(TauTransverseImpactParameters_token, tauLifetimeInfos);
166 evt.
getByToken(ChargedIsoPtSum_token, chargedIsoPtSums_);
167 evt.
getByToken(NeutralIsoPtSum_token, neutralIsoPtSums_);
168 evt.
getByToken(PUcorrPtSum_token, puCorrPtSums_);
178 category_output_->setValue(tauIndex_, category);
181 if ( tau->leadChargedHadrCand().
isNull() )
return 0.;
183 int tauDecayMode = tau->decayMode();
185 if ( ((mvaOpt_ ==
kOldDMwoLT || mvaOpt_ ==
kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
186 ((mvaOpt_ ==
kNewDMwoLT || mvaOpt_ ==
kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
197 double decayDistMag = TMath::Sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
200 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
202 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
203 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
204 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
205 mvaInput_[5] = tauDecayMode;
207 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
209 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
210 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
211 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
212 mvaInput_[5] = tauDecayMode;
217 mvaInput_[10] = TMath::Sqrt(decayDistMag);
221 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
223 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:";
224 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
225 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " <<
puCorrPtSum;
226 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
227 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy() <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
229 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
230 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
250 desc.
add<
bool>(
"loadMVAfromDB");
258 desc.
add<
int>(
"verbosity", 0);
260 fillProducerDescriptions(desc);
262 descriptions.
add(
"pfRecoTauDiscriminationByIsolationMVA2", desc);
T getParameter(std::string const &) const
void beginEvent(const edm::Event &, const edm::EventSetup &) override
bool hasSecondaryVertex() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > PFTauTIPAssociationByRef
edm::Handle< reco::PFTauDiscriminator > chargedIsoPtSums_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token
edm::Handle< TauCollection > taus_
#define DEFINE_FWK_MODULE(type)
const GBRForest * mvaReader_
double flightLengthSig() const
PFRecoTauDiscriminationByIsolationMVA2(const edm::ParameterSet &cfg)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const Vector & flightLength() const
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
std::vector< TFile * > inputFilesToDelete_
LocationCode location() const
Where was the file found?
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double discriminate(const PFTauRef &) const override
std::unique_ptr< PFTauDiscriminator > category_output_
edm::FileInPath inputFileName_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
edm::Handle< reco::PFTauDiscriminator > puCorrPtSums_
void endEvent(edm::Event &) override
std::string fullPath() const
~PFRecoTauDiscriminationByIsolationMVA2() override
T const * product() const
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token