test
CMS 3D CMS Logo

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