CMS 3D CMS Logo

MVAJetPuId.cc
Go to the documentation of this file.
10 #include "TMatrixDSym.h"
11 #include "TMatrixDSymEigen.h"
13 
15 
18 
20  tmvaMethod_ = ps.getParameter<std::string>("tmvaMethod");
21  tmvaVariables_ = ps.getParameter<std::vector<std::string> >("tmvaVariables");
22  tmvaSpectators_ = ps.getParameter<std::vector<std::string> >("tmvaSpectators");
23  version_ = ps.getParameter<int>("version");
24  reader_ = nullptr;
25  edm::ParameterSet jetConfig = ps.getParameter<edm::ParameterSet>("JetIdParams");
26  for (int i0 = 0; i0 < NWPs; i0++) {
27  std::string lCutType = "Tight";
29  lCutType = "Medium";
31  lCutType = "Loose";
32  for (int i1 = 0; i1 < 1; i1++) {
33  std::vector<double> pt010 = jetConfig.getParameter<std::vector<double> >(("Pt010_" + lCutType).c_str());
34  std::vector<double> pt1020 = jetConfig.getParameter<std::vector<double> >(("Pt1020_" + lCutType).c_str());
35  std::vector<double> pt2030 = jetConfig.getParameter<std::vector<double> >(("Pt2030_" + lCutType).c_str());
36  std::vector<double> pt3050 = jetConfig.getParameter<std::vector<double> >(("Pt3050_" + lCutType).c_str());
37  for (int i2 = 0; i2 < NPts; i2++)
38  mvacut_[i0][0][i2] = pt010[i2];
39  for (int i2 = 0; i2 < NPts; i2++)
40  mvacut_[i0][1][i2] = pt1020[i2];
41  for (int i2 = 0; i2 < NPts; i2++)
42  mvacut_[i0][2][i2] = pt2030[i2];
43  for (int i2 = 0; i2 < NPts; i2++)
44  mvacut_[i0][3][i2] = pt3050[i2];
45  }
46  }
47  setup();
48 }
49 
51  const std::string &tmvaWeights,
52  const std::string &tmvaMethod,
53  Float_t impactParTkThreshod,
54  const std::vector<std::string> &tmvaVariables) {
55  impactParTkThreshod_ = impactParTkThreshod;
59  version_ = version;
60 
61  reader_ = nullptr;
62 
63  setup();
64 }
65 
67  initVariables();
68 
69  tmvaVariables_.clear();
70  tmvaVariables_.push_back("rho");
71  tmvaVariables_.push_back("nParticles");
72  tmvaVariables_.push_back("nCharged");
73  tmvaVariables_.push_back("majW");
74  tmvaVariables_.push_back("minW");
75  tmvaVariables_.push_back("frac01");
76  tmvaVariables_.push_back("frac02");
77  tmvaVariables_.push_back("frac03");
78  tmvaVariables_.push_back("frac04");
79  tmvaVariables_.push_back("ptD");
80  tmvaVariables_.push_back("beta");
81  tmvaVariables_.push_back("betaStar");
82  tmvaVariables_.push_back("dR2Mean");
83  tmvaVariables_.push_back("pull");
84  tmvaVariables_.push_back("jetR");
85  tmvaVariables_.push_back("jetRchg");
86 
87  tmvaNames_["rho"] = "rho";
88  tmvaNames_["nParticles"] = "nParticles";
89  tmvaNames_["nCharged"] = "nCharged";
90  tmvaNames_["majW"] = "majW";
91  tmvaNames_["minW"] = "minW";
92  tmvaNames_["frac01"] = "frac01";
93  tmvaNames_["frac02"] = "frac02";
94  tmvaNames_["frac03"] = "frac03";
95  tmvaNames_["frac04"] = "frac04";
96  tmvaNames_["ptD"] = "ptD";
97  tmvaNames_["beta"] = "beta";
98  tmvaNames_["betaStar"] = "betaStar";
99  tmvaNames_["dR2Mean"] = "dR2Mean";
100  tmvaNames_["pull"] = "pull";
101  tmvaNames_["jetR"] = "jetR";
102  tmvaNames_["jetRchg"] = "jetRchg";
103 }
104 
106  if (reader_) {
107  delete reader_;
108  }
109 }
110 
111 void Assign(const std::vector<float> &vec, float &a, float &b, float &c, float &d) {
112  size_t sz = vec.size();
113  a = (sz > 0 ? vec[0] : 0.);
114  b = (sz > 1 ? vec[1] : 0.);
115  c = (sz > 2 ? vec[2] : 0.);
116  d = (sz > 3 ? vec[3] : 0.);
117 }
118 
119 void SetPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi) {
120  pt = p.pt();
121  eta = p.eta();
122  phi = p.phi();
123 }
124 
126  reader_ = new TMVA::Reader("!Color:Silent");
127  assert(!tmvaMethod_.empty() && !tmvaWeights_.empty());
128  for (std::vector<std::string>::iterator it = tmvaVariables_.begin(); it != tmvaVariables_.end(); ++it) {
129  if (tmvaNames_[*it].empty()) {
130  tmvaNames_[*it] = *it;
131  }
132  reader_->AddVariable(*it, variables_[tmvaNames_[*it]].first);
133  }
134  for (std::vector<std::string>::iterator it = tmvaSpectators_.begin(); it != tmvaSpectators_.end(); ++it) {
135  if (tmvaNames_[*it].empty()) {
136  tmvaNames_[*it] = *it;
137  }
138  reader_->AddSpectator(*it, variables_[tmvaNames_[*it]].first);
139  }
141 }
142 
144 
146  if (!reader_) {
147  bookReader();
148  }
149  if (fabs(internalId_.jetEta_) < 5.0)
150  internalId_.mva_ = reader_->EvaluateMVA(tmvaMethod_.c_str());
151  if (fabs(internalId_.jetEta_) >= 5.0)
152  internalId_.mva_ = -2.;
154 }
155 
156 std::pair<int, int> MVAJetPuId::getJetIdKey(float jetPt, float jetEta) {
157  int ptId = 0;
158  if (jetPt > 10 && jetPt < 20)
159  ptId = 1;
160  if (jetPt >= 20 && jetPt < 30)
161  ptId = 2;
162  if (jetPt >= 30)
163  ptId = 3;
164 
165  int etaId = 0;
166  if (fabs(jetEta) > 2.5 && fabs(jetEta) < 2.75)
167  etaId = 1;
168  if (fabs(jetEta) >= 2.75 && fabs(jetEta) < 3.0)
169  etaId = 2;
170  if (fabs(jetEta) >= 3.0 && fabs(jetEta) < 5.0)
171  etaId = 3;
172  return std::pair<int, int>(ptId, etaId);
173 }
174 
175 int MVAJetPuId::computeIDflag(float mva, float jetPt, float jetEta) {
176  std::pair<int, int> jetIdKey = getJetIdKey(jetPt, jetEta);
177  return computeIDflag(mva, jetIdKey.first, jetIdKey.second);
178 }
179 
180 int MVAJetPuId::computeIDflag(float mva, int ptId, int etaId) {
181  int idFlag(0);
182  if (mva > mvacut_[PileupJetIdentifier::kTight][ptId][etaId])
183  idFlag += 1 << PileupJetIdentifier::kTight;
184  if (mva > mvacut_[PileupJetIdentifier::kMedium][ptId][etaId])
185  idFlag += 1 << PileupJetIdentifier::kMedium;
186  if (mva > mvacut_[PileupJetIdentifier::kLoose][ptId][etaId])
187  idFlag += 1 << PileupJetIdentifier::kLoose;
188  return idFlag;
189 }
190 
192  runMva();
194 }
195 
197  float jec,
198  const reco::Vertex *vtx,
199  const reco::VertexCollection &allvtx,
200  double rho,
201  bool calculateMva) {
202  typedef std::vector<reco::PFCandidatePtr> constituents_type;
203  typedef std::vector<reco::PFCandidatePtr>::iterator constituents_iterator;
204 
205  resetVariables();
206 
207  const reco::PFJet *pfjet = dynamic_cast<const reco::PFJet *>(jet);
208 
209  if (jec < 0.) {
210  jec = 1.;
211  }
212 
213  constituents_type constituents = pfjet->getPFConstituents();
214 
215  reco::PFCandidatePtr lLead, lSecond, lLeadNeut, lLeadEm, lLeadCh, lTrail;
216  std::vector<float> frac, fracCh, fracEm, fracNeut;
217  constexpr int ncones = 4;
218  std::array<float, ncones> cones{{0.1, 0.2, 0.3, 0.4}};
219  std::array<float *, ncones> coneFracs{
220  {&internalId_.frac01_, &internalId_.frac02_, &internalId_.frac03_, &internalId_.frac04_}};
221  TMatrixDSym covMatrix(2);
222  covMatrix = 0.;
223 
224  reco::TrackRef impactTrack;
225  float jetPt = jet->pt() / jec; // use uncorrected pt for shape variables
226  float sumPt = 0., sumPt2 = 0., sumPtCh = 0, sumPtNe = 0;
227  float sum_deta = 0;
228  float sum_dphi = 0;
229  float sum_deta2 = 0;
230  float sum_detadphi = 0;
231  float sum_dphi2 = 0;
232  SetPtEtaPhi(
233  *jet, internalId_.jetPt_, internalId_.jetEta_, internalId_.jetPhi_); // use corrected pt for jet kinematics
234  internalId_.jetM_ = jet->mass();
235  internalId_.rho_ = rho; //allvtx.size();
236  for (constituents_iterator it = constituents.begin(); it != constituents.end(); ++it) {
237  reco::PFCandidatePtr &icand = *it;
238  float candPt = icand->pt();
239  float candPtFrac = candPt / jetPt;
240  float candDr = reco::deltaR(**it, *jet);
241  float candDeta = fabs((*it)->eta() - jet->eta());
242  float candDphi = reco::deltaPhi(**it, *jet);
243  float candPtDr = candPt * candDr;
244  size_t icone = std::lower_bound(&cones[0], &cones[ncones], candDr) - &cones[0];
245  float weight2 = candPt * candPt;
246 
247  if (lLead.isNull() || candPt > lLead->pt()) {
248  lSecond = lLead;
249  lLead = icand;
250  } else if ((lSecond.isNull() || candPt > lSecond->pt()) && (candPt < lLead->pt())) {
251  lSecond = icand;
252  }
253 
254  //internalId_.dRMean_ += candPtDr;
255  internalId_.dR2Mean_ += candPtDr * candPtDr;
256 
257  internalId_.ptD_ += candPt * candPt;
258  sumPt += candPt;
259  sumPt2 += candPt * candPt;
260  sum_deta += candDeta * weight2;
261  sum_dphi += candDphi * weight2;
262  sum_deta2 += candDeta * candDeta * weight2;
263  sum_detadphi += candDeta * candDphi * weight2;
264  sum_dphi2 += candDphi * candDphi * weight2;
265  //Teta += candPt * candDR * candDeta;
266  //Tphi += candPt * candDR * candDphi;
267 
268  frac.push_back(candPtFrac);
269  if (icone < ncones) {
270  *coneFracs[icone] += candPt;
271  }
272 
273  if (icand->particleId() == reco::PFCandidate::h0) {
274  if (lLeadNeut.isNull() || candPt > lLeadNeut->pt()) {
275  lLeadNeut = icand;
276  }
277  internalId_.dRMeanNeut_ += candPtDr;
278  fracNeut.push_back(candPtFrac);
279  sumPtNe += candPt;
280  }
281 
282  if (icand->particleId() == reco::PFCandidate::gamma) {
283  if (lLeadEm.isNull() || candPt > lLeadEm->pt()) {
284  lLeadEm = icand;
285  }
286  internalId_.dRMeanEm_ += candPtDr;
287  fracEm.push_back(candPtFrac);
288  sumPtNe += candPt;
289  }
290 
291  if (icand->trackRef().isNonnull() && icand->trackRef().isAvailable()) {
292  if (lLeadCh.isNull() || candPt > lLeadCh->pt()) {
293  lLeadCh = icand;
294  }
295  //internalId_.jetRchg_ += candPtDr;
296  fracCh.push_back(candPtFrac);
297  sumPtCh += candPt;
298  }
299 
300  if (icand->trackRef().isNonnull() && icand->trackRef().isAvailable()) {
301  float tkpt = icand->trackRef()->pt();
302  bool inVtx0 =
303  find(vtx->tracks_begin(), vtx->tracks_end(), reco::TrackBaseRef(icand->trackRef())) != vtx->tracks_end();
304  bool inAnyOther = false;
305 
306  double dZ0 = fabs(icand->trackRef()->dz(vtx->position()));
307  double dZ = dZ0;
308  for (reco::VertexCollection::const_iterator vi = allvtx.begin(); vi != allvtx.end(); ++vi) {
309  const reco::Vertex &iv = *vi;
310  if (iv.isFake() || iv.ndof() < 4) {
311  continue;
312  }
313 
314  bool isVtx0 = (iv.position() - vtx->position()).r() < 0.02;
315 
316  if (!isVtx0 && !inAnyOther) {
317  inAnyOther =
318  find(iv.tracks_begin(), iv.tracks_end(), reco::TrackBaseRef(icand->trackRef())) != iv.tracks_end();
319  }
320 
321  dZ = std::min(dZ, fabs(icand->trackRef()->dz(iv.position())));
322  }
323  if (inVtx0 && !inAnyOther) {
324  internalId_.betaClassic_ += tkpt;
325  } else if (!inVtx0 && inAnyOther) {
326  internalId_.betaStarClassic_ += tkpt;
327  }
328 
329  if (dZ0 < 0.2) {
330  internalId_.beta_ += tkpt;
331  } else if (dZ < 0.2) {
332  internalId_.betaStar_ += tkpt;
333  }
334  }
335 
336  if (lTrail.isNull() || candPt < lTrail->pt()) {
337  lTrail = icand;
338  }
339  }
340 
341  assert(lLead.isNonnull());
342  if (lSecond.isNull()) {
343  lSecond = lTrail;
344  }
345  if (lLeadNeut.isNull()) {
346  lLeadNeut = lTrail;
347  }
348  if (lLeadEm.isNull()) {
349  lLeadEm = lTrail;
350  }
351  if (lLeadCh.isNull()) {
352  lLeadCh = lTrail;
353  }
354  impactTrack = lLeadCh->trackRef();
355 
356  internalId_.nCharged_ = pfjet->chargedMultiplicity();
357  internalId_.nNeutrals_ = pfjet->neutralMultiplicity();
358  internalId_.chgEMfrac_ = pfjet->chargedEmEnergy() / jet->energy();
359  internalId_.neuEMfrac_ = pfjet->neutralEmEnergy() / jet->energy();
360  internalId_.chgHadrfrac_ = pfjet->chargedHadronEnergy() / jet->energy();
361  internalId_.neuHadrfrac_ = pfjet->neutralHadronEnergy() / jet->energy();
362 
363  if (impactTrack.isNonnull() && impactTrack.isAvailable()) {
364  internalId_.d0_ = fabs(impactTrack->dxy(vtx->position()));
365  internalId_.dZ_ = fabs(impactTrack->dz(vtx->position()));
366  } else {
367  internalId_.nParticles_ = constituents.size();
373  std::sort(frac.begin(), frac.end(), std::greater<float>());
374  std::sort(fracCh.begin(), fracCh.end(), std::greater<float>());
375  std::sort(fracEm.begin(), fracEm.end(), std::greater<float>());
376  std::sort(fracNeut.begin(), fracNeut.end(), std::greater<float>());
378 
379  //covMatrix(0,0) /= sumPt2;
380  //covMatrix(0,1) /= sumPt2;
381  //covMatrix(1,1) /= sumPt2;
382  //covMatrix(1,0) = covMatrix(0,1);
383  //internalId_.etaW_ = sqrt(covMatrix(0,0));
384  //internalId_.phiW_ = sqrt(covMatrix(1,1));
385  //internalId_.jetW_ = 0.5*(internalId_.etaW_+internalId_.phiW_);
386  //TVectorD eigVals(2); eigVals = TMatrixDSymEigen(covMatrix).GetEigenValues();
387  //
388  if (internalId_.majW_ < internalId_.minW_) {
389  std::swap(internalId_.majW_, internalId_.minW_);
390  }
391 
392  //internalId_.dRLeadCent_ = reco::deltaR(*jet,*lLead);
393  if (lSecond.isNonnull()) {
394  internalId_.dRLead2nd_ = reco::deltaR(*jet, *lSecond);
395  }
398  //internalId_.jetRchg_ /= jetPt;
399  internalId_.dR2Mean_ /= sumPt2;
400  for (size_t ic = 0; ic < ncones; ++ic) {
401  *coneFracs[ic] /= jetPt;
402  }
403 
404  double ptMean = sumPt / internalId_.nParticles_;
405  double ptRMS = 0;
406  for (unsigned int i0 = 0; i0 < frac.size(); i0++) {
407  ptRMS += (frac[i0] - ptMean) * (frac[i0] - ptMean);
408  }
409  ptRMS /= internalId_.nParticles_;
410  ptRMS = sqrt(ptRMS);
411  internalId_.jetRchg_ = internalId_.leadChPt_ / sumPt;
413 
414  internalId_.ptMean_ = ptMean;
415  internalId_.ptRMS_ = ptRMS / jetPt;
416  internalId_.pt2A_ = sqrt(internalId_.ptD_ / internalId_.nParticles_) / jetPt;
417  internalId_.ptD_ = sqrt(internalId_.ptD_) / sumPt;
419  internalId_.sumChPt_ = sumPtCh;
420  internalId_.sumNePt_ = sumPtNe;
421  if (sumPt > 0) {
422  internalId_.beta_ /= sumPt;
423  internalId_.betaStar_ /= sumPt;
424  } else {
425  assert(internalId_.beta_ == 0. && internalId_.betaStar_ == 0.);
426  }
427  float ave_deta = sum_deta / sumPt2;
428  float ave_dphi = sum_dphi / sumPt2;
429  float ave_deta2 = sum_deta2 / sumPt2;
430  float ave_dphi2 = sum_dphi2 / sumPt2;
431  float a = ave_deta2 - ave_deta * ave_deta;
432  float b = ave_dphi2 - ave_dphi * ave_dphi;
433  float c = -(sum_detadphi / sumPt2 - ave_deta * ave_dphi);
434  float axis1 = 0;
435  float axis2 = 0;
436  if ((((a - b) * (a - b) + 4 * c * c)) > 0) {
437  float delta = sqrt(((a - b) * (a - b) + 4 * c * c));
438  if (a + b + delta > 0) {
439  axis1 = sqrt(0.5 * (a + b + delta));
440  }
441  if (a + b - delta > 0) {
442  axis2 = sqrt(0.5 * (a + b - delta));
443  }
444  } else {
445  axis1 = -1;
446  axis2 = -1;
447  }
448  internalId_.majW_ = axis1; //sqrt(fabs(eigVals(0)));
449  internalId_.minW_ = axis2; //sqrt(fabs(eigVals(1)));
450  //compute Pull
451 
452  float ddetaR_sum(0.0), ddphiR_sum(0.0);
453  for (int i = 0; i < internalId_.nParticles_; ++i) {
455  float weight = part->pt() * part->pt();
456  float deta = part->eta() - jet->eta();
457  float dphi = reco::deltaPhi(*part, *jet);
458  float ddeta, ddphi, ddR;
459  ddeta = deta - ave_deta;
460  ddphi = reco::deltaPhi(dphi, ave_dphi); //2*atan(tan((dphi - ave_dphi)/2.)) ;
461  ddR = sqrt(ddeta * ddeta + ddphi * ddphi);
462  ddetaR_sum += ddR * ddeta * weight;
463  ddphiR_sum += ddR * ddphi * weight;
464  }
465  if (sumPt2 > 0) {
466  float ddetaR_ave = ddetaR_sum / sumPt2;
467  float ddphiR_ave = ddphiR_sum / sumPt2;
468  internalId_.dRMean_ = sqrt(ddetaR_ave * ddetaR_ave + ddphiR_ave * ddphiR_ave);
469  }
470  }
471 
472  if (calculateMva) {
473  runMva();
474  }
475 
477 }
478 
480  std::stringstream out;
481  for (variables_list_t::const_iterator it = variables_.begin(); it != variables_.end(); ++it) {
482  out << std::setw(15) << it->first << std::setw(3) << "=" << std::setw(5) << *it->second.first << " ("
483  << std::setw(5) << it->second.second << ")" << std::endl;
484  }
485  return out.str();
486 }
487 
489  internalId_.idFlag_ = 0;
490  for (variables_list_t::iterator it = variables_.begin(); it != variables_.end(); ++it) {
491  *it->second.first = it->second.second;
492  }
493 }
494 
495 #define INIT_VARIABLE(NAME, TMVANAME, VAL) \
496  internalId_.NAME##_ = VAL; \
497  variables_[#NAME] = std::make_pair(&internalId_.NAME##_, VAL);
498 
500  internalId_.idFlag_ = 0;
501  INIT_VARIABLE(mva, "", -100.);
502 
503  INIT_VARIABLE(jetPt, "jetPt", 0.);
504  INIT_VARIABLE(jetEta, "jetEta", large_val);
506  INIT_VARIABLE(jetM, "", 0.);
507  INIT_VARIABLE(nCharged, "nCharged", 0.);
508  INIT_VARIABLE(nNeutrals, "", 0.);
509 
510  INIT_VARIABLE(chgEMfrac, "", 0.);
511  INIT_VARIABLE(neuEMfrac, "", 0.);
512  INIT_VARIABLE(chgHadrfrac, "", 0.);
513  INIT_VARIABLE(neuHadrfrac, "", 0.);
514 
515  INIT_VARIABLE(d0, "", -1000.);
516  INIT_VARIABLE(dZ, "", -1000.);
517  INIT_VARIABLE(nParticles, "nParticles", 0.);
518 
519  INIT_VARIABLE(leadPt, "", 0.);
520  INIT_VARIABLE(leadEta, "", large_val);
521  INIT_VARIABLE(leadPhi, "", large_val);
522  INIT_VARIABLE(secondPt, "", 0.);
523  INIT_VARIABLE(secondEta, "", large_val);
524  INIT_VARIABLE(secondPhi, "", large_val);
525  INIT_VARIABLE(leadNeutPt, "", 0.);
526  INIT_VARIABLE(leadNeutEta, "", large_val);
527 
528  INIT_VARIABLE(jetR, "jetR", 0.);
529  INIT_VARIABLE(pull, "pull", 0.);
530  INIT_VARIABLE(jetRchg, "jetRchg", 0.);
531  INIT_VARIABLE(dR2Mean, "dR2Mean", 0.);
532 
533  INIT_VARIABLE(ptD, "ptD", 0.);
534  INIT_VARIABLE(ptMean, "", 0.);
535  INIT_VARIABLE(ptRMS, "", 0.);
536  INIT_VARIABLE(pt2A, "", 0.);
537  INIT_VARIABLE(ptDCh, "", 0.);
538  INIT_VARIABLE(ptDNe, "", 0.);
539  INIT_VARIABLE(sumPt, "", 0.);
540  INIT_VARIABLE(sumChPt, "", 0.);
541  INIT_VARIABLE(sumNePt, "", 0.);
542  INIT_VARIABLE(secondFrac, "", 0.);
543  INIT_VARIABLE(thirdFrac, "", 0.);
544  INIT_VARIABLE(fourthFrac, "", 0.);
545  INIT_VARIABLE(leadChFrac, "", 0.);
546  INIT_VARIABLE(secondChFrac, "", 0.);
547  INIT_VARIABLE(thirdChFrac, "", 0.);
548  INIT_VARIABLE(fourthChFrac, "", 0.);
549  INIT_VARIABLE(leadNeutFrac, "", 0.);
550  INIT_VARIABLE(secondNeutFrac, "", 0.);
551  INIT_VARIABLE(thirdNeutFrac, "", 0.);
552  INIT_VARIABLE(fourthNeutFrac, "", 0.);
553  INIT_VARIABLE(leadEmFrac, "", 0.);
554  INIT_VARIABLE(secondEmFrac, "", 0.);
555  INIT_VARIABLE(thirdEmFrac, "", 0.);
556  INIT_VARIABLE(fourthEmFrac, "", 0.);
557  INIT_VARIABLE(jetW, "", 1.);
558  INIT_VARIABLE(etaW, "", 1.);
559  INIT_VARIABLE(phiW, "", 1.);
560  INIT_VARIABLE(majW, "majW", 1.);
561  INIT_VARIABLE(minW, "minW", 1.);
562  INIT_VARIABLE(frac01, "frac01", 0.);
563  INIT_VARIABLE(frac02, "frac02", 0.);
564  INIT_VARIABLE(frac03, "frac03", 0.);
565  INIT_VARIABLE(frac04, "frac04", 0.);
566 
567  INIT_VARIABLE(beta, "beta", 0.);
568  INIT_VARIABLE(betaStar, "betaStar", 0.);
569  INIT_VARIABLE(betaClassic, "betaClassic", 0.);
570  INIT_VARIABLE(betaStarClassic, "betaStarClassic", 0.);
571  INIT_VARIABLE(rho, "rho", 0.);
572 }
573 #undef INIT_VARIABLE
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:66
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
std::string fullPath() const
Definition: FileInPath.cc:161
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
Float_t mvacut_[NWPs][NEtas][NPts]
Definition: MVAJetPuId.h:73
#define INIT_VARIABLE(NAME, TMVANAME, VAL)
Definition: MVAJetPuId.cc:495
Base class for all types of Jets.
Definition: Jet.h:20
Int_t version_
Definition: MVAJetPuId.h:70
std::vector< std::string > tmvaSpectators_
Definition: MVAJetPuId.h:67
void bookReader()
Definition: MVAJetPuId.cc:125
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Definition: weight.py:1
variables_list_t variables_
Definition: MVAJetPuId.h:62
int neutralMultiplicity() const
neutralMultiplicity
Definition: PFJet.h:154
static constexpr int NPts
Definition: MVAJetPuId.h:18
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
assert(be >=bs)
Jets made from PFObjects.
Definition: PFJet.h:20
bool isAvailable() const
Definition: Ptr.h:234
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
void runMva()
Definition: MVAJetPuId.cc:145
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
bool isNull() const
Checks for null.
Definition: Ptr.h:144
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
T sqrt(T t)
Definition: SSEVec.h:23
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
virtual reco::PFCandidatePtr getPFConstituent(unsigned fIndex) const
get specific constituent
Definition: PFJet.cc:27
bool isAvailable() const
Definition: Ref.h:541
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho, bool calculateMva=false)
Definition: MVAJetPuId.cc:196
void initVariables()
Definition: MVAJetPuId.cc:499
void SetPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi)
Definition: MVAJetPuId.cc:119
d
Definition: ztail.py:151
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
static constexpr float d0
TMVA::Reader * reader_
Definition: MVAJetPuId.h:64
part
Definition: HCALResponse.h:20
const float large_val
Definition: MVAJetPuId.cc:14
double b
Definition: hdecay.h:120
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:61
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::string tmvaWeights_
Definition: MVAJetPuId.h:65
void set(const PileupJetIdentifier &)
Definition: MVAJetPuId.cc:143
void resetVariables()
Definition: MVAJetPuId.cc:488
std::string dumpVariables() const
Definition: MVAJetPuId.cc:479
std::map< std::string, std::string > tmvaNames_
Definition: MVAJetPuId.h:68
std::pair< int, int > getJetIdKey(float jetPt, float jetEta)
Definition: MVAJetPuId.cc:156
double a
Definition: hdecay.h:121
PileupJetIdentifier computeMva()
Definition: MVAJetPuId.cc:191
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
Float_t impactParTkThreshod_
Definition: MVAJetPuId.h:71
MVAJetPuId(int version=CATEv0, const std::string &tmvaWeight="", const std::string &tmvaMethod="", Float_t impactParTkThreshod_=1., const std::vector< std::string > &tmvaVariables=std::vector< std::string >())
Definition: MVAJetPuId.cc:50
void setup()
Definition: MVAJetPuId.cc:66
int computeIDflag(float mva, float jetPt, float jetEta)
Definition: MVAJetPuId.cc:175
void Assign(const std::vector< float > &vec, float &a, float &b, float &c, float &d)
Definition: MVAJetPuId.cc:111
static constexpr int NWPs
Definition: MVAJetPuId.h:17
std::string tmvaMethod_
Definition: MVAJetPuId.h:65