From 193780181c88904304ce1fdbc2fcee7b6f75c4a9 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Wed, 2 Oct 2024 17:14:08 +0200 Subject: [PATCH 01/10] remove not necessary merging steps --- .../MCEmbeddingTools/python/customisers.py | 82 ++----------------- 1 file changed, 9 insertions(+), 73 deletions(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index 47f5d5d23fe05..b352c7a5554b8 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -3,7 +3,6 @@ # Various set of customise functions needed for embedding import FWCore.ParameterSet.Config as cms - from PhysicsTools.NanoAOD.common_cff import ExtVar ################################ Customizer for skimming ########################### @@ -61,6 +60,7 @@ def __init__( module_name="generalTracks", manipulator_name="Track", steps=["SIM", "MERGE"] ) ) +# needed by the PFLinker:particleFlow to create MuonProducer:muons to_bemanipulate.append( module_manipulate( module_name="cosmicsVetoTracksRaw", manipulator_name="Track", steps=["SIM", "MERGE"] @@ -80,13 +80,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) -to_bemanipulate.append( - module_manipulate( - module_name="conversionStepTracks", - manipulator_name="Track", - steps=["SIM", "MERGE"], - ) -) +# This is needed by displacedMuonReducedTrackExtras which is specifically added in the merging_step to_bemanipulate.append( module_manipulate( module_name="displacedTracks", @@ -94,13 +88,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) -to_bemanipulate.append( - module_manipulate( - module_name="ckfInOutTracksFromConversions", - manipulator_name="Track", - steps=["SIM", "MERGE"], - ) -) +# This is needed by the conversion producer which is run by the highlevelreco task to_bemanipulate.append( module_manipulate( module_name="ckfOutInTracksFromConversions", @@ -114,6 +102,7 @@ def __init__( module_name="muons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"] ) ) +# needed by MuIsoDepositCopyProducer/'muIsoDepositTkDisplaced' to_bemanipulate.append( module_manipulate( module_name="displacedMuons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"] @@ -133,6 +122,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) +# needed by the PFLinker:particleFlow to create MuonProducer:muons to_bemanipulate.append( module_manipulate( module_name="particleFlowTmp", @@ -155,25 +145,12 @@ def __init__( module_name="ecalDigis", manipulator_name="EcalSrFlag", steps=["SIM", "MERGE"] ) ) +# this is needed by the HcalNoiseInfoProducer/'hcalnoise' to_bemanipulate.append( module_manipulate( module_name="hcalDigis", manipulator_name="HcalDigi", steps=["SIM", "MERGE"] ) ) -to_bemanipulate.append( - module_manipulate( - module_name="electronMergedSeeds", - manipulator_name="ElectronSeed", - steps=["SIM", "MERGE"], - ) -) -to_bemanipulate.append( - module_manipulate( - module_name="ecalDrivenElectronSeeds", - manipulator_name="EcalDrivenElectronSeed", - steps=["SIM", "MERGE"], - ) -) to_bemanipulate.append( module_manipulate( @@ -190,15 +167,9 @@ def __init__( ) ) -to_bemanipulate.append( - module_manipulate(module_name="hbheprereco", manipulator_name="HBHERecHit") -) to_bemanipulate.append( module_manipulate(module_name="hbhereco", manipulator_name="HBHERecHit") ) -to_bemanipulate.append( - module_manipulate(module_name="zdcreco", manipulator_name="ZDCRecHit") -) to_bemanipulate.append( module_manipulate(module_name="horeco", manipulator_name="HORecHit") @@ -583,8 +554,6 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False): ) # Disable noise simulation - process.mix.digitizers.castor.doNoise = cms.bool(False) - process.mix.digitizers.ecal.doESNoise = cms.bool(False) process.mix.digitizers.ecal.doENoise = cms.bool(False) @@ -801,12 +770,10 @@ def customiseMerging(process, changeProcessname=True, reselect=False): print("**** Attention: overriding behaviour of 'removeMCMatching' ****") + import PhysicsTools.PatAlgos.tools.coreTools from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeMC - def performMCMatching(process, names, postfix, outputModules): - miniAOD_customizeMC(process) - import PhysicsTools.PatAlgos.tools.coreTools - PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = performMCMatching + PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = lambda process, names, postfix, outputModules : miniAOD_customizeMC(process) if changeProcessname: process._Process__name = "MERGE" @@ -893,42 +860,10 @@ def performMCMatching(process, names, postfix, outputModules): ) process.dedxHitInfo.clusterShapeCache = cms.InputTag("") - # process.muons.FillDetectorBasedIsolation = cms.bool(False) - # process.muons.FillSelectorMaps = cms.bool(False) - # process.muons.FillShoweringInfo = cms.bool(False) - # process.muons.FillCosmicsIdMap = cms.bool(False) - - # process.displacedMuons.FillDetectorBasedIsolation = cms.bool(False) - # process.displacedMuons.FillSelectorMaps = cms.bool(False) - # process.displacedMuons.FillShoweringInfo = cms.bool(False) - # process.displacedMuons.FillCosmicsIdMap = cms.bool(False) - - # seed configuration needed for seedmerger - #process.load( - # "RecoEgamma.EgammaElectronProducers.ecalDrivenElectronSeedsParameters_cff" - #) - #process.ecalDrivenElectronSeeds.SeedConfiguration = cms.PSet( - # process.ecalDrivenElectronSeedsParameters - #) - process.merge_step += process.highlevelreco - # process.merge_step.remove(process.reducedEcalRecHitsEE) - # process.merge_step.remove(process.reducedEcalRecHitsEB) - - # process.merge_step.remove(process.ak4JetTracksAssociatorExplicit) - - # process.merge_step.remove(process.cosmicsVeto) - # process.merge_step.remove(process.cosmicsVetoTrackCandidates) - # process.merge_step.remove(process.ecalDrivenGsfElectronCores) - # process.merge_step.remove(process.ecalDrivenGsfElectrons) - # process.merge_step.remove(process.gedPhotonsTmp) - # process.merge_step.remove(process.particleFlowTmp) - - # process.merge_step.remove(process.hcalnoise) process.load("CommonTools.ParticleFlow.genForPF2PAT_cff") - # process.muonsFromCosmics.ShowerDigiFillerParameters.dtDigiCollectionLabel = cms.InputTag("simMuonDTDigis") process.merge_step += process.genForPF2PATSequence @@ -970,6 +905,7 @@ def performMCMatching(process, names, postfix, outputModules): if name in reconstruction_modules_list: modules_to_be_ordered[name] = reconstruction_modules_list.index(name) else: + import sys print("ERROR:",name,"not prepared in modules list. Please adapt 'customiseMerging'") sys.exit(1) From 878160f7e0555fa14876d6da554f1d6d4c7973be Mon Sep 17 00:00:00 2001 From: Moritz Molch Date: Tue, 8 Oct 2024 18:17:46 +0200 Subject: [PATCH 02/10] Introduce dummy DetectorStateFilter for embedding, which is passed by each events --- .../MCEmbeddingTools/plugins/BuildFile.xml | 4 + .../plugins/EmbeddingDetectorStateFilter.cc | 109 ++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc diff --git a/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml b/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml index 0a5bb71cd687a..6dcc35285da79 100644 --- a/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml +++ b/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml @@ -2,6 +2,10 @@ + + + + diff --git a/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc b/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc new file mode 100644 index 0000000000000..2082dd5037136 --- /dev/null +++ b/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc @@ -0,0 +1,109 @@ +// -*- C++ -*- +// +// Package: TauAnalysis/MCEmbeddingTools +// Class: EmbeddingDetecorStateFilter +// +/**\class EmbeddingDetectorStateFilter EmbeddingDetectorStateFilter.cc TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc + + Description: Dummy implementation of the DetectorStateFilter class from DQM/TrackerCommon/plugins/DetectorStateFilter.cc + + Implementation: + [Notes on implementation] +*/ + +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/FEDRawData/interface/FEDNumbering.h" +#include "DataFormats/FEDRawData/interface/FEDRawData.h" +#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" +#include "DataFormats/Scalers/interface/DcsStatus.h" +#include "DataFormats/OnlineMetaData/interface/DCSRecord.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" + +#include // for std::is_same + + +class EmbeddingDetectorStateFilter : public edm::stream::EDFilter<> { +public: + EmbeddingDetectorStateFilter(const edm::ParameterSet&); + ~EmbeddingDetectorStateFilter() override; + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + +private: + bool filter(edm::Event&, edm::EventSetup const&) override; + + const bool verbose_; + uint64_t nEvents_, nSelectedEvents_; + bool detectorOn_; + const std::string detectorType_; + const std::vector combinations_; // Vector of strings specifying accepted combinations + const edm::EDGetTokenT dcsStatusLabel_; + const edm::EDGetTokenT dcsRecordToken_; +}; + + +/** + * Dummy implementation of the DetectorStateFilter class in DQM/TrackerCommon/plugins/DetectorStateFilter.cc. + * + * This implementation emulates the branch of the DetectorStateFilter class for MC events. Embedding events are data events, but the detector is simulated. This means that this module fails as the detector state of the simulated detector is tried to read out. This dummy implementation aims to mitigate the detector read-out so that this module, which is part of some HLT sequences, is passed. + */ +EmbeddingDetectorStateFilter::EmbeddingDetectorStateFilter(const edm::ParameterSet& pset) + : verbose_(pset.getUntrackedParameter("DebugOn", false)), + detectorType_(pset.getUntrackedParameter("DetectorType", "sistrip")), + combinations_(pset.getUntrackedParameter>("acceptedCombinations")), + dcsStatusLabel_(consumes( + pset.getUntrackedParameter("DcsStatusLabel", edm::InputTag("scalersRawToDigi")))), + dcsRecordToken_(consumes( + pset.getUntrackedParameter("DCSRecordLabel", edm::InputTag("onlineMetaDataDigis")))) { + nEvents_ = 0; + nSelectedEvents_ = 0; + detectorOn_ = false; +} + + +/** + * Destructor of the EmbeddingDetectorStateFilter class. + */ +EmbeddingDetectorStateFilter::~EmbeddingDetectorStateFilter() = default; + + +/** + * Dummy filter implementation, in which each event passes the filter. + */ +bool EmbeddingDetectorStateFilter::filter(edm::Event& evt, edm::EventSetup const& es) +{ + // implement the branch for MC events from the original DetectorStateFilter implementation + nEvents_++; + detectorOn_ = true; + nSelectedEvents_++; + if (verbose_) { + edm::LogInfo("DetectorStatusFilter") << "Total MC Events " << nEvents_ << " Selected Events " << nSelectedEvents_ + << " Detector States " << detectorOn_ << std::endl; + } + return detectorOn_; +} + + +/** + * Fill 'descriptions' with the allowed parameters for the module. + */ +void EmbeddingDetectorStateFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setComment("filters on the HV status of the Tracker (either pixels or strips)"); + desc.addUntracked("DebugOn", false)->setComment("activates debugging"); + desc.addUntracked("DetectorType", "sistrip")->setComment("either strips or pixels"); + desc.addUntracked>("acceptedCombinations", {}); + desc.addUntracked("DcsStatusLabel", edm::InputTag("scalersRawToDigi")) + ->setComment("event data for DCS (Run2)"); + desc.addUntracked("DCSRecordLabel", edm::InputTag("onlineMetaDataDigis")) + ->setComment("event data for DCS (Run3)"); + descriptions.add("_detectorStateFilter", desc); +} + + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(EmbeddingDetectorStateFilter); From a059d008f33bbff907293ea495c7366040059c89 Mon Sep 17 00:00:00 2001 From: Moritz Molch Date: Tue, 8 Oct 2024 18:18:30 +0200 Subject: [PATCH 03/10] Replace original DetectorStateFilter in HLT path with EmbeddingDetectorStateFilter during HLT step --- TauAnalysis/MCEmbeddingTools/python/customisers.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index b352c7a5554b8..cbaf355b9c337 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -608,6 +608,19 @@ def customiseGenerator_HLT(process, changeProcessname=True, reselect=False): process.embeddingHltPixelVertices.clone() ) + # replace the original detector state filters in the HLT with a dummy module + process.hltPixelTrackerHVOn = cms.EDFilter("EmbeddingDetectorStateFilter", + DcsStatusLabel = cms.untracked.InputTag("hltScalersRawToDigi"), + DebugOn = cms.untracked.bool(False), + DetectorType = cms.untracked.string('pixel') + ) + + process.hltStripTrackerHVOn = cms.EDFilter("EmbeddingDetectorStateFilter", + DcsStatusLabel = cms.untracked.InputTag("hltScalersRawToDigi"), + DebugOn = cms.untracked.bool(False), + DetectorType = cms.untracked.string('sistrip') + ) + process = customisoptions(process) ##process = fix_input_tags(process) From 24ff9bcd7648e73c19c6403f56b482e325b1392c Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Wed, 2 Oct 2024 17:14:08 +0200 Subject: [PATCH 04/10] remove not necessary merging steps --- .../MCEmbeddingTools/python/customisers.py | 82 ++----------------- 1 file changed, 9 insertions(+), 73 deletions(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index 47f5d5d23fe05..b352c7a5554b8 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -3,7 +3,6 @@ # Various set of customise functions needed for embedding import FWCore.ParameterSet.Config as cms - from PhysicsTools.NanoAOD.common_cff import ExtVar ################################ Customizer for skimming ########################### @@ -61,6 +60,7 @@ def __init__( module_name="generalTracks", manipulator_name="Track", steps=["SIM", "MERGE"] ) ) +# needed by the PFLinker:particleFlow to create MuonProducer:muons to_bemanipulate.append( module_manipulate( module_name="cosmicsVetoTracksRaw", manipulator_name="Track", steps=["SIM", "MERGE"] @@ -80,13 +80,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) -to_bemanipulate.append( - module_manipulate( - module_name="conversionStepTracks", - manipulator_name="Track", - steps=["SIM", "MERGE"], - ) -) +# This is needed by displacedMuonReducedTrackExtras which is specifically added in the merging_step to_bemanipulate.append( module_manipulate( module_name="displacedTracks", @@ -94,13 +88,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) -to_bemanipulate.append( - module_manipulate( - module_name="ckfInOutTracksFromConversions", - manipulator_name="Track", - steps=["SIM", "MERGE"], - ) -) +# This is needed by the conversion producer which is run by the highlevelreco task to_bemanipulate.append( module_manipulate( module_name="ckfOutInTracksFromConversions", @@ -114,6 +102,7 @@ def __init__( module_name="muons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"] ) ) +# needed by MuIsoDepositCopyProducer/'muIsoDepositTkDisplaced' to_bemanipulate.append( module_manipulate( module_name="displacedMuons1stStep", manipulator_name="Muon", steps=["SIM", "MERGE"] @@ -133,6 +122,7 @@ def __init__( steps=["SIM", "MERGE"], ) ) +# needed by the PFLinker:particleFlow to create MuonProducer:muons to_bemanipulate.append( module_manipulate( module_name="particleFlowTmp", @@ -155,25 +145,12 @@ def __init__( module_name="ecalDigis", manipulator_name="EcalSrFlag", steps=["SIM", "MERGE"] ) ) +# this is needed by the HcalNoiseInfoProducer/'hcalnoise' to_bemanipulate.append( module_manipulate( module_name="hcalDigis", manipulator_name="HcalDigi", steps=["SIM", "MERGE"] ) ) -to_bemanipulate.append( - module_manipulate( - module_name="electronMergedSeeds", - manipulator_name="ElectronSeed", - steps=["SIM", "MERGE"], - ) -) -to_bemanipulate.append( - module_manipulate( - module_name="ecalDrivenElectronSeeds", - manipulator_name="EcalDrivenElectronSeed", - steps=["SIM", "MERGE"], - ) -) to_bemanipulate.append( module_manipulate( @@ -190,15 +167,9 @@ def __init__( ) ) -to_bemanipulate.append( - module_manipulate(module_name="hbheprereco", manipulator_name="HBHERecHit") -) to_bemanipulate.append( module_manipulate(module_name="hbhereco", manipulator_name="HBHERecHit") ) -to_bemanipulate.append( - module_manipulate(module_name="zdcreco", manipulator_name="ZDCRecHit") -) to_bemanipulate.append( module_manipulate(module_name="horeco", manipulator_name="HORecHit") @@ -583,8 +554,6 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False): ) # Disable noise simulation - process.mix.digitizers.castor.doNoise = cms.bool(False) - process.mix.digitizers.ecal.doESNoise = cms.bool(False) process.mix.digitizers.ecal.doENoise = cms.bool(False) @@ -801,12 +770,10 @@ def customiseMerging(process, changeProcessname=True, reselect=False): print("**** Attention: overriding behaviour of 'removeMCMatching' ****") + import PhysicsTools.PatAlgos.tools.coreTools from PhysicsTools.PatAlgos.slimming.miniAOD_tools import miniAOD_customizeMC - def performMCMatching(process, names, postfix, outputModules): - miniAOD_customizeMC(process) - import PhysicsTools.PatAlgos.tools.coreTools - PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = performMCMatching + PhysicsTools.PatAlgos.tools.coreTools.removeMCMatching = lambda process, names, postfix, outputModules : miniAOD_customizeMC(process) if changeProcessname: process._Process__name = "MERGE" @@ -893,42 +860,10 @@ def performMCMatching(process, names, postfix, outputModules): ) process.dedxHitInfo.clusterShapeCache = cms.InputTag("") - # process.muons.FillDetectorBasedIsolation = cms.bool(False) - # process.muons.FillSelectorMaps = cms.bool(False) - # process.muons.FillShoweringInfo = cms.bool(False) - # process.muons.FillCosmicsIdMap = cms.bool(False) - - # process.displacedMuons.FillDetectorBasedIsolation = cms.bool(False) - # process.displacedMuons.FillSelectorMaps = cms.bool(False) - # process.displacedMuons.FillShoweringInfo = cms.bool(False) - # process.displacedMuons.FillCosmicsIdMap = cms.bool(False) - - # seed configuration needed for seedmerger - #process.load( - # "RecoEgamma.EgammaElectronProducers.ecalDrivenElectronSeedsParameters_cff" - #) - #process.ecalDrivenElectronSeeds.SeedConfiguration = cms.PSet( - # process.ecalDrivenElectronSeedsParameters - #) - process.merge_step += process.highlevelreco - # process.merge_step.remove(process.reducedEcalRecHitsEE) - # process.merge_step.remove(process.reducedEcalRecHitsEB) - - # process.merge_step.remove(process.ak4JetTracksAssociatorExplicit) - - # process.merge_step.remove(process.cosmicsVeto) - # process.merge_step.remove(process.cosmicsVetoTrackCandidates) - # process.merge_step.remove(process.ecalDrivenGsfElectronCores) - # process.merge_step.remove(process.ecalDrivenGsfElectrons) - # process.merge_step.remove(process.gedPhotonsTmp) - # process.merge_step.remove(process.particleFlowTmp) - - # process.merge_step.remove(process.hcalnoise) process.load("CommonTools.ParticleFlow.genForPF2PAT_cff") - # process.muonsFromCosmics.ShowerDigiFillerParameters.dtDigiCollectionLabel = cms.InputTag("simMuonDTDigis") process.merge_step += process.genForPF2PATSequence @@ -970,6 +905,7 @@ def performMCMatching(process, names, postfix, outputModules): if name in reconstruction_modules_list: modules_to_be_ordered[name] = reconstruction_modules_list.index(name) else: + import sys print("ERROR:",name,"not prepared in modules list. Please adapt 'customiseMerging'") sys.exit(1) From 69a3e805b68a88a726143aa5a823d4201d95abcd Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Fri, 7 Feb 2025 18:11:17 +0100 Subject: [PATCH 05/10] change muon HLT trigger in selection decission --- TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py index d142fd56a9f81..a883594a3b79e 100644 --- a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py +++ b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py @@ -10,7 +10,7 @@ hltResults = cms.InputTag("TriggerResults","","HLT"), l1tResults = cms.InputTag(""), throw = cms.bool(False), - 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) + triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*") # from 2017 on (up to Run 3, it seems) ) run2_HLTconditions_2016.toModify(doubleMuonHLTTrigger, From d27b7fe7117d7b7a83c2fe9c2ed0948b718c7abd Mon Sep 17 00:00:00 2001 From: moritzmolch Date: Mon, 10 Feb 2025 14:45:29 +0100 Subject: [PATCH 06/10] Simplify implementation of dummy detector state filters (#4) * Revert changes of commit 064da79 and replace detector state checks with simple 'True' filters * add a explaining comment --------- Co-authored-by: Chris Winter <44822168+winterchristian@users.noreply.github.com> --- .../MCEmbeddingTools/plugins/BuildFile.xml | 4 - .../plugins/EmbeddingDetectorStateFilter.cc | 109 ------------------ .../MCEmbeddingTools/python/customisers.py | 17 ++- 3 files changed, 8 insertions(+), 122 deletions(-) delete mode 100644 TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc diff --git a/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml b/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml index 6dcc35285da79..0a5bb71cd687a 100644 --- a/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml +++ b/TauAnalysis/MCEmbeddingTools/plugins/BuildFile.xml @@ -2,10 +2,6 @@ - - - - diff --git a/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc b/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc deleted file mode 100644 index 2082dd5037136..0000000000000 --- a/TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc +++ /dev/null @@ -1,109 +0,0 @@ -// -*- C++ -*- -// -// Package: TauAnalysis/MCEmbeddingTools -// Class: EmbeddingDetecorStateFilter -// -/**\class EmbeddingDetectorStateFilter EmbeddingDetectorStateFilter.cc TauAnalysis/MCEmbeddingTools/plugins/EmbeddingDetectorStateFilter.cc - - Description: Dummy implementation of the DetectorStateFilter class from DQM/TrackerCommon/plugins/DetectorStateFilter.cc - - Implementation: - [Notes on implementation] -*/ - -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/FEDRawData/interface/FEDNumbering.h" -#include "DataFormats/FEDRawData/interface/FEDRawData.h" -#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h" -#include "DataFormats/Scalers/interface/DcsStatus.h" -#include "DataFormats/OnlineMetaData/interface/DCSRecord.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/stream/EDFilter.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" -#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" - -#include // for std::is_same - - -class EmbeddingDetectorStateFilter : public edm::stream::EDFilter<> { -public: - EmbeddingDetectorStateFilter(const edm::ParameterSet&); - ~EmbeddingDetectorStateFilter() override; - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - -private: - bool filter(edm::Event&, edm::EventSetup const&) override; - - const bool verbose_; - uint64_t nEvents_, nSelectedEvents_; - bool detectorOn_; - const std::string detectorType_; - const std::vector combinations_; // Vector of strings specifying accepted combinations - const edm::EDGetTokenT dcsStatusLabel_; - const edm::EDGetTokenT dcsRecordToken_; -}; - - -/** - * Dummy implementation of the DetectorStateFilter class in DQM/TrackerCommon/plugins/DetectorStateFilter.cc. - * - * This implementation emulates the branch of the DetectorStateFilter class for MC events. Embedding events are data events, but the detector is simulated. This means that this module fails as the detector state of the simulated detector is tried to read out. This dummy implementation aims to mitigate the detector read-out so that this module, which is part of some HLT sequences, is passed. - */ -EmbeddingDetectorStateFilter::EmbeddingDetectorStateFilter(const edm::ParameterSet& pset) - : verbose_(pset.getUntrackedParameter("DebugOn", false)), - detectorType_(pset.getUntrackedParameter("DetectorType", "sistrip")), - combinations_(pset.getUntrackedParameter>("acceptedCombinations")), - dcsStatusLabel_(consumes( - pset.getUntrackedParameter("DcsStatusLabel", edm::InputTag("scalersRawToDigi")))), - dcsRecordToken_(consumes( - pset.getUntrackedParameter("DCSRecordLabel", edm::InputTag("onlineMetaDataDigis")))) { - nEvents_ = 0; - nSelectedEvents_ = 0; - detectorOn_ = false; -} - - -/** - * Destructor of the EmbeddingDetectorStateFilter class. - */ -EmbeddingDetectorStateFilter::~EmbeddingDetectorStateFilter() = default; - - -/** - * Dummy filter implementation, in which each event passes the filter. - */ -bool EmbeddingDetectorStateFilter::filter(edm::Event& evt, edm::EventSetup const& es) -{ - // implement the branch for MC events from the original DetectorStateFilter implementation - nEvents_++; - detectorOn_ = true; - nSelectedEvents_++; - if (verbose_) { - edm::LogInfo("DetectorStatusFilter") << "Total MC Events " << nEvents_ << " Selected Events " << nSelectedEvents_ - << " Detector States " << detectorOn_ << std::endl; - } - return detectorOn_; -} - - -/** - * Fill 'descriptions' with the allowed parameters for the module. - */ -void EmbeddingDetectorStateFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.setComment("filters on the HV status of the Tracker (either pixels or strips)"); - desc.addUntracked("DebugOn", false)->setComment("activates debugging"); - desc.addUntracked("DetectorType", "sistrip")->setComment("either strips or pixels"); - desc.addUntracked>("acceptedCombinations", {}); - desc.addUntracked("DcsStatusLabel", edm::InputTag("scalersRawToDigi")) - ->setComment("event data for DCS (Run2)"); - desc.addUntracked("DCSRecordLabel", edm::InputTag("onlineMetaDataDigis")) - ->setComment("event data for DCS (Run3)"); - descriptions.add("_detectorStateFilter", desc); -} - - -#include "FWCore/Framework/interface/MakerMacros.h" -DEFINE_FWK_MODULE(EmbeddingDetectorStateFilter); diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index cbaf355b9c337..d3c975eb1d292 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -608,17 +608,16 @@ def customiseGenerator_HLT(process, changeProcessname=True, reselect=False): process.embeddingHltPixelVertices.clone() ) - # replace the original detector state filters in the HLT with a dummy module - process.hltPixelTrackerHVOn = cms.EDFilter("EmbeddingDetectorStateFilter", - DcsStatusLabel = cms.untracked.InputTag("hltScalersRawToDigi"), - DebugOn = cms.untracked.bool(False), - DetectorType = cms.untracked.string('pixel') + # Replace the original detector state filters in the HLT with a dummy module with 100% efficiency. + # Those original filters have a efficiency of 0% for embedding samples. + # This is due to the fact that the simulation of the tau decay happens in an empty detector. + # For more info see https://github.com/cms-sw/cmssw/pull/47299#discussion_r1949023230 + process.hltPixelTrackerHVOn = cms.EDFilter("HLTBool", + result = cms.bool(True) ) - process.hltStripTrackerHVOn = cms.EDFilter("EmbeddingDetectorStateFilter", - DcsStatusLabel = cms.untracked.InputTag("hltScalersRawToDigi"), - DebugOn = cms.untracked.bool(False), - DetectorType = cms.untracked.string('sistrip') + process.hltStripTrackerHVOn = cms.EDFilter("HLTBool", + result = cms.bool(True) ) process = customisoptions(process) From c55bde04c2867c3c1a872d585a590959fa98fe50 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Wed, 12 Feb 2025 19:39:58 +0100 Subject: [PATCH 07/10] readd stuff from run2 with era modifier --- .../python/SelectingProcedure_cff.py | 22 +++++++++-- .../MCEmbeddingTools/python/customisers.py | 37 ++++++++++++++++++- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py index a883594a3b79e..2755d5c92d60f 100644 --- a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py +++ b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py @@ -1,18 +1,32 @@ import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import ( + run2_HLTconditions_2016, +) +from Configuration.Eras.Modifier_run2_HLTconditions_2017_cff import ( + run2_HLTconditions_2017, +) +from Configuration.Eras.Modifier_run2_HLTconditions_2018_cff import ( + run2_HLTconditions_2018, +) from Configuration.StandardSequences.PAT_cff import * - -from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import patMuons from HLTrigger.HLTfilters.triggerResultsFilter_cfi import * -from Configuration.Eras.Modifier_run2_HLTconditions_2016_cff import run2_HLTconditions_2016 +from PhysicsTools.PatAlgos.producersLayer1.muonProducer_cfi import patMuons ## Trigger requirements doubleMuonHLTTrigger = cms.EDFilter("TriggerResultsFilter", hltResults = cms.InputTag("TriggerResults","","HLT"), l1tResults = cms.InputTag(""), throw = cms.bool(False), - triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*") # from 2017 on (up to Run 3, it seems) + triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_v*") # unprescaled trigger for 2022,23,24 (see 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) ) +# change the used triggers for run2 +run2_HLTconditions_2018.toModify(doubleMuonHLTTrigger, + triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*"]) + +run2_HLTconditions_2017.toModify(doubleMuonHLTTrigger, + triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*"]) + run2_HLTconditions_2016.toModify(doubleMuonHLTTrigger, triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ_v*"]) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index d3c975eb1d292..188fd7387a9d2 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -3,6 +3,7 @@ # Various set of customise functions needed for embedding import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Modifier_run2_common_cff import run2_common from PhysicsTools.NanoAOD.common_cff import ExtVar ################################ Customizer for skimming ########################### @@ -234,6 +235,37 @@ def __init__( ) ) +# add some collections for run2 +run2_common.toModify( + to_bemanipulate, + lambda l: l.extend( + [ + module_manipulate( + module_name="conversionStepTracks", + manipulator_name="Track", + steps=["SIM", "MERGE"], + ), + module_manipulate( + module_name="ckfInOutTracksFromConversions", + manipulator_name="Track", + steps=["SIM", "MERGE"], + ), + module_manipulate( + module_name="electronMergedSeeds", + manipulator_name="ElectronSeed", + steps=["SIM", "MERGE"], + ), + module_manipulate( + module_name="ecalDrivenElectronSeeds", + manipulator_name="EcalDrivenElectronSeed", + steps=["SIM", "MERGE"], + ), + module_manipulate(module_name="hbheprereco", manipulator_name="HBHERecHit"), + module_manipulate(module_name="zdcreco", manipulator_name="ZDCRecHit"), + ] + ), +) + def modify_outputModules(process, keep_drop_list=[], module_veto_list=[]): outputModulesList = [key for key, value in process.outputModules.items()] @@ -324,7 +356,7 @@ def keepCleaned(dataTier): "keep *_l1extraParticles_*_" + dataTier, "keep TrajectorySeeds_*_*_*", "keep recoElectronSeeds_*_*_*", - "drop recoIsoDepositedmValueMap_muIsoDepositTk_*_*" , + "drop recoIsoDepositedmValueMap_muIsoDepositTk_*_*", "drop recoIsoDepositedmValueMap_muIsoDepositTkDisplaced_*_*", "drop *_ctppsProtons_*_*", "drop *_ctppsLocalTrackLiteProducer_*_*", @@ -554,6 +586,7 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False): ) # Disable noise simulation + run2_common.toModify(process.mix.digitizers.castor, doNoise = cms.bool(False)) process.mix.digitizers.ecal.doESNoise = cms.bool(False) process.mix.digitizers.ecal.doENoise = cms.bool(False) @@ -608,7 +641,7 @@ def customiseGenerator_HLT(process, changeProcessname=True, reselect=False): process.embeddingHltPixelVertices.clone() ) - # Replace the original detector state filters in the HLT with a dummy module with 100% efficiency. + # Replace the original detector state filters in the HLT with a dummy module with 100% efficiency. # Those original filters have a efficiency of 0% for embedding samples. # This is due to the fact that the simulation of the tau decay happens in an empty detector. # For more info see https://github.com/cms-sw/cmssw/pull/47299#discussion_r1949023230 From ac654611bea989d63f30e08ffdf45c071577b146 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Thu, 13 Feb 2025 17:44:43 +0100 Subject: [PATCH 08/10] change Trigger conditions in selection step and add comments --- .../MCEmbeddingTools/python/SelectingProcedure_cff.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py index 2755d5c92d60f..14468297b14e3 100644 --- a/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py +++ b/TauAnalysis/MCEmbeddingTools/python/SelectingProcedure_cff.py @@ -17,16 +17,17 @@ hltResults = cms.InputTag("TriggerResults","","HLT"), l1tResults = cms.InputTag(""), throw = cms.bool(False), - triggerConditions = cms.vstring("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass3p8_v*") # unprescaled trigger for 2022,23,24 (see 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) + 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) ) -# change the used triggers for run2 -run2_HLTconditions_2018.toModify(doubleMuonHLTTrigger, - triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*"]) - +#### change the used triggers for run2 #### +# 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 +# probably because he was already active in earlier runs than the Mass3p8 trigger +# Both are unprescaled run2_HLTconditions_2017.toModify(doubleMuonHLTTrigger, triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8_v*"]) +# Both are unprescaled according to https://cmshltinfo.app.cern.ch/summary?search=HLT_Mu17_TrkIsoVVL_&year=2016&paths=true&prescaled=true&stream-types=Physics run2_HLTconditions_2016.toModify(doubleMuonHLTTrigger, triggerConditions = ["HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_v* OR HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_DZ_v*"]) From 36d2593e266e681aeb7eb6b626e6fb025ee76f86 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Thu, 13 Feb 2025 20:47:33 +0100 Subject: [PATCH 09/10] add a unit test for 2022postEE data --- .../MCEmbeddingTools/python/customisers.py | 8 +- .../MCEmbeddingTools/test/BuildFile.xml | 1 + .../test/run_2022_workflow_tests.sh | 132 ++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100755 TauAnalysis/MCEmbeddingTools/test/run_2022_workflow_tests.sh diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index 188fd7387a9d2..ed203d86be192 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -585,8 +585,12 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False): "Correcting Vertex in genEvent to one from input. Replaced 'VtxSmeared' with the Corrector." ) - # Disable noise simulation - run2_common.toModify(process.mix.digitizers.castor, doNoise = cms.bool(False)) + #### Disable noise simulation #### + # Castor was a detector in CMS till 2018. + for i in to_bemanipulate: + print(i.module_name) + run2_common.toModify(process, lambda x: print("DAS ######################################", to_bemanipulate)) + run2_common.toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False))) process.mix.digitizers.ecal.doESNoise = cms.bool(False) process.mix.digitizers.ecal.doENoise = cms.bool(False) diff --git a/TauAnalysis/MCEmbeddingTools/test/BuildFile.xml b/TauAnalysis/MCEmbeddingTools/test/BuildFile.xml index 1fc12a955bbc7..735e65bc6cf7a 100644 --- a/TauAnalysis/MCEmbeddingTools/test/BuildFile.xml +++ b/TauAnalysis/MCEmbeddingTools/test/BuildFile.xml @@ -2,4 +2,5 @@ + diff --git a/TauAnalysis/MCEmbeddingTools/test/run_2022_workflow_tests.sh b/TauAnalysis/MCEmbeddingTools/test/run_2022_workflow_tests.sh new file mode 100755 index 0000000000000..dc0e44454bbcc --- /dev/null +++ b/TauAnalysis/MCEmbeddingTools/test/run_2022_workflow_tests.sh @@ -0,0 +1,132 @@ +#!/bin/bash +# This script runs all the steps of the embedding workflow +# author: Christian Winter (christian.winter@cern.ch) +# TODO: move the dataset to a more persistent and for cmssw accessible place than a private EOS user folder + +# print the exit status before exiting +function die { + echo $1: status $2 + exit $2 +} + +## This is a PRE SKIMED dataset +dataset="root://eoscms.cern.ch//store/group/phys_tau/embedding_test_files/2022_G_RAW.root" + +echo "################ Selection ################" +cmsDriver.py RECO \ + --step RAW2DIGI,L1Reco,RECO,PAT \ + --data \ + --scenario pp \ + --conditions auto:run3_data \ + --era Run3 \ + --eventcontent RAWRECO \ + --datatier RAWRECO \ + --customise TauAnalysis/MCEmbeddingTools/customisers.customiseSelecting \ + --filein $dataset \ + --fileout file:selection.root \ + -n -1 \ + --python_filename selection.py || die 'Failure during selecting step' $? + +echo "################ LHE production and cleaning ################" +cmsDriver.py LHEprodandCLEAN \ + --step RAW2DIGI,RECO,PAT \ + --data \ + --scenario pp \ + --conditions auto:run3_data \ + --era Run3 \ + --eventcontent RAWRECO \ + --datatier RAWRECO \ + --customise Configuration/DataProcessing/RecoTLR.customisePostEra_Run2_2018,TauAnalysis/MCEmbeddingTools/customisers.customiseLHEandCleaning \ + --filein file:selection.root \ + --fileout file:lhe_and_cleaned.root \ + -n -1 \ + --python_filename lheprodandcleaning.py || die 'Failure during LHE and Cleaning step' $? + +# Simulation (MC & Detector) +echo "################ Simulation (MC & Detector) ################" +cmsDriver.py TauAnalysis/MCEmbeddingTools/python/EmbeddingPythia8Hadronizer_cfi.py \ + --step GEN,SIM,DIGI,L1,DIGI2RAW \ + --mc \ + --beamspot Realistic25ns13p6TeVEarly2022Collision \ + --geometry DB:Extended \ + --era Run3 \ + --conditions auto:phase1_2022_realistic_postEE \ + --eventcontent RAWSIM \ + --datatier RAWSIM \ + --customise \ + TauAnalysis/MCEmbeddingTools/customisers.customiseGenerator_preHLT \ + --customise_commands 'process.generator.HepMCFilter.filterParameters.MuMuCut = cms.string("(Mu.Pt > 18 && Had.Pt > 18 && Mu.Eta < 2.2 && Had.Eta < 2.4)");process.generator.HepMCFilter.filterParameters.Final_States = cms.vstring("MuHad");process.generator.nAttempts = cms.uint32(1000);' \ + --filein file:lhe_and_cleaned.root \ + --fileout file:simulated_and_cleaned_prehlt.root \ + -n -1 \ + --python_filename generator_preHLT.py || die 'Failure during MC & Detector simulation step' $? + +# Simulation (Trigger) +echo "################ Simulation (Trigger) ################" +cmsDriver.py TauAnalysis/MCEmbeddingTools/python/EmbeddingPythia8Hadronizer_cfi.py \ + --step HLT:Fake2 \ + --mc \ + --beamspot Realistic25ns13p6TeVEarly2022Collision \ + --geometry DB:Extended \ + --era Run3 \ + --conditions auto:phase1_2022_realistic_postEE \ + --eventcontent RAWSIM \ + --datatier RAWSIM \ + --customise \ + TauAnalysis/MCEmbeddingTools/customisers.customiseGenerator_HLT \ + --customise_commands 'process.source.bypassVersionCheck = cms.untracked.bool(True);' \ + --filein file:simulated_and_cleaned_prehlt.root \ + --fileout file:simulated_and_cleaned_hlt.root \ + -n -1 \ + --python_filename generator_HLT.py || die 'Failure during Fake Trigger simulation step' $? + +# Simulation (Reconstruction) +echo "################ Simulation (Reconstruction) ################" +cmsDriver.py TauAnalysis/MCEmbeddingTools/python/EmbeddingPythia8Hadronizer_cfi.py \ + --step RAW2DIGI,L1Reco,RECO,RECOSIM \ + --mc \ + --beamspot Realistic25ns13p6TeVEarly2022Collision \ + --geometry DB:Extended \ + --era Run3 \ + --conditions auto:phase1_2022_realistic_postEE \ + --eventcontent RAWRECOSIMHLT \ + --datatier RAW-RECO-SIM \ + --customise \ + TauAnalysis/MCEmbeddingTools/customisers.customiseGenerator_postHLT \ + --customise_commands 'process.source.bypassVersionCheck = cms.untracked.bool(True);' \ + --filein file:simulated_and_cleaned_hlt.root \ + --fileout file:simulated_and_cleaned_posthlt.root \ + -n -1 \ + --python_filename generator_postHLT.py || die 'Failure during reconstruction simulation step' $? + +# Merging +echo "################ Merging ################" +cmsDriver.py PAT \ + --step PAT \ + --data \ + --scenario pp \ + --conditions auto:run3_data \ + --era Run3 \ + --eventcontent MINIAODSIM \ + --datatier USER \ + --customise \ + TauAnalysis/MCEmbeddingTools/customisers.customiseMerging \ + --filein file:simulated_and_cleaned_posthlt.root \ + --fileout file:merged.root \ + -n -1 \ + --python_filename merging.py || die 'Failure during the merging step' $? + +# NanoAOD Production +echo "################ NanoAOD Production ################" +cmsDriver.py \ + --step NANO \ + --data \ + --conditions auto:run3_data \ + --era Run3 \ + --eventcontent NANOAODSIM \ + --datatier NANOAODSIM \ + --customise TauAnalysis/MCEmbeddingTools/customisers.customiseNanoAOD \ + --filein file:merged.root \ + --fileout file:merged_nano.root \ + -n -1 \ + --python_filename embedding_nanoAOD.py || die 'Failure during the nanoAOD step' $? From a3c5795c2ea3ad7e2277d244ef2cc6e15cbcdd34 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Fri, 14 Feb 2025 15:16:43 +0100 Subject: [PATCH 10/10] implement the era modifiers, for run2 only, the correct way --- TauAnalysis/MCEmbeddingTools/python/customisers.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TauAnalysis/MCEmbeddingTools/python/customisers.py b/TauAnalysis/MCEmbeddingTools/python/customisers.py index ed203d86be192..5785077f2b955 100644 --- a/TauAnalysis/MCEmbeddingTools/python/customisers.py +++ b/TauAnalysis/MCEmbeddingTools/python/customisers.py @@ -4,6 +4,7 @@ # Various set of customise functions needed for embedding import FWCore.ParameterSet.Config as cms from Configuration.Eras.Modifier_run2_common_cff import run2_common +from Configuration.Eras.Modifier_run3_common_cff import run3_common from PhysicsTools.NanoAOD.common_cff import ExtVar ################################ Customizer for skimming ########################### @@ -236,7 +237,11 @@ def __init__( ) # add some collections for run2 -run2_common.toModify( +# The era Modifier/ModifierChain is specified with the cmsDriver `--era` option or the cms.Process('NAME', era=...) constructor in the python config. +# 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) +# The Run3 ModifierChain is based on the Run2 ModifierChain. Therefore the `run2_common` Modifier is included in both ModifierChains. +# 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`. +(run2_common & ~run3_common).toModify( to_bemanipulate, lambda l: l.extend( [ @@ -587,10 +592,7 @@ def customiseGenerator_preHLT(process, changeProcessname=True, reselect=False): #### Disable noise simulation #### # Castor was a detector in CMS till 2018. - for i in to_bemanipulate: - print(i.module_name) - run2_common.toModify(process, lambda x: print("DAS ######################################", to_bemanipulate)) - run2_common.toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False))) + (run2_common & ~run3_common).toModify(process, lambda p: setattr(p.mix.digitizers.castor, "doNoise", cms.bool(False))) process.mix.digitizers.ecal.doESNoise = cms.bool(False) process.mix.digitizers.ecal.doENoise = cms.bool(False)