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

Sub-event aware genJet and parton matching for HI miniAOD #31698

Merged
merged 10 commits into from
Oct 20, 2020
4 changes: 4 additions & 0 deletions Configuration/ProcessModifiers/python/genJetSubEvent_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import FWCore.ParameterSet.Config as cms

genJetSubEvent = cms.Modifier()

6 changes: 3 additions & 3 deletions Configuration/PyReleaseValidation/python/relval_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,14 @@
workflows[148] = ['',['HydjetQ_MinBias_XeXe_5442GeV_2017','DIGIHI2017','RECOHI2017','HARVESTHI2017']]
### Run II cond., 2018
workflows[150] = ['',['HydjetQ_B12_5020GeV_2018','DIGIHI2018','RECOHI2018','HARVESTHI2018']]
workflows[158] = ['',['HydjetQ_B12_5020GeV_2018_ppReco','DIGIHI2018PPRECO','RECOHI2018PPRECO','ALCARECOHI2018PPRECO','HARVESTHI2018PPRECO']]
workflows[158.01] = ['',['HydjetQ_reminiaodPbPb2018_INPUT','REMINIAODHI2018PPRECO','HARVESTHI2018PPRECOMINIAOD']]
workflows[158] = ['',['HydjetQ_B12_5020GeV_2018_ppReco','DIGIHI2018PPRECO','RECOHI2018PPRECOMB','ALCARECOHI2018PPRECO','HARVESTHI2018PPRECO']]
workflows[158.01] = ['',['HydjetQ_reminiaodPbPb2018_INPUT','REMINIAODHI2018PPRECOMB','HARVESTHI2018PPRECOMINIAOD']]
workflows[158.1] = ['',['QCD_Pt_80_120_13_HI','DIGIHI2018PPRECO','RECOHI2018PPRECO','HARVESTHI2018PPRECO']]
workflows[158.2] = ['',['PhotonJets_Pt_10_13_HI','DIGIHI2018PPRECO','RECOHI2018PPRECO','HARVESTHI2018PPRECO']]
workflows[158.3] = ['',['ZEEMM_13_HI','DIGIHI2018PPRECO','RECOHI2018PPRECO','HARVESTHI2018PPRECO']]
# 158.0 with multiple concurrent lumi sections
workflows[158.181] = ['',['HydjetQ_B12_5020GeV_2018_ppReco_ml','DIGIHI2018PPRECOml','RECOHI2018PPRECOml','ALCARECOHI2018PPRECOml','HARVESTHI2018PPRECO']]
workflows[159] = ['',['HydjetQ_B12_5020GeV_2021_ppReco','DIGIHI2021PPRECO','RECOHI2021PPRECO','ALCARECOHI2021PPRECO','HARVESTHI2021PPRECO']]
workflows[159] = ['',['HydjetQ_B12_5020GeV_2021_ppReco','DIGIHI2021PPRECO','RECOHI2021PPRECOMB','ALCARECOHI2021PPRECO','HARVESTHI2021PPRECO']]
workflows[159.1] = ['',['QCD_Pt_80_120_14_HI_2021','DIGIHI2021PPRECO','RECOHI2021PPRECO','HARVESTHI2021PPRECO']]
workflows[159.2] = ['',['PhotonJets_Pt_10_14_HI_2021','DIGIHI2021PPRECO','RECOHI2021PPRECO','HARVESTHI2021PPRECO']]
workflows[159.3] = ['',['ZMM_14_HI_2021','DIGIHI2021PPRECO','RECOHI2021PPRECO','HARVESTHI2021PPRECO']]
Expand Down
21 changes: 20 additions & 1 deletion Configuration/PyReleaseValidation/python/relval_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,12 @@ def gen2021HiMix(fragment,howMuch):
'--datatier':'GEN-SIM-RECO,MINIAODSIM,DQMIO',
'--eventcontent':'RECOSIM,MINIAODSIM,DQM',
},step3Up2015Defaults])
steps['RECOHI2021PPRECOMB']=merge([hiDefaults2021_ppReco,{'-s':'RAW2DIGI,L1Reco,RECO,EI,PAT,VALIDATION:@standardValidationNoHLT+@miniAODValidation,DQM:@standardDQMFakeHLT+@miniAODDQM',
'--datatier':'GEN-SIM-RECO,MINIAODSIM,DQMIO',
'--eventcontent':'RECOSIM,MINIAODSIM,DQM',
'--era':'Run3_pp_on_PbPb',
'--procModifiers':'genJetSubEvent',
},step3Up2015Defaults])

steps['ALCARECOHI2021PPRECO']=merge([hiDefaults2021_ppReco,{'-s':'ALCA:TkAlMinBias+SiStripCalMinBias',
'--datatier':'ALCARECO',
Expand All @@ -2484,13 +2490,26 @@ def gen2021HiMix(fragment,howMuch):
'--datatier':'GEN-SIM-RECO,MINIAODSIM,DQMIO,ALCARECO',
'--eventcontent':'RECOSIM,MINIAODSIM,DQM,ALCARECO',
},step3Up2015Defaults])
steps['RECOHI2018PPRECOml']=merge([concurrentLumis,steps['RECOHI2018PPRECO']])
steps['RECOHI2018PPRECOMB']=merge([hiDefaults2018_ppReco,{'-s':'RAW2DIGI,L1Reco,RECO,ALCA:SiStripCalZeroBias+SiPixelCalZeroBias,EI,PAT,VALIDATION:@standardValidationNoHLT+@miniAODValidation,DQM:@standardDQMFakeHLT+@miniAODDQM',
'--datatier':'GEN-SIM-RECO,MINIAODSIM,DQMIO,ALCARECO',
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
'--eventcontent':'RECOSIM,MINIAODSIM,DQM,ALCARECO',
'--era':'Run2_2018_pp_on_AA',
'--procModifiers':'genJetSubEvent',
},step3Up2015Defaults])
steps['RECOHI2018PPRECOml']=merge([concurrentLumis,steps['RECOHI2018PPRECOMB']])

steps['REMINIAODHI2018PPRECO']=merge([{'-s':'PAT,VALIDATION:@miniAODValidation,DQM:@miniAODDQM',
'--datatier':'MINIAODSIM,DQMIO',
'--eventcontent':'MINIAODSIM,DQM',
'-n':100,
},hiDefaults2018_ppReco,step3Up2015Defaults])
steps['REMINIAODHI2018PPRECOMB']=merge([{'-s':'PAT,VALIDATION:@miniAODValidation,DQM:@miniAODDQM',
'--datatier':'MINIAODSIM,DQMIO',
'--eventcontent':'MINIAODSIM,DQM',
'-n':100,
'--era':'Run2_2018_pp_on_AA',
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
'--procModifiers':'genJetSubEvent',
},hiDefaults2018_ppReco,step3Up2015Defaults])

steps['ALCARECOHI2018PPRECO']=merge([hiDefaults2018_ppReco,{'-s':'ALCA:TkAlMinBias+SiStripCalMinBias',
'--datatier':'ALCARECO',
Expand Down
3 changes: 2 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATGenJetSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ void pat::PATGenJetSlimmer::produce(edm::Event& iEvent, const edm::EventSetup& i
auto mapping = std::make_unique<std::vector<int> >();
mapping->reserve(src->size());

unsigned nm = 0; // number of mapped jets
unsigned nl = 0; // number of loose jets
for (View<reco::GenJet>::const_iterator it = src->begin(), ed = src->end(); it != ed; ++it) {
bool selectedLoose = false;
Expand All @@ -93,7 +94,7 @@ void pat::PATGenJetSlimmer::produce(edm::Event& iEvent, const edm::EventSetup& i
out->push_back(*it);
reco::GenJet& jet = out->back();

mapping->push_back(it - src->begin());
mapping->push_back(nm++);

if (clearDaughters_) {
jet.clearDaughters();
Expand Down
6 changes: 1 addition & 5 deletions PhysicsTools/PatAlgos/python/mcMatchLayer0/jetMatch_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@
from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
from Configuration.Eras.Modifier_pp_on_PbPb_run3_cff import pp_on_PbPb_run3
(pp_on_AA_2018 | pp_on_PbPb_run3).toModify(patJetGenJetMatch,
matched = 'ak4HiCleanedGenJets',
maxDeltaR = 0.4,
resolveByMatchQuality = True,
src = "akCs4PFJets",
)

(pp_on_AA_2018 | pp_on_PbPb_run3).toModify(patJetPartonMatch,
matched = "cleanedPartons",
src = "akCs4PFJets",
)
(pp_on_AA_2018 | pp_on_PbPb_run3).toModify(patJetPartonMatch, src = "akCs4PFJets")
Original file line number Diff line number Diff line change
@@ -1,29 +1,40 @@
import FWCore.ParameterSet.Config as cms

from RecoHI.HiJetAlgos.HiSignalParticleProducer_cfi import hiSignalGenParticles
from RecoJets.Configuration.GenJetParticles_cff import genParticlesForJets
from RecoHI.HiJetAlgos.HiGenCleaner_cff import hiPartons
from RecoHI.HiJetAlgos.HiGenJets_cff import ak4HiGenJets
from RecoHI.HiJetAlgos.HiGenCleaner_cff import heavyIonCleanedGenJets
from RecoHI.HiJetAlgos.HiSignalGenJetProducer_cfi import hiSignalGenJets

allPartons = cms.EDProducer(
"PartonSelector",
src = cms.InputTag('genParticles'),
src = cms.InputTag('hiSignalGenParticles'),
withLeptons = cms.bool(False),
)

from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
genJetSubEvent.toModify(allPartons,src = "genParticles")

cleanedPartons = hiPartons.clone(
src = 'allPartons',
)

ak4HiGenJetsCleaned = heavyIonCleanedGenJets.clone(src = "ak4HiGenJets")
ak4HiSignalGenJets = hiSignalGenJets.clone(src = "ak4HiGenJets")

cleanedGenJetsTask = cms.Task(
hiGenJetsTask = cms.Task(
hiSignalGenParticles,
genParticlesForJets,
cleanedPartons,
allPartons,
ak4HiGenJets,
ak4HiGenJetsCleaned
ak4HiSignalGenJets
)

ak4HiGenJetsCleaned = heavyIonCleanedGenJets.clone(src = "ak4HiGenJets")
hiCleanedGenJetsTask_ = hiGenJetsTask.copyAndExclude([hiSignalGenParticles,ak4HiSignalGenJets])
hiCleanedGenJetsTask_.add(cleanedPartons,ak4HiGenJetsCleaned)
genJetSubEvent.toReplaceWith(hiGenJetsTask,hiCleanedGenJetsTask_)

from RecoHI.HiJetAlgos.HiRecoPFJets_cff import PFTowers, pfEmptyCollection, ak4PFJetsForFlow, hiPuRho, hiFJRhoFlowModulation, akCs4PFJets
from RecoHI.HiTracking.highPurityGeneralTracks_cfi import highPurityGeneralTracks
from RecoJets.JetAssociationProducers.ak5JTA_cff import *
Expand Down Expand Up @@ -62,5 +73,5 @@
recoJetsHIpostAODTask = cms.Task(
recoPFJetsHIpostAODTask,
allPartons,
cleanedGenJetsTask,
hiGenJetsTask,
)
4 changes: 4 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/miniAOD_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ def miniAOD_customizeMC(process):
process.tauGenJetsBoosted.GenParticles = "prunedGenParticles"
process.patJetPartons.particles = "genParticles"
process.patJetPartonMatch.matched = "prunedGenParticles"
_hiGeneral.toModify(process.patJetPartonMatch, matched = "hiSignalGenParticles")
from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
genJetSubEvent.toModify(process.patJetPartonMatch, matched = "cleanedPartons")
process.patJetPartonMatch.mcStatus = [ 3, 23 ]
process.patJetGenJetMatch.matched = "slimmedGenJets"
(~_hiGeneral).toModify(process, patJetGenJetMatchAK8Puppi = dict(matched = "slimmedGenJetsAK8"))
Expand All @@ -603,6 +606,7 @@ def miniAOD_customizeMC(process):

from PhysicsTools.PatAlgos.producersHeavyIons.heavyIonJetSetup import removeJECsForMC
_hiGeneral.toModify(process, removeJECsForMC)
_hiGeneral.toReplaceWith(task,task.copyAndExclude([process.slimmedGenJetsFlavourInfos]))


def miniAOD_customizeOutput(out):
Expand Down
3 changes: 3 additions & 0 deletions PhysicsTools/PatAlgos/python/slimming/slimmedGenJets_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@

from Configuration.Eras.Modifier_pp_on_AA_2018_cff import pp_on_AA_2018
from Configuration.Eras.Modifier_pp_on_PbPb_run3_cff import pp_on_PbPb_run3
(pp_on_AA_2018 | pp_on_PbPb_run3).toModify(slimmedGenJets, src = "ak4HiSignalGenJets")
(pp_on_AA_2018 | pp_on_PbPb_run3).toModify(slimmedGenJetsAK8, cut = 'pt>9999', nLoose = 0)
from Configuration.ProcessModifiers.genJetSubEvent_cff import genJetSubEvent
genJetSubEvent.toModify(slimmedGenJets, src = "ak4HiGenJetsCleaned")
128 changes: 128 additions & 0 deletions RecoHI/HiJetAlgos/plugins/HiSignalGenJetProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// -*- C++ -*-
//
// Package: HiSignalGenJetProducer
// Class: HiSignalGenJetProducer
//
/**\class HiSignalGenJetProducer HiSignalGenJetProducer.cc yetkin/HiSignalGenJetProducer/src/HiSignalGenJetProducer.cc
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved

Description: <one line class summary>

Implementation:
<Notes on implementation>
*/
//
// Original Author: Yetkin Yilmaz
// Created: Tue Jul 21 04:26:01 EDT 2009
//
//

// system include files
#include <memory>
#include <vector>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/Common/interface/View.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"
#include "DataFormats/GeometryVector/interface/VectorUtil.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

#include "DataFormats/Math/interface/Point3D.h"
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
#include "DataFormats/Math/interface/LorentzVector.h"

using namespace std;
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
using namespace edm;

//
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
// class decleration
//

class HiSignalGenJetProducer : public edm::EDProducer {
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
public:
explicit HiSignalGenJetProducer(const edm::ParameterSet&);
~HiSignalGenJetProducer() override;
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved

private:
void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------

edm::EDGetTokenT<edm::View<reco::GenJet> > jetSrc_;
};

//
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//

HiSignalGenJetProducer::HiSignalGenJetProducer(const edm::ParameterSet& iConfig)
: jetSrc_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src"))) {
std::string alias = (iConfig.getParameter<InputTag>("src")).label();
produces<reco::GenJetCollection>().setBranchAlias(alias);
}

HiSignalGenJetProducer::~HiSignalGenJetProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}

//
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
// member functions
//

// ------------ method called to produce the data ------------

void HiSignalGenJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
using namespace reco;

auto jets = std::make_unique<GenJetCollection>();

edm::Handle<edm::View<GenJet> > genjets;
iEvent.getByToken(jetSrc_, genjets);

int jetsize = genjets->size();

vector<int> selection;
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
selection.reserve(jetsize);
for (int ijet = 0; ijet < jetsize; ++ijet) {
selection.push_back(-1);
}

vector<int> selectedIndices;
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
vector<int> removedIndices;
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved

for (int ijet = 0; ijet < jetsize; ++ijet) {
mandrenguyen marked this conversation as resolved.
Show resolved Hide resolved
const GenJet* jet1 = &((*genjets)[ijet]);

const GenParticle* gencon = jet1->getGenConstituent(0);

if (gencon == nullptr)
throw cms::Exception("GenConstituent", "GenJet is missing its constituents");
else if (gencon->collisionId() == 0) {
jets->push_back(*jet1);
selection[ijet] = 1;
} else {
selection[ijet] = 0;
removedIndices.push_back(ijet);
}
}

iEvent.put(std::move(jets));
}

DEFINE_FWK_MODULE(HiSignalGenJetProducer);
Loading