Skip to content

Commit afa07e5

Browse files
authored
Merge pull request #47299 from KIT-CMS/embedding_update_for_run3
Embedding update for run3
2 parents 365705a + a3c5795 commit afa07e5

File tree

4 files changed

+214
-79
lines changed

4 files changed

+214
-79
lines changed

TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
import FWCore.ParameterSet.Config as cms
2+
from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import (
3+
run2_HLTconditions_2016,
4+
)
5+
from Configuration.Eras.Modifier_run2_HLTconditions_2017_cff import (
6+
run2_HLTconditions_2017,
7+
)
8+
from Configuration.Eras.Modifier_run2_HLTconditions_2018_cff import (
9+
run2_HLTconditions_2018,
10+
)
211
from Configuration.StandardSequences.PAT_cff import *
3-
4-
from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import patMuons
512
from HLTrigger.HLTfilters.triggerResultsFilter_cfi import *
6-
from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import run2_HLTconditions_2016
13+
from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import patMuons
714

815
## Trigger requirements
916
doubleMuonHLTTrigger = cms.EDFilter("TriggerResultsFilter",
1017
hltResults = cms.InputTag("TriggerResults","","HLT"),
1118
l1tResults = cms.InputTag(""),
1219
throw = cms.bool(False),
13-
triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*") # from 2017 on (up to Run 3, it seems)
20+
triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_v*") # unprescaled trigger for 2018,22,23,24 (see https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLT2018, https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLT2022, https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLT2023, https://twiki.cern.ch/twiki/bin/view/CMS/MuonHLT2024)
1421
)
1522

23+
#### change the used triggers for run2 ####
24+
# Use two different triggers as the Mass8 one has a higer luminosity in 2017 according to https://cmshltinfo.app.cern.ch/summary?search=HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass&year=2017&paths=true&prescaled=true&stream-types=Physics
25+
# probably because he was already active in earlier runs than the Mass3p8 trigger
26+
# Both are unprescaled
27+
run2_HLTconditions_2017.toModify(doubleMuonHLTTrigger,
28+
triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*"])
29+
30+
# Both are unprescaled according to https://cmshltinfo.app.cern.ch/summary?search=HLT_Mu17_TrkIsoVVL_&year=2016&paths=true&prescaled=true&stream-types=Physics
1631
run2_HLTconditions_2016.toModify(doubleMuonHLTTrigger,
1732
triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ_v*"])
1833

TauAnalysis/MCEmbeddingTools/python/customisers.py

Lines changed: 62 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
# Various set of customise functions needed for embedding
55
import FWCore.ParameterSet.Config as cms
6-
6+
from Configuration.Eras.Modifier_run2_common_cff import run2_common
7+
from Configuration.Eras.Modifier_run3_common_cff import run3_common
78
from PhysicsTools.NanoAOD.common_cff import ExtVar
89

910
################################ Customizer for skimming ###########################
@@ -61,6 +62,7 @@ def __init__(
6162
module_name="generalTracks", manipulator_name="Track", steps=["SIM", "MERGE"]
6263
)
6364
)
65+
# needed by the PFLinker:particleFlow to create MuonProducer:muons
6466
to_bemanipulate.append(
6567
module_manipulate(
6668
module_name="cosmicsVetoTracksRaw", manipulator_name="Track", steps=["SIM", "MERGE"]
@@ -80,27 +82,15 @@ def __init__(
8082
steps=["SIM", "MERGE"],
8183
)
8284
)
83-
to_bemanipulate.append(
84-
module_manipulate(
85-
module_name="conversionStepTracks",
86-
manipulator_name="Track",
87-
steps=["SIM", "MERGE"],
88-
)
89-
)
85+
# This is needed by displacedMuonReducedTrackExtras which is specifically added in the merging_step
9086
to_bemanipulate.append(
9187
module_manipulate(
9288
module_name="displacedTracks",
9389
manipulator_name="Track",
9490
steps=["SIM", "MERGE"],
9591
)
9692
)
97-
to_bemanipulate.append(
98-
module_manipulate(
99-
module_name="ckfInOutTracksFromConversions",
100-
manipulator_name="Track",
101-
steps=["SIM", "MERGE"],
102-
)
103-
)
93+
# This is needed by the conversion producer which is run by the highlevelreco task
10494
to_bemanipulate.append(
10595
module_manipulate(
10696
module_name="ckfOutInTracksFromConversions",
@@ -114,6 +104,7 @@ def __init__(
114104
module_name="muons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"]
115105
)
116106
)
107+
# needed by MuIsoDepositCopyProducer/'muIsoDepositTkDisplaced'
117108
to_bemanipulate.append(
118109
module_manipulate(
119110
module_name="displacedMuons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"]
@@ -133,6 +124,7 @@ def __init__(
133124
steps=["SIM", "MERGE"],
134125
)
135126
)
127+
# needed by the PFLinker:particleFlow to create MuonProducer:muons
136128
to_bemanipulate.append(
137129
module_manipulate(
138130
module_name="particleFlowTmp",
@@ -155,25 +147,12 @@ def __init__(
155147
module_name="ecalDigis", manipulator_name="EcalSrFlag", steps=["SIM", "MERGE"]
156148
)
157149
)
150+
# this is needed by the HcalNoiseInfoProducer/'hcalnoise'
158151
to_bemanipulate.append(
159152
module_manipulate(
160153
module_name="hcalDigis", manipulator_name="HcalDigi", steps=["SIM", "MERGE"]
161154
)
162155
)
163-
to_bemanipulate.append(
164-
module_manipulate(
165-
module_name="electronMergedSeeds",
166-
manipulator_name="ElectronSeed",
167-
steps=["SIM", "MERGE"],
168-
)
169-
)
170-
to_bemanipulate.append(
171-
module_manipulate(
172-
module_name="ecalDrivenElectronSeeds",
173-
manipulator_name="EcalDrivenElectronSeed",
174-
steps=["SIM", "MERGE"],
175-
)
176-
)
177156

178157
to_bemanipulate.append(
179158
module_manipulate(
@@ -190,15 +169,9 @@ def __init__(
190169
)
191170
)
192171

193-
to_bemanipulate.append(
194-
module_manipulate(module_name="hbheprereco", manipulator_name="HBHERecHit")
195-
)
196172
to_bemanipulate.append(
197173
module_manipulate(module_name="hbhereco", manipulator_name="HBHERecHit")
198174
)
199-
to_bemanipulate.append(
200-
module_manipulate(module_name="zdcreco", manipulator_name="ZDCRecHit")
201-
)
202175

203176
to_bemanipulate.append(
204177
module_manipulate(module_name="horeco", manipulator_name="HORecHit")
@@ -263,6 +236,41 @@ def __init__(
263236
)
264237
)
265238

239+
# add some collections for run2
240+
# The era Modifier/ModifierChain is specified with the cmsDriver `--era` option or the cms.Process('NAME', era=...) constructor in the python config.
241+
# The `Modifier.toModify` method is executed if the Modifier is in the ModifierChain. (see https://github.com/cms-sw/cmssw/blob/master/FWCore/ParameterSet/python/Config.py#L1831)
242+
# The Run3 ModifierChain is based on the Run2 ModifierChain. Therefore the `run2_common` Modifier is included in both ModifierChains.
243+
# Those Modifiers allow bool operators to combine them. With `(run2_common & ~run3_common)` the `toModify` function is only executed if the era ModifierChain contains `run2_common` but not `run3_common`.
244+
(run2_common & ~run3_common).toModify(
245+
to_bemanipulate,
246+
lambda l: l.extend(
247+
[
248+
module_manipulate(
249+
module_name="conversionStepTracks",
250+
manipulator_name="Track",
251+
steps=["SIM", "MERGE"],
252+
),
253+
module_manipulate(
254+
module_name="ckfInOutTracksFromConversions",
255+
manipulator_name="Track",
256+
steps=["SIM", "MERGE"],
257+
),
258+
module_manipulate(
259+
module_name="electronMergedSeeds",
260+
manipulator_name="ElectronSeed",
261+
steps=["SIM", "MERGE"],
262+
),
263+
module_manipulate(
264+
module_name="ecalDrivenElectronSeeds",
265+
manipulator_name="EcalDrivenElectronSeed",
266+
steps=["SIM", "MERGE"],
267+
),
268+
module_manipulate(module_name="hbheprereco", manipulator_name="HBHERecHit"),
269+
module_manipulate(module_name="zdcreco", manipulator_name="ZDCRecHit"),
270+
]
271+
),
272+
)
273+
266274

267275
def modify_outputModules(process, keep_drop_list=[], module_veto_list=[]):
268276
outputModulesList = [key for key, value in process.outputModules.items()]
@@ -353,7 +361,7 @@ def keepCleaned(dataTier):
353361
"keep *_l1extraParticles_*_" + dataTier,
354362
"keep TrajectorySeeds_*_*_*",
355363
"keep recoElectronSeeds_*_*_*",
356-
"drop recoIsoDepositedmValueMap_muIsoDepositTk_*_*" ,
364+
"drop recoIsoDepositedmValueMap_muIsoDepositTk_*_*",
357365
"drop recoIsoDepositedmValueMap_muIsoDepositTkDisplaced_*_*",
358366
"drop *_ctppsProtons_*_*",
359367
"drop *_ctppsLocalTrackLiteProducer_*_*",
@@ -582,9 +590,9 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False):
582590
"Correcting Vertex in genEvent to one from input. Replaced 'VtxSmeared' with the Corrector."
583591
)
584592

585-
# Disable noise simulation
586-
process.mix.digitizers.castor.doNoise = cms.bool(False)
587-
593+
#### Disable noise simulation ####
594+
# Castor was a detector in CMS till 2018.
595+
(run2_common & ~run3_common).toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False)))
588596
process.mix.digitizers.ecal.doESNoise = cms.bool(False)
589597
process.mix.digitizers.ecal.doENoise = cms.bool(False)
590598

@@ -639,6 +647,18 @@ def customiseGenerator_HLT(process, changeProcessname=True, reselect=False):
639647
process.embeddingHltPixelVertices.clone()
640648
)
641649

650+
# Replace the original detector state filters in the HLT with a dummy module with 100% efficiency.
651+
# Those original filters have a efficiency of 0% for embedding samples.
652+
# This is due to the fact that the simulation of the tau decay happens in an empty detector.
653+
# For more info see https://github.com/cms-sw/cmssw/pull/47299#discussion_r1949023230
654+
process.hltPixelTrackerHVOn = cms.EDFilter("HLTBool",
655+
result = cms.bool(True)
656+
)
657+
658+
process.hltStripTrackerHVOn = cms.EDFilter("HLTBool",
659+
result = cms.bool(True)
660+
)
661+
642662
process = customisoptions(process)
643663
##process = fix_input_tags(process)
644664

@@ -801,12 +821,10 @@ def customiseMerging(process, changeProcessname=True, reselect=False):
801821

802822
print("**** Attention: overriding behaviour of 'removeMCMatching' ****")
803823

824+
import PhysicsTools.PatAlgos.tools.coreTools
804825
from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeMC
805-
def performMCMatching(process, names, postfix, outputModules):
806-
miniAOD_customizeMC(process)
807826

808-
import PhysicsTools.PatAlgos.tools.coreTools
809-
PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = performMCMatching
827+
PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = lambda process, names, postfix, outputModules : miniAOD_customizeMC(process)
810828

811829
if changeProcessname:
812830
process._Process__name = "MERGE"
@@ -893,42 +911,10 @@ def performMCMatching(process, names, postfix, outputModules):
893911
)
894912
process.dedxHitInfo.clusterShapeCache = cms.InputTag("")
895913

896-
# process.muons.FillDetectorBasedIsolation = cms.bool(False)
897-
# process.muons.FillSelectorMaps = cms.bool(False)
898-
# process.muons.FillShoweringInfo = cms.bool(False)
899-
# process.muons.FillCosmicsIdMap = cms.bool(False)
900-
901-
# process.displacedMuons.FillDetectorBasedIsolation = cms.bool(False)
902-
# process.displacedMuons.FillSelectorMaps = cms.bool(False)
903-
# process.displacedMuons.FillShoweringInfo = cms.bool(False)
904-
# process.displacedMuons.FillCosmicsIdMap = cms.bool(False)
905-
906-
# seed configuration needed for seedmerger
907-
#process.load(
908-
# "RecoEgamma.EgammaElectronProducers.ecalDrivenElectronSeedsParameters_cff"
909-
#)
910-
#process.ecalDrivenElectronSeeds.SeedConfiguration = cms.PSet(
911-
# process.ecalDrivenElectronSeedsParameters
912-
#)
913-
914914
process.merge_step += process.highlevelreco
915-
# process.merge_step.remove(process.reducedEcalRecHitsEE)
916-
# process.merge_step.remove(process.reducedEcalRecHitsEB)
917-
918-
# process.merge_step.remove(process.ak4JetTracksAssociatorExplicit)
919-
920-
# process.merge_step.remove(process.cosmicsVeto)
921-
# process.merge_step.remove(process.cosmicsVetoTrackCandidates)
922-
# process.merge_step.remove(process.ecalDrivenGsfElectronCores)
923-
# process.merge_step.remove(process.ecalDrivenGsfElectrons)
924-
# process.merge_step.remove(process.gedPhotonsTmp)
925-
# process.merge_step.remove(process.particleFlowTmp)
926-
927-
# process.merge_step.remove(process.hcalnoise)
928915

929916
process.load("CommonTools.ParticleFlow.genForPF2PAT_cff")
930917

931-
# process.muonsFromCosmics.ShowerDigiFillerParameters.dtDigiCollectionLabel = cms.InputTag("simMuonDTDigis")
932918

933919
process.merge_step += process.genForPF2PATSequence
934920

@@ -970,6 +956,7 @@ def performMCMatching(process, names, postfix, outputModules):
970956
if name in reconstruction_modules_list:
971957
modules_to_be_ordered[name] = reconstruction_modules_list.index(name)
972958
else:
959+
import sys
973960
print("ERROR:",name,"not prepared in modules list. Please adapt 'customiseMerging'")
974961
sys.exit(1)
975962

TauAnalysis/MCEmbeddingTools/test/BuildFile.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<test name="testTauEmbeddingWorkflow2016preVFP" command="run_2016postVFPUL_workflow_tests.sh"/>
33
<test name="testTauEmbeddingWorkflow2017" command="run_2017UL_workflow_tests.sh"/>
44
<test name="testTauEmbeddingWorkflow2018" command="run_2018UL_workflow_tests.sh"/>
5+
<test name="testTauEmbeddingWorkflow2022postEE" command="run_2022_workflow_tests.sh"/>
56

0 commit comments

Comments
 (0)