CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes
MVAJetPuId Class Reference

#include <MVAJetPuId.h>

Public Types

typedef std::map< std::string, std::pair< float *, float > > variables_list_t
 
enum  version_t { USER =-1, CATEv0 =0 }
 

Public Member Functions

int computeCutIDflag (float betaStarClassic, float dR2Mean, float nvtx, float jetPt, float jetEta)
 
int computeIDflag (float mva, float jetPt, float jetEta)
 
int computeIDflag (float mva, int ptId, int etaId)
 
PileupJetIdentifier computeIdVariables (const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, double rho, bool calculateMva=false)
 
PileupJetIdentifier computeMva ()
 
std::string dumpVariables () const
 
std::pair< int, int > getJetIdKey (float jetPt, float jetEta)
 
const variables_list_tgetVariables () const
 
const std::string method () const
 
 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 >())
 
 MVAJetPuId (const edm::ParameterSet &ps)
 
void set (const PileupJetIdentifier &)
 
 ~MVAJetPuId ()
 

Protected Member Functions

void bookReader ()
 
void initVariables ()
 
void resetVariables ()
 
void runMva ()
 
void setup ()
 

Protected Attributes

Float_t betaStarCut_ [NWPs][NEtas][NPts]
 
bool cutBased_
 
Float_t impactParTkThreshod_
 
PileupJetIdentifier internalId_
 
Float_t mvacut_ [NWPs][NEtas][NPts]
 
TMVA::Reader * reader_
 
Float_t rmsCut_ [NWPs][NEtas][NPts]
 
std::string tmvaMethod_
 
std::map< std::string, std::string > tmvaNames_
 
std::vector< std::string > tmvaSpectators_
 
std::vector< std::string > tmvaVariables_
 
std::string tmvaWeights_
 
variables_list_t variables_
 
Int_t version_
 

Static Private Attributes

static int NEtas = 4
 
static int NPts = 4
 
static int NWPs = 3
 

Detailed Description

Definition at line 17 of file MVAJetPuId.h.

Member Typedef Documentation

typedef std::map<std::string,std::pair<float *,float> > MVAJetPuId::variables_list_t

Definition at line 42 of file MVAJetPuId.h.

Member Enumeration Documentation

Enumerator
USER 
CATEv0 

Definition at line 25 of file MVAJetPuId.h.

Constructor & Destructor Documentation

MVAJetPuId::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 at line 51 of file MVAJetPuId.cc.

References impactParTkThreshod_, reader_, setup(), hltPUIdAlgo_cff::tmvaMethod, tmvaMethod_, hltPUIdAlgo_cff::tmvaVariables, tmvaVariables_, hltPUIdAlgo_cff::tmvaWeights, tmvaWeights_, jets_cff::version, and version_.

57 {
58  impactParTkThreshod_ = impactParTkThreshod;
62  version_ = version;
63 
64  reader_ = nullptr;
65 
66  setup();
67 }
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:69
Int_t version_
Definition: MVAJetPuId.h:73
TMVA::Reader * reader_
Definition: MVAJetPuId.h:67
std::string tmvaWeights_
Definition: MVAJetPuId.h:68
Float_t impactParTkThreshod_
Definition: MVAJetPuId.h:74
void setup()
Definition: MVAJetPuId.cc:71
std::string tmvaMethod_
Definition: MVAJetPuId.h:68
MVAJetPuId::MVAJetPuId ( const edm::ParameterSet ps)

Definition at line 17 of file MVAJetPuId.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), impactParTkThreshod_, PileupJetIdentifier::kLoose, PileupJetIdentifier::kMedium, mvacut_, NPts, NWPs, reader_, setup(), AlCaHLTBitMon_QueryRunRegistry::string, tmvaMethod_, tmvaSpectators_, tmvaVariables_, tmvaWeights_, and version_.

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_ = nullptr;
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 }
T getParameter(std::string const &) const
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:69
Float_t mvacut_[NWPs][NEtas][NPts]
Definition: MVAJetPuId.h:76
Int_t version_
Definition: MVAJetPuId.h:73
std::vector< std::string > tmvaSpectators_
Definition: MVAJetPuId.h:70
static int NWPs
Definition: MVAJetPuId.h:20
TMVA::Reader * reader_
Definition: MVAJetPuId.h:67
static int NPts
Definition: MVAJetPuId.h:21
std::string tmvaWeights_
Definition: MVAJetPuId.h:68
std::string fullPath() const
Definition: FileInPath.cc:197
Float_t impactParTkThreshod_
Definition: MVAJetPuId.h:74
void setup()
Definition: MVAJetPuId.cc:71
std::string tmvaMethod_
Definition: MVAJetPuId.h:68
MVAJetPuId::~MVAJetPuId ( )

Definition at line 114 of file MVAJetPuId.cc.

References reader_.

115 {
116  if( reader_ ) {
117  delete reader_;
118  }
119 }
TMVA::Reader * reader_
Definition: MVAJetPuId.h:67

Member Function Documentation

void MVAJetPuId::bookReader ( )
protected

Definition at line 140 of file MVAJetPuId.cc.

References relativeConstraints::empty, plotBeamSpotDB::first, reco::details::loadTMVAWeights(), reader_, tmvaMethod_, tmvaNames_, tmvaSpectators_, tmvaVariables_, tmvaWeights_, and variables_.

Referenced by getVariables(), and runMva().

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 }
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:69
std::vector< std::string > tmvaSpectators_
Definition: MVAJetPuId.h:70
variables_list_t variables_
Definition: MVAJetPuId.h:65
std::map< std::string, std::string > tmvaNames_
Definition: MVAJetPuId.h:71
TMVA::Reader * reader_
Definition: MVAJetPuId.h:67
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::string tmvaWeights_
Definition: MVAJetPuId.h:68
std::string tmvaMethod_
Definition: MVAJetPuId.h:68
int MVAJetPuId::computeCutIDflag ( float  betaStarClassic,
float  dR2Mean,
float  nvtx,
float  jetPt,
float  jetEta 
)
int MVAJetPuId::computeIDflag ( float  mva,
float  jetPt,
float  jetEta 
)

Definition at line 189 of file MVAJetPuId.cc.

References getJetIdKey().

Referenced by runMva().

190 {
191  std::pair<int,int> jetIdKey = getJetIdKey(jetPt,jetEta);
192  return computeIDflag(mva,jetIdKey.first,jetIdKey.second);
193 }
std::pair< int, int > getJetIdKey(float jetPt, float jetEta)
Definition: MVAJetPuId.cc:174
int computeIDflag(float mva, float jetPt, float jetEta)
Definition: MVAJetPuId.cc:189
int MVAJetPuId::computeIDflag ( float  mva,
int  ptId,
int  etaId 
)
PileupJetIdentifier MVAJetPuId::computeIdVariables ( const reco::Jet jet,
float  jec,
const reco::Vertex vtx,
const reco::VertexCollection allvtx,
double  rho,
bool  calculateMva = false 
)

Definition at line 210 of file MVAJetPuId.cc.

References a, Assign(), b, EnergyCorrector::c, reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), PileupJetIdentifier::chgEMfrac_, PileupJetIdentifier::chgHadrfrac_, constexpr, PileupJetIdentifier::d0_, delta, reco::deltaPhi(), reco::deltaR(), PileupJetIdentifier::dRLead2nd_, PileupJetIdentifier::dRMeanEm_, PileupJetIdentifier::dRMeanNeut_, reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), spr::find(), PileupJetIdentifier::fourthFrac_, cropTnPTrees::frac, reco::PFCandidate::gamma, reco::PFJet::getPFConstituent(), reco::PFJet::getPFConstituents(), reco::PFCandidate::h0, mps_fire::i, internalId_, edm::Ptr< T >::isAvailable(), edm::Ref< C, T, F >::isAvailable(), reco::Vertex::isFake(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), edm::Ptr< T >::isNull(), patTestJEC_cfi::jec, metsig::jet, PileupJetIdentifier::jetM_, PileupJetIdentifier::jetPhi_, reco::btau::jetPt, PileupJetIdentifier::leadChEta_, PileupJetIdentifier::leadChPhi_, PileupJetIdentifier::leadChPt_, PileupJetIdentifier::leadEmEta_, PileupJetIdentifier::leadEmPhi_, PileupJetIdentifier::leadEmPt_, PileupJetIdentifier::leadEta_, PileupJetIdentifier::leadFrac_, PileupJetIdentifier::leadNeutEta_, PileupJetIdentifier::leadNeutPhi_, PileupJetIdentifier::leadNeutPt_, PileupJetIdentifier::leadPhi_, PileupJetIdentifier::leadPt_, reco::LeafCandidate::mass(), min(), reco::Vertex::ndof(), PileupJetIdentifier::neuEMfrac_, PileupJetIdentifier::neuHadrfrac_, reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralHadronEnergy(), reco::PFJet::neutralMultiplicity(), reco::Vertex::position(), EnergyCorrector::pt, reco::LeafCandidate::pt(), PileupJetIdentifier::pt2A_, PileupJetIdentifier::ptMean_, PileupJetIdentifier::ptRMS_, alignCSCRings::r, resetVariables(), rho, runMva(), PileupJetIdentifier::secondEta_, PileupJetIdentifier::secondFrac_, PileupJetIdentifier::secondPhi_, PileupJetIdentifier::secondPt_, SetPtEtaPhi(), mathSSE::sqrt(), PileupJetIdentifier::sumChPt_, PileupJetIdentifier::sumNePt_, TtFullHadEvtBuilder_cfi::sumPt, PileupJetIdentifier::sumPt_, std::swap(), PileupJetIdentifier::thirdFrac_, reco::Vertex::tracks_begin(), reco::Vertex::tracks_end(), and mps_merge::weight.

Referenced by MVAJetPuIdProducer::produce().

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);
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;
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 }
dbl * delta
Definition: mlp_gen.cc:36
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
bool isAvailable() const
Definition: Ref.h:577
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
double eta() const final
momentum pseudorapidity
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:142
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:81
bool isAvailable() const
Definition: Ptr.h:258
double pt() const final
transverse momentum
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:155
const Point & position() const
position
Definition: Vertex.h:109
Jets made from PFObjects.
Definition: PFJet.h:21
#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
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:18
double energy() const final
energy
bool isNull() const
Checks for null.
Definition: Ptr.h:164
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:105
int neutralMultiplicity() const
neutralMultiplicity
Definition: PFJet.h:157
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
bool isFake() const
Definition: Vertex.h:72
part
Definition: HCALResponse.h:20
double b
Definition: hdecay.h:120
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
void resetVariables()
Definition: MVAJetPuId.cc:477
double a
Definition: hdecay.h:121
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:52
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:102
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:76
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
double mass() const final
mass
PileupJetIdentifier MVAJetPuId::computeMva ( )

Definition at line 204 of file MVAJetPuId.cc.

References internalId_, and runMva().

Referenced by MVAJetPuIdProducer::produce().

205 {
206  runMva();
208 }
void runMva()
Definition: MVAJetPuId.cc:166
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
std::string MVAJetPuId::dumpVariables ( ) const

Definition at line 465 of file MVAJetPuId.cc.

References MillePedeFileConverter_cfg::out, and variables_.

Referenced by method().

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 }
variables_list_t variables_
Definition: MVAJetPuId.h:65
std::pair< int, int > MVAJetPuId::getJetIdKey ( float  jetPt,
float  jetEta 
)

Definition at line 174 of file MVAJetPuId.cc.

Referenced by computeIDflag().

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 }
const variables_list_t& MVAJetPuId::getVariables ( ) const
inline

Definition at line 49 of file MVAJetPuId.h.

References bookReader(), initVariables(), resetVariables(), runMva(), setup(), and variables_.

49 { return variables_; };
variables_list_t variables_
Definition: MVAJetPuId.h:65
void MVAJetPuId::initVariables ( )
protected

Definition at line 490 of file MVAJetPuId.cc.

References pfBoostedDoubleSVAK8TagInfos_cfi::beta, BeamSpotFakeParameters_cfi::betaStar, allConversions_cfi::d0, PileupJetIdentifier::idFlag_, INIT_VARIABLE, internalId_, reco::btau::jetEta, reco::btau::jetPhi, reco::btau::jetPt, large_val, DetachedQuadStep_cff::mva, hpstanc_transforms::nCharged, jets_cff::ptD, rho, and TtFullHadEvtBuilder_cfi::sumPt.

Referenced by getVariables(), and setup().

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 }
const float large_val
Definition: MVAJetPuId.cc:14
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
#define INIT_VARIABLE(NAME, TMVANAME, VAL)
Definition: MVAJetPuId.cc:486
const std::string MVAJetPuId::method ( ) const
inline

Definition at line 38 of file MVAJetPuId.h.

References dumpVariables(), AlCaHLTBitMon_QueryRunRegistry::string, and tmvaMethod_.

38 { return tmvaMethod_; }
std::string tmvaMethod_
Definition: MVAJetPuId.h:68
void MVAJetPuId::resetVariables ( )
protected

Definition at line 477 of file MVAJetPuId.cc.

References PileupJetIdentifier::idFlag_, internalId_, and variables_.

Referenced by computeIdVariables(), and getVariables().

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 }
variables_list_t variables_
Definition: MVAJetPuId.h:65
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
void MVAJetPuId::runMva ( )
protected

Definition at line 166 of file MVAJetPuId.cc.

References bookReader(), computeIDflag(), PileupJetIdentifier::idFlag_, internalId_, PileupJetIdentifier::mva_, reader_, and tmvaMethod_.

Referenced by computeIdVariables(), computeMva(), and getVariables().

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 }
void bookReader()
Definition: MVAJetPuId.cc:140
TMVA::Reader * reader_
Definition: MVAJetPuId.h:67
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
int computeIDflag(float mva, float jetPt, float jetEta)
Definition: MVAJetPuId.cc:189
std::string tmvaMethod_
Definition: MVAJetPuId.h:68
void MVAJetPuId::set ( const PileupJetIdentifier id)

Definition at line 160 of file MVAJetPuId.cc.

References triggerObjects_cff::id, and internalId_.

Referenced by MVAJetPuIdProducer::produce().

161 {
162  internalId_ = id;
163 }
PileupJetIdentifier internalId_
Definition: MVAJetPuId.h:64
void MVAJetPuId::setup ( )
protected

Definition at line 71 of file MVAJetPuId.cc.

References initVariables(), tmvaNames_, and tmvaVariables_.

Referenced by getVariables(), and MVAJetPuId().

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 }
std::vector< std::string > tmvaVariables_
Definition: MVAJetPuId.h:69
std::map< std::string, std::string > tmvaNames_
Definition: MVAJetPuId.h:71
void initVariables()
Definition: MVAJetPuId.cc:490

Member Data Documentation

Float_t MVAJetPuId::betaStarCut_[NWPs][NEtas][NPts]
protected

Definition at line 78 of file MVAJetPuId.h.

bool MVAJetPuId::cutBased_
protected

Definition at line 75 of file MVAJetPuId.h.

Float_t MVAJetPuId::impactParTkThreshod_
protected

Definition at line 74 of file MVAJetPuId.h.

Referenced by MVAJetPuId().

PileupJetIdentifier MVAJetPuId::internalId_
protected

Definition at line 64 of file MVAJetPuId.h.

Referenced by computeIdVariables(), computeMva(), initVariables(), resetVariables(), runMva(), and set().

Float_t MVAJetPuId::mvacut_[NWPs][NEtas][NPts]
protected

Definition at line 76 of file MVAJetPuId.h.

Referenced by computeIDflag(), and MVAJetPuId().

int MVAJetPuId::NEtas = 4
staticprivate

Definition at line 22 of file MVAJetPuId.h.

int MVAJetPuId::NPts = 4
staticprivate

Definition at line 21 of file MVAJetPuId.h.

Referenced by MVAJetPuId().

int MVAJetPuId::NWPs = 3
staticprivate

Definition at line 20 of file MVAJetPuId.h.

Referenced by MVAJetPuId().

TMVA::Reader* MVAJetPuId::reader_
protected

Definition at line 67 of file MVAJetPuId.h.

Referenced by bookReader(), MVAJetPuId(), runMva(), and ~MVAJetPuId().

Float_t MVAJetPuId::rmsCut_[NWPs][NEtas][NPts]
protected

Definition at line 77 of file MVAJetPuId.h.

std::string MVAJetPuId::tmvaMethod_
protected

Definition at line 68 of file MVAJetPuId.h.

Referenced by bookReader(), method(), MVAJetPuId(), and runMva().

std::map<std::string,std::string> MVAJetPuId::tmvaNames_
protected

Definition at line 71 of file MVAJetPuId.h.

Referenced by bookReader(), and setup().

std::vector<std::string> MVAJetPuId::tmvaSpectators_
protected

Definition at line 70 of file MVAJetPuId.h.

Referenced by bookReader(), and MVAJetPuId().

std::vector<std::string> MVAJetPuId::tmvaVariables_
protected

Definition at line 69 of file MVAJetPuId.h.

Referenced by bookReader(), MVAJetPuId(), and setup().

std::string MVAJetPuId::tmvaWeights_
protected

Definition at line 68 of file MVAJetPuId.h.

Referenced by bookReader(), and MVAJetPuId().

variables_list_t MVAJetPuId::variables_
protected

Definition at line 65 of file MVAJetPuId.h.

Referenced by bookReader(), dumpVariables(), getVariables(), and resetVariables().

Int_t MVAJetPuId::version_
protected

Definition at line 73 of file MVAJetPuId.h.

Referenced by MVAJetPuId().