53 <<
" Failed to find File = " << inputFileName <<
" !!\n";
59 throw cms::Exception(
"PATTauDiscriminationByIsolationMVARun2::loadMVA")
60 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
62 inputFilesToDelete.push_back(inputFile);
75 namespace reco {
namespace tau {
82 moduleLabel_(cfg.getParameter<
std::
string>(
"@module_label")),
88 loadMVAfromDB_ = cfg.
getParameter<
bool>(
"loadMVAfromDB");
89 if ( !loadMVAfromDB_ ) {
93 if ( mvaOpt_string ==
"oldDMwoLT" ) mvaOpt_ =
kOldDMwoLT;
94 else if ( mvaOpt_string ==
"oldDMwLT" ) mvaOpt_ =
kOldDMwLT;
95 else if ( mvaOpt_string ==
"newDMwoLT" ) mvaOpt_ =
kNewDMwoLT;
96 else if ( mvaOpt_string ==
"newDMwLT" ) mvaOpt_ =
kNewDMwLT;
97 else if ( mvaOpt_string ==
"DBoldDMwLT" ) mvaOpt_ =
kDBoldDMwLT;
98 else if ( mvaOpt_string ==
"DBnewDMwLT" ) mvaOpt_ =
kDBnewDMwLT;
99 else if ( mvaOpt_string ==
"PWoldDMwLT" ) mvaOpt_ =
kPWoldDMwLT;
100 else if ( mvaOpt_string ==
"PWnewDMwLT" ) mvaOpt_ =
kPWnewDMwLT;
101 else if ( mvaOpt_string ==
"DBoldDMwLTwGJ" ) mvaOpt_ =
kDBoldDMwLTwGJ;
102 else if ( mvaOpt_string ==
"DBnewDMwLTwGJ" ) mvaOpt_ =
kDBnewDMwLTwGJ;
103 else throw cms::Exception(
"PATTauDiscriminationByMVAIsolationRun2")
104 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
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 ) {
169 if ( loadMVAfromDB_ ) {
172 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
180 double PATTauDiscriminationByMVAIsolationRun2::discriminate(
const TauRef&
tau)
const 184 category_output_->setValue(tauIndex_, category);
187 if ( tau->leadChargedHadrCand().
isNull() )
return 0.;
189 if (
reco::tau::fillIsoMVARun2Inputs(mvaInput_, *tau, mvaOpt_, chargedIsoPtSums_, neutralIsoPtSums_, puCorrPtSums_, photonPtSumOutsideSignalCone_, footprintCorrection_)) {
190 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
192 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
"<PATTauDiscriminationByMVAIsolationRun2::discriminate>:";
193 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
194 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" isolation: charged = " << tau->tauID(chargedIsoPtSums_) <<
", neutral = " << tau->tauID(neutralIsoPtSums_) <<
", PUcorr = " << tau->tauID(puCorrPtSums_);
195 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" decay mode = " << tau->decayMode();
196 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" impact parameter: distance = " << tau->dxy() <<
", significance = " << tau->dxy_Sig();
197 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
" has decay vertex = " << tau->hasSecondaryVertex() <<
":" 198 <<
", significance = " << tau->flightLengthSig();
199 edm::LogPrint(
"PATTauDiscByMVAIsolRun2") <<
"--> mvaValue = " << mvaValue;
206 void PATTauDiscriminationByMVAIsolationRun2::endEvent(
edm::Event& evt)
218 desc.
add<
bool>(
"loadMVAfromDB");
227 desc.
add<
int>(
"verbosity", 0);
229 fillProducerDescriptions(desc);
231 descriptions.
add(
"patTauDiscriminationByMVAIsolationRun2", desc);
std::string footprintCorrection_
T getParameter(std::string const &) 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
std::unique_ptr< pat::PATTauDiscriminator > category_output_
edm::Handle< TauCollection > taus_
const GBRForest * mvaReader_
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_
#define DEFINE_FWK_MODULE(type)
PATTauDiscriminationByMVAIsolationRun2(const edm::ParameterSet &cfg)
~PATTauDiscriminationByMVAIsolationRun2() override
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)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string neutralIsoPtSums_
std::vector< TFile * > inputFilesToDelete_
std::string puCorrPtSums_
std::string fullPath() const
T const * product() const
edm::FileInPath inputFileName_