Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions CommonTools/RecoAlgos/plugins/JetDeltaRValueMapProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/Math/interface/deltaR.h"

template <class T, class C = T>
template <class T, class C = T, typename TN = float>
class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
public:
typedef edm::ValueMap<float> JetValueMap;
typedef TN value_type;
typedef edm::ValueMap<value_type> JetValueMap;
typedef std::vector<value_type> ValueVector;

JetDeltaRValueMapProducer(edm::ParameterSet const& params)
: srcToken_(consumes<typename edm::View<T> >(params.getParameter<edm::InputTag>("src"))),
Expand All @@ -46,8 +48,10 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
lazyParser_(params.existsAs<bool>("lazyParser") ? params.getParameter<bool>("lazyParser") : false),
multiValue_(false) {
if (!value_.empty()) {
evaluationMap_.insert(std::make_pair(
value_, std::unique_ptr<StringObjectFunction<C> >(new StringObjectFunction<C>(value_, lazyParser_))));
if (value_ != "index") {
evaluationMap_.insert(std::make_pair(
value_, std::unique_ptr<StringObjectFunction<C> >(new StringObjectFunction<C>(value_, lazyParser_))));
}
produces<JetValueMap>();
}

Expand Down Expand Up @@ -75,7 +79,8 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
edm::Handle<typename edm::View<C> > h_jets2;
iEvent.getByToken(matchedToken_, h_jets2);

std::vector<float> values(h_jets1->size(), -99999);
ValueVector values(h_jets1->size(), -99999);

std::map<std::string, std::vector<float> > valuesMap;
if (multiValue_) {
for (size_t i = 0; i < valueLabels_.size(); ++i)
Expand All @@ -88,19 +93,20 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
++ijet) {
float matched_dR2 = 1e9;
int matched_index = -1;
int iindex = ijet - ibegin;

for (typename edm::View<T>::const_iterator jbegin = h_jets1->begin(), jend = h_jets1->end(), jjet = jbegin;
jjet != jend;
++jjet) {
int index = jjet - jbegin;
int jindex = jjet - jbegin;

if (jets1_locks.at(index))
if (jets1_locks.at(jindex))
continue; // skip jets that have already been matched

float temp_dR2 = reco::deltaR2(ijet->eta(), ijet->phi(), jjet->eta(), jjet->phi());
if (temp_dR2 < matched_dR2) {
matched_dR2 = temp_dR2;
matched_index = index;
matched_index = jindex;
}
} // end loop over src jets

Expand All @@ -109,8 +115,13 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
edm::LogInfo("MatchedJetsFarApart") << "Matched jets separated by dR greater than distMax=" << distMax_;
else {
jets1_locks.at(matched_index) = true;
if (!value_.empty())
values.at(matched_index) = (*(evaluationMap_.at(value_)))(*ijet);
if (!value_.empty()) {
if (value_ == "index") {
values.at(matched_index) = iindex;
} else {
values.at(matched_index) = (*(evaluationMap_.at(value_)))(*ijet);
}
}
if (multiValue_) {
for (size_t i = 0; i < valueLabels_.size(); ++i)
valuesMap.at(valueLabels_[i]).at(matched_index) = (*(evaluationMap_.at(valueLabels_[i])))(*ijet);
Expand All @@ -122,7 +133,7 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
if (!value_.empty()) {
std::unique_ptr<JetValueMap> jetValueMap(new JetValueMap());

JetValueMap::Filler filler(*jetValueMap);
typename JetValueMap::Filler filler(*jetValueMap);
filler.insert(h_jets1, values.begin(), values.end());
filler.fill();

Expand All @@ -133,7 +144,7 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
for (size_t i = 0; i < valueLabels_.size(); ++i) {
std::unique_ptr<JetValueMap> jetValueMap(new JetValueMap());

JetValueMap::Filler filler(*jetValueMap);
typename JetValueMap::Filler filler(*jetValueMap);
filler.insert(h_jets1, valuesMap.at(valueLabels_[i]).begin(), valuesMap.at(valueLabels_[i]).end());
filler.fill();

Expand All @@ -157,7 +168,9 @@ class JetDeltaRValueMapProducer : public edm::stream::EDProducer<> {
typedef JetDeltaRValueMapProducer<reco::Jet> RecoJetDeltaRValueMapProducer;
typedef JetDeltaRValueMapProducer<reco::Jet, pat::Jet> RecoJetToPatJetDeltaRValueMapProducer;
typedef JetDeltaRValueMapProducer<pat::Jet> PatJetDeltaRValueMapProducer;
typedef JetDeltaRValueMapProducer<reco::Jet, reco::GenJet, int> RecoJetToGenJetDeltaRValueMapProducer;

DEFINE_FWK_MODULE(RecoJetDeltaRValueMapProducer);
DEFINE_FWK_MODULE(RecoJetToPatJetDeltaRValueMapProducer);
DEFINE_FWK_MODULE(PatJetDeltaRValueMapProducer);
DEFINE_FWK_MODULE(RecoJetToGenJetDeltaRValueMapProducer);
31 changes: 31 additions & 0 deletions Configuration/PyReleaseValidation/python/relval_nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ def subnext(self):
'--conditions':'auto:phase1_2022_realistic'},
_NANO_mc])

##13.X INPUT
steps['RunScoutingPFRun32022D13.X']={'INPUT':InputInfo(dataSet='/ScoutingPFRun3/Run2022D-v1/RAW',label='2022D',events=100000,location='STD', ls=Run2022D)}

steps['NANO_dataRun3ScoutingPF13.X']=merge([{'-s':'NANO:PhysicsTools/NanoAOD/custom_run3scouting_cff',
'--conditions':'auto:run3_data',
'-n':'10',
'--era' : 'Run3',
'--geometry' : 'DB:Extended',
'--datatier':'NANOAOD',
'--eventcontent':'NANOAOD'}])

steps['NANO_mcRun3ScoutingPF13.X']=merge([{'-s':'NANO:PhysicsTools/NanoAOD/custom_run3scouting_cff.nanoSequenceMC',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying here the comment of @vlimant in the original PR (that could even had been addressed here, since you are making a new PR):

I believe that the .nanoSequenceMC is not necessary, since --mc will have cmsDriver pick that one up automatically. We'll deal with this at a later stage during the NANO:@Scouting integration

'--conditions':'auto:phase1_2022_realistic',
'-n':'10',
'--mc':'',
'--era' : 'Run3',
'--geometry' : 'DB:Extended',
'--datatier':'NANOAOD',
'--eventcontent':'NANOAOD',
'--filein':'/store/mc/Run3Summer22MiniAODv3/BulkGravitonToHH_MX1120_MH121_TuneCP5_13p6TeV_madgraph-pythia8/MINIAODSIM/124X_mcRun3_2022_realistic_v12-v3/2810000/f9cdd76c-faac-4f24-bf0c-2496c8fffe54.root',
'--secondfilein':'/store/mc/Run3Summer22DRPremix/BulkGravitonToHH_MX1120_MH121_TuneCP5_13p6TeV_madgraph-pythia8/AODSIM/124X_mcRun3_2022_realistic_v12-v3/2810000/ab09fc5d-859c-407f-b7ce-74b0bae9bb96.root'}])

_wfn=WFN(2500)
################
#10.6 input
Expand Down Expand Up @@ -191,3 +213,12 @@ def subnext(self):
################
#13.2 workflows
workflows[_wfn()] = ['NANOmc132X', ['TTBarMINIAOD13.2', 'NANO_mc13.2', 'HRV_NANO_mc']]

_wfn.next()
################
#13.X workflows
workflows[_wfn()] = ['ScoutingNanodata13X',['RunScoutingPFRun32022D13.X', 'NANO_dataRun3ScoutingPF13.X']]
_wfn.subnext()
workflows[_wfn()] = ['ScoutingNanomc13X',['NANO_mcRun3ScoutingPF13.X']]

################
20 changes: 20 additions & 0 deletions PhysicsTools/NanoAOD/plugins/SimpleFlatTableProducerPlugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ typedef BXVectorSimpleFlatTableProducer<l1t::Muon> SimpleTriggerL1MuonFlatTableP
#include "DataFormats/L1Trigger/interface/EtSum.h"
typedef BXVectorSimpleFlatTableProducer<l1t::EtSum> SimpleTriggerL1EtSumFlatTableProducer;

#include "DataFormats/Scouting/interface/Run3ScoutingVertex.h"
typedef SimpleFlatTableProducer<Run3ScoutingVertex> SimpleRun3ScoutingVertexFlatTableProducer;

#include "DataFormats/Scouting/interface/Run3ScoutingPhoton.h"
typedef SimpleFlatTableProducer<Run3ScoutingPhoton> SimpleRun3ScoutingPhotonFlatTableProducer;

#include "DataFormats/Scouting/interface/Run3ScoutingMuon.h"
typedef SimpleFlatTableProducer<Run3ScoutingMuon> SimpleRun3ScoutingMuonFlatTableProducer;

#include "DataFormats/Scouting/interface/Run3ScoutingElectron.h"
typedef SimpleFlatTableProducer<Run3ScoutingElectron> SimpleRun3ScoutingElectronFlatTableProducer;

#include "DataFormats/Scouting/interface/Run3ScoutingTrack.h"
typedef SimpleFlatTableProducer<Run3ScoutingTrack> SimpleRun3ScoutingTrackFlatTableProducer;

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(SimpleCandidateFlatTableProducer);
DEFINE_FWK_MODULE(SimpleGenEventFlatTableProducer);
Expand All @@ -53,3 +68,8 @@ DEFINE_FWK_MODULE(SimpleTriggerL1JetFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1MuonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1TauFlatTableProducer);
DEFINE_FWK_MODULE(SimpleTriggerL1EtSumFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingVertexFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingPhotonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingMuonFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingElectronFlatTableProducer);
DEFINE_FWK_MODULE(SimpleRun3ScoutingTrackFlatTableProducer);
9 changes: 6 additions & 3 deletions PhysicsTools/NanoAOD/plugins/TriggerOutputBranches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ void TriggerOutputBranches::updateTriggerNames(TTree& tree,
for (unsigned int j = 0; j < newNames.size(); j++) {
std::string name = newNames[j]; // no const & as it will be modified below!
std::size_t vfound = name.rfind("_v");
if (vfound != std::string::npos && (name.compare(0, 3, "HLT") == 0 || name.compare(0, 2, "L1") == 0)) {
if (vfound != std::string::npos && (name.compare(0, 3, "HLT") == 0 || name.compare(0, 2, "L1") == 0 ||
name.find("Scouting") != std::string::npos)) {
name.replace(vfound, name.size() - vfound, "");
}
if (name == existing.name)
Expand All @@ -32,11 +33,13 @@ void TriggerOutputBranches::updateTriggerNames(TTree& tree,
for (unsigned int j = 0; j < newNames.size(); j++) {
std::string name = newNames[j]; // no const & as it will be modified below!
std::size_t vfound = name.rfind("_v");
if (vfound != std::string::npos && (name.compare(0, 3, "HLT") == 0 || name.compare(0, 2, "L1") == 0)) {
if (vfound != std::string::npos && (name.compare(0, 3, "HLT") == 0 || name.compare(0, 2, "L1") == 0 ||
name.find("Scouting") != std::string::npos)) {
name.replace(vfound, name.size() - vfound, "");
}
bool found = false;
if (name.compare(0, 3, "HLT") == 0 || name.compare(0, 4, "Flag") == 0 || name.compare(0, 2, "L1") == 0) {
if (name.compare(0, 3, "HLT") == 0 || name.compare(0, 4, "Flag") == 0 || name.compare(0, 2, "L1") == 0 ||
name.find("Scouting") != std::string::npos) {
for (auto& existing : m_triggerBranches) {
if (name == existing.name)
found = true;
Expand Down
41 changes: 41 additions & 0 deletions PhysicsTools/NanoAOD/python/custom_run3scouting_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import FWCore.ParameterSet.Config as cms
from PhysicsTools.NanoAOD.run3scouting_cff import *
from PhysicsTools.NanoAOD.globals_cff import puTable
from PhysicsTools.NanoAOD.triggerObjects_cff import unpackedPatTrigger, triggerObjectTable, l1bits
from L1Trigger.Configuration.L1TRawToDigi_cff import *
from EventFilter.L1TRawToDigi.gtStage2Digis_cfi import gtStage2Digis
from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
from PhysicsTools.PatAlgos.slimming.selectedPatTrigger_cfi import selectedPatTrigger
from PhysicsTools.PatAlgos.slimming.slimmedPatTrigger_cfi import slimmedPatTrigger

# common tasks
particleTask = cms.Task(scoutingPFCands)
particleTableTask = cms.Task(particleScoutingTable)
ak4JetTableTask = cms.Task(ak4ScoutingJets,ak4ScoutingJetParticleNetJetTagInfos,ak4ScoutingJetParticleNetJetTags,ak4ScoutingJetTable)
ak8JetTableTask = cms.Task(ak8ScoutingJets,ak8ScoutingJetsSoftDrop,ak8ScoutingJetsSoftDropMass,ak8ScoutingJetEcfNbeta1,ak8ScoutingJetNjettiness,ak8ScoutingJetParticleNetJetTagInfos,ak8ScoutingJetParticleNetJetTags,ak8ScoutingJetParticleNetMassRegressionJetTags,ak8ScoutingJetTable)

gtStage2DigisScouting = gtStage2Digis.clone(InputLabel="hltFEDSelectorL1")
l1bitsScouting = l1bits.clone(src="gtStage2DigisScouting")
patTriggerScouting = patTrigger.clone(l1tAlgBlkInputTag="gtStage2DigisScouting",l1tExtBlkInputTag="gtStage2DigisScouting")
selectedPatTriggerScouting = selectedPatTrigger.clone(src="patTriggerScouting")
slimmedPatTriggerScouting = slimmedPatTrigger.clone(src="selectedPatTriggerScouting")
unpackedPatTriggerScouting = unpackedPatTrigger.clone(patTriggerObjectsStandAlone="slimmedPatTriggerScouting")
triggerObjectTableScouting = triggerObjectTable.clone(src="unpackedPatTriggerScouting")

triggerTask = cms.Task(gtStage2DigisScouting,unpackedPatTriggerScouting,triggerObjectTableScouting,l1bitsScouting)
triggerSequence = cms.Sequence(L1TRawToDigi+patTriggerScouting+selectedPatTriggerScouting+slimmedPatTriggerScouting+cms.Sequence(triggerTask))

# MC tasks
genJetTask = cms.Task(ak4ScoutingJetMatchGen,ak4ScoutingJetExtTable,ak8ScoutingJetMatchGen,ak8ScoutingJetExtTable)
puTask = cms.Task(puTable)

nanoTableTaskCommon = cms.Task(photonScoutingTable,muonScoutingTable,electronScoutingTable,trackScoutingTable,primaryvertexScoutingTable,displacedvertexScoutingTable,rhoScoutingTable,metScoutingTable,particleTask,particleTableTask,ak4JetTableTask,ak8JetTableTask)

nanoSequenceCommon = cms.Sequence(triggerSequence,nanoTableTaskCommon)

nanoSequence = cms.Sequence(nanoSequenceCommon)

nanoSequenceMC = cms.Sequence(nanoSequenceCommon + cms.Sequence(cms.Task(genJetTask,puTask)))

def nanoAOD_customizeCommon(process):
return process
Loading