50 <<
" Failed to find File = " << inputFileName <<
" !!\n";
56 throw cms::Exception(
"PATTauDiscriminationByIsolationMVARun2::loadMVA")
57 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
59 inputFilesToDelete.push_back(inputFile);
72 namespace reco {
namespace tau {
79 moduleLabel_(cfg.getParameter<
std::
string>(
"@module_label")),
85 loadMVAfromDB_ = cfg.
exists(
"loadMVAfromDB") ? cfg.
getParameter<
bool>(
"loadMVAfromDB") :
false;
86 if ( !loadMVAfromDB_ ) {
87 if(cfg.
exists(
"inputFileName")){
89 }
else throw cms::Exception(
"MVA input not defined") <<
"Requested to load tau MVA input from ROOT file but no file provided in cfg file";
92 if ( mvaOpt_string ==
"oldDMwoLT" ) mvaOpt_ =
kOldDMwoLT;
93 else if ( mvaOpt_string ==
"oldDMwLT" ) mvaOpt_ =
kOldDMwLT;
94 else if ( mvaOpt_string ==
"newDMwoLT" ) mvaOpt_ =
kNewDMwoLT;
95 else if ( mvaOpt_string ==
"newDMwLT" ) mvaOpt_ =
kNewDMwLT;
96 else if ( mvaOpt_string ==
"DBoldDMwLT" ) mvaOpt_ =
kDBoldDMwLT;
97 else if ( mvaOpt_string ==
"DBnewDMwLT" ) mvaOpt_ =
kDBnewDMwLT;
98 else if ( mvaOpt_string ==
"PWoldDMwLT" ) mvaOpt_ =
kPWoldDMwLT;
99 else if ( mvaOpt_string ==
"PWnewDMwLT" ) mvaOpt_ =
kPWnewDMwLT;
100 else if ( mvaOpt_string ==
"DBoldDMwLTwGJ" ) mvaOpt_ =
kDBoldDMwLTwGJ;
101 else if ( mvaOpt_string ==
"DBnewDMwLTwGJ" ) mvaOpt_ =
kDBnewDMwLTwGJ;
102 else throw cms::Exception(
"PATTauDiscriminationByMVAIsolationRun2")
103 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
118 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
121 produces<pat::PATTauDiscriminator>(
"category");
126 double discriminate(
const TauRef&)
const override;
132 if(!loadMVAfromDB_)
delete mvaReader_;
134 for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
135 it != inputFilesToDelete_.end(); ++it ) {
167 if ( loadMVAfromDB_ ) {
170 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
178 double PATTauDiscriminationByMVAIsolationRun2::discriminate(
const TauRef&
tau)
const 182 category_output_->setValue(tauIndex_, category);
185 if ( tau->leadChargedHadrCand().
isNull() )
return 0.;
187 if (
reco::tau::fillIsoMVARun2Inputs(mvaInput_, *tau, mvaOpt_, chargedIsoPtSums_, neutralIsoPtSums_, puCorrPtSums_, photonPtSumOutsideSignalCone_, footprintCorrection_)) {
188 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
190 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
"<PATTauDiscriminationByMVAIsolationRun2::discriminate>:";
191 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
192 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" isolation: charged = " << tau->tauID(chargedIsoPtSums_) <<
", neutral = " << tau->tauID(neutralIsoPtSums_) <<
", PUcorr = " << tau->tauID(puCorrPtSums_);
193 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" decay mode = " << tau->decayMode();
194 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" impact parameter: distance = " << tau->dxy() <<
", significance = " << tau->dxy_Sig();
195 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" has decay vertex = " << tau->hasSecondaryVertex() <<
":" 196 <<
", significance = " << tau->flightLengthSig();
197 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
"--> mvaValue = " << mvaValue;
204 void PATTauDiscriminationByMVAIsolationRun2::endEvent(
edm::Event& evt)
std::string footprintCorrection_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::RefProd< TauCollection > TauRefProd
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< pat::PATTauDiscriminator > category_output_
#define DEFINE_FWK_MODULE(type)
edm::Handle< TauCollection > taus_
const GBRForest * mvaReader_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
bool fillIsoMVARun2Inputs(float *mvaInput, const pat::Tau &tau, int mvaOpt, const std::string &nameCharged, const std::string &nameNeutral, const std::string &namePu, const std::string &nameOutside, const std::string &nameFootprint)
std::string photonPtSumOutsideSignalCone_
std::string chargedIsoPtSums_
PATTauDiscriminationByMVAIsolationRun2(const edm::ParameterSet &cfg)
~PATTauDiscriminationByMVAIsolationRun2() override
LocationCode location() const
Where was the file found?
bool isNull() const
Checks for null.
std::string neutralIsoPtSums_
std::vector< TFile * > inputFilesToDelete_
std::string puCorrPtSums_
std::string fullPath() const
T const * product() const
edm::FileInPath inputFileName_