New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to jet pileup subtraction #29948
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
59a7068
move ParticleTowerProducer to plugins
stepobr f4d176c
fix pileup subtraction bug
stepobr a4a984d
calculateOrphanInput overwritten in plugin
stepobr d632591
add minimumTowersFraction to fillDescriptions
stepobr 2083ce9
quick update to move ParticleTowerProducer to plugins
stepobr 299c48a
small fixes
stepobr 501a13d
fix code and style checks issues
stepobr 4e180bd
Update RecoHI/HiJetAlgos/interface/MultipleAlgoIterator.h
stepobr 52ceb17
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.h
stepobr 198576b
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr e6aa240
Update RecoHI/HiJetAlgos/src/MultipleAlgoIterator.cc
stepobr b3f6205
Update RecoHI/HiJetAlgos/src/MultipleAlgoIterator.cc
stepobr eeeef32
Update RecoHI/HiJetAlgos/src/ParametrizedSubtractor.cc
stepobr 317bda7
Update RecoJets/JetProducers/src/PileUpSubtractor.cc
stepobr a7c45c7
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr 7b74388
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr 0fce04c
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr d50f116
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr d10d04c
Update RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc
stepobr 19624dc
Apply suggestions from code review
stepobr f6af73b
Merged pusubtraction_05_2020 from repository stepobr with cms-merge-t…
stepobr aa74a4f
apply suggestions
stepobr e7afc11
import PFTowers from cfi
stepobr add8df3
minor fixes and cleaning
stepobr e06ba5b
fix code check warnings
stepobr File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
// -*- C++ -*- | ||
// | ||
// Package: RecoHI/HiJetAlgos | ||
// Class: ParticleTowerProducer | ||
// | ||
/**\class ParticleTowerProducer RecoHI/HiJetAlgos/plugins/ParticleTowerProducer.cc | ||
Description: [one line class summary] | ||
Implementation: | ||
[Notes on implementation] | ||
*/ | ||
// | ||
// Original Author: Yetkin Yilmaz,32 4-A08,+41227673039, | ||
// Created: Thu Jan 20 19:53:58 CET 2011 | ||
// | ||
// | ||
|
||
#include "DataFormats/CaloTowers/interface/CaloTowerDefs.h" | ||
#include "DataFormats/CaloTowers/interface/CaloTowerDetId.h" | ||
#include "DataFormats/Candidate/interface/Particle.h" | ||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "DataFormats/Common/interface/SortedCollection.h" | ||
#include "DataFormats/GeometryVector/interface/GlobalPoint.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
#include "FWCore/Framework/src/WorkerMaker.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescriptionFiller.h" | ||
#include "DataFormats/Math/interface/deltaPhi.h" | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" | ||
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" | ||
#include "FWCore/Framework/interface/stream/EDProducer.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/Utilities/interface/EDGetToken.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
|
||
#include <cmath> | ||
#include <cstdlib> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
#include <utility> | ||
|
||
class ParticleTowerProducer : public edm::stream::EDProducer<> { | ||
public: | ||
explicit ParticleTowerProducer(const edm::ParameterSet&); | ||
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
||
private: | ||
void produce(edm::Event&, const edm::EventSetup&) override; | ||
int eta2ieta(double eta) const; | ||
int phi2iphi(double phi, int ieta) const; | ||
double ieta2eta(int ieta) const; | ||
double iphi2phi(int iphi, int ieta) const; | ||
// ----------member data --------------------------- | ||
|
||
edm::EDGetTokenT<reco::PFCandidateCollection> src_; | ||
const bool useHF_; | ||
|
||
// tower edges from fast sim, used starting at index 30 for the HF | ||
static constexpr int ietaMax = 42; | ||
static constexpr double etaedge[ietaMax] = { | ||
0.000, 0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609, 0.696, 0.783, 0.870, 0.957, 1.044, 1.131, | ||
1.218, 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650, | ||
2.853, 3.000, 3.139, 3.314, 3.489, 3.664, 3.839, 4.013, 4.191, 4.363, 4.538, 4.716, 4.889, 5.191}; | ||
}; | ||
// | ||
// constructors and destructor | ||
// | ||
ParticleTowerProducer::ParticleTowerProducer(const edm::ParameterSet& iConfig) | ||
: src_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("src"))), | ||
useHF_(iConfig.getParameter<bool>("useHF")) { | ||
produces<CaloTowerCollection>(); | ||
} | ||
|
||
// | ||
// member functions | ||
// | ||
|
||
// ------------ method called to produce the data ------------ | ||
void ParticleTowerProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
using namespace edm; | ||
|
||
typedef std::pair<int, int> EtaPhi; | ||
typedef std::map<EtaPhi, double> EtaPhiMap; | ||
EtaPhiMap towers_; | ||
towers_.clear(); | ||
|
||
auto const& inputs = iEvent.get(src_); | ||
for (auto const& particle : inputs) { | ||
double eta = particle.eta(); | ||
|
||
int ieta = eta2ieta(eta); | ||
int iphi = phi2iphi(particle.phi(), ieta); | ||
|
||
if (!useHF_ && abs(ieta) > 29) | ||
continue; | ||
|
||
EtaPhi ep(ieta, iphi); | ||
towers_[ep] += particle.et(); | ||
} | ||
|
||
auto prod = std::make_unique<CaloTowerCollection>(); | ||
prod->reserve(towers_.size()); | ||
for (auto const& tower : towers_) { | ||
EtaPhi ep = tower.first; | ||
double et = tower.second; | ||
|
||
int ieta = ep.first; | ||
int iphi = ep.second; | ||
|
||
CaloTowerDetId newTowerId(ieta, iphi); // totally dummy id | ||
|
||
// currently sets et = pt, mass to zero | ||
// pt, eta, phi, mass | ||
reco::Particle::PolarLorentzVector p4(et, ieta2eta(ieta), iphi2phi(iphi, ieta), 0.); | ||
GlobalPoint point(p4.x(), p4.y(), p4.z()); | ||
prod->emplace_back(newTowerId, p4.e(), 0, 0, 0, 0, p4, point, point); | ||
} | ||
|
||
iEvent.put(std::move(prod)); | ||
} | ||
|
||
// Taken from FastSimulation/CalorimeterProperties/src/HCALProperties.cc | ||
// Note this returns an abs(ieta) | ||
int ParticleTowerProducer::eta2ieta(double eta) const { | ||
// binary search in the array of towers eta edges | ||
|
||
int ieta = 0; | ||
while (fabs(eta) > etaedge[ieta] && ieta < ietaMax - 1) { | ||
++ieta; | ||
} | ||
|
||
if (eta < 0) | ||
ieta = -ieta; | ||
return ieta; | ||
} | ||
|
||
int ParticleTowerProducer::phi2iphi(double phi, int ieta) const { | ||
phi = angle0to2pi::make0To2pi(phi); | ||
int nphi = 72; | ||
int n = 1; | ||
if (abs(ieta) > 20) | ||
n = 2; | ||
if (abs(ieta) >= 40) | ||
n = 4; | ||
|
||
int iphi = (int)std::ceil(phi / 2.0 / M_PI * nphi / n); | ||
|
||
iphi = n * (iphi - 1) + 1; | ||
|
||
return iphi; | ||
} | ||
|
||
double ParticleTowerProducer::iphi2phi(int iphi, int ieta) const { | ||
double phi = 0; | ||
int nphi = 72; | ||
|
||
int n = 1; | ||
if (abs(ieta) > 20) | ||
n = 2; | ||
if (abs(ieta) >= 40) | ||
n = 4; | ||
|
||
int myphi = (iphi - 1) / n + 1; | ||
|
||
phi = 2. * M_PI * (myphi - 0.5) / nphi * n; | ||
while (phi > M_PI) | ||
phi -= 2. * M_PI; | ||
|
||
return phi; | ||
} | ||
|
||
double ParticleTowerProducer::ieta2eta(int ieta) const { | ||
int sign = 1; | ||
if (ieta < 0) { | ||
sign = -1; | ||
ieta = -ieta; | ||
} | ||
|
||
double eta = sign * (etaedge[ieta] + etaedge[ieta - 1]) / 2.; | ||
return eta; | ||
} | ||
|
||
void ParticleTowerProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
// particleTowerProducer | ||
edm::ParameterSetDescription desc; | ||
desc.add<edm::InputTag>("src", edm::InputTag("particleFlow")); | ||
desc.add<bool>("useHF", true); | ||
descriptions.add("particleTowerProducer", desc); | ||
} | ||
|
||
// define this as a plug-in | ||
DEFINE_FWK_MODULE(ParticleTowerProducer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why
positionAtECALEntrance
is not used here.Is the goal to map to iEta,iPhi simply to bin with momentum at IP, without actual goal of projecting to the formally the same and proper CaloTower ?
Please add a comment to clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the original idea was to make a 2D grid in the physical eta-phi space, i.e., using the direction of the particles from the PV. The idea of using a grid is basically to reuse the calorimetric style of background subtraction, approximating the same granularity to get the gross changes vs eta. There is some smearing due to the difference between the physical eta-phi, and the values at the calorimeter face. Perhaps there's a more precise way to do it, but the subtraction seems to work rather well with this hybrid method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying. Some comment inline in the code would help.
On technical performance side (speed) it probably means that some simpler indexing (even a flat rectangular grid in eta-phi) may work.
Remind me please where is this code expected to be running (to see if it can become CPU-limited)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the code is already running and has been for quite some time. It's used in akPu4PFJets, which we are writing to AOD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I thought that we do not have legacy modules running in reco anymore (ParticleTowerProducer is the legacy
edm::EDProducer
).Indeed, it's there, I found it in e.g. 140.55 in a test I have around from 11_1_0_pre7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slow to realize that this is in the HeavyIons scenario, while the later Run2 and Run3 plans are to run pp_on_AA setup.
Is there a plan to enable it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
akPu4PFJets was enabled for in the pp_on_AA setup for Run 2, so I believe this module was run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is on the subject of ParticleTowerProducer.cc (a producer by itself)
akPu4PFJets
is made by FastjetJetProducer with MultipleAlgoIteratorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input to Pu jets is PFTowers:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you.