9 #include "TMatrixDSym.h"
10 #include "TMatrixDSymEigen.h"
32 for(
int i0 = 0; i0 < 3; i0++) {
38 for(
int i1 = 0; i1 < nCut; i1++) {
40 if(
cutBased_ && i1 == 0) lFullCutType =
"BetaStar"+ lCutType;
41 if(
cutBased_ && i1 == 1) lFullCutType =
"RMS" + lCutType;
42 std::vector<double> pt010 = jetConfig.
getParameter<std::vector<double> >((
"Pt010_" +lFullCutType).c_str());
43 std::vector<double> pt1020 = jetConfig.
getParameter<std::vector<double> >((
"Pt1020_"+lFullCutType).c_str());
44 std::vector<double> pt2030 = jetConfig.
getParameter<std::vector<double> >((
"Pt2030_"+lFullCutType).c_str());
45 std::vector<double> pt3050 = jetConfig.
getParameter<std::vector<double> >((
"Pt3050_"+lFullCutType).c_str());
47 for(
int i2 = 0; i2 < 4; i2++)
mvacut_[i0][0][i2] = pt010 [i2];
48 for(
int i2 = 0; i2 < 4; i2++)
mvacut_[i0][1][i2] = pt1020[i2];
49 for(
int i2 = 0; i2 < 4; i2++)
mvacut_[i0][2][i2] = pt2030[i2];
50 for(
int i2 = 0; i2 < 4; i2++)
mvacut_[i0][3][i2] = pt3050[i2];
53 for(
int i2 = 0; i2 < 4; i2++)
betaStarCut_[i0][0][i2] = pt010 [i2];
54 for(
int i2 = 0; i2 < 4; i2++)
betaStarCut_[i0][1][i2] = pt1020[i2];
55 for(
int i2 = 0; i2 < 4; i2++)
betaStarCut_[i0][2][i2] = pt2030[i2];
56 for(
int i2 = 0; i2 < 4; i2++)
betaStarCut_[i0][3][i2] = pt3050[i2];
59 for(
int i2 = 0; i2 < 4; i2++)
rmsCut_[i0][0][i2] = pt010 [i2];
60 for(
int i2 = 0; i2 < 4; i2++)
rmsCut_[i0][1][i2] = pt1020[i2];
61 for(
int i2 = 0; i2 < 4; i2++)
rmsCut_[i0][2][i2] = pt2030[i2];
62 for(
int i2 = 0; i2 < 4; i2++)
rmsCut_[i0][3][i2] = pt3050[i2];
74 Float_t impactParTkThreshod,
75 const std::vector<std::string> & tmvaVariables
172 void assign(
const std::vector<float> & vec,
float &
a,
float &
b,
float &
c,
float & d )
174 size_t sz = vec.size();
175 a = ( sz > 0 ? vec[0] : 0. );
176 b = ( sz > 1 ? vec[1] : 0. );
177 c = ( sz > 2 ? vec[2] : 0. );
178 d = ( sz > 3 ? vec[3] : 0. );
191 reader_ =
new TMVA::Reader(
"!Color:!Silent");
231 if(jetPt > 10 && jetPt < 20) ptId = 1;
232 if(jetPt > 20 && jetPt < 30) ptId = 2;
233 if(jetPt > 30 ) ptId = 3;
236 if(fabs(jetEta) > 2.5 && fabs(jetEta) < 2.75) etaId = 1;
237 if(fabs(jetEta) > 2.75 && fabs(jetEta) < 3.0 ) etaId = 2;
238 if(fabs(jetEta) > 3.0 && fabs(jetEta) < 5.0 ) etaId = 3;
240 return std::pair<int,int>(ptId,etaId);
245 std::pair<int,int> jetIdKey =
getJetIdKey(jetPt,jetEta);
246 float betaStarModified = betaStarClassic/
log(nvtx-0.64);
264 std::pair<int,int> jetIdKey =
getJetIdKey(jetPt,jetEta);
291 static int printWarning = 10;
292 typedef std::vector <reco::PFCandidatePtr> constituents_type;
293 typedef std::vector <reco::PFCandidatePtr>::iterator constituents_iterator;
312 std::vector<float>
frac, fracCh, fracEm, fracNeut;
313 float cones[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
314 size_t ncones =
sizeof(cones)/
sizeof(
float);
323 TMatrixDSym covMatrix(2); covMatrix = 0.;
327 float sumPt = 0., sumPt2 = 0., sumTkPt = 0.,sumPtCh=0,sumPtNe = 0;
332 for(constituents_iterator it=constituents.begin(); it!=constituents.end(); ++it) {
334 float candPt = icand->pt();
335 float candPtFrac = candPt/
jetPt;
337 float candDeta = fabs( (*it)->eta() - jet->
eta() );
339 float candPtDr = candPt * candDr;
340 size_t icone = std::lower_bound(&cones[0],&cones[ncones],candDr) - &cones[0];
343 if( lLead.
isNull() || candPt > lLead->pt() ) {
346 }
else if( (lSecond.
isNull() || candPt > lSecond->pt()) && (candPt < lLead->pt()) ) {
353 covMatrix(0,0) += candPt*candPt*candDeta*candDeta;
354 covMatrix(0,1) += candPt*candPt*candDeta*candDphi;
355 covMatrix(1,1) += candPt*candPt*candDphi*candDphi;
358 sumPt2 += candPt*candPt;
361 frac.push_back(candPtFrac);
362 if( icone < ncones ) { *coneFracs[icone] += candPt; }
366 if (lLeadNeut.
isNull() || candPt > lLeadNeut->pt()) { lLeadNeut = icand; }
368 fracNeut.push_back(candPtFrac);
369 if( icone < ncones ) { *coneNeutFracs[icone] += candPt; }
375 if(lLeadEm.
isNull() || candPt > lLeadEm->pt()) { lLeadEm = icand; }
377 fracEm.push_back(candPtFrac);
378 if( icone < ncones ) { *coneEmFracs[icone] += candPt; }
384 if (lLeadCh.
isNull() || candPt > lLeadCh->pt()) { lLeadCh = icand; }
387 fracCh.push_back(candPtFrac);
388 if( icone < ncones ) { *coneChFracs[icone] += candPt; }
394 float tkpt = icand->trackRef()->pt();
398 bool inAnyOther =
false;
400 double dZ0 = fabs(icand->trackRef()->dz(vtx->
position()));
402 for(reco::VertexCollection::const_iterator vi=allvtx.begin(); vi!=allvtx.end(); ++vi ) {
404 if( iv.
isFake() || iv.
ndof() < 4 ) {
continue; }
408 if( ! isVtx0 && ! inAnyOther ) {
415 if( inVtx0 && ! inAnyOther ) {
417 }
else if( ! inVtx0 && inAnyOther ) {
423 }
else if( dZ < 0.2 ) {
427 if(printWarning-- > 0) {
std::cerr << e << std::endl; }
431 if( lTrail.
isNull() || candPt < lTrail->pt() ) {
439 if ( lSecond.
isNull() ) { lSecond = lTrail; }
440 if ( lLeadNeut.
isNull() ) { lLeadNeut = lTrail; }
441 if ( lLeadEm.
isNull() ) { lLeadEm = lTrail; }
442 if ( lLeadCh.
isNull() ) { lLeadCh = lTrail; }
443 impactTrack = lLeadCh->trackRef();
456 if(printWarning-- > 0) {
std::cerr <<
"WARNING : did not find any valid track reference attached to the jet " << std::endl; }
466 std::sort(frac.begin(),frac.end(),std::greater<float>());
467 std::sort(fracCh.begin(),fracCh.end(),std::greater<float>());
468 std::sort(fracEm.begin(),fracEm.end(),std::greater<float>());
469 std::sort(fracNeut.begin(),fracNeut.end(),std::greater<float>());
475 covMatrix(0,0) /= sumPt2;
476 covMatrix(0,1) /= sumPt2;
477 covMatrix(1,1) /= sumPt2;
478 covMatrix(1,0) = covMatrix(0,1);
482 TVectorD eigVals(2); eigVals = TMatrixDSymEigen(covMatrix).GetEigenValues();
495 for(
size_t ic=0; ic<ncones; ++ic){
496 *coneFracs[ic] /=
jetPt;
497 *coneEmFracs[ic] /=
jetPt;
498 *coneNeutFracs[ic] /=
jetPt;
499 *coneChFracs[ic] /=
jetPt;
504 for(
unsigned int i0 = 0; i0 < frac.size(); i0++) {ptRMS+=(frac[i0]-ptMean)*(frac[i0]-ptMean);}
518 if( sumTkPt != 0. ) {
539 std::stringstream
out;
540 for(variables_list_t::const_iterator it=
variables_.begin();
542 out << std::setw(15) << it->first << std::setw(3) <<
"="
543 << std::setw(5) << *it->second.first
544 <<
" (" << std::setw(5) << it->second.second <<
")" << std::endl;
553 for(variables_list_t::iterator it=
variables_.begin();
555 *it->second.first = it->second.second;
560 #define INIT_VARIABLE(NAME,TMVANAME,VAL) \
561 internalId_.NAME ## _ = VAL; \
562 variables_[ # NAME ] = std::make_pair(& internalId_.NAME ## _, VAL);
virtual double energy() const GCC11_FINAL
energy
T getParameter(std::string const &) const
void set(const PileupJetIdentifier &)
Float_t impactParTkThreshod_
std::vector< std::string > tmvaVariables_
#define INIT_VARIABLE(NAME, TMVANAME, VAL)
float chargedEmEnergy() const
chargedEmEnergy
trackRef_iterator tracks_end() const
last iterator over tracks
virtual float eta() const =0
momentum pseudorapidity
Base class for all types of Jets.
std::pair< int, int > getJetIdKey(float jetPt, float jetEta)
std::map< std::string, std::string > tmvaNames_
virtual float phi() const =0
momentum azimuthal angle
std::vector< Vertex > VertexCollection
collection of Vertex objects
int computeCutIDflag(float betaStarClassic, float dR2Mean, float nvtx, float jetPt, float jetEta)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Float_t betaStarCut_[3][4][4]
int chargedMultiplicity() const
chargedMultiplicity
const Point & position() const
position
Jets made from PFObjects.
float neutralEmEnergy() const
neutralEmEnergy
bool isNonnull() const
Checks for non-null.
bool isNonnull() const
Checks for non-null.
virtual float pt() const =0
transverse momentum
const T & max(const T &a, const T &b)
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
PileupJetIdentifier internalId_
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::string dumpVariables() const
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void assign(const std::vector< float > &vec, float &a, float &b, float &c, float &d)
PileupJetIdentifier computeIdVariables(const reco::Jet *jet, float jec, const reco::Vertex *, const reco::VertexCollection &, bool calculateMva=false)
int computeIDflag(float mva, float jetPt, float jetEta)
int neutralMultiplicity() const
neutralMultiplicity
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
void setPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi)
double deltaPhi(double phi1, double phi2)
virtual float mass() const GCC11_FINAL
mass
unsigned int nCharged(const GenJet &jet)
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 >())
PileupJetIdentifier computeMva()
std::vector< std::string > tmvaSpectators_
bool isNull() const
Checks for null.
variables_list_t variables_
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
float neutralHadronEnergy() const
neutralHadronEnergy
std::string fullPath() const
trackRef_iterator tracks_begin() const
first iterator over tracks
virtual float pt() const GCC11_FINAL
transverse momentum
float chargedHadronEnergy() const
chargedHadronEnergy