CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PileupJetIdAlgo Class Reference

#include <PileupJetIdAlgo.h>

Public Types

typedef std::map< std::string,
std::pair< float *, float > > 
variables_list_t
 
enum  version_t { USER =-1, PHILv0 =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)
 
PileupJetIdentifier computeMva ()
 
std::string dumpVariables () const
 
std::pair< int, int > getJetIdKey (float jetPt, float jetEta)
 
const variables_list_tgetVariables () const
 const PileupJetIdentifier::variables_list_t & getVariables() const { return variables_; }; More...
 
const std::string method () const
 
 PileupJetIdAlgo (int version=PHILv0, const std::string &tmvaWeight="", const std::string &tmvaMethod="", Float_t impactParTkThreshod_=1., const std::vector< std::string > &tmvaVariables=std::vector< std::string >(), bool runMvas=true)
 
 PileupJetIdAlgo (const edm::ParameterSet &ps, bool runMvas)
 
void set (const PileupJetIdentifier &)
 
 ~PileupJetIdAlgo ()
 

Protected Member Functions

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

Protected Attributes

float betaStarCut_ [3][4][4]
 
bool cutBased_
 
bool etaBinnedWeights_
 
std::vector< std::unique_ptr
< TMVA::Reader > > 
etaReader_
 
float impactParTkThreshod_
 
PileupJetIdentifier internalId_
 
std::vector< double > jEtaMax_
 
std::vector< double > jEtaMin_
 
float mvacut_ [3][4][4]
 
int nEtaBins_
 
std::unique_ptr< TMVA::Reader > reader_
 
float rmsCut_ [3][4][4]
 
bool runMvas_
 
std::vector< std::vector
< std::string > > 
tmvaEtaVariables_
 
std::vector< std::string > tmvaEtaWeights_
 
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 version_
 

Detailed Description

Definition at line 27 of file PileupJetIdAlgo.h.

Member Typedef Documentation

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

Definition at line 45 of file PileupJetIdAlgo.h.

Member Enumeration Documentation

Enumerator
USER 
PHILv0 

Definition at line 29 of file PileupJetIdAlgo.h.

Constructor & Destructor Documentation

PileupJetIdAlgo::PileupJetIdAlgo ( int  version = PHILv0,
const std::string &  tmvaWeight = "",
const std::string &  tmvaMethod = "",
Float_t  impactParTkThreshod_ = 1.,
const std::vector< std::string > &  tmvaVariables = std::vector<std::string>(),
bool  runMvas = true 
)
PileupJetIdAlgo::PileupJetIdAlgo ( const edm::ParameterSet ps,
bool  runMvas 
)

ps.getParameter<double>("impactParTkThreshod");

Definition at line 18 of file PileupJetIdAlgo.cc.

References betaStarCut_, cutBased_, etaBinnedWeights_, edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), impactParTkThreshod_, jEtaMax_, jEtaMin_, PileupJetIdentifier::kLoose, PileupJetIdentifier::kMedium, mvacut_, nEtaBins_, rmsCut_, runMvas_, setup(), AlCaHLTBitMon_QueryRunRegistry::string, tmvaEtaVariables_, tmvaEtaWeights_, tmvaMethod_, tmvaSpectators_, tmvaVariables_, tmvaWeights_, USER, findQualityFiles::v, and version_.

19 {
21  cutBased_ = false;
22  etaBinnedWeights_ = false;
23  runMvas_=runMvas;
24  //std::string label = ps.getParameter<std::string>("label");
25  cutBased_ = ps.getParameter<bool>("cutBased");
26  if(!cutBased_)
27  {
28  etaBinnedWeights_ = ps.getParameter<bool>("etaBinnedWeights");
30 
31  const std::vector<edm::ParameterSet>& trainings = ps.getParameter<std::vector <edm::ParameterSet> >("trainings");
32  nEtaBins_ = ps.getParameter<int>("nEtaBins");
33  for(int v=0; v<nEtaBins_;v++){
34  tmvaEtaWeights_.push_back( edm::FileInPath(trainings.at(v).getParameter<std::string>("tmvaWeights")).fullPath() );
35  jEtaMin_.push_back( trainings.at(v).getParameter<double>("jEtaMin") );
36  jEtaMax_.push_back( trainings.at(v).getParameter<double>("jEtaMax") );
37  }
38  for(int v=0; v<nEtaBins_;v++){
39  tmvaEtaVariables_.push_back( trainings.at(v).getParameter<std::vector<std::string> >("tmvaVariables") );
40  }
41  }
42  else{
44  tmvaVariables_ = ps.getParameter<std::vector<std::string> >("tmvaVariables");
45  }
46  tmvaMethod_ = ps.getParameter<std::string>("tmvaMethod");
47  tmvaSpectators_ = ps.getParameter<std::vector<std::string> >("tmvaSpectators");
48  version_ = ps.getParameter<int>("version");
49  }
50  else version_ = USER;
51  edm::ParameterSet jetConfig = ps.getParameter<edm::ParameterSet>("JetIdParams");
52  for(int i0 = 0; i0 < 3; i0++) {
53  std::string lCutType = "Tight";
54  if(i0 == PileupJetIdentifier::kMedium) lCutType = "Medium";
55  if(i0 == PileupJetIdentifier::kLoose) lCutType = "Loose";
56  int nCut = 1;
57  if(cutBased_) nCut++;
58  for(int i1 = 0; i1 < nCut; i1++) {
59  std::string lFullCutType = lCutType;
60  if(cutBased_ && i1 == 0) lFullCutType = "BetaStar"+ lCutType;
61  if(cutBased_ && i1 == 1) lFullCutType = "RMS" + lCutType;
62  std::vector<double> pt010 = jetConfig.getParameter<std::vector<double> >(("Pt010_" +lFullCutType).c_str());
63  std::vector<double> pt1020 = jetConfig.getParameter<std::vector<double> >(("Pt1020_"+lFullCutType).c_str());
64  std::vector<double> pt2030 = jetConfig.getParameter<std::vector<double> >(("Pt2030_"+lFullCutType).c_str());
65  std::vector<double> pt3050 = jetConfig.getParameter<std::vector<double> >(("Pt3050_"+lFullCutType).c_str());
66  if(!cutBased_) {
67  for(int i2 = 0; i2 < 4; i2++) mvacut_[i0][0][i2] = pt010 [i2];
68  for(int i2 = 0; i2 < 4; i2++) mvacut_[i0][1][i2] = pt1020[i2];
69  for(int i2 = 0; i2 < 4; i2++) mvacut_[i0][2][i2] = pt2030[i2];
70  for(int i2 = 0; i2 < 4; i2++) mvacut_[i0][3][i2] = pt3050[i2];
71  }
72  if(cutBased_ && i1 == 0) {
73  for(int i2 = 0; i2 < 4; i2++) betaStarCut_[i0][0][i2] = pt010 [i2];
74  for(int i2 = 0; i2 < 4; i2++) betaStarCut_[i0][1][i2] = pt1020[i2];
75  for(int i2 = 0; i2 < 4; i2++) betaStarCut_[i0][2][i2] = pt2030[i2];
76  for(int i2 = 0; i2 < 4; i2++) betaStarCut_[i0][3][i2] = pt3050[i2];
77  }
78  if(cutBased_ && i1 == 1) {
79  for(int i2 = 0; i2 < 4; i2++) rmsCut_[i0][0][i2] = pt010 [i2];
80  for(int i2 = 0; i2 < 4; i2++) rmsCut_[i0][1][i2] = pt1020[i2];
81  for(int i2 = 0; i2 < 4; i2++) rmsCut_[i0][2][i2] = pt2030[i2];
82  for(int i2 = 0; i2 < 4; i2++) rmsCut_[i0][3][i2] = pt3050[i2];
83  }
84  }
85  }
86  setup();
87 }
T getParameter(std::string const &) const
float mvacut_[3][4][4]
std::vector< std::string > tmvaEtaWeights_
std::vector< std::string > tmvaVariables_
float rmsCut_[3][4][4]
std::string tmvaMethod_
std::vector< double > jEtaMin_
float impactParTkThreshod_
float betaStarCut_[3][4][4]
std::vector< std::vector< std::string > > tmvaEtaVariables_
std::vector< std::string > tmvaSpectators_
std::string tmvaWeights_
std::vector< double > jEtaMax_
std::string fullPath() const
Definition: FileInPath.cc:184
PileupJetIdAlgo::~PileupJetIdAlgo ( )

Definition at line 121 of file PileupJetIdAlgo.cc.

122 {
123 }

Member Function Documentation

void PileupJetIdAlgo::bookReader ( )
protected

Definition at line 143 of file PileupJetIdAlgo.cc.

References relativeConstraints::empty, etaBinnedWeights_, etaReader_, plotBeamSpotDB::first, reco::details::loadTMVAWeights(), eostools::move(), nEtaBins_, reader_, tmvaEtaVariables_, tmvaEtaWeights_, tmvaMethod_, tmvaNames_, tmvaSpectators_, tmvaVariables_, tmvaWeights_, findQualityFiles::v, and variables_.

Referenced by setup().

144 {
145  if(etaBinnedWeights_){
146  for(int v=0; v<nEtaBins_;v++){
147  std::unique_ptr<TMVA::Reader> etaReader = std::unique_ptr<TMVA::Reader>(new TMVA::Reader("!Color:Silent"));
148  etaReader_.push_back(std::move(etaReader));
149  }
150  } else {
151  reader_ = std::unique_ptr<TMVA::Reader>(new TMVA::Reader("!Color:Silent"));
152  }
153  if(etaBinnedWeights_){
154  for(int v=0; v<nEtaBins_;v++){
155  for(std::vector<std::string>::iterator it=tmvaEtaVariables_.at(v).begin(); it!=tmvaEtaVariables_.at(v).end(); ++it) {
156  if( tmvaNames_[*it].empty() ) {
157  tmvaNames_[*it] = *it;
158  }
159  etaReader_.at(v)->AddVariable( *it, variables_[ tmvaNames_[*it] ].first );
160  }
161  }
162  } else {
163  for(std::vector<std::string>::iterator it=tmvaVariables_.begin(); it!=tmvaVariables_.end(); ++it) {
164  if( tmvaNames_[*it].empty() ) {
165  tmvaNames_[*it] = *it;
166  }
167  reader_->AddVariable( *it, variables_[ tmvaNames_[*it] ].first );
168  }
169  }
170  for(std::vector<std::string>::iterator it=tmvaSpectators_.begin(); it!=tmvaSpectators_.end(); ++it) {
171  if( tmvaNames_[*it].empty() ) {
172  tmvaNames_[*it] = *it;
173  }
174  if(etaBinnedWeights_){
175  for(int v=0; v<nEtaBins_;v++){
176  etaReader_.at(v)->AddSpectator( *it, variables_[ tmvaNames_[*it] ].first );
177  }
178  } else {
179  reader_->AddSpectator( *it, variables_[ tmvaNames_[*it] ].first );
180  }
181  }
182  if(etaBinnedWeights_){
183  for(int v=0; v<nEtaBins_;v++){
184  reco::details::loadTMVAWeights(etaReader_.at(v).get(), tmvaMethod_.c_str(), tmvaEtaWeights_.at(v).c_str() );
185  }
186  } else {
188  }
189 }
std::vector< std::string > tmvaEtaWeights_
std::vector< std::string > tmvaVariables_
std::map< std::string, std::string > tmvaNames_
std::string tmvaMethod_
def move
Definition: eostools.py:510
std::vector< std::vector< std::string > > tmvaEtaVariables_
std::vector< std::string > tmvaSpectators_
TMVA::IMethod * loadTMVAWeights(TMVA::Reader *reader, const std::string &method, const std::string &weightFile, bool verbose=false)
std::unique_ptr< TMVA::Reader > reader_
std::string tmvaWeights_
variables_list_t variables_
std::vector< std::unique_ptr< TMVA::Reader > > etaReader_
int PileupJetIdAlgo::computeCutIDflag ( float  betaStarClassic,
float  dR2Mean,
float  nvtx,
float  jetPt,
float  jetEta 
)

Definition at line 241 of file PileupJetIdAlgo.cc.

References betaStarCut_, getJetIdKey(), PileupJetIdentifier::kLoose, PileupJetIdentifier::kMedium, PileupJetIdentifier::kTight, dqm-mbProfile::log, and rmsCut_.

Referenced by runMva().

242 {
243  std::pair<int,int> jetIdKey = getJetIdKey(jetPt,jetEta);
244  float betaStarModified = betaStarClassic/log(nvtx-0.64);
245  int idFlag(0);
246  if(betaStarModified < betaStarCut_[PileupJetIdentifier::kTight ][jetIdKey.first][jetIdKey.second] &&
247  dR2Mean < rmsCut_ [PileupJetIdentifier::kTight ][jetIdKey.first][jetIdKey.second]
248  ) idFlag += 1 << PileupJetIdentifier::kTight;
249 
250  if(betaStarModified < betaStarCut_[PileupJetIdentifier::kMedium ][jetIdKey.first][jetIdKey.second] &&
251  dR2Mean < rmsCut_ [PileupJetIdentifier::kMedium ][jetIdKey.first][jetIdKey.second]
252  ) idFlag += 1 << PileupJetIdentifier::kMedium;
253 
254  if(betaStarModified < betaStarCut_[PileupJetIdentifier::kLoose ][jetIdKey.first][jetIdKey.second] &&
255  dR2Mean < rmsCut_ [PileupJetIdentifier::kLoose ][jetIdKey.first][jetIdKey.second]
256  ) idFlag += 1 << PileupJetIdentifier::kLoose;
257  return idFlag;
258 }
float rmsCut_[3][4][4]
std::pair< int, int > getJetIdKey(float jetPt, float jetEta)
float betaStarCut_[3][4][4]
int PileupJetIdAlgo::computeIDflag ( float  mva,
float  jetPt,
float  jetEta 
)

Definition at line 260 of file PileupJetIdAlgo.cc.

References getJetIdKey().

Referenced by runMva().

261 {
262  std::pair<int,int> jetIdKey = getJetIdKey(jetPt,jetEta);
263  return computeIDflag(mva,jetIdKey.first,jetIdKey.second);
264 }
std::pair< int, int > getJetIdKey(float jetPt, float jetEta)
int computeIDflag(float mva, float jetPt, float jetEta)
int PileupJetIdAlgo::computeIDflag ( float  mva,
int  ptId,
int  etaId 
)
PileupJetIdentifier PileupJetIdAlgo::computeIdVariables ( const reco::Jet jet,
float  jec,
const reco::Vertex vtx,
const reco::VertexCollection allvtx,
double  rho 
)

Definition at line 285 of file PileupJetIdAlgo.cc.

References funct::abs(), assert(), assign(), reco::Muon::bestTrack(), reco::Candidate::bestTrack(), reco::Candidate::charge(), reco::PFJet::chargedEmEnergy(), pat::Jet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), pat::Jet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), pat::Jet::chargedMultiplicity(), PileupJetIdentifier::chFrac01_, PileupJetIdentifier::chFrac02_, PileupJetIdentifier::chFrac03_, PileupJetIdentifier::chFrac04_, PileupJetIdentifier::chFrac05_, PileupJetIdentifier::chFrac06_, PileupJetIdentifier::chFrac07_, PileupJetIdentifier::chgEMfrac_, PileupJetIdentifier::chgHadrfrac_, pat::Jet::correctedJet(), PileupJetIdentifier::d0_, reco::CompositePtrCandidate::daughterPtr(), reco::deltaPhi(), reco::deltaR(), PileupJetIdentifier::dRLead2nd_, PileupJetIdentifier::dRLeadCent_, PileupJetIdentifier::dRMeanCh_, PileupJetIdentifier::dRMeanEm_, PileupJetIdentifier::dRMeanNeut_, reco::TrackBase::dxy(), reco::TrackBase::dz(), pat::PackedCandidate::dz(), PileupJetIdentifier::emFrac01_, PileupJetIdentifier::emFrac02_, PileupJetIdentifier::emFrac03_, PileupJetIdentifier::emFrac04_, PileupJetIdentifier::emFrac05_, PileupJetIdentifier::emFrac06_, PileupJetIdentifier::emFrac07_, reco::LeafCandidate::energy(), reco::Candidate::eta(), reco::LeafCandidate::eta(), PileupJetIdentifier::etaW_, PileupJetIdentifier::fourthChFrac_, PileupJetIdentifier::fourthEmFrac_, PileupJetIdentifier::fourthFrac_, PileupJetIdentifier::fourthNeutFrac_, cropTnPTrees::frac, pat::PackedCandidate::fromPV(), edm::Ptr< T >::get(), edm::Ref< C, T, F >::get(), reco::PFCandidate::gsfTrackRef(), i, internalId_, reco::Vertex::isFake(), edm::Ref< C, T, F >::isNonnull(), j, patTestJEC_cfi::jec, metsig::jet, PileupJetIdentifier::jetM_, PileupJetIdentifier::jetPhi_, reco::btau::jetPt, PileupJetIdentifier::jetW_, PileupJetIdentifier::leadChEta_, PileupJetIdentifier::leadChFrac_, PileupJetIdentifier::leadChPhi_, PileupJetIdentifier::leadChPt_, PileupJetIdentifier::leadEmEta_, PileupJetIdentifier::leadEmFrac_, PileupJetIdentifier::leadEmPhi_, PileupJetIdentifier::leadEmPt_, PileupJetIdentifier::leadEta_, PileupJetIdentifier::leadFrac_, PileupJetIdentifier::leadNeutEta_, PileupJetIdentifier::leadNeutFrac_, PileupJetIdentifier::leadNeutPhi_, PileupJetIdentifier::leadNeutPt_, PileupJetIdentifier::leadPhi_, PileupJetIdentifier::leadPt_, reco::LeafCandidate::mass(), min(), reco::PFCandidate::muonRef(), reco::Jet::nConstituents(), reco::Vertex::ndof(), PileupJetIdentifier::neuEMfrac_, PileupJetIdentifier::neuHadrfrac_, PileupJetIdentifier::neutFrac01_, PileupJetIdentifier::neutFrac02_, PileupJetIdentifier::neutFrac03_, PileupJetIdentifier::neutFrac04_, PileupJetIdentifier::neutFrac05_, PileupJetIdentifier::neutFrac06_, PileupJetIdentifier::neutFrac07_, reco::PFJet::neutralEmEnergy(), pat::Jet::neutralEmEnergy(), reco::PFJet::neutralHadronEnergy(), pat::Jet::neutralHadronEnergy(), reco::PFJet::neutralMultiplicity(), pat::Jet::neutralMultiplicity(), reco::CompositePtrCandidate::numberOfDaughters(), reco::CompositePtrCandidate::numberOfSourceCandidatePtrs(), reco::Candidate::pdgId(), PileupJetIdentifier::phiW_, reco::Vertex::position(), pat::PackedCandidate::pseudoTrack(), EnergyCorrector::pt, reco::Candidate::pt(), reco::LeafCandidate::pt(), PileupJetIdentifier::pt2A_, PileupJetIdentifier::ptDCh_, PileupJetIdentifier::ptDNe_, PileupJetIdentifier::ptMean_, PileupJetIdentifier::ptRMS_, pat::PackedCandidate::PVUsedInFit, alignCSCRings::r, resetVariables(), rho, runMva(), runMvas_, PileupJetIdentifier::secondChFrac_, PileupJetIdentifier::secondEmFrac_, PileupJetIdentifier::secondEta_, PileupJetIdentifier::secondFrac_, PileupJetIdentifier::secondNeutFrac_, PileupJetIdentifier::secondPhi_, PileupJetIdentifier::secondPt_, setPtEtaPhi(), reco::CompositePtrCandidate::sourceCandidatePtr(), mathSSE::sqrt(), PileupJetIdentifier::sumChPt_, PileupJetIdentifier::sumNePt_, PileupJetIdentifier::sumPt_, std::swap(), PileupJetIdentifier::thirdChFrac_, PileupJetIdentifier::thirdEmFrac_, PileupJetIdentifier::thirdFrac_, PileupJetIdentifier::thirdNeutFrac_, reco::PFCandidate::trackRef(), reco::Vertex::trackWeight(), and histoStyle::weight.

Referenced by PileupJetIdProducer::produce().

287 {
288 
289  static std::atomic<int> printWarning{10};
290 
291  // initialize all variables to 0
292  resetVariables();
293 
294  // loop over constituents, accumulate sums and find leading candidates
295  const pat::Jet * patjet = dynamic_cast<const pat::Jet *>(jet);
296  const reco::PFJet * pfjet = dynamic_cast<const reco::PFJet *>(jet);
297  assert( patjet != nullptr || pfjet != nullptr );
298  if( patjet != nullptr && jec == 0. ) { // if this is a pat jet and no jec has been passed take the jec from the object
299  jec = patjet->pt()/patjet->correctedJet(0).pt();
300  }
301  if( jec <= 0. ) {
302  jec = 1.;
303  }
304 
305  const reco::Candidate* lLead = nullptr, *lSecond = nullptr, *lLeadNeut = nullptr, *lLeadEm = nullptr, *lLeadCh = nullptr, *lTrail = nullptr;
306  std::vector<float> frac, fracCh, fracEm, fracNeut;
307  float cones[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
308  size_t ncones = sizeof(cones)/sizeof(float);
309  float * coneFracs[] = { &internalId_.frac01_, &internalId_.frac02_, &internalId_.frac03_, &internalId_.frac04_,
310  &internalId_.frac05_, &internalId_.frac06_, &internalId_.frac07_ };
317  TMatrixDSym covMatrix(2); covMatrix = 0.;
318  float jetPt = jet->pt() / jec; // use uncorrected pt for shape variables
319  float sumPt = 0., sumPt2 = 0., sumTkPt = 0.,sumPtCh=0,sumPtNe = 0;
320  setPtEtaPhi(*jet,internalId_.jetPt_,internalId_.jetEta_,internalId_.jetPhi_); // use corrected pt for jet kinematics
321  internalId_.jetM_ = jet->mass();
322  internalId_.nvtx_ = allvtx.size();
323  internalId_.rho_ = rho;
324 
325  float dRmin(1000);
326 
327  for ( unsigned i = 0; i < jet->numberOfSourceCandidatePtrs(); ++i ) {
328  reco::CandidatePtr pfJetConstituent = jet->sourceCandidatePtr(i);
329 
330  const reco::Candidate* icand = pfJetConstituent.get();
331  const pat::PackedCandidate* lPack = dynamic_cast<const pat::PackedCandidate *>( icand );
332  const reco::PFCandidate *lPF=dynamic_cast<const reco::PFCandidate*>( icand );
333  bool isPacked = true;
334  if (lPack == nullptr){
335  isPacked = false;
336  }
337 
338  float candPt = icand->pt();
339  float candPtFrac = candPt/jetPt;
340  float candDr = reco::deltaR(*icand,*jet);
341  float candDeta = icand->eta() - jet->eta();
342  float candDphi = reco::deltaPhi(*icand,*jet);
343  float candPtDr = candPt * candDr;
344  size_t icone = std::lower_bound(&cones[0],&cones[ncones],candDr) - &cones[0];
345 
346  if(candDr < dRmin) dRmin = candDr;
347 
348  // // all particles
349  if( lLead == nullptr || candPt > lLead->pt() ) {
350  lSecond = lLead;
351  lLead = icand;
352  } else if( (lSecond == nullptr || candPt > lSecond->pt()) && (candPt < lLead->pt()) ) {
353  lSecond = icand;
354  }
355 
356  // // average shapes
357  internalId_.dRMean_ += candPtDr;
358  internalId_.dR2Mean_ += candPtDr*candPtDr;
359  covMatrix(0,0) += candPt*candPt*candDeta*candDeta;
360  covMatrix(0,1) += candPt*candPt*candDeta*candDphi;
361  covMatrix(1,1) += candPt*candPt*candDphi*candDphi;
362  internalId_.ptD_ += candPt*candPt;
363  sumPt += candPt;
364  sumPt2 += candPt*candPt;
365 
366  // single most energetic candiates and jet shape profiles
367  frac.push_back(candPtFrac);
368 
369  if( icone < ncones ) { *coneFracs[icone] += candPt; }
370 
371  // neutrals
372  if( abs(icand->pdgId()) == 130) {
373  if (lLeadNeut == nullptr || candPt > lLeadNeut->pt()) { lLeadNeut = icand; }
374  internalId_.dRMeanNeut_ += candPtDr;
375  fracNeut.push_back(candPtFrac);
376  if( icone < ncones ) { *coneNeutFracs[icone] += candPt; }
377  internalId_.ptDNe_ += candPt*candPt;
378  sumPtNe += candPt;
379  }
380  // EM candidated
381  if( icand->pdgId() == 22 ) {
382  if(lLeadEm == nullptr || candPt > lLeadEm->pt()) { lLeadEm = icand; }
383  internalId_.dRMeanEm_ += candPtDr;
384  fracEm.push_back(candPtFrac);
385  if( icone < ncones ) { *coneEmFracs[icone] += candPt; }
386  internalId_.ptDNe_ += candPt*candPt;
387  sumPtNe += candPt;
388  }
389  // Charged particles
390  if( icand->charge() != 0 ) {
391  if (lLeadCh == nullptr || candPt > lLeadCh->pt()) {
392  lLeadCh = icand;
393 
394  const reco::Track* pfTrk = icand->bestTrack();
395  if (lPF && std::abs(icand->pdgId()) == 13 && pfTrk == nullptr){
396  reco::MuonRef lmuRef = lPF->muonRef();
397  if (lmuRef.isNonnull()){
398  const reco::Muon& lmu = *lmuRef.get();
399  pfTrk = lmu.bestTrack();
400  edm::LogWarning("BadMuon")<<"Found a PFCandidate muon without a trackRef: falling back to Muon::bestTrack ";
401  }
402  }
403  if(pfTrk==nullptr) { //protection against empty pointers for the miniAOD case
404  //To handle the electron case
405  if(lPF!=nullptr) {
406  pfTrk=(lPF->trackRef().get()==nullptr)?lPF->gsfTrackRef().get():lPF->trackRef().get();
407  }
408  const reco::Track& impactTrack = (lPack==nullptr)?(*pfTrk):(lPack->pseudoTrack());
409  internalId_.d0_ = std::abs(impactTrack.dxy(vtx->position()));
410  internalId_.dZ_ = std::abs(impactTrack.dz(vtx->position()));
411  }
412  else {
413  internalId_.d0_ = std::abs(pfTrk->dxy(vtx->position()));
414  internalId_.dZ_ = std::abs(pfTrk->dz(vtx->position()));
415  }
416  }
417  internalId_.dRMeanCh_ += candPtDr;
418  internalId_.ptDCh_ += candPt*candPt;
419  fracCh.push_back(candPtFrac);
420  if( icone < ncones ) { *coneChFracs[icone] += candPt; }
421  sumPtCh += candPt;
422  }
423  // // beta and betastar
424  if( icand->charge() != 0 ) {
425  if (!isPacked){
426  if(lPF->trackRef().isNonnull() ) {
427  float tkpt = candPt;
428  sumTkPt += tkpt;
429  // 'classic' beta definition based on track-vertex association
430  bool inVtx0 = vtx->trackWeight ( lPF->trackRef()) > 0 ;
431 
432  bool inAnyOther = false;
433  // alternative beta definition based on track-vertex distance of closest approach
434  double dZ0 = std::abs(lPF->trackRef()->dz(vtx->position()));
435  double dZ = dZ0;
436  for(reco::VertexCollection::const_iterator vi=allvtx.begin(); vi!=allvtx.end(); ++vi ) {
437  const reco::Vertex & iv = *vi;
438  if( iv.isFake() || iv.ndof() < 4 ) { continue; }
439  // the primary vertex may have been copied by the user: check identity by position
440  bool isVtx0 = (iv.position() - vtx->position()).r() < 0.02;
441  // 'classic' beta definition: check if the track is associated with
442  // any vertex other than the primary one
443  if( ! isVtx0 && ! inAnyOther ) {
444  inAnyOther = vtx->trackWeight ( lPF->trackRef()) <= 0 ;
445  }
446  // alternative beta: find closest vertex to the track
447  dZ = std::min(dZ,std::abs(lPF->trackRef()->dz(iv.position())));
448  }
449  // classic beta/betaStar
450  if( inVtx0 && ! inAnyOther ) {
451  internalId_.betaClassic_ += tkpt;
452  } else if( ! inVtx0 && inAnyOther ) {
453  internalId_.betaStarClassic_ += tkpt;
454  }
455  // alternative beta/betaStar
456  if( dZ0 < 0.2 ) {
457  internalId_.beta_ += tkpt;
458  } else if( dZ < 0.2 ) {
459  internalId_.betaStar_ += tkpt;
460  }
461  }
462  }
463  else{
464  float tkpt = candPt;
465  sumTkPt += tkpt;
466  bool inVtx0 = false;
467  bool inVtxOther = false;
468  double dZ0=9999.;
469  double dZ_tmp = 9999.;
470  for (unsigned vtx_i = 0 ; vtx_i < allvtx.size() ; vtx_i++ ) {
471  auto iv = allvtx[vtx_i];
472 
473  if (iv.isFake())
474  continue;
475 
476  // Match to vertex in case of copy as above
477  bool isVtx0 = (iv.position() - vtx->position()).r() < 0.02;
478 
479  if (isVtx0) {
480  if (lPack->fromPV(vtx_i) == pat::PackedCandidate::PVUsedInFit) inVtx0 = true;
481  if (lPack->fromPV(vtx_i) == 0) inVtxOther = true;
482  dZ0 = lPack->dz(vtx_i);
483  }
484 
485  if (fabs(lPack->dz(iv.position())) < fabs(dZ_tmp)) {
486  dZ_tmp = lPack->dz(iv.position());
487  }
488  }
489  if (inVtx0){
490  internalId_.betaClassic_ += tkpt;
491  } else if (inVtxOther){
492  internalId_.betaStarClassic_ += tkpt;
493  }
494  if (fabs(dZ0) < 0.2){
495  internalId_.beta_ += tkpt;
496  } else if (fabs(dZ_tmp) < 0.2){
497  internalId_.betaStar_ += tkpt;
498  }
499  }
500  }
501  // trailing candidate
502  if( lTrail == nullptr || candPt < lTrail->pt() ) {
503  lTrail = icand;
504  }
505 
506  }
507 
508  // // Finalize all variables
509  assert( !(lLead == nullptr) );
510 
511  if ( lSecond == nullptr ) { lSecond = lTrail; }
512  if ( lLeadNeut == nullptr ) { lLeadNeut = lTrail; }
513  if ( lLeadEm == nullptr ) { lLeadEm = lTrail; }
514  if ( lLeadCh == nullptr ) { lLeadCh = lTrail; }
515 
516  if( patjet != nullptr ) { // to enable running on MiniAOD slimmedJets
517  internalId_.nCharged_ = patjet->chargedMultiplicity();
518  internalId_.nNeutrals_ = patjet->neutralMultiplicity();
519  internalId_.chgEMfrac_ = patjet->chargedEmEnergy() /jet->energy();
520  internalId_.neuEMfrac_ = patjet->neutralEmEnergy() /jet->energy();
523  } else {
524  internalId_.nCharged_ = pfjet->chargedMultiplicity();
525  internalId_.nNeutrals_ = pfjet->neutralMultiplicity();
526  internalId_.chgEMfrac_ = pfjet->chargedEmEnergy() /jet->energy();
527  internalId_.neuEMfrac_ = pfjet->neutralEmEnergy() /jet->energy();
530  }
531  internalId_.nParticles_ = jet->nConstituents();
532 
534  float sumW2(0.0);
535  float sum_deta(0.0),sum_dphi(0.0);
536  float ave_deta(0.0), ave_dphi(0.0);
537  for (size_t j = 0; j < jet->numberOfDaughters(); j++) {
538  const auto& part = jet->daughterPtr(j);
539  if (!(part.isAvailable() && part.isNonnull()) ){
540  continue;
541  }
542 
543  float weight = part->pt();
544  float weight2 = weight * weight;
545  sumW2 += weight2;
546  float deta = part->eta() - jet->eta();
547  float dphi = reco::deltaPhi(*part, *jet);
548  sum_deta += deta*weight2;
549  sum_dphi += dphi*weight2;
550  if (sumW2 > 0) {
551  ave_deta = sum_deta/sumW2;
552  ave_dphi = sum_dphi/sumW2;
553  }
554  }
555 
556  float ddetaR_sum(0.0), ddphiR_sum(0.0), pull_tmp(0.0);
557  for (size_t i = 0; i < jet->numberOfDaughters(); i++) {
558  const auto& part = jet->daughterPtr(i);
559  if (!(part.isAvailable() && part.isNonnull()) ){
560  continue;
561  }
562  float weight =part->pt()*part->pt();
563  float deta = part->eta() - jet->eta();
564  float dphi = reco::deltaPhi(*part, *jet);
565  float ddeta, ddphi, ddR;
566  ddeta = deta - ave_deta ;
567  ddphi = dphi-ave_dphi;
568  ddR = sqrt(ddeta*ddeta + ddphi*ddphi);
569  ddetaR_sum += ddR*ddeta*weight;
570  ddphiR_sum += ddR*ddphi*weight;
571  }
572  if (sumW2 > 0) {
573  float ddetaR_ave = ddetaR_sum/sumW2;
574  float ddphiR_ave = ddphiR_sum/sumW2;
575  pull_tmp = sqrt(ddetaR_ave*ddetaR_ave+ddphiR_ave*ddphiR_ave);
576  }
577  internalId_.pull_ = pull_tmp;
579 
580 
586 
587  std::sort(frac.begin(),frac.end(),std::greater<float>());
588  std::sort(fracCh.begin(),fracCh.end(),std::greater<float>());
589  std::sort(fracEm.begin(),fracEm.end(),std::greater<float>());
590  std::sort(fracNeut.begin(),fracNeut.end(),std::greater<float>());
595 
596  covMatrix(0,0) /= sumPt2;
597  covMatrix(0,1) /= sumPt2;
598  covMatrix(1,1) /= sumPt2;
599  covMatrix(1,0) = covMatrix(0,1);
600  internalId_.etaW_ = sqrt(covMatrix(0,0));
601  internalId_.phiW_ = sqrt(covMatrix(1,1));
603  TVectorD eigVals(2); eigVals = TMatrixDSymEigen(covMatrix).GetEigenValues();
604  internalId_.majW_ = sqrt(std::abs(eigVals(0)));
605  internalId_.minW_ = sqrt(std::abs(eigVals(1)));
606  if( internalId_.majW_ < internalId_.minW_ ) { std::swap(internalId_.majW_,internalId_.minW_); }
607 
608  internalId_.dRLeadCent_ = reco::deltaR(*jet,*lLead);
609  if( lSecond == nullptr ) { internalId_.dRLead2nd_ = reco::deltaR(*jet,*lSecond); }
610  internalId_.dRMean_ /= jetPt;
614  internalId_.dR2Mean_ /= sumPt2;
615 
616  for(size_t ic=0; ic<ncones; ++ic){
617  *coneFracs[ic] /= jetPt;
618  *coneEmFracs[ic] /= jetPt;
619  *coneNeutFracs[ic] /= jetPt;
620  *coneChFracs[ic] /= jetPt;
621  }
622  //http://jets.physics.harvard.edu/qvg/
623  double ptMean = sumPt/internalId_.nParticles_;
624  double ptRMS = 0;
625  for(unsigned int i0 = 0; i0 < frac.size(); i0++) {ptRMS+=(frac[i0]-ptMean)*(frac[i0]-ptMean);}
626  ptRMS/=internalId_.nParticles_;
627  ptRMS=sqrt(ptRMS);
628 
629  internalId_.ptMean_ = ptMean;
630  internalId_.ptRMS_ = ptRMS/jetPt;
631  internalId_.pt2A_ = sqrt( internalId_.ptD_ /internalId_.nParticles_)/jetPt;
632  internalId_.ptD_ = sqrt( internalId_.ptD_) / sumPt;
633  internalId_.ptDCh_ = sqrt( internalId_.ptDCh_) / sumPtCh;
634  internalId_.ptDNe_ = sqrt( internalId_.ptDNe_) / sumPtNe;
635  internalId_.sumPt_ = sumPt;
636  internalId_.sumChPt_ = sumPtCh;
637  internalId_.sumNePt_ = sumPtNe;
638 
639  internalId_.jetR_ = lLead->pt()/sumPt;
640  internalId_.jetRchg_ = lLeadCh->pt()/sumPt;
641  internalId_.dRMatch_ = dRmin;
642 
643  if( sumTkPt != 0. ) {
644  internalId_.beta_ /= sumTkPt;
645  internalId_.betaStar_ /= sumTkPt;
646  internalId_.betaClassic_ /= sumTkPt;
647  internalId_.betaStarClassic_ /= sumTkPt;
648  } else {
649  assert( internalId_.beta_ == 0. && internalId_.betaStar_ == 0.&& internalId_.betaClassic_ == 0. && internalId_.betaStarClassic_ == 0. );
650  }
651 
652  if( runMvas_ ) {
653  runMva();
654  }
655 
657 }
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: Jet.h:624
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:142
float neutralEmEnergy() const
neutralEmEnergy
Definition: Jet.h:645
virtual double energy() const final
energy
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
virtual const Track * bestTrack() const
Definition: Candidate.h:247
virtual double pt() const =0
transverse momentum
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:160
assert(m_qm.get())
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: Jet.h:631
int neutralMultiplicity() const
neutralMultiplicity
Definition: Jet.h:418
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:155
const Point & position() const
position
Definition: Vertex.h:99
Jets made from PFObjects.
Definition: PFJet.h:21
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:150
float chargedEmEnergy() const
chargedEmEnergy
Definition: Jet.h:638
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
virtual const Track * bestTrack() const
best track pointer
Definition: Muon.h:61
virtual size_t numberOfDaughters() const
number of daughters
virtual CandidatePtr sourceCandidatePtr(size_type i) const
PileupJetIdentifier internalId_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
const PVAssoc fromPV(size_t ipv=0) const
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
virtual const reco::Track & pseudoTrack() const
Return reference to a pseudo track made with candidate kinematics, parameterized error for eta...
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
void assign(const std::vector< float > &vec, float &a, float &b, float &c, float &d)
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:73
virtual int charge() const =0
electric charge
virtual size_type numberOfSourceCandidatePtrs() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
T min(T a, T b)
Definition: MathUtil.h:58
virtual double mass() const final
mass
double ndof() const
Definition: Vertex.h:95
int neutralMultiplicity() const
neutralMultiplicity
Definition: PFJet.h:157
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:450
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:604
virtual int pdgId() const =0
PDG identifier.
void setPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi)
double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
bool isFake() const
Definition: Vertex.h:64
part
Definition: HCALResponse.h:20
Analysis-level calorimeter jet class.
Definition: Jet.h:78
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
virtual int nConstituents() const
of constituents
Definition: Jet.h:65
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:471
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:102
virtual double eta() const final
momentum pseudorapidity
int weight
Definition: histoStyle.py:50
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:586
Jet correctedJet(const std::string &level, const std::string &flavor="none", const std::string &set="") const
int chargedMultiplicity() const
chargedMultiplicity
Definition: Jet.h:659
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:98
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const final
transverse momentum
PileupJetIdentifier PileupJetIdAlgo::computeMva ( )

Definition at line 278 of file PileupJetIdAlgo.cc.

References internalId_, and runMva().

Referenced by PileupJetIdProducer::produce().

279 {
280  runMva();
282 }
PileupJetIdentifier internalId_
std::string PileupJetIdAlgo::dumpVariables ( ) const

Definition at line 662 of file PileupJetIdAlgo.cc.

References GenerateHcalLaserBadRunList::out, and variables_.

663 {
664  std::stringstream out;
665  for(variables_list_t::const_iterator it=variables_.begin();
666  it!=variables_.end(); ++it ) {
667  out << std::setw(15) << it->first << std::setw(3) << "="
668  << std::setw(5) << *it->second.first
669  << " (" << std::setw(5) << it->second.second << ")" << std::endl;
670  }
671  return out.str();
672 }
variables_list_t variables_
std::pair< int, int > PileupJetIdAlgo::getJetIdKey ( float  jetPt,
float  jetEta 
)

Definition at line 226 of file PileupJetIdAlgo.cc.

References funct::abs().

Referenced by computeCutIDflag(), and computeIDflag().

227 {
228  int ptId = 0;
229  if(jetPt >= 10 && jetPt < 20) ptId = 1;
230  if(jetPt >= 20 && jetPt < 30) ptId = 2;
231  if(jetPt >= 30 ) ptId = 3;
232 
233  int etaId = 0;
234  if(std::abs(jetEta) >= 2.5 && std::abs(jetEta) < 2.75) etaId = 1;
235  if(std::abs(jetEta) >= 2.75 && std::abs(jetEta) < 3.0 ) etaId = 2;
236  if(std::abs(jetEta) >= 3.0 && std::abs(jetEta) < 5.0 ) etaId = 3;
237 
238  return std::pair<int,int>(ptId,etaId);
239 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const variables_list_t& PileupJetIdAlgo::getVariables ( ) const
inline

const PileupJetIdentifier::variables_list_t & getVariables() const { return variables_; };

Definition at line 53 of file PileupJetIdAlgo.h.

References variables_.

53 { return variables_; };
variables_list_t variables_
void PileupJetIdAlgo::initVariables ( )
protected

Definition at line 690 of file PileupJetIdAlgo.cc.

References beta, PileupJetIdentifier::idFlag_, INIT_VARIABLE, internalId_, reco::btau::jetEta, reco::btau::jetPhi, reco::btau::jetPt, large_val, HLT_25ns10e33_v2_cff::mva, reco::tau::helpers::nCharged(), and rho.

Referenced by setup().

691 {
692  internalId_.idFlag_ = 0;
693  INIT_VARIABLE(mva , "", -100.);
694  //INIT_VARIABLE(jetPt , "jspt_1", 0.);
695  //INIT_VARIABLE(jetEta , "jseta_1", large_val);
696  INIT_VARIABLE(jetPt , "", 0.);
698  INIT_VARIABLE(jetPhi , "jsphi_1", large_val);
699  INIT_VARIABLE(jetM , "jm_1", 0.);
700 
701  INIT_VARIABLE(nCharged , "", 0.);
702  INIT_VARIABLE(nNeutrals , "", 0.);
703 
704  INIT_VARIABLE(chgEMfrac , "", 0.);
705  INIT_VARIABLE(neuEMfrac , "", 0.);
706  INIT_VARIABLE(chgHadrfrac, "", 0.);
707  INIT_VARIABLE(neuHadrfrac, "", 0.);
708 
709  INIT_VARIABLE(d0 , "jd0_1" , -1000.);
710  INIT_VARIABLE(dZ , "jdZ_1" , -1000.);
711  //INIT_VARIABLE(nParticles , "npart_1" , 0.);
712  INIT_VARIABLE(nParticles , "" , 0.);
713 
714  INIT_VARIABLE(leadPt , "lpt_1" , 0.);
715  INIT_VARIABLE(leadEta , "leta_1" , large_val);
716  INIT_VARIABLE(leadPhi , "lphi_1" , large_val);
717  INIT_VARIABLE(secondPt , "spt_1" , 0.);
718  INIT_VARIABLE(secondEta , "seta_1" , large_val);
719  INIT_VARIABLE(secondPhi , "sphi_1" , large_val);
720  INIT_VARIABLE(leadNeutPt , "lnept_1" , 0.);
721  INIT_VARIABLE(leadNeutEta, "lneeta_1" , large_val);
722  INIT_VARIABLE(leadNeutPhi, "lnephi_1" , large_val);
723  INIT_VARIABLE(leadEmPt , "lempt_1" , 0.);
724  INIT_VARIABLE(leadEmEta , "lemeta_1" , large_val);
725  INIT_VARIABLE(leadEmPhi , "lemphi_1" , large_val);
726  INIT_VARIABLE(leadChPt , "lchpt_1" , 0.);
727  INIT_VARIABLE(leadChEta , "lcheta_1" , large_val);
728  INIT_VARIABLE(leadChPhi , "lchphi_1" , large_val);
729  INIT_VARIABLE(leadFrac , "lLfr_1" , 0.);
730 
731  INIT_VARIABLE(dRLeadCent , "drlc_1" , 0.);
732  INIT_VARIABLE(dRLead2nd , "drls_1" , 0.);
733  INIT_VARIABLE(dRMean , "drm_1" , 0.);
734  INIT_VARIABLE(dRMean , "" , 0.);
735  INIT_VARIABLE(pull , "" , 0.);
736  INIT_VARIABLE(dRMeanNeut , "drmne_1" , 0.);
737  INIT_VARIABLE(dRMeanEm , "drem_1" , 0.);
738  INIT_VARIABLE(dRMeanCh , "drch_1" , 0.);
739  INIT_VARIABLE(dR2Mean , "" , 0.);
740 
741  INIT_VARIABLE(ptD , "", 0.);
742  INIT_VARIABLE(ptMean , "", 0.);
743  INIT_VARIABLE(ptRMS , "", 0.);
744  INIT_VARIABLE(pt2A , "", 0.);
745  INIT_VARIABLE(ptDCh , "", 0.);
746  INIT_VARIABLE(ptDNe , "", 0.);
747  INIT_VARIABLE(sumPt , "", 0.);
748  INIT_VARIABLE(sumChPt , "", 0.);
749  INIT_VARIABLE(sumNePt , "", 0.);
750 
751  INIT_VARIABLE(secondFrac ,"" ,0.);
752  INIT_VARIABLE(thirdFrac ,"" ,0.);
753  INIT_VARIABLE(fourthFrac ,"" ,0.);
754 
755  INIT_VARIABLE(leadChFrac ,"" ,0.);
756  INIT_VARIABLE(secondChFrac ,"" ,0.);
757  INIT_VARIABLE(thirdChFrac ,"" ,0.);
758  INIT_VARIABLE(fourthChFrac ,"" ,0.);
759 
760  INIT_VARIABLE(leadNeutFrac ,"" ,0.);
761  INIT_VARIABLE(secondNeutFrac ,"" ,0.);
762  INIT_VARIABLE(thirdNeutFrac ,"" ,0.);
763  INIT_VARIABLE(fourthNeutFrac ,"" ,0.);
764 
765  INIT_VARIABLE(leadEmFrac ,"" ,0.);
766  INIT_VARIABLE(secondEmFrac ,"" ,0.);
767  INIT_VARIABLE(thirdEmFrac ,"" ,0.);
768  INIT_VARIABLE(fourthEmFrac ,"" ,0.);
769 
770  INIT_VARIABLE(jetW ,"" ,1.);
771  INIT_VARIABLE(etaW ,"" ,1.);
772  INIT_VARIABLE(phiW ,"" ,1.);
773 
774  INIT_VARIABLE(majW ,"" ,1.);
775  INIT_VARIABLE(minW ,"" ,1.);
776 
777  INIT_VARIABLE(frac01 ,"" ,0.);
778  INIT_VARIABLE(frac02 ,"" ,0.);
779  INIT_VARIABLE(frac03 ,"" ,0.);
780  INIT_VARIABLE(frac04 ,"" ,0.);
781  INIT_VARIABLE(frac05 ,"" ,0.);
782  INIT_VARIABLE(frac06 ,"" ,0.);
783  INIT_VARIABLE(frac07 ,"" ,0.);
784 
785  INIT_VARIABLE(chFrac01 ,"" ,0.);
786  INIT_VARIABLE(chFrac02 ,"" ,0.);
787  INIT_VARIABLE(chFrac03 ,"" ,0.);
788  INIT_VARIABLE(chFrac04 ,"" ,0.);
789  INIT_VARIABLE(chFrac05 ,"" ,0.);
790  INIT_VARIABLE(chFrac06 ,"" ,0.);
791  INIT_VARIABLE(chFrac07 ,"" ,0.);
792 
793  INIT_VARIABLE(neutFrac01 ,"" ,0.);
794  INIT_VARIABLE(neutFrac02 ,"" ,0.);
795  INIT_VARIABLE(neutFrac03 ,"" ,0.);
796  INIT_VARIABLE(neutFrac04 ,"" ,0.);
797  INIT_VARIABLE(neutFrac05 ,"" ,0.);
798  INIT_VARIABLE(neutFrac06 ,"" ,0.);
799  INIT_VARIABLE(neutFrac07 ,"" ,0.);
800 
801  INIT_VARIABLE(emFrac01 ,"" ,0.);
802  INIT_VARIABLE(emFrac02 ,"" ,0.);
803  INIT_VARIABLE(emFrac03 ,"" ,0.);
804  INIT_VARIABLE(emFrac04 ,"" ,0.);
805  INIT_VARIABLE(emFrac05 ,"" ,0.);
806  INIT_VARIABLE(emFrac06 ,"" ,0.);
807  INIT_VARIABLE(emFrac07 ,"" ,0.);
808 
809  INIT_VARIABLE(beta ,"" ,0.);
810  INIT_VARIABLE(betaStar ,"" ,0.);
811  INIT_VARIABLE(betaClassic ,"" ,0.);
812  INIT_VARIABLE(betaStarClassic ,"" ,0.);
813 
814  INIT_VARIABLE(nvtx ,"" ,0.);
815  INIT_VARIABLE(rho ,"" ,0.);
816  INIT_VARIABLE(nTrueInt ,"" ,0.);
817 
818  INIT_VARIABLE(jetR , "", 0.);
819  INIT_VARIABLE(jetRchg , "", 0.);
820  INIT_VARIABLE(dRMatch , "", 0.);
821 
822 }
const double beta
#define INIT_VARIABLE(NAME, TMVANAME, VAL)
PileupJetIdentifier internalId_
unsigned int nCharged(const GenJet &jet)
const float large_val
Definition: MVAJetPuId.cc:14
const std::string PileupJetIdAlgo::method ( ) const
inline

Definition at line 41 of file PileupJetIdAlgo.h.

References tmvaMethod_.

41 { return tmvaMethod_; }
std::string tmvaMethod_
void PileupJetIdAlgo::resetVariables ( )
protected

Definition at line 675 of file PileupJetIdAlgo.cc.

References PileupJetIdentifier::idFlag_, internalId_, and variables_.

Referenced by computeIdVariables().

676 {
677  internalId_.idFlag_ = 0;
678  for(variables_list_t::iterator it=variables_.begin();
679  it!=variables_.end(); ++it ) {
680  *it->second.first = it->second.second;
681  }
682 }
PileupJetIdentifier internalId_
variables_list_t variables_
void PileupJetIdAlgo::runMva ( )
protected

Definition at line 198 of file PileupJetIdAlgo.cc.

References funct::abs(), computeCutIDflag(), computeIDflag(), cutBased_, etaBinnedWeights_, etaReader_, PileupJetIdentifier::idFlag_, internalId_, jEtaMax_, jEtaMin_, PileupJetIdentifier::mva_, nEtaBins_, reader_, tmvaMethod_, and findQualityFiles::v.

Referenced by computeIdVariables(), and computeMva().

199 {
200  if( cutBased_ ) {
201  internalId_.idFlag_ = computeCutIDflag(internalId_.betaStarClassic_,internalId_.dR2Mean_,internalId_.nvtx_,internalId_.jetPt_,internalId_.jetEta_);
202  } else {
203  if(std::abs(internalId_.jetEta_) >= 5.0) {
204  internalId_.mva_ = -2.;
205  } else {
206  if(etaBinnedWeights_){
207  if(std::abs(internalId_.jetEta_) > jEtaMax_.at(nEtaBins_-1)) {
208  internalId_.mva_ = -2.;
209  } else {
210  for(int v=0; v<nEtaBins_;v++){
211  if(std::abs(internalId_.jetEta_)>=jEtaMin_.at(v) && std::abs(internalId_.jetEta_)<jEtaMax_.at(v)){
212  internalId_.mva_ = etaReader_.at(v)->EvaluateMVA( tmvaMethod_.c_str() );
213  break;
214  }
215  }
216  }
217  } else {
218  internalId_.mva_ = reader_->EvaluateMVA( tmvaMethod_.c_str() );
219  }
220  }
222  }
223 }
std::string tmvaMethod_
std::vector< double > jEtaMin_
int computeCutIDflag(float betaStarClassic, float dR2Mean, float nvtx, float jetPt, float jetEta)
PileupJetIdentifier internalId_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int computeIDflag(float mva, float jetPt, float jetEta)
std::unique_ptr< TMVA::Reader > reader_
std::vector< double > jEtaMax_
std::vector< std::unique_ptr< TMVA::Reader > > etaReader_
void PileupJetIdAlgo::set ( const PileupJetIdentifier id)

Definition at line 192 of file PileupJetIdAlgo.cc.

References internalId_.

Referenced by PileupJetIdProducer::produce().

193 {
194  internalId_ = id;
195 }
PileupJetIdentifier internalId_
void PileupJetIdAlgo::setup ( void  )
protected

Definition at line 110 of file PileupJetIdAlgo.cc.

References assert(), bookReader(), cutBased_, initVariables(), runMvas_, tmvaEtaVariables_, tmvaMethod_, tmvaVariables_, USER, and version_.

Referenced by PileupJetIdAlgo().

111 {
112  initVariables();
113 
114  if( ! cutBased_ ){
115  assert( tmvaMethod_.empty() || ((! tmvaVariables_.empty() || ( !tmvaEtaVariables_.empty() )) && version_ == USER) );
116  }
117  if(( ! cutBased_ ) && (runMvas_)) { bookReader();}
118 }
std::vector< std::string > tmvaVariables_
assert(m_qm.get())
std::string tmvaMethod_
std::vector< std::vector< std::string > > tmvaEtaVariables_

Member Data Documentation

float PileupJetIdAlgo::betaStarCut_[3][4][4]
protected

Definition at line 86 of file PileupJetIdAlgo.h.

Referenced by computeCutIDflag(), and PileupJetIdAlgo().

bool PileupJetIdAlgo::cutBased_
protected

Definition at line 78 of file PileupJetIdAlgo.h.

Referenced by PileupJetIdAlgo(), runMva(), and setup().

bool PileupJetIdAlgo::etaBinnedWeights_
protected

Definition at line 79 of file PileupJetIdAlgo.h.

Referenced by bookReader(), PileupJetIdAlgo(), and runMva().

std::vector<std::unique_ptr<TMVA::Reader> > PileupJetIdAlgo::etaReader_
protected

Definition at line 68 of file PileupJetIdAlgo.h.

Referenced by bookReader(), and runMva().

float PileupJetIdAlgo::impactParTkThreshod_
protected

Definition at line 77 of file PileupJetIdAlgo.h.

Referenced by PileupJetIdAlgo().

PileupJetIdentifier PileupJetIdAlgo::internalId_
protected
std::vector<double> PileupJetIdAlgo::jEtaMax_
protected

Definition at line 82 of file PileupJetIdAlgo.h.

Referenced by PileupJetIdAlgo(), and runMva().

std::vector<double> PileupJetIdAlgo::jEtaMin_
protected

Definition at line 81 of file PileupJetIdAlgo.h.

Referenced by PileupJetIdAlgo(), and runMva().

float PileupJetIdAlgo::mvacut_[3][4][4]
protected

Definition at line 84 of file PileupJetIdAlgo.h.

Referenced by computeIDflag(), and PileupJetIdAlgo().

int PileupJetIdAlgo::nEtaBins_
protected

Definition at line 80 of file PileupJetIdAlgo.h.

Referenced by bookReader(), PileupJetIdAlgo(), and runMva().

std::unique_ptr<TMVA::Reader> PileupJetIdAlgo::reader_
protected

Definition at line 67 of file PileupJetIdAlgo.h.

Referenced by bookReader(), and runMva().

float PileupJetIdAlgo::rmsCut_[3][4][4]
protected

Definition at line 85 of file PileupJetIdAlgo.h.

Referenced by computeCutIDflag(), and PileupJetIdAlgo().

bool PileupJetIdAlgo::runMvas_
protected

Definition at line 83 of file PileupJetIdAlgo.h.

Referenced by computeIdVariables(), PileupJetIdAlgo(), and setup().

std::vector<std::vector<std::string> > PileupJetIdAlgo::tmvaEtaVariables_
protected

Definition at line 72 of file PileupJetIdAlgo.h.

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

std::vector<std::string> PileupJetIdAlgo::tmvaEtaWeights_
protected

Definition at line 70 of file PileupJetIdAlgo.h.

Referenced by bookReader(), and PileupJetIdAlgo().

std::string PileupJetIdAlgo::tmvaMethod_
protected

Definition at line 69 of file PileupJetIdAlgo.h.

Referenced by bookReader(), method(), PileupJetIdAlgo(), runMva(), and setup().

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

Definition at line 74 of file PileupJetIdAlgo.h.

Referenced by bookReader().

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

Definition at line 73 of file PileupJetIdAlgo.h.

Referenced by bookReader(), and PileupJetIdAlgo().

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

Definition at line 71 of file PileupJetIdAlgo.h.

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

std::string PileupJetIdAlgo::tmvaWeights_
protected

Definition at line 69 of file PileupJetIdAlgo.h.

Referenced by bookReader(), and PileupJetIdAlgo().

variables_list_t PileupJetIdAlgo::variables_
protected

Definition at line 65 of file PileupJetIdAlgo.h.

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

int PileupJetIdAlgo::version_
protected

Definition at line 76 of file PileupJetIdAlgo.h.

Referenced by PileupJetIdAlgo(), and setup().