Skip to content

Commit a3c5795

Browse files
author
Christian Winter
committed
implement the era modifiers, for run2 only, the correct way
1 parent 36d2593 commit a3c5795

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

TauAnalysis/MCEmbeddingTools/python/customisers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Various set of customise functions needed for embedding
55
import FWCore.ParameterSet.Config as cms
66
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 ###########################
@@ -236,7 +237,11 @@ def __init__(
236237
)
237238

238239
# add some collections for run2
239-
run2_common.toModify(
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(
240245
to_bemanipulate,
241246
lambda l: l.extend(
242247
[
@@ -587,10 +592,7 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False):
587592

588593
#### Disable noise simulation ####
589594
# Castor was a detector in CMS till 2018.
590-
for i in to_bemanipulate:
591-
print(i.module_name)
592-
run2_common.toModify(process, lambda x: print("DAS ######################################", to_bemanipulate))
593-
run2_common.toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False)))
595+
(run2_common & ~run3_common).toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False)))
594596
process.mix.digitizers.ecal.doESNoise = cms.bool(False)
595597
process.mix.digitizers.ecal.doENoise = cms.bool(False)
596598

0 commit comments

Comments
 (0)