Skip to content
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

PUPPI jets in RECO #28936

Merged
merged 57 commits into from Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
84d5245
Adding PUPPI weight to PFCandidate. Adding AK4Puppi to RECO by defaul…
rappoccio Sep 20, 2019
f66300b
Mistakingly didn't set the standard weights
rappoccio Jan 7, 2020
06c47ed
Addressing code review
rappoccio Jan 9, 2020
7cde892
Addressing review
rappoccio Jan 13, 2020
53ddf65
Merge branch 'master' into puppi_firstcircleofhell
rappoccio Jan 13, 2020
88b29b8
Code checks
rappoccio Jan 13, 2020
0e951d8
BTV fix for Puppi integration
emilbols Jan 23, 2020
294b34c
Merge pull request #4 from emilbols/BTV_LO_fix
rappoccio Jan 24, 2020
fbe06c1
Addressing most remaining issues from code review
rappoccio Jan 30, 2020
18c315a
store puppi weight in AOD as value map
ahinzmann Feb 11, 2020
54ec19b
fixes
ahinzmann Feb 11, 2020
47214ff
fix
ahinzmann Feb 12, 2020
af96089
fixes
ahinzmann Feb 12, 2020
d636797
fix
ahinzmann Feb 12, 2020
d969c1e
matrix fixes
ahinzmann Feb 12, 2020
a88f883
revert some
ahinzmann Feb 12, 2020
01f7656
revert HI
ahinzmann Feb 12, 2020
b650c9e
fix HI workflow
ahinzmann Feb 12, 2020
fbdabd2
code format
ahinzmann Feb 12, 2020
f1b8c2f
compute puppi jet id variables
ahinzmann Feb 13, 2020
468fc54
convert to int
ahinzmann Feb 13, 2020
6c65ae9
code format
ahinzmann Feb 13, 2020
19008ef
adapt jet clustering in MET
ahinzmann Feb 14, 2020
aa70e05
code format
ahinzmann Feb 14, 2020
7a02dd3
fix python3 error
ahinzmann Feb 14, 2020
9511a7f
remove inconsistencies for puppi in met tools
ahinzmann Feb 15, 2020
dee41bb
adapt njettiness
ahinzmann Feb 15, 2020
df0b3d5
code format
ahinzmann Feb 15, 2020
72387f2
fix python3 error
ahinzmann Feb 19, 2020
5399ed8
revert 80X change
ahinzmann Mar 3, 2020
f7808c2
remove space
ahinzmann Mar 3, 2020
912736d
puppi weight for softdrop
ahinzmann Mar 4, 2020
781fd5f
fix discrepancies in deepBoosted and ECF
ahinzmann Mar 4, 2020
f0567d8
resolve conflict with master
ahinzmann Mar 4, 2020
4ff85c1
round multiplicties
ahinzmann Mar 4, 2020
9788993
Merge branch 'master' into puppi_weight_in_aod
ahinzmann Mar 4, 2020
4999569
fix python 3 error
ahinzmann Mar 4, 2020
86e593b
Merge branch 'puppi_weight_in_aod' of https://github.com/ahinzmann/cm…
ahinzmann Mar 4, 2020
eb1ba06
fix doubleb
ahinzmann Mar 5, 2020
0ff64fa
add isWeighted
ahinzmann Mar 6, 2020
d6acc0b
introduce isWeighted in jet interface
ahinzmann Mar 6, 2020
946ed9b
code format
ahinzmann Mar 6, 2020
1cee3a9
fix jet tools
ahinzmann Mar 6, 2020
0c8c71e
initialize isweighted
ahinzmann Mar 7, 2020
050cb18
code format
ahinzmann Mar 7, 2020
f7bd780
merge
ahinzmann Mar 12, 2020
767c68e
remove handling of packed candidates
ahinzmann Mar 12, 2020
6854ca1
code format
ahinzmann Mar 12, 2020
30a1dac
python3
ahinzmann Mar 12, 2020
9390597
cast warning
ahinzmann Mar 12, 2020
7cd66c8
indentation
ahinzmann Mar 12, 2020
02ebd29
fix segfault
ahinzmann Mar 13, 2020
a3d9421
fix segfault and hlt config
ahinzmann Mar 14, 2020
ac708e1
Merge branch 'master' into puppi_weight_in_aod
ahinzmann Mar 14, 2020
fb71552
merge with master
ahinzmann Mar 14, 2020
76e2731
remove trackSelection desc
ahinzmann Mar 17, 2020
584aa25
add trackSelection
ahinzmann Mar 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 44 additions & 36 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.cc
Expand Up @@ -41,21 +41,22 @@ PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) {
tokenPFCandidates_ = consumes<CandidateView>(iConfig.getParameter<edm::InputTag>("candName"));
tokenVertices_ = consumes<VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexName"));

produces<edm::ValueMap<float>>();
produces<edm::ValueMap<LorentzVector>>();
produces<edm::ValueMap<reco::CandidatePtr>>();
ptokenPupOut_ = produces<edm::ValueMap<float>>();
ptokenP4PupOut_ = produces<edm::ValueMap<LorentzVector>>();
ptokenValues_ = produces<edm::ValueMap<reco::CandidatePtr>>();

if (fUseExistingWeights || fClonePackedCands)
produces<pat::PackedCandidateCollection>();
else
produces<reco::PFCandidateCollection>();
ptokenPackedPuppiCandidates_ = produces<pat::PackedCandidateCollection>();
else {
ptokenPuppiCandidates_ = produces<reco::PFCandidateCollection>();
}

if (fPuppiDiagnostics) {
produces<double>("PuppiNAlgos");
produces<std::vector<double>>("PuppiRawAlphas");
produces<std::vector<double>>("PuppiAlphas");
produces<std::vector<double>>("PuppiAlphasMed");
produces<std::vector<double>>("PuppiAlphasRms");
ptokenNalgos_ = produces<double>("PuppiNAlgos");
ptokenRawAlphas_ = produces<std::vector<double>>("PuppiRawAlphas");
ptokenAlphas_ = produces<std::vector<double>>("PuppiAlphas");
ptokenAlphasMed_ = produces<std::vector<double>>("PuppiAlphasMed");
ptokenAlphasRms_ = produces<std::vector<double>>("PuppiAlphasRms");
}
}
// ------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -238,8 +239,8 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
}

//Fill it into the event
std::unique_ptr<edm::ValueMap<float>> lPupOut(new edm::ValueMap<float>());
edm::ValueMap<float>::Filler lPupFiller(*lPupOut);
edm::ValueMap<float> lPupOut;
edm::ValueMap<float>::Filler lPupFiller(lPupOut);
lPupFiller.insert(hPFProduct, lWeights.begin(), lWeights.end());
lPupFiller.fill();

Expand All @@ -252,9 +253,10 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
// Since the size of the ValueMap must be equal to the input collection, we need
// to search the "puppi" particles to find a match for each input. If none is found,
// the input is set to have a four-vector of 0,0,0,0
fPuppiCandidates.reset(new PFOutputCollection);
fPackedPuppiCandidates.reset(new PackedOutputCollection);
std::unique_ptr<edm::ValueMap<LorentzVector>> p4PupOut(new edm::ValueMap<LorentzVector>());
PFOutputCollection fPuppiCandidates;
PackedOutputCollection fPackedPuppiCandidates;

edm::ValueMap<LorentzVector> p4PupOut;
LorentzVectorCollection puppiP4s;
std::vector<reco::CandidatePtr> values(hPFProduct->size());

Expand All @@ -263,6 +265,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
++iCand;
std::unique_ptr<pat::PackedCandidate> pCand;
std::unique_ptr<reco::PFCandidate> pfCand;

if (fUseExistingWeights || fClonePackedCands) {
const pat::PackedCandidate* cand = dynamic_cast<const pat::PackedCandidate*>(&aCand);
if (!cand)
Expand All @@ -274,6 +277,7 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
pfCand.reset(new reco::PFCandidate(cand ? *cand : reco::PFCandidate(aCand.charge(), aCand.p4(), id)));
}

// Here, we are using new weights computed and putting them in the packed candidates.
if (fClonePackedCands && (!fUseExistingWeights)) {
if (fPuppiForLeptons)
pCand->setPuppiWeight(pCand->puppiWeight(), lWeights[iCand]);
Expand All @@ -286,58 +290,62 @@ void PuppiProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
lWeights[iCand] * aCand.pz(),
lWeights[iCand] * aCand.energy());

// Here, we are using existing weights, or we're using packed candidates.
// That is, whether or not we recomputed the weights, we store the
// source candidate appropriately, and set the p4 of the packed candidate.
if (fUseExistingWeights || fClonePackedCands) {
pCand->setP4(puppiP4s.back());
pCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
fPackedPuppiCandidates->push_back(*pCand);
fPackedPuppiCandidates.push_back(*pCand);
} else {
pfCand->setP4(puppiP4s.back());
pfCand->setSourceCandidatePtr(aCand.sourceCandidatePtr(0));
fPuppiCandidates->push_back(*pfCand);
fPuppiCandidates.push_back(*pfCand);
}
}

//Compute the modified p4s
edm::ValueMap<LorentzVector>::Filler p4PupFiller(*p4PupOut);
edm::ValueMap<LorentzVector>::Filler p4PupFiller(p4PupOut);
p4PupFiller.insert(hPFProduct, puppiP4s.begin(), puppiP4s.end());
p4PupFiller.fill();

iEvent.put(std::move(lPupOut));
iEvent.put(std::move(p4PupOut));
iEvent.emplace(ptokenPupOut_, lPupOut);
iEvent.emplace(ptokenP4PupOut_, p4PupOut);
if (fUseExistingWeights || fClonePackedCands) {
edm::OrphanHandle<pat::PackedCandidateCollection> oh = iEvent.put(std::move(fPackedPuppiCandidates));
edm::OrphanHandle<pat::PackedCandidateCollection> oh =
iEvent.emplace(ptokenPackedPuppiCandidates_, fPackedPuppiCandidates);
for (unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
reco::CandidatePtr pkref(oh, ic);
values[ic] = pkref;
}
} else {
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.put(std::move(fPuppiCandidates));
edm::OrphanHandle<reco::PFCandidateCollection> oh = iEvent.emplace(ptokenPuppiCandidates_, fPuppiCandidates);
for (unsigned int ic = 0, nc = oh->size(); ic < nc; ++ic) {
reco::CandidatePtr pkref(oh, ic);
values[ic] = pkref;
}
}
std::unique_ptr<edm::ValueMap<reco::CandidatePtr>> pfMap_p(new edm::ValueMap<reco::CandidatePtr>());
edm::ValueMap<reco::CandidatePtr>::Filler filler(*pfMap_p);
edm::ValueMap<reco::CandidatePtr> pfMap_p;
edm::ValueMap<reco::CandidatePtr>::Filler filler(pfMap_p);
filler.insert(hPFProduct, values.begin(), values.end());
filler.fill();
iEvent.put(std::move(pfMap_p));
iEvent.emplace(ptokenValues_, pfMap_p);

//////////////////////////////////////////////
if (fPuppiDiagnostics && !fUseExistingWeights) {
// all the different alphas per particle
// THE alpha per particle
std::unique_ptr<std::vector<double>> theAlphas(new std::vector<double>(fPuppiContainer->puppiAlphas()));
std::unique_ptr<std::vector<double>> theAlphasMed(new std::vector<double>(fPuppiContainer->puppiAlphasMed()));
std::unique_ptr<std::vector<double>> theAlphasRms(new std::vector<double>(fPuppiContainer->puppiAlphasRMS()));
std::unique_ptr<std::vector<double>> alphas(new std::vector<double>(fPuppiContainer->puppiRawAlphas()));
std::unique_ptr<double> nalgos(new double(fPuppiContainer->puppiNAlgos()));
std::vector<double> theAlphas(fPuppiContainer->puppiAlphas());
std::vector<double> theAlphasMed(fPuppiContainer->puppiAlphasMed());
std::vector<double> theAlphasRms(fPuppiContainer->puppiAlphasRMS());
std::vector<double> alphas(fPuppiContainer->puppiRawAlphas());
double nalgos(fPuppiContainer->puppiNAlgos());

iEvent.put(std::move(alphas), "PuppiRawAlphas");
iEvent.put(std::move(nalgos), "PuppiNAlgos");
iEvent.put(std::move(theAlphas), "PuppiAlphas");
iEvent.put(std::move(theAlphasMed), "PuppiAlphasMed");
iEvent.put(std::move(theAlphasRms), "PuppiAlphasRms");
iEvent.emplace(ptokenRawAlphas_, alphas);
iEvent.emplace(ptokenNalgos_, nalgos);
iEvent.emplace(ptokenAlphas_, theAlphas);
iEvent.emplace(ptokenAlphasMed_, theAlphasMed);
iEvent.emplace(ptokenAlphasRms_, theAlphasRms);
}
}

Expand Down
15 changes: 13 additions & 2 deletions CommonTools/PileupAlgos/plugins/PuppiProducer.h
Expand Up @@ -42,6 +42,19 @@ class PuppiProducer : public edm::stream::EDProducer<> {

edm::EDGetTokenT<CandidateView> tokenPFCandidates_;
edm::EDGetTokenT<VertexCollection> tokenVertices_;
edm::EDGetTokenT<PuppiContainer> tokenPuppiContainer_;
edm::EDGetTokenT<PFOutputCollection> tokenPuppiCandidates_;
edm::EDGetTokenT<PackedOutputCollection> tokenPackedPuppiCandidates_;
edm::EDPutTokenT<edm::ValueMap<float>> ptokenPupOut_;
edm::EDPutTokenT<edm::ValueMap<LorentzVector>> ptokenP4PupOut_;
edm::EDPutTokenT<edm::ValueMap<reco::CandidatePtr>> ptokenValues_;
edm::EDPutTokenT<pat::PackedCandidateCollection> ptokenPackedPuppiCandidates_;
edm::EDPutTokenT<reco::PFCandidateCollection> ptokenPuppiCandidates_;
edm::EDPutTokenT<double> ptokenNalgos_;
edm::EDPutTokenT<std::vector<double>> ptokenRawAlphas_;
edm::EDPutTokenT<std::vector<double>> ptokenAlphas_;
edm::EDPutTokenT<std::vector<double>> ptokenAlphasMed_;
edm::EDPutTokenT<std::vector<double>> ptokenAlphasRms_;
std::string fPuppiName;
std::string fPFName;
std::string fPVName;
Expand All @@ -61,7 +74,5 @@ class PuppiProducer : public edm::stream::EDProducer<> {
double fVtxZCut;
std::unique_ptr<PuppiContainer> fPuppiContainer;
std::vector<RecoObj> fRecoObjCollection;
std::unique_ptr<PFOutputCollection> fPuppiCandidates;
std::unique_ptr<PackedOutputCollection> fPackedPuppiCandidates;
};
#endif
11 changes: 5 additions & 6 deletions DQM/Physics/python/B2GDQM_cfi.py
Expand Up @@ -13,10 +13,9 @@

jetLabels = cms.VInputTag(
'ak4PFJets',
'ak4PFJetsCHS',
'ak8PFJetsCHS',
'ak8PFJetsCHSSoftDrop',
'cmsTopTagPFJetsCHS'
'ak4PFJetsPuppi',
'ak8PFJetsPuppi',
'ak8PFJetsPuppiSoftDrop'
),
jetPtMins = cms.vdouble(
50.,
Expand All @@ -27,11 +26,11 @@
),
pfMETCollection = cms.InputTag("pfMet"),

cmsTagLabel = cms.InputTag("cmsTopTagPFJetsCHS"),
sdjetLabel = cms.InputTag("ak8PFJetsPuppiSoftDrop"),
muonSrc = cms.InputTag("muons"),
electronSrc = cms.InputTag("gedGsfElectrons"),

allHadPtCut = cms.double(400.0),
allHadPtCut = cms.double(380.0), # Edit in 2019: Lower pt cut slightly because this now selects groomed jet pt
allHadRapidityCut = cms.double(1.0),
allHadDeltaPhiCut = cms.double( pi / 2.0),

Expand Down
2 changes: 1 addition & 1 deletion DQM/Physics/python/ExoticaDQM_cfi.py
Expand Up @@ -19,7 +19,7 @@
pfJetCollection = cms.InputTag('ak4PFJetsCHS'),
jetCorrector = cms.InputTag('ak4PFL1FastL2L3Corrector'),

DiJetPFJetCollection = cms.VInputTag('ak4PFJetsCHS','ak8PFJetsCHS'),
DiJetPFJetCollection = cms.VInputTag('ak4PFJetsCHS','ak8PFJetsPuppi'),

caloMETCollection = cms.InputTag("caloMetM"),
pfMETCollection = cms.InputTag("pfMet"),
Expand Down