Skip to content

Commit e193249

Browse files
committed
Modify NANOGEN to use autoNANO.
1 parent db3008e commit e193249

File tree

4 files changed

+54
-63
lines changed

4 files changed

+54
-63
lines changed

Configuration/Applications/python/ConfigBuilder.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,6 @@ def define_Configs(self):
10071007
self.RECOSIMDefaultCFF="Configuration/StandardSequences/RecoSim_cff"
10081008
self.PATDefaultCFF="Configuration/StandardSequences/PAT_cff"
10091009
self.NANODefaultCFF="PhysicsTools/NanoAOD/nano_cff"
1010-
self.NANOGENDefaultCFF="PhysicsTools/NanoAOD/nanogen_cff"
10111010
self.SKIMDefaultCFF="Configuration/StandardSequences/Skims_cff"
10121011
self.POSTRECODefaultCFF="Configuration/StandardSequences/PostRecoGenerator_cff"
10131012
self.VALIDATIONDefaultCFF="Configuration/StandardSequences/Validation_cff"
@@ -1057,7 +1056,6 @@ def define_Configs(self):
10571056
self.PATDefaultSeq='miniAOD'
10581057
self.PATGENDefaultSeq='miniGEN'
10591058
#TODO: Check based of file input
1060-
self.NANOGENDefaultSeq='nanogenSequence'
10611059
self.NANODefaultSeq='nanoSequence'
10621060
self.NANODefaultCustom='nanoAOD_customizeCommon'
10631061

@@ -1844,18 +1842,6 @@ def prepare_NANO(self, stepSpec = '' ):
18441842
self._options.customise_commands = self._options.customise_commands + " \n"
18451843
self._options.customise_commands = self._options.customise_commands + "process.unpackedPatTrigger.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n"
18461844

1847-
def prepare_NANOGEN(self, stepSpec = "nanoAOD"):
1848-
''' Enrich the schedule with NANOGEN '''
1849-
# TODO: Need to modify this based on the input file type
1850-
fromGen = any([x in self.stepMap for x in ['LHE', 'GEN', 'AOD']])
1851-
_,_nanogenSeq,_nanogenCff = self.loadDefaultOrSpecifiedCFF(stepSpec,self.NANOGENDefaultCFF)
1852-
self.scheduleSequence(_nanogenSeq,'nanoAOD_step')
1853-
custom = "customizeNanoGEN" if fromGen else "customizeNanoGENFromMini"
1854-
if self._options.runUnscheduled:
1855-
self._options.customisation_file_unsch.insert(0, '.'.join([_nanogenCff, custom]))
1856-
else:
1857-
self._options.customisation_file.insert(0, '.'.join([_nanogenCff, custom]))
1858-
18591845
def prepare_SKIM(self, stepSpec = "all"):
18601846
''' Enrich the schedule with skimming fragments'''
18611847
skimConfig,sequence,_ = self.loadDefaultOrSpecifiedCFF(stepSpec,self.SKIMDefaultCFF)

PhysicsTools/NanoAOD/python/NanoAODEDMEventContent_cff.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,3 @@
1919
compressionLevel = cms.untracked.int32(9),
2020
compressionAlgorithm = cms.untracked.string("LZMA"),
2121
)
22-
23-
NanoGenOutput = NanoAODEDMEventContent.outputCommands[:]
24-
NanoGenOutput.remove("keep edmTriggerResults_*_*_*")
25-
26-
NANOAODGENEventContent = cms.PSet(
27-
compressionLevel = cms.untracked.int32(9),
28-
compressionAlgorithm = cms.untracked.string("LZMA"),
29-
outputCommands = cms.untracked.vstring(NanoGenOutput)
30-
)
Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,76 @@
11
def expandNanoMapping(seqList, mapping, key):
2-
maxLevel=30
3-
level=0
4-
while '@' in repr(seqList) and level<maxLevel:
5-
level+=1
2+
maxLevel = 30
3+
level = 0
4+
while '@' in repr(seqList) and level < maxLevel:
5+
level += 1
66
for specifiedCommand in seqList:
77
if specifiedCommand.startswith('@'):
8-
location=specifiedCommand[1:]
8+
location = specifiedCommand[1:]
99
if not location in mapping:
10-
raise Exception("Impossible to map "+location+" from "+repr(mapping))
11-
mappedTo=mapping[location]
10+
raise Exception("Impossible to map " + location + " from " + repr(mapping))
11+
mappedTo = mapping[location]
1212
# no mapping for specified key
1313
# NOTE: mising key of key=None is interpreted differently than empty string:
1414
# - An empty string recalls the default for the given key
1515
# - None is interpreted as "ignore this"
16-
insertAt=seqList.index(specifiedCommand)
16+
insertAt = seqList.index(specifiedCommand)
1717
seqList.remove(specifiedCommand)
1818
if key in mappedTo and mappedTo[key] is not None:
19-
allToInsert=mappedTo[key].split('+')
20-
for offset,toInsert in enumerate(allToInsert):
21-
seqList.insert(insertAt+offset,toInsert)
22-
break;
23-
if level==maxLevel:
24-
raise Exception("Could not fully expand "+repr(seqList)+" from "+repr(mapping))
19+
allToInsert = mappedTo[key].split('+')
20+
for offset, toInsert in enumerate(allToInsert):
21+
seqList.insert(insertAt + offset, toInsert)
22+
break
23+
if level == maxLevel:
24+
raise Exception("Could not fully expand " + repr(seqList) + " from " + repr(mapping))
2525

2626

2727
autoNANO = {
2828
# PHYS is a mapping to the default NANO config, i.e. empty strings
2929
'PHYS': {'sequence': '',
3030
'customize': ''},
3131
# L1 flavours: add tables through customize, supposed to be combined with PHYS
32-
'L1' : {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomize'},
33-
'L1FULL' : {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull'},
34-
#scouting nano
35-
'Scout' : {'sequence': 'PhysicsTools/NanoAOD/custom_run3scouting_cff'},
36-
'JME' : { 'sequence': '@PHYS',
37-
'customize': '@PHYS+PhysicsTools/NanoAOD/custom_jme_cff.PrepJMECustomNanoAOD'},
38-
'JMErePuppi' : { 'sequence': '@PHYS',
39-
'customize': '@PHYS+@JME+PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET'},
32+
'L1': {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomize'},
33+
'L1FULL': {'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull'},
34+
# scouting nano
35+
'Scout': {'sequence': 'PhysicsTools/NanoAOD/custom_run3scouting_cff'},
36+
# JME nano
37+
'JME': {'sequence': '@PHYS',
38+
'customize': '@PHYS+PhysicsTools/NanoAOD/custom_jme_cff.PrepJMECustomNanoAOD'},
39+
'JMErePuppi': {'sequence': '@PHYS',
40+
'customize': '@PHYS+@JME+PhysicsTools/NanoAOD/custom_jme_cff.RecomputePuppiWeightsAndMET'},
4041
# L1 DPG (standalone with full calo TP info, L1T reemulation customization)
4142
'L1DPG' : {'sequence': 'DPGAnalysis/L1TNanoAOD/l1tNano_cff.l1tNanoSequence',
42-
'customize': 'PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull,DPGAnalysis/L1TNanoAOD/l1tNano_cff.addCaloFull,L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW'},
43+
'customize': ','.join(['PhysicsTools/NanoAOD/l1trig_cff.nanoL1TrigObjCustomizeFull',
44+
'DPGAnalysis/L1TNanoAOD/l1tNano_cff.addCaloFull',
45+
'L1Trigger/Configuration/customiseReEmul.L1TReEmulFromRAW'])},
4346
# Muon POG flavours : add tables through customize, supposed to be combined with PHYS
44-
'MUPOG' : {'sequence': '@PHYS',
45-
'customize' : '@PHYS+PhysicsTools/NanoAOD/custom_muon_cff.PrepMuonCustomNanoAOD'},
47+
'MUPOG': {'sequence': '@PHYS',
48+
'customize': '@PHYS+PhysicsTools/NanoAOD/custom_muon_cff.PrepMuonCustomNanoAOD'},
4649
# MUDPG flavours: use their own sequence
47-
'MUDPG' : {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoProducer',
48-
'customize': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoCustomize'},
49-
'MUDPGBKG' : {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoProducerBkg',
50-
'customize': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoBkgCustomize'},
51-
# HCAL favlours:
52-
'HCAL' : {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask'},
53-
'HCALCalib' : { 'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask',
54-
'customize': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.customiseHcalCalib'},
55-
#EGM flavours: add variables through customize
56-
'EGM' : {'sequence': '@PHYS',
57-
'customize' : '@PHYS+PhysicsTools/NanoAOD/egamma_custom_cff.addExtraEGammaVarsCustomize'},
50+
'MUDPG': {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoProducer',
51+
'customize': 'DPGAnalysis/MuonTools/muNtupleProducer_cff.muDPGNanoCustomize'},
52+
'MUDPGBKG': {'sequence': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoProducerBkg',
53+
'customize': 'DPGAnalysis/MuonTools/muNtupleProducerBkg_cff.muDPGNanoBkgCustomize'},
54+
# HCAL flavors:
55+
'HCAL': {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask'},
56+
'HCALCalib': {'sequence': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.hcalNanoTask',
57+
'customize': 'DPGAnalysis/HcalNanoAOD/hcalNano_cff.customiseHcalCalib'},
58+
# EGM flavours: add variables through customize
59+
'EGM': {'sequence': '@PHYS',
60+
'customize': '@PHYS+PhysicsTools/NanoAOD/egamma_custom_cff.addExtraEGammaVarsCustomize'},
5861
# PromptReco config: PHYS+L1
59-
'Prompt' : {'sequence': '@PHYS',
60-
'customize': '@PHYS+@L1'},
62+
'Prompt': {'sequence': '@PHYS',
63+
'customize': '@PHYS+@L1'},
6164
# Add lepton track parameters through customize combined with PHYS
6265
'LepTrackInfo' : {'sequence': '@PHYS',
6366
'customize': '@PHYS+PhysicsTools/NanoAOD/leptonTimeLifeInfo_common_cff.addTrackVarsToTimeLifeInfo'},
6467
# Custom BTV Nano for SF measurements or tagger training
65-
'BTV' : {'sequence': '@PHYS',
66-
'customize':'@PHYS+PhysicsTools/NanoAOD/custom_btv_cff.BTVCustomNanoAOD'}
68+
'BTV': {'sequence': '@PHYS',
69+
'customize': '@PHYS+PhysicsTools/NanoAOD/custom_btv_cff.BTVCustomNanoAOD'},
70+
# NANOGEN (from LHE/GEN/AOD)
71+
'GEN': {'sequence': 'PhysicsTools/NanoAOD/nanogen_cff.nanogenSequence',
72+
'customize': 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGEN'},
73+
# NANOGEN (from MiniAOD)
74+
'GENFromMini': {'sequence': 'PhysicsTools/NanoAOD/nanogen_cff.nanogenSequence',
75+
'customize': 'PhysicsTools/NanoAOD/nanogen_cff.customizeNanoGENFromMini'},
6776
}

PhysicsTools/NanoAOD/python/nanogen_cff.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def nanoGenCommonCustomize(process):
5757
setGenPhiPrecision(process, CandVars.phi.precision)
5858
setGenMassPrecision(process, CandVars.mass.precision)
5959

60+
for output in ("NANOEDMAODSIMoutput", "NANOAODSIMoutput"):
61+
if hasattr(process, output):
62+
getattr(process, output).outputCommands.append("drop edmTriggerResults_*_*_*")
63+
6064
def customizeNanoGENFromMini(process):
6165
process.nanogenSequence.insert(0, process.genParticles2HepMCHiggsVtx)
6266
process.nanogenSequence.insert(0, process.genParticles2HepMC)
@@ -71,6 +75,7 @@ def customizeNanoGENFromMini(process):
7175
process.genParticleTable.src = "prunedGenParticles"
7276
process.patJetPartonsNano.particles = "prunedGenParticles"
7377
process.particleLevel.src = "genParticles2HepMC:unsmeared"
78+
process.genIso.genPart = "prunedGenParticles"
7479

7580
process.genJetTable.src = "slimmedGenJets"
7681
process.genJetAK8Table.src = "slimmedGenJetsAK8"

0 commit comments

Comments
 (0)