9 using namespace HWWFunctions;
15 return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
55 fMethodname(
"BDTG method"),
56 fisInitialized(kFALSE),
57 fPrintMVADebug(kFALSE),
59 fUseBinnedVersion(kTRUE),
78 std::vector<std::string> tempWeightFileVector;
79 tempWeightFileVector.push_back(weightsfile);
80 initialize(methodName,type,kFALSE,tempWeightFileVector);
87 Bool_t useBinnedVersion,
88 std::vector<std::string> weightsfiles
104 unsigned int ExpectedNBins = 0;
113 }
else if (type ==
kID) {
120 edm::LogError(
"InvalidInput") <<
"Error: Expected Number of bins = " <<
fNMVABins <<
" does not equal to weightsfiles.size() = "
121 << weightsfiles.size();
122 assert(
fNMVABins == weightsfiles.size());
130 TMVA::Reader *tmpTMVAReader =
new TMVA::Reader(
"!Color:Silent:Error" );
132 tmpTMVAReader->SetVerbose(kFALSE);
226 unsigned int bin = 0;
229 if (isGlobal && isTrackerMuon) {
230 if (pt < 10 && fabs(eta) < 1.479) bin = 0;
231 if (pt < 10 && fabs(eta) >= 1.479) bin = 1;
232 if (pt >= 10 && fabs(eta) < 1.479) bin = 2;
233 if (pt >= 10 && fabs(eta) >= 1.479) bin = 3;
235 else if (isTrackerMuon) bin = 4;
236 else if (isGlobal) bin = 5;
241 if (isGlobal && isTrackerMuon) {
242 if (pt < 10 && fabs(eta) < 1.479) bin = 0;
243 if (pt < 10 && fabs(eta) >= 1.479) bin = 1;
244 if (pt >= 10 && fabs(eta) < 1.479) bin = 2;
245 if (pt >= 10 && fabs(eta) >= 1.479) bin = 3;
247 else if (isTrackerMuon) bin = 4;
248 else if (isGlobal) bin = 5;
254 if (isGlobal && isTrackerMuon) {
255 if (pt < 10 && fabs(eta) < 1.479) bin = 0;
256 if (pt < 10 && fabs(eta) >= 1.479) bin = 1;
257 if (pt >= 10 && fabs(eta) < 1.479) bin = 2;
258 if (pt >= 10 && fabs(eta) >= 1.479) bin = 3;
260 else if (!isGlobal && isTrackerMuon) {
264 edm::LogWarning(
"NotTrackerMuon") <<
"Warning: Muon is not a tracker muon. Such muons are not supported.";
269 if (pt < 20 && fabs(eta) < 1.479) bin = 0;
270 if (pt < 20 && fabs(eta) >= 1.479) bin = 1;
271 if (pt >= 20 && fabs(eta) < 1.479) bin = 2;
272 if (pt >= 20 && fabs(eta) >= 1.479) bin = 3;
288 Bool_t isTrackerMuon,
291 Double_t ChargedIso_DR0p0To0p1,
292 Double_t ChargedIso_DR0p1To0p2,
293 Double_t ChargedIso_DR0p2To0p3,
294 Double_t ChargedIso_DR0p3To0p4,
295 Double_t ChargedIso_DR0p4To0p5,
296 Double_t GammaIso_DR0p0To0p1,
297 Double_t GammaIso_DR0p1To0p2,
298 Double_t GammaIso_DR0p2To0p3,
299 Double_t GammaIso_DR0p3To0p4,
300 Double_t GammaIso_DR0p4To0p5,
301 Double_t NeutralHadronIso_DR0p0To0p1,
302 Double_t NeutralHadronIso_DR0p1To0p2,
303 Double_t NeutralHadronIso_DR0p2To0p3,
304 Double_t NeutralHadronIso_DR0p3To0p4,
305 Double_t NeutralHadronIso_DR0p4To0p5,
309 edm::LogError(
"NotInitialized") <<
"Error: MuonMVAEstimator not properly initialized.";
334 <<
"ChargedIso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
340 <<
"PF Gamma Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
346 <<
"PF Neutral Hadron Iso ( 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 ): "
352 <<
" ### MVA " << mva << endl;
360 std::vector<Int_t> IdentifiedEle, std::vector<Int_t> IdentifiedMu, Bool_t
printDebug ) {
364 edm::LogError(
"NotInitialized") <<
"Error: MuonMVAEstimator not properly initialized.\n";
369 Double_t mvavalue = -9999.;
383 Bool_t isGlobalMuon = (hww.
mus_type().at(mu)) & (1<<1);
384 Bool_t isTrackerMuon = (hww.
mus_type().at(mu)) & (1<<2);
388 Double_t ChargedIso_DR0p0To0p1 = 0;
389 Double_t ChargedIso_DR0p1To0p2 = 0;
390 Double_t ChargedIso_DR0p2To0p3 = 0;
391 Double_t ChargedIso_DR0p3To0p4 = 0;
392 Double_t ChargedIso_DR0p4To0p5 = 0;
393 Double_t GammaIso_DR0p0To0p1 = 0;
394 Double_t GammaIso_DR0p1To0p2 = 0;
395 Double_t GammaIso_DR0p2To0p3 = 0;
396 Double_t GammaIso_DR0p3To0p4 = 0;
397 Double_t GammaIso_DR0p4To0p5 = 0;
398 Double_t NeutralHadronIso_DR0p0To0p1 = 0;
399 Double_t NeutralHadronIso_DR0p1To0p2 = 0;
400 Double_t NeutralHadronIso_DR0p2To0p3 = 0;
401 Double_t NeutralHadronIso_DR0p3To0p4 = 0;
402 Double_t NeutralHadronIso_DR0p4To0p5 = 0;
406 for(
unsigned int ipf = 0; ipf < hww.
pfcands_p4().size(); ++ipf) {
420 Bool_t IsLeptonFootprint = kFALSE;
427 for (
unsigned int iele=0; iele<IdentifiedEle.size(); iele++) {
429 int ele = IdentifiedEle[iele];
446 && tmpDR < 0.015) IsLeptonFootprint = kTRUE;
448 && tmpDR < 0.08) IsLeptonFootprint = kTRUE;
451 for (
unsigned int imu=0; imu<IdentifiedMu.size(); imu++) {
453 unsigned int idenmu = IdentifiedMu[imu];
462 if(hww.
pfcands_trkidx().at(ipf)>=0 && tmpDR < 0.01) IsLeptonFootprint = kTRUE;
465 if( !IsLeptonFootprint ) {
478 if (fabs(Eta) > 1.479 && dr < 0.01)
continue;
480 if (dr < 0.1) ChargedIso_DR0p0To0p1 += hww.
pfcands_p4().at(ipf).pt();
481 if (dr >= 0.1 && dr < 0.2) ChargedIso_DR0p1To0p2 += hww.
pfcands_p4().at(ipf).pt();
482 if (dr >= 0.2 && dr < 0.3) ChargedIso_DR0p2To0p3 += hww.
pfcands_p4().at(ipf).pt();
483 if (dr >= 0.3 && dr < 0.4) ChargedIso_DR0p3To0p4 += hww.
pfcands_p4().at(ipf).pt();
484 if (dr >= 0.4 && dr < 0.5) ChargedIso_DR0p4To0p5 += hww.
pfcands_p4().at(ipf).pt();
487 if (dr < 0.1) GammaIso_DR0p0To0p1 += hww.
pfcands_p4().at(ipf).pt();
488 if (dr >= 0.1 && dr < 0.2) GammaIso_DR0p1To0p2 += hww.
pfcands_p4().at(ipf).pt();
489 if (dr >= 0.2 && dr < 0.3) GammaIso_DR0p2To0p3 += hww.
pfcands_p4().at(ipf).pt();
490 if (dr >= 0.3 && dr < 0.4) GammaIso_DR0p3To0p4 += hww.
pfcands_p4().at(ipf).pt();
491 if (dr >= 0.4 && dr < 0.5) GammaIso_DR0p4To0p5 += hww.
pfcands_p4().at(ipf).pt();
494 if (dr < 0.1) NeutralHadronIso_DR0p0To0p1 += hww.
pfcands_p4().at(ipf).pt();
495 if (dr >= 0.1 && dr < 0.2) NeutralHadronIso_DR0p1To0p2 += hww.
pfcands_p4().at(ipf).pt();
496 if (dr >= 0.2 && dr < 0.3) NeutralHadronIso_DR0p2To0p3 += hww.
pfcands_p4().at(ipf).pt();
497 if (dr >= 0.3 && dr < 0.4) NeutralHadronIso_DR0p3To0p4 += hww.
pfcands_p4().at(ipf).pt();
498 if (dr >= 0.4 && dr < 0.5) NeutralHadronIso_DR0p4To0p5 += hww.
pfcands_p4().at(ipf).pt();
513 ChargedIso_DR0p0To0p1,
514 ChargedIso_DR0p1To0p2,
515 ChargedIso_DR0p2To0p3,
516 ChargedIso_DR0p3To0p4,
517 ChargedIso_DR0p4To0p5,
523 NeutralHadronIso_DR0p0To0p1,
524 NeutralHadronIso_DR0p1To0p2,
525 NeutralHadronIso_DR0p2To0p3,
526 NeutralHadronIso_DR0p3To0p4,
527 NeutralHadronIso_DR0p4To0p5,
Float_t fMVAVar_MuEmEnergy
Float_t fMVAVar_MuTrkKink
Float_t fMVAVar_MuNPixelHits
std::vector< int > & pfels_elsidx()
Float_t fMVAVar_MuNValidHits
Float_t fMVAVar_MuCaloCompatibility
Float_t fMVAVar_ChargedIso_DR0p2To0p3
std::vector< TMVA::Reader * > fTMVAReader
Float_t fMVAVar_NeutralHadronIso_DR0p1To0p2
Float_t fMVAVar_ChargedIso_DR0p3To0p4
Float_t fMVAVar_ChargedIso_DR0p1To0p2
Float_t fMVAVar_GammaIso_DR0p4To0p5
std::vector< int > & mus_trkidx()
Float_t fMVAVar_GammaIso_DR0p3To0p4
std::vector< LorentzVector > & mus_p4()
std::vector< LorentzVector > & pfcands_p4()
Float_t fMVAVar_GammaIso_DR0p1To0p2
Float_t fMVAVar_MuSegmentCompatibility
std::vector< int > & pfcands_trkidx()
std::vector< int > & pfcands_pfelsidx()
UInt_t GetMVABin(double eta, double pt, Bool_t isGlobal, Bool_t isTrackerMuon) const
Float_t fMVAVar_ChargedIso_DR0p0To0p1
std::vector< LorentzVector > & mus_trk_p4()
Double_t mvaValue_Iso(Double_t Pt, Double_t Eta, Bool_t isGlobalMuon, Bool_t isTrackerMuon, Double_t Rho, MuonEffectiveArea::MuonEffectiveAreaTarget EATarget, Double_t ChargedIso_DR0p0To0p1, Double_t ChargedIso_DR0p1To0p2, Double_t ChargedIso_DR0p2To0p3, Double_t ChargedIso_DR0p3To0p4, Double_t ChargedIso_DR0p4To0p5, Double_t GammaIso_DR0p0To0p1, Double_t GammaIso_DR0p1To0p2, Double_t GammaIso_DR0p2To0p3, Double_t GammaIso_DR0p3To0p4, Double_t GammaIso_DR0p4To0p5, Double_t NeutralHadronIso_DR0p0To0p1, Double_t NeutralHadronIso_DR0p1To0p2, Double_t NeutralHadronIso_DR0p2To0p3, Double_t NeutralHadronIso_DR0p3To0p4, Double_t NeutralHadronIso_DR0p4To0p5, Bool_t printDebug=kFALSE)
Cos< T >::type cos(const T &t)
std::vector< int > & pfcands_particleId()
Abs< T >::type abs(const T &t)
Double_t mvaValueIso(HWW &, Int_t imu, Double_t rho, MuonEffectiveArea::MuonEffectiveAreaTarget EATarget, std::vector< Int_t > IdentifiedEle, std::vector< Int_t > IdentifiedMu, Bool_t printDebug)
std::vector< LorentzVector > & vtxs_position()
static const Double_t GetMuonEffectiveArea(MuonEffectiveAreaType type, Double_t SCEta, MuonEffectiveAreaTarget EffectiveAreaTarget=kMuEAData2011)
Float_t fMVAVar_ChargedIso_DR0p4To0p5
std::vector< LorentzVector > & els_p4()
std::vector< float > & els_etaSC()
double dzPVmu(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
Float_t fMVAVar_NeutralHadronIso_DR0p3To0p4
Float_t fMVAVar_NeutralHadronIso_DR0p2To0p3
Float_t fMVAVar_MuDeltaRSum
Float_t fMVAVar_MuHadS9Energy
void initialize(std::string methodName, std::string weightsfile, MuonMVAEstimator::MVAType type)
std::vector< float > & mus_sta_d0()
Float_t fMVAVar_MuDeltaRMean
Float_t fMVAVar_MuTypeBits
Float_t fMVAVar_MuDensity
std::pair< double, double > trks_dz_pv(HWW &, int itrk, int ipv)
Float_t fMVAVar_GammaIso_DR0p0To0p1
Float_t fMVAVar_MuNMatches
Float_t fMVAVar_MuRelIsoPFCharged
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Float_t fMVAVar_NeutralHadronIso_DR0p0To0p1
Float_t fMVAVar_NeutralHadronIso_DR0p4To0p5
Float_t fMVAVar_MuGlobalNchi2
Float_t fMVAVar_MuRelIsoPFNeutral
Float_t fMVAVar_MuHadEnergy
Float_t fMVAVar_GammaIso_DR0p2To0p3
int translatePdgIdToType(int pdgid)
std::vector< LorentzVector > & mus_vertex_p4()
Float_t fMVAVar_MuRelIsoPFPhotons
std::vector< LorentzVector > & mus_sta_p4()
Float_t fMVAVar_MuTkNchi2
Power< A, B >::type pow(const A &a, const B &b)
Float_t fMVAVar_MuEmS9Energy
Float_t fMVAVar_MuNTrackerHits
std::vector< int > & els_trkidx()
std::vector< int > & mus_type()