CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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., sumTkPt = 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  sumTkPt += tkpt;
303  bool inVtx0 =
304  find(vtx->tracks_begin(), vtx->tracks_end(), reco::TrackBaseRef(icand->trackRef())) != vtx->tracks_end();
305  bool inAnyOther = false;
306 
307  double dZ0 = fabs(icand->trackRef()->dz(vtx->position()));
308  double dZ = dZ0;
309  for (reco::VertexCollection::const_iterator vi = allvtx.begin(); vi != allvtx.end(); ++vi) {
310  const reco::Vertex &iv = *vi;
311  if (iv.isFake() || iv.ndof() < 4) {
312  continue;
313  }
314 
315  bool isVtx0 = (iv.position() - vtx->position()).r() < 0.02;
316 
317  if (!isVtx0 && !inAnyOther) {
318  inAnyOther =
319  find(iv.tracks_begin(), iv.tracks_end(), reco::TrackBaseRef(icand->trackRef())) != iv.tracks_end();
320  }
321 
322  dZ = std::min(dZ, fabs(icand->trackRef()->dz(iv.position())));
323  }
324  if (inVtx0 && !inAnyOther) {
325  internalId_.betaClassic_ += tkpt;
326  } else if (!inVtx0 && inAnyOther) {
327  internalId_.betaStarClassic_ += tkpt;
328  }
329 
330  if (dZ0 < 0.2) {
331  internalId_.beta_ += tkpt;
332  } else if (dZ < 0.2) {
333  internalId_.betaStar_ += tkpt;
334  }
335  }
336 
337  if (lTrail.isNull() || candPt < lTrail->pt()) {
338  lTrail = icand;
339  }
340  }
341 
342  assert(lLead.isNonnull());
343  if (lSecond.isNull()) {
344  lSecond = lTrail;
345  }
346  if (lLeadNeut.isNull()) {
347  lLeadNeut = lTrail;
348  }
349  if (lLeadEm.isNull()) {
350  lLeadEm = lTrail;
351  }
352  if (lLeadCh.isNull()) {
353  lLeadCh = lTrail;
354  }
355  impactTrack = lLeadCh->trackRef();
356 
357  internalId_.nCharged_ = pfjet->chargedMultiplicity();
358  internalId_.nNeutrals_ = pfjet->neutralMultiplicity();
359  internalId_.chgEMfrac_ = pfjet->chargedEmEnergy() / jet->energy();
360  internalId_.neuEMfrac_ = pfjet->neutralEmEnergy() / jet->energy();
363 
364  if (impactTrack.isNonnull() && impactTrack.isAvailable()) {
365  internalId_.d0_ = fabs(impactTrack->dxy(vtx->position()));
366  internalId_.dZ_ = fabs(impactTrack->dz(vtx->position()));
367  } else {
368  internalId_.nParticles_ = constituents.size();
374  std::sort(frac.begin(), frac.end(), std::greater<float>());
375  std::sort(fracCh.begin(), fracCh.end(), std::greater<float>());
376  std::sort(fracEm.begin(), fracEm.end(), std::greater<float>());
377  std::sort(fracNeut.begin(), fracNeut.end(), std::greater<float>());
379 
380  //covMatrix(0,0) /= sumPt2;
381  //covMatrix(0,1) /= sumPt2;
382  //covMatrix(1,1) /= sumPt2;
383  //covMatrix(1,0) = covMatrix(0,1);
384  //internalId_.etaW_ = sqrt(covMatrix(0,0));
385  //internalId_.phiW_ = sqrt(covMatrix(1,1));
386  //internalId_.jetW_ = 0.5*(internalId_.etaW_+internalId_.phiW_);
387  //TVectorD eigVals(2); eigVals = TMatrixDSymEigen(covMatrix).GetEigenValues();
388  //
389  if (internalId_.majW_ < internalId_.minW_) {
390  std::swap(internalId_.majW_, internalId_.minW_);
391  }
392 
393  //internalId_.dRLeadCent_ = reco::deltaR(*jet,*lLead);
394  if (lSecond.isNonnull()) {
395  internalId_.dRLead2nd_ = reco::deltaR(*jet, *lSecond);
396  }
399  //internalId_.jetRchg_ /= jetPt;
400  internalId_.dR2Mean_ /= sumPt2;
401  for (size_t ic = 0; ic < ncones; ++ic) {
402  *coneFracs[ic] /= jetPt;
403  }
404 
405  double ptMean = sumPt / internalId_.nParticles_;
406  double ptRMS = 0;
407  for (unsigned int i0 = 0; i0 < frac.size(); i0++) {
408  ptRMS += (frac[i0] - ptMean) * (frac[i0] - ptMean);
409  }
410  ptRMS /= internalId_.nParticles_;
411  ptRMS = sqrt(ptRMS);
412  internalId_.jetRchg_ = internalId_.leadChPt_ / sumPt;
413  internalId_.jetR_ = internalId_.leadPt_ / sumPt;
414 
415  internalId_.ptMean_ = ptMean;
416  internalId_.ptRMS_ = ptRMS / jetPt;
417  internalId_.pt2A_ = sqrt(internalId_.ptD_ / internalId_.nParticles_) / jetPt;
418  internalId_.ptD_ = sqrt(internalId_.ptD_) / sumPt;
419  internalId_.sumPt_ = sumPt;
420  internalId_.sumChPt_ = sumPtCh;
421  internalId_.sumNePt_ = sumPtNe;
422  if (sumPt > 0) {
423  internalId_.beta_ /= sumPt;
424  internalId_.betaStar_ /= sumPt;
425  } else {
426  assert(internalId_.beta_ == 0. && internalId_.betaStar_ == 0.);
427  }
428  float ave_deta = sum_deta / sumPt2;
429  float ave_dphi = sum_dphi / sumPt2;
430  float ave_deta2 = sum_deta2 / sumPt2;
431  float ave_dphi2 = sum_dphi2 / sumPt2;
432  float a = ave_deta2 - ave_deta * ave_deta;
433  float b = ave_dphi2 - ave_dphi * ave_dphi;
434  float c = -(sum_detadphi / sumPt2 - ave_deta * ave_dphi);
435  float axis1 = 0;
436  float axis2 = 0;
437  if ((((a - b) * (a - b) + 4 * c * c)) > 0) {
438  float delta = sqrt(((a - b) * (a - b) + 4 * c * c));
439  if (a + b + delta > 0) {
440  axis1 = sqrt(0.5 * (a + b + delta));
441  }
442  if (a + b - delta > 0) {
443  axis2 = sqrt(0.5 * (a + b - delta));
444  }
445  } else {
446  axis1 = -1;
447  axis2 = -1;
448  }
449  internalId_.majW_ = axis1; //sqrt(fabs(eigVals(0)));
450  internalId_.minW_ = axis2; //sqrt(fabs(eigVals(1)));
451  //compute Pull
452 
453  float ddetaR_sum(0.0), ddphiR_sum(0.0);
454  for (int i = 0; i < internalId_.nParticles_; ++i) {
456  float weight = part->pt() * part->pt();
457  float deta = part->eta() - jet->eta();
458  float dphi = reco::deltaPhi(*part, *jet);
459  float ddeta, ddphi, ddR;
460  ddeta = deta - ave_deta;
461  ddphi = reco::deltaPhi(dphi, ave_dphi); //2*atan(tan((dphi - ave_dphi)/2.)) ;
462  ddR = sqrt(ddeta * ddeta + ddphi * ddphi);
463  ddetaR_sum += ddR * ddeta * weight;
464  ddphiR_sum += ddR * ddphi * weight;
465  }
466  if (sumPt2 > 0) {
467  float ddetaR_ave = ddetaR_sum / sumPt2;
468  float ddphiR_ave = ddphiR_sum / sumPt2;
469  internalId_.dRMean_ = sqrt(ddetaR_ave * ddetaR_ave + ddphiR_ave * ddphiR_ave);
470  }
471  }
472 
473  if (calculateMva) {
474  runMva();
475  }
476 
478 }
479 
481  std::stringstream out;
482  for (variables_list_t::const_iterator it = variables_.begin(); it != variables_.end(); ++it) {
483  out << std::setw(15) << it->first << std::setw(3) << "=" << std::setw(5) << *it->second.first << " ("
484  << std::setw(5) << it->second.second << ")" << std::endl;
485  }
486  return out.str();
487 }
488 
490  internalId_.idFlag_ = 0;
491  for (variables_list_t::iterator it = variables_.begin(); it != variables_.end(); ++it) {
492  *it->second.first = it->second.second;
493  }
494 }
495 
496 #define INIT_VARIABLE(NAME, TMVANAME, VAL) \
497  internalId_.NAME##_ = VAL; \
498  variables_[#NAME] = std::make_pair(&internalId_.NAME##_, VAL);
499 
501  internalId_.idFlag_ = 0;
502  INIT_VARIABLE(mva, "", -100.);
503 
504  INIT_VARIABLE(jetPt, "jetPt", 0.);
505  INIT_VARIABLE(jetEta, "jetEta", large_val);
507  INIT_VARIABLE(jetM, "", 0.);
508  INIT_VARIABLE(nCharged, "nCharged", 0.);
509  INIT_VARIABLE(nNeutrals, "", 0.);
510 
511  INIT_VARIABLE(chgEMfrac, "", 0.);
512  INIT_VARIABLE(neuEMfrac, "", 0.);
513  INIT_VARIABLE(chgHadrfrac, "", 0.);
514  INIT_VARIABLE(neuHadrfrac, "", 0.);
515 
516  INIT_VARIABLE(d0, "", -1000.);
517  INIT_VARIABLE(dZ, "", -1000.);
518  INIT_VARIABLE(nParticles, "nParticles", 0.);
519 
520  INIT_VARIABLE(leadPt, "", 0.);
521  INIT_VARIABLE(leadEta, "", large_val);
522  INIT_VARIABLE(leadPhi, "", large_val);
523  INIT_VARIABLE(secondPt, "", 0.);
524  INIT_VARIABLE(secondEta, "", large_val);
525  INIT_VARIABLE(secondPhi, "", large_val);
526  INIT_VARIABLE(leadNeutPt, "", 0.);
527  INIT_VARIABLE(leadNeutEta, "", large_val);
528 
529  INIT_VARIABLE(jetR, "jetR", 0.);
530  INIT_VARIABLE(pull, "pull", 0.);
531  INIT_VARIABLE(jetRchg, "jetRchg", 0.);
532  INIT_VARIABLE(dR2Mean, "dR2Mean", 0.);
533 
534  INIT_VARIABLE(ptD, "ptD", 0.);
535  INIT_VARIABLE(ptMean, "", 0.);
536  INIT_VARIABLE(ptRMS, "", 0.);
537  INIT_VARIABLE(pt2A, "", 0.);
538  INIT_VARIABLE(ptDCh, "", 0.);
539  INIT_VARIABLE(ptDNe, "", 0.);
540  INIT_VARIABLE(sumPt, "", 0.);
541  INIT_VARIABLE(sumChPt, "", 0.);
542  INIT_VARIABLE(sumNePt, "", 0.);
543  INIT_VARIABLE(secondFrac, "", 0.);
544  INIT_VARIABLE(thirdFrac, "", 0.);
545  INIT_VARIABLE(fourthFrac, "", 0.);
546  INIT_VARIABLE(leadChFrac, "", 0.);
547  INIT_VARIABLE(secondChFrac, "", 0.);
548  INIT_VARIABLE(thirdChFrac, "", 0.);
549  INIT_VARIABLE(fourthChFrac, "", 0.);
550  INIT_VARIABLE(leadNeutFrac, "", 0.);
551  INIT_VARIABLE(secondNeutFrac, "", 0.);
552  INIT_VARIABLE(thirdNeutFrac, "", 0.);
553  INIT_VARIABLE(fourthNeutFrac, "", 0.);
554  INIT_VARIABLE(leadEmFrac, "", 0.);
555  INIT_VARIABLE(secondEmFrac, "", 0.);
556  INIT_VARIABLE(thirdEmFrac, "", 0.);
557  INIT_VARIABLE(fourthEmFrac, "", 0.);
558  INIT_VARIABLE(jetW, "", 1.);
559  INIT_VARIABLE(etaW, "", 1.);
560  INIT_VARIABLE(phiW, "", 1.);
561  INIT_VARIABLE(majW, "majW", 1.);
562  INIT_VARIABLE(minW, "minW", 1.);
563  INIT_VARIABLE(frac01, "frac01", 0.);
564  INIT_VARIABLE(frac02, "frac02", 0.);
565  INIT_VARIABLE(frac03, "frac03", 0.);
566  INIT_VARIABLE(frac04, "frac04", 0.);
567 
568  INIT_VARIABLE(beta, "beta", 0.);
569  INIT_VARIABLE(betaStar, "betaStar", 0.);
570  INIT_VARIABLE(betaClassic, "betaClassic", 0.);
571  INIT_VARIABLE(betaStarClassic, "betaStarClassic", 0.);
572  INIT_VARIABLE(rho, "rho", 0.);
573 }
574 #undef INIT_VARIABLE
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
bool isAvailable() const
Definition: Ref.h:537
const edm::EventSetup & c
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:66
int32_t *__restrict__ iv
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
double pt() const final
transverse momentum
uint16_t *__restrict__ id
Float_t mvacut_[NWPs][NEtas][NPts]
Definition: MVAJetPuId.h:73
#define INIT_VARIABLE(NAME, TMVANAME, VAL)
Definition: MVAJetPuId.cc:496
virtual double pt() const =0
transverse momentum
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
bool isAvailable() const
Definition: Ptr.h:230
void bookReader()
Definition: MVAJetPuId.cc:125
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
variables_list_t variables_
Definition: MVAJetPuId.h:62
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)
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
const Point & position() const
position
Definition: Vertex.h:127
Jets made from PFObjects.
Definition: PFJet.h:20
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
void runMva()
Definition: MVAJetPuId.cc:145
virtual reco::PFCandidatePtr getPFConstituent(unsigned fIndex) const
get specific constituent
Definition: PFJet.cc:27
tuple d
Definition: ztail.py:151
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
Definition: TrackFwd.h:35
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
bool isNull() const
Checks for null.
Definition: Ptr.h:142
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho, bool calculateMva=false)
Definition: MVAJetPuId.cc:196
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.h:110
void initVariables()
Definition: MVAJetPuId.cc:500
void SetPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi)
Definition: MVAJetPuId.cc:119
T min(T a, T b)
Definition: MathUtil.h:58
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.h:108
double ndof() const
Definition: Vertex.h:123
int neutralMultiplicity() const
neutralMultiplicity
Definition: PFJet.h:154
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
static constexpr float d0
bool isFake() const
Definition: Vertex.h:76
TMVA::Reader * reader_
Definition: MVAJetPuId.h:64
part
Definition: HCALResponse.h:20
const float large_val
Definition: MVAJetPuId.cc:14
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double b
Definition: hdecay.h:118
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:489
double mass() const final
mass
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
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:119
PileupJetIdentifier computeMva()
Definition: MVAJetPuId.cc:191
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
std::string fullPath() const
Definition: FileInPath.cc:161
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
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
int weight
Definition: histoStyle.py:51
void setup()
Definition: MVAJetPuId.cc:66
int computeIDflag(float mva, float jetPt, float jetEta)
Definition: MVAJetPuId.cc:175
std::string dumpVariables() const
Definition: MVAJetPuId.cc:480
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
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
virtual double phi() const =0
momentum azimuthal angle
virtual double eta() const =0
momentum pseudorapidity
std::string tmvaMethod_
Definition: MVAJetPuId.h:65
double energy() const final
energy
double eta() const final
momentum pseudorapidity