41 <<
" Failed to find File = " << inputFileName <<
" !!\n";
47 throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2::loadMVA")
48 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data() <<
" !!\n";
50 inputFilesToDelete.push_back(inputFile);
68 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
70 if ( mvaOpt_string ==
"oldDMwoLT" ) mvaOpt_ = kOldDMwoLT;
71 else if ( mvaOpt_string ==
"oldDMwLT" ) mvaOpt_ = kOldDMwLT;
72 else if ( mvaOpt_string ==
"newDMwoLT" ) mvaOpt_ = kNewDMwoLT;
73 else if ( mvaOpt_string ==
"newDMwLT" ) mvaOpt_ = kNewDMwLT;
74 else throw cms::Exception(
"PFRecoTauDiscriminationByIsolationMVA2")
75 <<
" Invalid Configuration Parameter 'mvaOpt' = " << mvaOpt_string <<
" !!\n";
77 if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) mvaInput_ =
new float[6];
78 else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) mvaInput_ =
new float[12];
81 TauTransverseImpactParameters_token = consumes<PFTauTIPAssociationByRef>(cfg.
getParameter<
edm::InputTag>(
"srcTauTransverseImpactParameters"));
87 verbosity_ = ( cfg.
exists(
"verbosity") ) ?
90 produces<PFTauDiscriminator>(
"category");
95 double discriminate(
const PFTauRef&);
103 for ( std::vector<TFile*>::iterator it = inputFilesToDelete_.begin();
104 it != inputFilesToDelete_.end(); ++it ) {
142 evt.
getByToken(TauTransverseImpactParameters_token, tauLifetimeInfos);
144 evt.
getByToken(ChargedIsoPtSum_token, chargedIsoPtSums_);
145 evt.
getByToken(NeutralIsoPtSum_token, neutralIsoPtSums_);
146 evt.
getByToken(PUcorrPtSum_token, puCorrPtSums_);
157 category_output_->setValue(tauIndex_, category);
161 if ( tau->leadPFChargedHadrCand().
isNull() )
return 0.;
163 int tauDecayMode = tau->decayMode();
165 if ( ((mvaOpt_ == kOldDMwoLT || mvaOpt_ == kOldDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
166 ((mvaOpt_ == kNewDMwoLT || mvaOpt_ == kNewDMwLT) && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10)) ) {
177 double decayDistMag = TMath::Sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
179 if ( mvaOpt_ == kOldDMwoLT || mvaOpt_ == kNewDMwoLT ) {
180 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
181 mvaInput_[1] = TMath::Abs(tau->eta());
182 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
183 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
184 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
185 mvaInput_[5] = tauDecayMode;
186 }
else if ( mvaOpt_ == kOldDMwLT || mvaOpt_ == kNewDMwLT ) {
187 mvaInput_[0] = TMath::Log(
TMath::Max(1., Double_t(tau->pt())));
188 mvaInput_[1] = TMath::Abs(tau->eta());
189 mvaInput_[2] = TMath::Log(
TMath::Max(1.
e-2, chargedIsoPtSum));
190 mvaInput_[3] = TMath::Log(
TMath::Max(1.
e-2, neutralIsoPtSum - 0.125*puCorrPtSum));
191 mvaInput_[4] = TMath::Log(
TMath::Max(1.
e-2, puCorrPtSum));
192 mvaInput_[5] = tauDecayMode;
193 mvaInput_[6] = TMath::Sign(+1., tauLifetimeInfo.
dxy());
194 mvaInput_[7] = TMath::Sqrt(TMath::Abs(
TMath::Min(1., tauLifetimeInfo.
dxy())));
197 mvaInput_[10] = TMath::Sqrt(decayDistMag);
201 double mvaValue = mvaReader_->GetClassifier(mvaInput_);
203 std::cout <<
"<PFRecoTauDiscriminationByIsolationMVA2::discriminate>:" << std::endl;
204 std::cout <<
" tau: Pt = " << tau->pt() <<
", eta = " << tau->eta() << std::endl;
205 std::cout <<
" isolation: charged = " << chargedIsoPtSum <<
", neutral = " << neutralIsoPtSum <<
", PUcorr = " << puCorrPtSum << std::endl;
206 std::cout <<
" decay mode = " << tauDecayMode << std::endl;
207 std::cout <<
" impact parameter: distance = " << tauLifetimeInfo.
dxy() <<
", significance = " << tauLifetimeInfo.
dxy_Sig() << std::endl;
209 <<
" distance = " << decayDistMag <<
", significance = " << tauLifetimeInfo.
flightLengthSig() << std::endl;
210 std::cout <<
"--> mvaValue = " << mvaValue << std::endl;
221 evt.
put(category_output_,
"category");
T getParameter(std::string const &) const
bool hasSecondaryVertex() const
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
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void endEvent(edm::Event &)
edm::EDGetTokenT< reco::PFTauDiscriminator > ChargedIsoPtSum_token
edm::EDGetTokenT< reco::PFTauDiscriminator > NeutralIsoPtSum_token
edm::Handle< TauCollection > taus_
const GBRForest * mvaReader_
double flightLengthSig() const
bool isNull() const
Checks for null.
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_
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
LocationCode location() const
Where was the file found?
std::auto_ptr< PFTauDiscriminator > category_output_
edm::FileInPath inputFileName_
edm::Handle< reco::PFTauDiscriminator > neutralIsoPtSums_
edm::Handle< reco::PFTauDiscriminator > puCorrPtSums_
double discriminate(const PFTauRef &)
std::string fullPath() const
~PFRecoTauDiscriminationByIsolationMVA2()
edm::EDGetTokenT< reco::PFTauDiscriminator > PUcorrPtSum_token