13 #include "TMVA/Reader.h" 14 #include "TMVA/MethodBDT.h" 25 TMVA::Reader tmvaReader(
"!Color:!Silent:Error");
26 tmvaReader.AddVariable(
"LepGood_pt", &
pt_ );
27 tmvaReader.AddVariable(
"LepGood_eta", &
eta_ );
28 tmvaReader.AddVariable(
"LepGood_jetNDauChargedMVASel", &
jetNDauCharged_ );
31 tmvaReader.AddVariable(
"LepGood_jetPtRelv2", &
jetPtRel_ );
32 tmvaReader.AddVariable(
"max(LepGood_jetBTagCSV,0)", &
jetBTagCSV_ );
33 tmvaReader.AddVariable(
"(LepGood_jetBTagCSV>-5)*min(LepGood_jetPtRatiov2,1.5)+(LepGood_jetBTagCSV<-5)/(1+LepGood_relIso04)", &
jetPtRatio_ );
34 tmvaReader.AddVariable(
"LepGood_sip3d", &
sip_ );
36 tmvaReader.AddVariable(
"log(abs(LepGood_dz))", &
log_abs_dzPV_ );
39 auto temp{ tmvaReader.BookMVA(muon_mva_name, weightsfile.c_str()) };
40 gbrForest_ = std::make_unique<GBRForest>(
dynamic_cast<TMVA::MethodBDT*
>(
temp ) );
59 kSegmentCompatibility,
64 bool subtractMuon=
true)
67 if (subtractMuon) jp4-=muP4;
68 float dot = muP4.Vect().Dot( jp4.Vect() );
69 float ptrel = muP4.P2() - dot*dot/jp4.P2();
70 ptrel = ptrel>0 ?
sqrt(ptrel) : 0.0;
95 var[kSip] = edB3D>0?fabs(dB3D/edB3D):0.0;
96 var[kLog_abs_dxyBS] = dB2D>0?
log(dB2D):0;
97 var[kLog_abs_dzPV] = dz>0?
log(dz):0;
101 double jecL1L2L3Res = 1.;
109 double dbCorrectedIsolation = chIso +
std::max( nIso + phoIso - .5*puIso, 0. ) ;
110 double dbCorrectedRelIso = dbCorrectedIsolation/muon.
pt();
112 var[kJetPtRatio] = 1./(1+dbCorrectedRelIso);
114 var[kJetBTagCSV] = -999;
115 var[kJetNDauCharged] = -1;
118 for (
const auto& tagI: bTags){
120 double dr =
deltaR(*(tagI.first), muon);
121 if(dr > minDr)
continue;
127 if (correctorL1 && correctorL1L2L3Res){
128 jecL1L2L3Res = correctorL1L2L3Res->
correction(*(tagI.first));
129 jecL1 = correctorL1->
correction(*(tagI.first));
133 var[kJetBTagCSV] = tagI.second;
134 var[kJetNDauCharged] = 0;
135 for (
auto jet: tagI.first->getJetConstituentsQuick()){
137 if (pfcand==
nullptr)
throw cms::Exception(
"ConfigurationError") <<
"Cannot get jet constituents";
138 if (pfcand->
charge()==0)
continue;
140 if (!bestTrackPtr)
continue;
142 if (bestTrackPtr->pt()<1.)
continue;
143 if (bestTrackPtr->hitPattern().numberOfValidHits()<8)
continue;
144 if (bestTrackPtr->hitPattern().numberOfValidPixelHits()<2)
continue;
145 if (bestTrackPtr->normalizedChi2()>=5)
continue;
147 if (std::fabs(bestTrackPtr->dxy(vertex.
position())) > 0.2)
continue;
148 if (std::fabs(bestTrackPtr->dz(vertex.
position())) > 17)
continue;
149 var[kJetNDauCharged]++;
153 if ((jetP4-muP4).Rho()<0.0001){
155 var[kJetPtRatio] = 1;
158 jetP4 *= jecL1L2L3Res;
161 var[kJetPtRatio] = muP4.pt()/jetP4.pt();
167 if (
var[kJetPtRatio] > 1.5)
var[kJetPtRatio] = 1.5;
168 if (
var[kJetBTagCSV] < 0)
var[kJetBTagCSV] = 0;
169 jetPtRatio =
var[kJetPtRatio];
170 jetPtRel =
var[kJetPtRel];
double eta() const final
momentum pseudorapidity
example_track example_track const char *const kPt
double dB(IPTYPE type) const
double pt() const final
transverse momentum
int charge() const final
electric charge
double correction(const LorentzVector &fJet) const
get correction using Jet information only
float sumPhotonEt
sum pt of PF photons
const Point & position() const
position
float segmentCompatibility_
float sumNeutralHadronEt
sum pt of neutral hadrons
const PFIsolation & miniPFIsolation() const
double segmentCompatibility(reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration) const
Returns the segment compatibility, using muon::segmentCompatibility (DataFormats/MuonReco/interface/M...
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
const LorentzVector & p4() const final
four-momentum Lorentz vector
double edB(IPTYPE type) const
float computeMva(const pat::Muon &imuon, const reco::Vertex &vertex, const reco::JetTagCollection &bTags, float &jetPtRatio, float &jetPtRel, const reco::JetCorrector *correctorL1=0, const reco::JetCorrector *correctorL1L2L3Res=0) const
double deltaR(double eta1, double eta2, double phi1, double phi2)
const MuonPFIsolation & pfIsolationR04() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Particle reconstructed by the particle flow algorithm.
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
std::unique_ptr< const GBRForest > gbrForest_
reco::TrackRef muonBestTrack() const override
Track selected to be the best measurement of the muon parameters (including PFlow global information)...
MuonMvaEstimator(const std::string &weightsfile, float dRmax)
float chargedHadronIso() const
Analysis-level muon class.
const reco::Track * bestTrack() const override
float neutralHadronIso() const
float sumChargedHadronPt
sum-pt of charged Hadron