43 <<
" Failed to find File = " << inputFileName <<
" !!\n";
49 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
50 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
52 inputFilesToDelete.push_back(inputFile);
76 loadMVAfromDB_ = cfg.
exists(
"loadMVAfromDB") ? cfg.
getParameter<
bool>(
"loadMVAfromDB") :
false;
77 if ( !loadMVAfromDB_ ) {
81 if ( mvaOpt_string ==
"oldDMwoLT" ) mvaOpt_ = kOldDMwoLT;
82 else if ( mvaOpt_string ==
"oldDMwLT" ) mvaOpt_ = kOldDMwLT;
83 else if ( mvaOpt_string ==
"newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
84 else if ( mvaOpt_string ==
"newDMwLT" ) mvaOpt_ = kNewDMwLT;
85 else throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2")
86 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
88 if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ =
new float[6];
89 else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ =
new float[12];
92 TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.
getParameter<
edm::InputTag>(
"srcTauTransverseImpactParameters"));
98 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
101 produces<PFTauDiscriminator>(
"category");
106 double discriminate(
const PFTauRef&)
const;
112 if(!loadMVAfromDB_)
delete mvaReader_;
114 for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
115 it != inputFilesToDelete_.end(); ++it ) {
154 if ( loadMVAfromDB_ ) {
157 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
161 evt.
getByToken(TauTransverseImpactParameters_token, tauLifetimeInfos);
163 evt.
getByToken(ChargedIsoPtSum_token, chargedIsoPtSums_);
164 evt.
getByToken(NeutralIsoPtSum_token, neutralIsoPtSums_);
165 evt.
getByToken(PUcorrPtSum_token, puCorrPtSums_);
175 category_output_->setValue(tauIndex_, category);
178 if ( tau->leadPFChargedHadrCand().
isNull() )
return 0.;
180 int tauDecayMode = tau->decayMode();
182 if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
183 ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
194 double decayDistMag = TMath::Sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
196 if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) {
197 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
199 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
200 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
201 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
202 mvaInput_[5] = tauDecayMode;
203 }
else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) {
204 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
206 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
207 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
208 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
209 mvaInput_[5] = tauDecayMode;
214 mvaInput_[10] = TMath::Sqrt(decayDistMag);
218 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
220 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:";
221 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta();
222 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" isolation: charged = " << chargedIsoPtSum <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " <<
puCorrPtSum;
223 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" decay mode = " << tauDecayMode;
224 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy() <<
", significance = " << tauLifetimeInfo.
dxy_Sig();
226 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig();
227 edm::LogPrint(
"PFTauDiscByMVAIsol2") <<
"--> mvaValue = " << mvaValue;
238 evt.
put(category_output_,
"category");
T getParameter(std::string const &) const
bool hasSecondaryVertex() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > PFTauTIPAssociationByRef
edm::Handle< reco::PFTauDiscriminator > chargedIsoPtSums_
edm::Handle< PFTauTIPAssociationByRef > tauLifetimeInfos
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void endEvent(edm::Event &)
double discriminate(const PFTauRef &) const
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token
edm::Handle< TauCollection > taus_
const GBRForest * mvaReader_
double flightLengthSig() const
PFRecoTauDiscriminationByIsolationMVA2(const edm::ParameterSet &cfg)
const Vector & flightLength() const
void beginEvent(const edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< PFTauTIPAssociationByRef > TauTransverseImpactParameters_token
std::vector< TFile * > inputFilesToDelete_
bool isNull() const
Checks for null.
LocationCode location() const
Where was the file found?
std::auto_ptr< PFTauDiscriminator > category_output_
T const * product() const
edm::FileInPath inputFileName_
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
edm::Handle< reco::PFTauDiscriminator > puCorrPtSums_
std::string fullPath() const
~PFRecoTauDiscriminationByIsolationMVA2()
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token