8 : isInitialized_(kFALSE),
11 for (
unsigned i = 0;
i < 10; ++
i ) {
20 for (
unsigned i = 0;
i < 10; ++
i ) {
49 for (
unsigned i = 0;
i < 10; ++
i ) {
82 for (
unsigned i = 0;
i < 10; ++
i ) {
91 int methodName_int = -1;
92 if (
methodName_ ==
"BDT" ) methodName_int = TMVA::Types::kBDT;
94 <<
"Invalid TMVA method name = " <<
methodName_ <<
" !!\n";
151 TMVA::Reader* readerNoEleMatch_BL =
new TMVA::Reader(
"!Color:Silent:Error" );
153 readerNoEleMatch_BL->AddVariable(
"Tau_Pt", &
Tau_Pt_);
156 readerNoEleMatch_BL->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
157 readerNoEleMatch_BL->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
158 readerNoEleMatch_BL->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
164 TMVA::Reader* readerwoG_BL =
new TMVA::Reader(
"!Color:Silent:Error" );
167 readerwoG_BL->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
168 readerwoG_BL->AddVariable(
"Elec_Chi2KF", &
Elec_Chi2KF_);
173 readerwoG_BL->AddVariable(
"Tau_Pt", &
Tau_Pt_);
175 readerwoG_BL->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
176 readerwoG_BL->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
177 readerwoG_BL->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
180 TMVA::Reader* readerwGwoGSF_BL =
new TMVA::Reader(
"!Color:Silent:Error" );
184 readerwGwoGSF_BL->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
185 readerwGwoGSF_BL->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
186 readerwGwoGSF_BL->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
191 readerwGwoGSF_BL->AddVariable(
"Tau_Pt", &
Tau_Pt_);
194 readerwGwoGSF_BL->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
195 readerwGwoGSF_BL->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
196 readerwGwoGSF_BL->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
202 TMVA::Reader* readerwGwGSFwoPFMVA_BL =
new TMVA::Reader(
"!Color:Silent:Error" );
203 readerwGwGSFwoPFMVA_BL->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
204 readerwGwGSFwoPFMVA_BL->AddVariable(
"Elec_Chi2KF", &
Elec_Chi2KF_);
205 readerwGwGSFwoPFMVA_BL->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
206 readerwGwGSFwoPFMVA_BL->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
211 readerwGwGSFwoPFMVA_BL->AddVariable(
"Tau_Pt", &
Tau_Pt_);
212 readerwGwGSFwoPFMVA_BL->AddVariable(
"Tau_EmFraction", &
Tau_EmFraction_);
214 readerwGwGSFwoPFMVA_BL->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
215 readerwGwGSFwoPFMVA_BL->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
216 readerwGwGSFwoPFMVA_BL->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
220 readerwGwGSFwoPFMVA_BL->SetVerbose(
verbosity_);
222 TMVA::Reader* readerwGwGSFwPFMVA_BL =
new TMVA::Reader(
"!Color:Silent:Error" );
225 readerwGwGSFwPFMVA_BL->AddVariable(
"Elec_LateBrem", &
Elec_LateBrem_);
226 readerwGwGSFwPFMVA_BL->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
227 readerwGwGSFwPFMVA_BL->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
232 readerwGwGSFwPFMVA_BL->AddVariable(
"Tau_Pt", &
Tau_Pt_);
233 readerwGwGSFwPFMVA_BL->AddVariable(
"Tau_EmFraction", &
Tau_EmFraction_);
235 readerwGwGSFwPFMVA_BL->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
236 readerwGwGSFwPFMVA_BL->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
237 readerwGwGSFwPFMVA_BL->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
241 readerwGwGSFwPFMVA_BL->SetVerbose(
verbosity_);
243 TMVA::Reader* readerNoEleMatch_EC =
new TMVA::Reader(
"!Color:Silent:Error" );
245 readerNoEleMatch_EC->AddVariable(
"Tau_Pt", &
Tau_Pt_);
248 readerNoEleMatch_EC->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
249 readerNoEleMatch_EC->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
250 readerNoEleMatch_EC->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
256 TMVA::Reader* readerwoG_EC =
new TMVA::Reader(
"!Color:Silent:Error" );
259 readerwoG_EC->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
260 readerwoG_EC->AddVariable(
"Elec_Chi2KF", &
Elec_Chi2KF_);
265 readerwoG_EC->AddVariable(
"Tau_Pt", &
Tau_Pt_);
267 readerwoG_EC->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
268 readerwoG_EC->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
269 readerwoG_EC->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
272 TMVA::Reader* readerwGwoGSF_EC =
new TMVA::Reader(
"!Color:Silent:Error" );
276 readerwGwoGSF_EC->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
277 readerwGwoGSF_EC->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
278 readerwGwoGSF_EC->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
283 readerwGwoGSF_EC->AddVariable(
"Tau_Pt", &
Tau_Pt_);
286 readerwGwoGSF_EC->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
287 readerwGwoGSF_EC->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
288 readerwGwoGSF_EC->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
294 TMVA::Reader* readerwGwGSFwoPFMVA_EC =
new TMVA::Reader(
"!Color:Silent:Error" );
295 readerwGwGSFwoPFMVA_EC->AddVariable(
"Elec_Fbrem", &
Elec_Fbrem_);
296 readerwGwGSFwoPFMVA_EC->AddVariable(
"Elec_Chi2KF", &
Elec_Chi2KF_);
297 readerwGwGSFwoPFMVA_EC->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
298 readerwGwGSFwoPFMVA_EC->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
303 readerwGwGSFwoPFMVA_EC->AddVariable(
"Tau_Pt", &
Tau_Pt_);
304 readerwGwGSFwoPFMVA_EC->AddVariable(
"Tau_EmFraction", &
Tau_EmFraction_);
306 readerwGwGSFwoPFMVA_EC->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
307 readerwGwGSFwoPFMVA_EC->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
308 readerwGwGSFwoPFMVA_EC->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
312 readerwGwGSFwoPFMVA_EC->SetVerbose(
verbosity_);
314 TMVA::Reader* readerwGwGSFwPFMVA_EC =
new TMVA::Reader(
"!Color:Silent:Error" );
317 readerwGwGSFwPFMVA_EC->AddVariable(
"Elec_LateBrem", &
Elec_LateBrem_);
318 readerwGwGSFwPFMVA_EC->AddVariable(
"Elec_Chi2GSF", &
Elec_Chi2GSF_);
319 readerwGwGSFwPFMVA_EC->AddVariable(
"Elec_NumHits", &
Elec_NumHits_);
324 readerwGwGSFwPFMVA_EC->AddVariable(
"Tau_Pt", &
Tau_Pt_);
325 readerwGwGSFwPFMVA_EC->AddVariable(
"Tau_EmFraction", &
Tau_EmFraction_);
327 readerwGwGSFwPFMVA_EC->AddVariable(
"Tau_HadrHoP", &
Tau_HadrHoP_);
328 readerwGwGSFwPFMVA_EC->AddVariable(
"Tau_HadrEoP", &
Tau_HadrEoP_);
329 readerwGwGSFwPFMVA_EC->AddVariable(
"Tau_VisMass", &
Tau_VisMass_);
333 readerwGwGSFwPFMVA_EC->SetVerbose(
verbosity_);
350 Float_t TauSignalPFChargedCands,
351 Float_t TauSignalPFGammaCands,
352 Float_t TauLeadPFChargedHadrHoP,
353 Float_t TauLeadPFChargedHadrEoP,
356 Float_t TauEmFraction,
357 const std::vector<Float_t>& GammasdEta,
358 const std::vector<Float_t>& GammasdPhi,
359 const std::vector<Float_t>& GammasPt,
363 Float_t ElecPFMvaOutput,
368 Float_t ElecEarlyBrem,
369 Float_t ElecLateBrem,
374 Float_t ElecGSFTrackResol,
375 Float_t ElecGSFTracklnPt,
376 Float_t ElecGSFTrackEta)
384 for (
unsigned int i = 0 ;
i < GammasPt.size() ; ++
i ) {
385 double pt_i = GammasPt[
i];
386 double phi_i = GammasdPhi[
i];
389 double eta_i = GammasdEta[
i];
391 sumPt2 += (pt_i*pt_i);
392 dEta += (pt_i*eta_i);
393 dEta2 += (pt_i*eta_i*eta_i);
394 dPhi += (pt_i*phi_i);
395 dPhi2 += (pt_i*phi_i*phi_i);
398 Float_t GammaEnFrac = sumPt/TauPt;
407 Float_t GammaEtaMom = TMath::Sqrt(dEta2)*TMath::Sqrt(GammaEnFrac)*TauPt;
408 Float_t GammaPhiMom = TMath::Sqrt(dPhi2)*TMath::Sqrt(GammaEnFrac)*TauPt;
410 return MVAValue(TauEtaAtEcalEntrance,
413 TauSignalPFChargedCands,
414 TauSignalPFGammaCands,
415 TauLeadPFChargedHadrHoP,
416 TauLeadPFChargedHadrEoP,
445 Float_t TauSignalPFChargedCands,
446 Float_t TauSignalPFGammaCands,
447 Float_t TauLeadPFChargedHadrHoP,
448 Float_t TauLeadPFChargedHadrEoP,
451 Float_t TauEmFraction,
458 Float_t ElecPFMvaOutput,
463 Float_t ElecEarlyBrem,
464 Float_t ElecLateBrem,
469 Float_t ElecGSFTrackResol,
470 Float_t ElecGSFTracklnPt,
471 Float_t ElecGSFTrackEta)
475 std::cout <<
"Error: AntiElectronMVA not properly initialized.\n";
508 else if (
deltaR(TauEtaAtEcalEntrance, TauPhi, ElecEta, ElecPhi) > 0.3 ) {
511 }
else if ( TauSignalPFGammaCands == 0 ) {
514 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf < 0.5 ) {
517 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 && ElecPFMvaOutput < -0.1 ) {
520 }
else if ( TauSignalPFGammaCands > 0 && TauHasGsf > 0.5 && ElecPFMvaOutput > -0.1 ) {
533 float sumEtaTimesEnergy = 0;
535 Float_t TauEtaAtEcalEntrance = 0;
538 sumEtaTimesEnergy += pfcandidate->positionAtECALEntrance().eta()*pfcandidate->energy();
539 sumEnergy += pfcandidate->energy();
541 if(sumEnergy>0)TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
543 Float_t TauPhi = thePFTau.
phi();
544 Float_t TauPt = thePFTau.
pt();
547 Float_t TauLeadPFChargedHadrHoP = 0.;
548 Float_t TauLeadPFChargedHadrEoP = 0.;
554 Float_t TauVisMass = thePFTau.
mass();
556 std::vector<Float_t> GammasdEta;
557 std::vector<Float_t> GammasdPhi;
558 std::vector<Float_t> GammasPt;
565 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
566 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
568 GammasPt.push_back(gamma->pt());
571 Float_t ElecEta = theGsfEle.
eta();
572 Float_t ElecPhi = theGsfEle.
phi();
573 Float_t ElecPt = theGsfEle.
pt();
577 Float_t ElecEgamma = 0.;
581 pfCluster != pfSuperCluster->clustersEnd(); ++pfCluster ) {
582 double pfClusterEn = (*pfCluster)->energy();
583 if ( pfCluster == pfSuperCluster->clustersBegin() )
Elec_Ee_ += pfClusterEn;
591 Float_t ElecFbrem = theGsfEle.
fbrem();
593 Float_t ElecChi2KF = -99.;
594 Float_t ElecNumHits = -99.;
600 Float_t ElecChi2GSF = -99.;
601 Float_t ElecGSFTrackResol = -99.;
602 Float_t ElecGSFTracklnPt = -99.;
603 Float_t ElecGSFTrackEta = -99.;
605 ElecChi2GSF = (theGsfEle).gsfTrack()->normalizedChi2();
606 if ( theGsfEle.
gsfTrack()->pt() > 0. ) {
607 ElecGSFTrackResol = theGsfEle.
gsfTrack()->ptError()/theGsfEle.
gsfTrack()->pt();
608 ElecGSFTracklnPt =
log(theGsfEle.
gsfTrack()->pt())*TMath::Ln10();
610 ElecGSFTrackEta = theGsfEle.
gsfTrack()->eta();
613 return MVAValue(TauEtaAtEcalEntrance,
616 TauSignalPFChargedCands,
617 TauSignalPFGammaCands,
618 TauLeadPFChargedHadrHoP,
619 TauLeadPFChargedHadrEoP,
647 float sumEtaTimesEnergy = 0;
649 Float_t TauEtaAtEcalEntrance =0;
652 sumEtaTimesEnergy += pfcandidate->positionAtECALEntrance().eta()*pfcandidate->energy();
653 sumEnergy += pfcandidate->energy();
655 if(sumEnergy>0)TauEtaAtEcalEntrance = sumEtaTimesEnergy/sumEnergy;
657 Float_t TauPhi = thePFTau.
phi();
658 Float_t TauPt = thePFTau.
pt();
661 Float_t TauLeadPFChargedHadrHoP = 0.;
662 Float_t TauLeadPFChargedHadrEoP = 0.;
668 Float_t TauVisMass = thePFTau.
mass();
670 std::vector<Float_t> GammasdEta;
671 std::vector<Float_t> GammasdPhi;
672 std::vector<Float_t> GammasPt;
679 GammasdEta.push_back(gamma->eta() - thePFTau.
eta());
680 GammasdPhi.push_back(gamma->phi() - thePFTau.
phi());
682 GammasPt.push_back(gamma->pt());
685 Float_t dummyElecEta = 9.9;
687 return MVAValue(TauEtaAtEcalEntrance,
690 TauSignalPFChargedCands,
691 TauSignalPFGammaCands,
692 TauLeadPFChargedHadrHoP,
693 TauLeadPFChargedHadrEoP,
Float_t Elec_GSFTracklnPt_
Float_t Tau_NumGammaCands_
Float_t Tau_NumChargedCands_
math::XYZVectorF trackMomentumAtVtx() const
Float_t Elec_PFMvaOutput_
Float_t Elec_GSFTrackResol_
Float_t Tau_EtaAtEcalEntrance_
const PFCandidateRefVector & signalPFChargedHadrCands() const
Charged hadrons in signal region.
const PFCandidateRefVector & signalPFCands() const
PFCandidates in signal region.
TrackRef closestCtfTrackRef() const
Float_t Elec_GSFTrackEta_
bool isNonnull() const
Checks for non-null.
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
void Initialize_from_string(const std::string &methodName, const std::string &oneProngNoEleMatch_BL, const std::string &oneProng0Pi0_BL, const std::string &oneProng1pi0woGSF_BL, const std::string &oneProng1pi0wGSFwoPfEleMva_BL, const std::string &oneProng1pi0wGSFwPfEleMva_BL, const std::string &oneProngNoEleMatch_EC, const std::string &oneProng0Pi0_EC, const std::string &oneProng1pi0woGSF_EC, const std::string &oneProng1pi0wGSFwoPfEleMva_EC, const std::string &oneProng1pi0wGSFwPfEleMva_EC)
double dPhi(double phi1, double phi2)
const MvaInput & mvaInput() const
math::XYZVectorF trackMomentumOut() const
TMVA::Reader * fTMVAReader_[10]
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
void Initialize_from_file(const std::string &methodName, const std::string &oneProngNoEleMatch_BL, const std::string &oneProng0Pi0_BL, const std::string &oneProng1pi0woGSF_BL, const std::string &oneProng1pi0wGSFwoPfEleMva_BL, const std::string &oneProng1pi0wGSFwPfEleMva_BL, const std::string &oneProngNoEleMatch_EC, const std::string &oneProng0Pi0_EC, const std::string &oneProng1pi0woGSF_EC, const std::string &oneProng1pi0wGSFwoPfEleMva_EC, const std::string &oneProng1pi0wGSFwPfEleMva_EC)
virtual float mass() const GCC11_FINAL
mass
const PFCandidateRef & leadPFChargedHadrCand() const
Float_t Elec_EgammaOverPdif_
const PFCandidateRefVector & signalPFGammaCands() const
Gamma candidates in signal region.
const MvaOutput & mvaOutput() const
value_type const at(size_type idx) const
Retrieve an element of the RefVector.
double MVAValue(Float_t TauEtaAtEcalEntrance, Float_t TauPhi, Float_t TauPt, Float_t TauSignalPFChargedCands, Float_t TauSignalPFGammaCands, Float_t TauLeadPFChargedHadrHoP, Float_t TauLeadPFChargedHadrEoP, Float_t TauHasGsf, Float_t TauVisMass, Float_t TauEmFraction, const std::vector< Float_t > &GammasdEta, const std::vector< Float_t > &GammasdPhi, const std::vector< Float_t > &GammasPt, Float_t ElecEta, Float_t ElecPhi, Float_t ElecPt, Float_t ElecPFMvaOutput, Float_t ElecEe, Float_t ElecEgamma, Float_t ElecPin, Float_t ElecPout, Float_t ElecEarlyBrem, Float_t ElecLateBrem, Float_t ElecFbrem, Float_t ElecChi2KF, Float_t ElecChi2GSF, Float_t ElecNumHits, Float_t ElecGSFTrackResol, Float_t ElecGSFTracklnPt, Float_t ElecGSFTrackEta)
Float_t Elec_EtotOverPin_
size_type size() const
Size of the RefVector.
virtual float pt() const GCC11_FINAL
transverse momentum
SuperClusterRef pflowSuperCluster() const
tuple size
Write out results.
virtual GsfTrackRef gsfTrack() const
reference to a GsfTrack
void loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)