Skip to content

Commit

Permalink
Merge pull request cms-sw#20 from doanhien/AddEleIsoCal
Browse files Browse the repository at this point in the history
Add electron isolation calculation
  • Loading branch information
R. Alex Barbieri committed Nov 16, 2015
2 parents 3d7ab64 + 4e2afd2 commit 7edf4a4
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
8 changes: 8 additions & 0 deletions HeavyIonsAnalysis/PhotonAnalysis/interface/ggHiNtuplizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class ggHiNtuplizer : public edm::EDAnalyzer {
vector<float> eleTrkChi2_;
vector<float> eleTrkNdof_;
vector<float> eleTrkNormalizedChi2_;
vector<int> eleTrkValidHits_;
vector<int> eleTrkLayers_;
vector<float> elePt_;
vector<float> eleEta_;
vector<float> elePhi_;
Expand All @@ -139,6 +141,12 @@ class ggHiNtuplizer : public edm::EDAnalyzer {
vector<float> elePFPhoIso_;
vector<float> elePFNeuIso_;
vector<float> elePFPUIso_;
vector<float> elePFChIso03_;
vector<float> elePFPhoIso03_;
vector<float> elePFNeuIso03_;
vector<float> elePFChIso04_;
vector<float> elePFPhoIso04_;
vector<float> elePFNeuIso04_;
vector<float> eleBC1E_;
vector<float> eleBC1Eta_;
vector<float> eleBC2E_;
Expand Down
37 changes: 37 additions & 0 deletions HeavyIonsAnalysis/PhotonAnalysis/plugins/ggHiNtuplizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ ggHiNtuplizer::ggHiNtuplizer(const edm::ParameterSet& ps)
tree_->Branch("eleTrkChi2", &eleTrkChi2_);
tree_->Branch("eleTrkNdof", &eleTrkNdof_);
tree_->Branch("eleTrkNormalizedChi2", &eleTrkNormalizedChi2_);
tree_->Branch("eleTrkValidHits", &eleTrkValidHits_);
tree_->Branch("eleTrkLayers", &eleTrkLayers_);

tree_->Branch("elePt", &elePt_);
tree_->Branch("eleEta", &eleEta_);
Expand Down Expand Up @@ -122,6 +124,12 @@ ggHiNtuplizer::ggHiNtuplizer(const edm::ParameterSet& ps)
tree_->Branch("elePFPhoIso", &elePFPhoIso_);
tree_->Branch("elePFNeuIso", &elePFNeuIso_);
tree_->Branch("elePFPUIso", &elePFPUIso_);
tree_->Branch("elePFChIso03", &elePFChIso03_);
tree_->Branch("elePFPhoIso03", &elePFPhoIso03_);
tree_->Branch("elePFNeuIso03", &elePFNeuIso03_);
tree_->Branch("elePFChIso04", &elePFChIso04_);
tree_->Branch("elePFPhoIso04", &elePFPhoIso04_);
tree_->Branch("elePFNeuIso04", &elePFNeuIso04_);
tree_->Branch("eleBC1E", &eleBC1E_);
tree_->Branch("eleBC1Eta", &eleBC1Eta_);
tree_->Branch("eleBC2E", &eleBC2E_);
Expand Down Expand Up @@ -384,6 +392,8 @@ void ggHiNtuplizer::analyze(const edm::Event& e, const edm::EventSetup& es)
eleTrkChi2_ .clear();
eleTrkNdof_ .clear();
eleTrkNormalizedChi2_ .clear();
eleTrkValidHits_ .clear();
eleTrkLayers_ .clear();
elePt_ .clear();
eleEta_ .clear();
elePhi_ .clear();
Expand All @@ -410,6 +420,12 @@ void ggHiNtuplizer::analyze(const edm::Event& e, const edm::EventSetup& es)
elePFPhoIso_ .clear();
elePFNeuIso_ .clear();
elePFPUIso_ .clear();
elePFChIso03_ .clear();
elePFPhoIso03_ .clear();
elePFNeuIso03_ .clear();
elePFChIso04_ .clear();
elePFPhoIso04_ .clear();
elePFNeuIso04_ .clear();
eleBC1E_ .clear();
eleBC1Eta_ .clear();
eleBC2E_ .clear();
Expand Down Expand Up @@ -827,6 +843,8 @@ void ggHiNtuplizer::fillElectrons(const edm::Event& e, const edm::EventSetup& es
eleTrkChi2_ .push_back(ele->gsfTrack()->chi2());
eleTrkNdof_ .push_back(ele->gsfTrack()->ndof());
eleTrkNormalizedChi2_.push_back(ele->gsfTrack()->normalizedChi2());
eleTrkValidHits_ .push_back(ele->gsfTrack()->numberOfValidHits());
eleTrkLayers_ .push_back(ele->gsfTrack()->hitPattern().trackerLayersWithMeasurement());
elePt_ .push_back(ele->pt());
eleEta_ .push_back(ele->eta());
elePhi_ .push_back(ele->phi());
Expand Down Expand Up @@ -861,6 +879,25 @@ void ggHiNtuplizer::fillElectrons(const edm::Event& e, const edm::EventSetup& es
elePFNeuIso_ .push_back(pfIso.sumNeutralHadronEt);
elePFPUIso_ .push_back(pfIso.sumPUPt);

//calculation on-fly
pfIsoCalculator pfIsoCal(e,es, pfCollection_, voronoiBkgPF_, pv);
if (fabs(ele->superCluster()->eta()) > 1.566) {
elePFChIso03_ .push_back(pfIsoCal.getPfIso(*ele, 1, 0.3, 0.015, 0.));
elePFChIso04_ .push_back(pfIsoCal.getPfIso(*ele, 1, 0.4, 0.015, 0.));

elePFPhoIso03_ .push_back(pfIsoCal.getPfIso(*ele, 4, 0.3, 0.08, 0.));
elePFPhoIso04_ .push_back(pfIsoCal.getPfIso(*ele, 4, 0.4, 0.08, 0.));
}
else {
elePFChIso03_ .push_back(pfIsoCal.getPfIso(*ele, 1, 0.3, 0.0, 0.));
elePFChIso04_ .push_back(pfIsoCal.getPfIso(*ele, 1, 0.4, 0.0, 0.));
elePFPhoIso03_ .push_back(pfIsoCal.getPfIso(*ele, 4, 0.3, 0.0, 0.));
elePFPhoIso04_ .push_back(pfIsoCal.getPfIso(*ele, 4, 0.4, 0.0, 0.));
}

elePFNeuIso03_ .push_back(pfIsoCal.getPfIso(*ele, 5, 0.3, 0., 0.));
elePFNeuIso04_ .push_back(pfIsoCal.getPfIso(*ele, 5, 0.4, 0., 0.));

// seed
// eleBC1E_ .push_back(ele->superCluster()->seed()->energy());
// eleBC1Eta_ .push_back(ele->superCluster()->seed()->eta());
Expand Down
46 changes: 46 additions & 0 deletions HeavyIonsAnalysis/PhotonAnalysis/src/pfIsoCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,49 @@ double pfIsoCalculator::getVsPfIso(const reco::Photon& photon, int pfId, double

return TotalEt;
}

double pfIsoCalculator::getPfIso(const reco::GsfElectron& ele, int pfId, double r1, double r2, double threshold)
{

using namespace edm;
using namespace reco;

double eleEta = ele.eta();
double elePhi = ele.phi();
double TotalEt = 0.;

for (edm::View<reco::PFCandidate>::const_iterator pf = candidatesView->begin(); pf != candidatesView->end(); ++pf) {
if ( pf->particleId() != pfId ) continue;
double pfEta = pf->eta();
double pfPhi = pf->phi();

double dEta = fabs( eleEta - pfEta);
double dPhi = pfPhi - elePhi;
while ( fabs(dPhi) > PI) {
if ( dPhi > PI ) dPhi = dPhi - 2.*PI;
if ( dPhi < PI*(-1.) ) dPhi = dPhi + 2.*PI;
}
double dR = sqrt(dEta*dEta+dPhi*dPhi);
double thePt = pf->pt();

// remove electron itself
if (pf->particleId() == reco::PFCandidate::e) continue;

if (pf->particleId() == reco::PFCandidate::h) {
float dz = fabs(pf->vz() - vtx_.z());
if (dz > 0.2) continue;
double dxy = ( -(pf->vx() - vtx_.x())*pf->py() + (pf->vy() - vtx_.y())*pf->px()) / pf->pt();
if ( fabs(dxy) > 0.1) continue;
}

//inside the cone size
if (dR > r1) continue;
if (dR < r2) continue;
if (thePt < threshold) continue;
TotalEt += thePt;

}

return TotalEt;

}
1 change: 1 addition & 0 deletions HeavyIonsAnalysis/PhotonAnalysis/src/pfIsoCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class pfIsoCalculator
pfIsoCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetTokenT<edm::View<reco::PFCandidate> > pfCandidates, const edm::EDGetTokenT<edm::ValueMap<reco::VoronoiBackground> > pfVoronoiBkg, const math::XYZPoint& pv) ;
double getPfIso (const reco::Photon& photon, int pfId, double r1=0.4, double r2=0.00, double jWidth=0.00, double threshold=0);
double getVsPfIso(const reco::Photon& photon, int pfId, double r1=0.4, double r2=0.00, double jWidth=0.00, double threshold=0, bool isVsCorrected=true);
double getPfIso (const reco::GsfElectron& ele, int pfId, double r = 0.4, double r2=0.00, double threshold = 0);

private:
//const reco::PFCandidateCollection *pfCandidateColl;
Expand Down

0 comments on commit 7edf4a4

Please sign in to comment.