diff --git a/Configuration/Eras/python/Era_Run2_2017_FastSim_cff.py b/Configuration/Eras/python/Era_Run2_2017_FastSim_cff.py deleted file mode 100644 index a85ded18409cd..0000000000000 --- a/Configuration/Eras/python/Era_Run2_2017_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run2_2017_cff import Run2_2017 -from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 - -Run2_2017_FastSim = Run2_2017.copyAndExclude([run2_GEM_2017]) diff --git a/Configuration/Eras/python/Era_Run2_2018_FastSim_cff.py b/Configuration/Eras/python/Era_Run2_2018_FastSim_cff.py deleted file mode 100644 index d9ff9f6aaefb7..0000000000000 --- a/Configuration/Eras/python/Era_Run2_2018_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run2_2018_cff import Run2_2018 -from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 - -Run2_2018_FastSim = Run2_2018.copyAndExclude([run2_GEM_2017]) diff --git a/Configuration/Eras/python/Era_Run3_2023_FastSim_cff.py b/Configuration/Eras/python/Era_Run3_2023_FastSim_cff.py deleted file mode 100644 index 620e986f2c303..0000000000000 --- a/Configuration/Eras/python/Era_Run3_2023_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run3_2023_cff import Run3_2023 -from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM - -Run3_2023_FastSim = Run3_2023.copyAndExclude([run3_GEM]) diff --git a/Configuration/Eras/python/Era_Run3_2024_FastSim_cff.py b/Configuration/Eras/python/Era_Run3_2024_FastSim_cff.py deleted file mode 100644 index 70fb8c7785187..0000000000000 --- a/Configuration/Eras/python/Era_Run3_2024_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run3_2024_cff import Run3_2024 -from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM - -Run3_2024_FastSim = Run3_2024.copyAndExclude([run3_GEM]) diff --git a/Configuration/Eras/python/Era_Run3_2025_FastSim_cff.py b/Configuration/Eras/python/Era_Run3_2025_FastSim_cff.py deleted file mode 100644 index ee5fe0e41fdeb..0000000000000 --- a/Configuration/Eras/python/Era_Run3_2025_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run3_2025_cff import Run3_2025 -from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM - -Run3_2025_FastSim = Run3_2025.copyAndExclude([run3_GEM]) diff --git a/Configuration/Eras/python/Era_Run3_2026_FastSim_cff.py b/Configuration/Eras/python/Era_Run3_2026_FastSim_cff.py deleted file mode 100644 index 3db12d3a102c8..0000000000000 --- a/Configuration/Eras/python/Era_Run3_2026_FastSim_cff.py +++ /dev/null @@ -1,5 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run3_2025_FastSim_cff import Run3_2025_FastSim - -Run3_2026_FastSim = cms.ModifierChain(Run3_2025_FastSim) diff --git a/Configuration/Eras/python/Era_Run3_FastSim_cff.py b/Configuration/Eras/python/Era_Run3_FastSim_cff.py deleted file mode 100644 index bd908d1472035..0000000000000 --- a/Configuration/Eras/python/Era_Run3_FastSim_cff.py +++ /dev/null @@ -1,6 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Run3_cff import Run3 -from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM - -Run3_FastSim = Run3.copyAndExclude([run3_GEM]) diff --git a/Configuration/PyReleaseValidation/python/relval_steps.py b/Configuration/PyReleaseValidation/python/relval_steps.py index 0202fbdeacdd2..a17f3e6858ace 100644 --- a/Configuration/PyReleaseValidation/python/relval_steps.py +++ b/Configuration/PyReleaseValidation/python/relval_steps.py @@ -1492,7 +1492,7 @@ def genS(fragment,howMuch): '--fast':'', '--conditions' :'auto:phase1_2017_realistic', '--beamspot' : 'Realistic25ns13TeVEarly2017Collision', - '--era' :'Run2_2017_FastSim', + '--era' :'Run2_2017', '--eventcontent':'FEVTDEBUGHLT,DQM', '--datatier':'GEN-SIM-DIGI-RECO,DQMIO', '--relval':'27000,3000'}, @@ -1508,7 +1508,7 @@ def genS(fragment,howMuch): '--fast':'', '--conditions' :'auto:phase1_2018_realistic', '--beamspot' :'Realistic25ns13TeVEarly2018Collision', - '--era' :'Run2_2018_FastSim', + '--era' :'Run2_2018', '--eventcontent':'FEVTDEBUGHLT,DQM', '--datatier':'GEN-SIM-DIGI-RECO,DQMIO', '--relval':'27000,3000'}, @@ -1658,7 +1658,7 @@ def genS(fragment,howMuch): "--eventcontent":"PREMIX", "--datatier":"PREMIX", "--procModifiers":"premix_stage1", - "--era":"Run2_2017_FastSim", + "--era":"Run2_2017", }, PUFSAVE50,Kby(100,500)]) @@ -1708,7 +1708,7 @@ def genS(fragment,howMuch): "--eventcontent":"PREMIX", "--datatier":"PREMIX", "--procModifiers":"premix_stage1", - "--era":"Run2_2018_FastSim", + "--era":"Run2_2018", }, PUFSAVE50UP18,Kby(100,500)]) @@ -4610,9 +4610,9 @@ def gen2024HiMix(fragment,howMuch): '--filetype':'DQM', '--scenario':'pp'} steps['HARVESTUP15FS_trackingOnly']=merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM'}, steps['HARVESTUP15FS']]) -steps['HARVESTUP17FS']=merge([{'--conditions':'auto:phase1_2017_realistic','--era' : 'Run2_2017_FastSim'},steps['HARVESTUP15FS']]) +steps['HARVESTUP17FS']=merge([{'--conditions':'auto:phase1_2017_realistic','--era' : 'Run2_2017'},steps['HARVESTUP15FS']]) steps['HARVESTUP17FS_trackingOnly']=merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM'}, steps['HARVESTUP17FS']]) -steps['HARVESTUP18FS']=merge([{'--conditions':'auto:phase1_2018_realistic','--era' : 'Run2_2018_FastSim'},steps['HARVESTUP15FS']]) +steps['HARVESTUP18FS']=merge([{'--conditions':'auto:phase1_2018_realistic','--era' : 'Run2_2018'},steps['HARVESTUP15FS']]) steps['HARVESTUP18FS_trackingOnly']=merge([{'-s': 'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM'}, steps['HARVESTUP18FS']]) steps['ALCASPLIT']={'-s':'ALCAOUTPUT:@allForPrompt', @@ -4779,12 +4779,12 @@ def gen2024HiMix(fragment,howMuch): '--eventcontent':'MINIAOD',},stepMiniAODMC]) #MiniAOD 2017 -steps['MINIAODMCUP17FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2017_realistic','--era':'Run2_2017_FastSim'},stepMiniAODMC]) +steps['MINIAODMCUP17FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2017_realistic','--era':'Run2_2017'},stepMiniAODMC]) #MiniAOD 2018 steps['MINIAODMCUP18'] =merge([{'--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018'},stepMiniAODMC]) steps['MINIAODMCUP18bParking'] =merge([{'--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018,bParking'},stepMiniAODMC]) -steps['MINIAODMCUP18FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018_FastSim'},stepMiniAODMC]) +steps['MINIAODMCUP18FS'] =merge([{'--filein':'file:step1.root','--fast':'','--conditions':'auto:phase1_2018_realistic','--era':'Run2_2018'},stepMiniAODMC]) stepNanoAODDefaults = { '-s': 'NANO,DQM:@nanoAODDQM', '-n': 1000 } stepNanoAODData = merge([{ '--data':'', '--eventcontent' : 'NANOAOD,DQM' ,'--datatier': 'NANOAOD,DQMIO' }, stepNanoAODDefaults ]) @@ -4805,8 +4805,8 @@ def gen2024HiMix(fragment,howMuch): steps['NANOPRODUP18']=merge([{'--filein':'file:step4.root'},steps['NANOUP18']]) steps['NANOUP15FS'] = merge([{'--filein':'file:step3.root','--fast':''}, steps['NANOUP15']]) -steps['NANOUP17FS'] = merge([{'--filein':'file:step3.root','--fast':'','--era':'Run2_2017_FastSim'}, steps['NANOUP17']]) -steps['NANOUP18FS'] = merge([{'--filein':'file:step3.root','--fast':'','--era':'Run2_2018_FastSim'}, steps['NANOUP18']]) +steps['NANOUP17FS'] = merge([{'--filein':'file:step3.root','--fast':'','--era':'Run2_2017'}, steps['NANOUP17']]) +steps['NANOUP18FS'] = merge([{'--filein':'file:step3.root','--fast':'','--era':'Run2_2018'}, steps['NANOUP18']]) steps['HEfail'] = {'--conditions':'auto:phase1_2018_realistic_HEfail', @@ -5124,7 +5124,7 @@ def gen2024HiMix(fragment,howMuch): upgradeStepDict['FastSimRun3'][k]={'-s':'SIM,RECOBEFMIX,DIGI:pdigi_valid,L1,DIGI2RAW,L1Reco,RECO,PAT,NANO,VALIDATION:@standardValidation+@miniAODValidation,DQM:@standardDQMFS+@miniAODDQM+@nanoAODDQM', '--fast':'', - '--era':'Run3_FastSim', + '--era':'Run3', '--beamspot':beamspot, '--conditions':gt, '--geometry':geom, diff --git a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py index fb1e68b543434..57ea6ca4fbc58 100644 --- a/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py +++ b/Configuration/PyReleaseValidation/python/upgradeWorkflowComponents.py @@ -3116,7 +3116,7 @@ def setupPU_(self, step, stepName, stepDict, k, properties): if not stepNameS1 in stepDict: stepDict[stepNameS1] = {} stepDict[stepNameS1][k] = merge([{ '--fast': '', - '--era': stepDict[stepName][k]['--era']+'_FastSim', + '--era': stepDict[stepName][k]['--era'], '--eventcontent': 'FASTPU', '--processName': 'FASTSIM', }, d]) @@ -3183,7 +3183,6 @@ def setup_(self, step, stepName, stepDict, k, properties): if 'HARVESTFastRun3' in step: stepDict[stepName][k] = merge([{'-s':'HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM', '--fast':'', - '--era':'Run3_FastSim', '--filein':'file:step1_inDQM.root'}, stepDict[step][k]]) else: stepDict[stepName][k] = merge([stepDict[step][k]]) @@ -3208,7 +3207,6 @@ def setup_(self, step, stepName, stepDict, k, properties): if 'Gen' in step and 'GenOnly' not in step: stepDict[stepName][k] = merge([{'-s':'GEN,SIM,RECOBEFMIX', '--fast':'', - '--era':'Run3_FastSim', '--eventcontent':'FASTPU', '--datatier':'GEN-SIM-RECO', '--relval':'27000,3000'}, stepDict[step][k]]) @@ -3503,7 +3501,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2022_realistic', 'HLTmenu': '@relval2022', - 'Era' : 'Run3_FastSim', + 'Era' : 'Run3', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['Gen','FastSimRun3','HARVESTFastRun3'], }, @@ -3519,7 +3517,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2023_realistic', 'HLTmenu': '@relval2023', - 'Era' : 'Run3_2023_FastSim', + 'Era' : 'Run3_2023', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['Gen','FastSimRun3','HARVESTFastRun3'], }, @@ -3574,7 +3572,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2024_realistic', 'HLTmenu': '@relval2024', - 'Era' : 'Run3_2024_FastSim', + 'Era' : 'Run3_2024', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['Gen','FastSimRun3','HARVESTFastRun3'], }, @@ -3614,7 +3612,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2025_realistic', 'HLTmenu': '@relval2025', - 'Era' : 'Run3_2025_FastSim', + 'Era' : 'Run3_2025', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['Gen','FastSimRun3','HARVESTFastRun3'], }, @@ -3655,7 +3653,7 @@ def condition(self, fragment, stepList, key, hasHarvest): 'Geom' : 'DB:Extended', 'GT' : 'auto:phase1_2026_realistic', 'HLTmenu': '@relval2026', - 'Era' : 'Run3_2026_FastSim', + 'Era' : 'Run3_2026', 'BeamSpot': 'DBrealistic', 'ScenToRun' : ['Gen','FastSimRun3','HARVESTFastRun3'], } diff --git a/Configuration/PyReleaseValidation/scripts/README.md b/Configuration/PyReleaseValidation/scripts/README.md index 831ebdd912366..71ec78bde5359 100644 --- a/Configuration/PyReleaseValidation/scripts/README.md +++ b/Configuration/PyReleaseValidation/scripts/README.md @@ -319,10 +319,10 @@ MC workflows for pp collisions: | **Run3** | | | | | | | | | | | | 11634.0 | TTbar_14TeV | phase1_2022_realistic | Run3 | | -| 13234.0 | RelValTTbar_14TeV | phase1_2022_realistic | Run3_FastSim | *FastSim* | +| 13234.0 | RelValTTbar_14TeV | phase1_2022_realistic | Run3 | *FastSim* | | 12434.0 | RelValTTbar_14TeV | phase1_2023_realistic | Run3_2023 | | -| 14034.0 | RelValTTbar_14TeV | phase1_2023_realistic | Run3_2023_FastSim | *FastSim* | -| 14234.0 | RelValTTbar_14TeV | phase1_2023_realistic | Run3_2023_FastSim | *FastSim* Run3_Flat55To75_PoissonOOTPU | +| 14034.0 | RelValTTbar_14TeV | phase1_2023_realistic | Run3_2023 | *FastSim* | +| 14234.0 | RelValTTbar_14TeV | phase1_2023_realistic | Run3_2023 | *FastSim* Run3_Flat55To75_PoissonOOTPU | | 12834.0 | RelValTTbar_14TeV | phase1_2024_realistic | Run3_2024 | | | 12846.0 | RelValZEE_14 | phase1_2023_realistic | Run3_2024 | | | 13034.0 | RelValTTbar_14TeV | phase1_2024_realistic | Run3_2024 | Run3_Flat55To75_PoissonOOTPU | diff --git a/Configuration/StandardSequences/python/Digi_cff.py b/Configuration/StandardSequences/python/Digi_cff.py index ad5a7092bdff9..4a1e56f21c9ba 100644 --- a/Configuration/StandardSequences/python/Digi_cff.py +++ b/Configuration/StandardSequences/python/Digi_cff.py @@ -74,10 +74,18 @@ def _fastSimDigis(process): # no need for the aliases for premixing stage1 modifyDigi_fastSimDigis = (fastSim & ~premix_stage1).makeProcessModifier(_fastSimDigis) +from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 +from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM +def _fastSimDigisGEM(process): + from FastSimulation.Configuration.DigiAliases_cff import loadDigiAliasesGEM + loadDigiAliasesGEM(process) +modifyDigi_fastSimDigisGEM = (fastSim & (run2_GEM_2017 | run3_GEM) & ~premix_stage1).makeProcessModifier(_fastSimDigisGEM) + from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal def _fastSimDigisHGCal(process): from FastSimulation.Configuration.DigiAliases_cff import loadDigiAliasesHGCal -modifyDigi_fastSimDigisHGCal = (fastSim & phase2_hgcal).makeProcessModifier(_fastSimDigisHGCal) + loadDigiAliasesHGCal(process) +modifyDigi_fastSimDigisHGCal = (fastSim & phase2_hgcal & ~premix_stage1).makeProcessModifier(_fastSimDigisHGCal) #phase 2 common mods def _modifyEnableHcalHardcode( theProcess ): diff --git a/FastSimulation/Configuration/python/DigiAliases_cff.py b/FastSimulation/Configuration/python/DigiAliases_cff.py index 32c58040df066..40e027f189b6c 100644 --- a/FastSimulation/Configuration/python/DigiAliases_cff.py +++ b/FastSimulation/Configuration/python/DigiAliases_cff.py @@ -125,6 +125,15 @@ def loadDigiAliases(process, premix=False): ) ) +def loadDigiAliasesGEM(process): + process.muonGEMDigis = cms.EDAlias( + simMuonGEMDigis = cms.VPSet( + cms.PSet( + type = cms.string("GEMDetIdGEMDigiMuonDigiCollection") + ), + ) + ) + def loadDigiAliasesHGCal(process): process.hgcalDigis = cms.EDAlias( mix = cms.VPSet( diff --git a/FastSimulation/MuonSimHitProducer/plugins/BuildFile.xml b/FastSimulation/MuonSimHitProducer/plugins/BuildFile.xml index 11c53eb823fe3..50e064ddd6d22 100644 --- a/FastSimulation/MuonSimHitProducer/plugins/BuildFile.xml +++ b/FastSimulation/MuonSimHitProducer/plugins/BuildFile.xml @@ -8,6 +8,7 @@ + diff --git a/FastSimulation/MuonSimHitProducer/plugins/MuonSimHitProducer.cc b/FastSimulation/MuonSimHitProducer/plugins/MuonSimHitProducer.cc index 8b9a814061dca..f7acb1177c78b 100644 --- a/FastSimulation/MuonSimHitProducer/plugins/MuonSimHitProducer.cc +++ b/FastSimulation/MuonSimHitProducer/plugins/MuonSimHitProducer.cc @@ -31,9 +31,11 @@ #include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h" @@ -48,32 +50,38 @@ #include "TrackingTools/GeomPropagators/interface/HelixArbitraryPlaneCrossing.h" #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h" +#include + class MuonSimHitProducer : public edm::stream::EDProducer { public: explicit MuonSimHitProducer(const edm::ParameterSet&); private: - MuonServiceProxy* theService; - Chi2MeasurementEstimator theEstimator; + static constexpr double c_cm_ns_ = 29.98; + + std::unique_ptr theService_; + Chi2MeasurementEstimator theEstimator_; - const MagneticField* magfield; - const DTGeometry* dtGeom; - const CSCGeometry* cscGeom; - const RPCGeometry* rpcGeom; - const Propagator* propagatorWithMaterial; - std::unique_ptr propagatorWithoutMaterial; + const MagneticField* magfield_; + const DTGeometry* dtGeom_; + const CSCGeometry* cscGeom_; + const RPCGeometry* rpcGeom_; + const GEMGeometry* gemGeom_; + const Propagator* propagatorWithMaterial_; + std::unique_ptr propagatorWithoutMaterial_; + bool enableGEM_; - std::unique_ptr theMaterialEffects; + std::unique_ptr theMaterialEffects_; void beginRun(edm::Run const& run, const edm::EventSetup& es) override; void produce(edm::Event&, const edm::EventSetup&) override; void readParameters(const edm::ParameterSet&, const edm::ParameterSet&, const edm::ParameterSet&); // Parameters to emulate the muonSimHit association inefficiency due to delta's - double kDT; - double fDT; - double kCSC; - double fCSC; + double kDT_; + double fDT_; + double kCSC_; + double fCSC_; /// Simulate material effects in iron (dE/dx, multiple scattering) void applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, @@ -87,34 +95,39 @@ class MuonSimHitProducer : public edm::stream::EDProducer > simMuonToken; - edm::EDGetTokenT > simVertexToken; + edm::EDGetTokenT> simMuonToken_; + edm::EDGetTokenT> simVertexToken_; const edm::ESGetToken magneticFieldESToken_; - const edm::ESGetToken dtGeometryESToken_; - const edm::ESGetToken cscGeometryESToken_; - const edm::ESGetToken rpcGeometryESToken_; + const edm::ESGetToken DTGeometryESToken_; + const edm::ESGetToken CSCGeometryESToken_; + const edm::ESGetToken RPCGeometryESToken_; + edm::ESGetToken GEMGeometryESToken_; const edm::ESGetToken particleDataTableESToken_; }; //for debug only -//#define FAMOS_DEBUG +//#define EDM_ML_DEBUG // // constructors and destructor // MuonSimHitProducer::MuonSimHitProducer(const edm::ParameterSet& iConfig) - : theEstimator(iConfig.getParameter("Chi2EstimatorCut")), - propagatorWithoutMaterial(nullptr), + : theEstimator_(iConfig.getParameter("Chi2EstimatorCut")), + propagatorWithoutMaterial_(nullptr), + enableGEM_(iConfig.getParameter("enableGEM")), magneticFieldESToken_(esConsumes()), - dtGeometryESToken_(esConsumes(edm::ESInputTag("", "MisAligned"))), - cscGeometryESToken_(esConsumes(edm::ESInputTag("", "MisAligned"))), - rpcGeometryESToken_(esConsumes()), + DTGeometryESToken_(esConsumes(edm::ESInputTag("", "MisAligned"))), + CSCGeometryESToken_(esConsumes(edm::ESInputTag("", "MisAligned"))), + RPCGeometryESToken_(esConsumes()), particleDataTableESToken_(esConsumes()) { + if (enableGEM_) + GEMGeometryESToken_ = esConsumes(); + // Read relevant parameters readParameters(iConfig.getParameter("MUONS"), iConfig.getParameter("TRACKS"), @@ -126,32 +139,37 @@ MuonSimHitProducer::MuonSimHitProducer(const edm::ParameterSet& iConfig) produces("MuonCSCHits"); produces("MuonDTHits"); produces("MuonRPCHits"); + if (enableGEM_) + produces("MuonGEMHits"); edm::ParameterSet serviceParameters = iConfig.getParameter("ServiceParameters"); - theService = new MuonServiceProxy(serviceParameters, consumesCollector(), MuonServiceProxy::UseEventSetupIn::Run); + theService_ = std::make_unique( + serviceParameters, consumesCollector(), MuonServiceProxy::UseEventSetupIn::Run); // consumes - simMuonToken = consumes >(simMuonLabel); - simVertexToken = consumes >(simVertexLabel); + simMuonToken_ = consumes>(simMuonLabel_); + simVertexToken_ = consumes>(simVertexLabel_); } // ---- method called once each job just before starting event loop ---- void MuonSimHitProducer::beginRun(edm::Run const& run, const edm::EventSetup& es) { //services - magfield = &es.getData(magneticFieldESToken_); - dtGeom = &es.getData(dtGeometryESToken_); - cscGeom = &es.getData(cscGeometryESToken_); - rpcGeom = &es.getData(rpcGeometryESToken_); + magfield_ = &es.getData(magneticFieldESToken_); + dtGeom_ = &es.getData(DTGeometryESToken_); + cscGeom_ = &es.getData(CSCGeometryESToken_); + rpcGeom_ = &es.getData(RPCGeometryESToken_); + if (enableGEM_) + gemGeom_ = &es.getData(GEMGeometryESToken_); bool duringEvent = false; - theService->update(es, duringEvent); + theService_->update(es, duringEvent); // A few propagators - propagatorWithMaterial = &(*(theService->propagator("SteppingHelixPropagatorAny"))); - propagatorWithoutMaterial.reset(propagatorWithMaterial->clone()); + propagatorWithMaterial_ = &(*(theService_->propagator("SteppingHelixPropagatorAny"))); + propagatorWithoutMaterial_.reset(propagatorWithMaterial_->clone()); SteppingHelixPropagator* SHpropagator = - dynamic_cast(propagatorWithoutMaterial.get()); // Beuark! - SHpropagator->setMaterialMode(true); // switches OFF material effects; + dynamic_cast(propagatorWithoutMaterial_.get()); // Beuark! + SHpropagator->setMaterialMode(true); // switches OFF material effects; } // @@ -167,21 +185,18 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet MuonPatternRecoDumper dumper; - edm::Handle > simMuons; - edm::Handle > simVertices; - std::vector theCSCHits; - std::vector theDTHits; - std::vector theRPCHits; + edm::Handle> simMuons; + edm::Handle> simVertices; + auto theCSCHits = std::make_unique(); + auto theDTHits = std::make_unique(); + auto theRPCHits = std::make_unique(); + auto theGEMHits = std::make_unique(); - DirectMuonNavigation navigation(theService->detLayerGeometry()); - iEvent.getByToken(simMuonToken, simMuons); - iEvent.getByToken(simVertexToken, simVertices); - - for (unsigned int itrk = 0; itrk < simMuons->size(); itrk++) { - const SimTrack& mySimTrack = (*simMuons)[itrk]; - math::XYZTLorentzVector mySimP4( - mySimTrack.momentum().x(), mySimTrack.momentum().y(), mySimTrack.momentum().z(), mySimTrack.momentum().t()); + DirectMuonNavigation navigation(theService_->detLayerGeometry()); + iEvent.getByToken(simMuonToken_, simMuons); + iEvent.getByToken(simVertexToken_, simVertices); + for (const auto& mySimTrack : *simMuons) { // Decaying hadrons are now in the list, and so are their muon daughter // Ignore the hadrons here. int pid = mySimTrack.type(); @@ -192,21 +207,21 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet int ivert = mySimTrack.vertIndex(); if (ivert >= 0) { t0 = (*simVertices)[ivert].position().t(); - GlobalPoint xyzzy((*simVertices)[ivert].position().x(), - (*simVertices)[ivert].position().y(), - (*simVertices)[ivert].position().z()); - initialPosition = xyzzy; + initialPosition = GlobalPoint((*simVertices)[ivert].position().x(), + (*simVertices)[ivert].position().y(), + (*simVertices)[ivert].position().z()); } // // Presumably t0 has dimensions of cm if not mm? // Convert to ns for internal calculations. // I wonder where we should get c from? // - double tof = t0 / 29.98; + double tof = t0 / c_cm_ns_; -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << " ===> MuonSimHitProducer::reconstruct() found SIMTRACK - pid = " << pid; - std::cout << " : pT = " << mySimP4.Pt() << ", eta = " << mySimP4.Eta() << ", phi = " << mySimP4.Phi() << std::endl; + std::cout << " : pT = " << mySimTrack.momentum().Pt() << ", eta = " << mySimTrack.momentum().Eta() + << ", phi = " << mySimTrack.momentum().Phi() << std::endl; #endif // @@ -225,9 +240,9 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // will be rather seldom... May as well ignore the mass too. // GlobalVector dtracker = startingPosition - initialPosition; - tof += dtracker.mag() / 29.98; + tof += dtracker.mag() / c_cm_ns_; -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << " the Muon START position " << startingPosition << std::endl; std::cout << " the Muon START momentum " << startingMomentum << std::endl; #endif @@ -239,41 +254,35 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet GlobalVector zAxis = startingMomentum.unit(); GlobalVector yAxis(zAxis.y(), -zAxis.x(), 0); GlobalVector xAxis = yAxis.cross(zAxis); - Surface::RotationType rot = Surface::RotationType(xAxis, yAxis, zAxis); + Surface::RotationType rot(xAxis, yAxis, zAxis); PlaneBuilder::ReturnType startingPlane = pb.plane(startingPosition, rot); - GlobalTrajectoryParameters gtp(startingPosition, startingMomentum, (int)mySimTrack.charge(), magfield); + GlobalTrajectoryParameters gtp(startingPosition, startingMomentum, (int)mySimTrack.charge(), magfield_); TrajectoryStateOnSurface startingState(gtp, *startingPlane); - std::vector navLayers; - if (fabs(startingState.globalMomentum().eta()) > 4.5) { - navLayers = navigation.compatibleEndcapLayers(*(startingState.freeState()), alongMomentum); - } else { - navLayers = navigation.compatibleLayers(*(startingState.freeState()), alongMomentum); - } - /* - edm::ESHandle propagator = - theService->propagator("SteppingHelixPropagatorAny"); - */ + const std::vector& navLayers = + (std::abs(startingState.globalMomentum().eta()) > 4.5) + ? navigation.compatibleEndcapLayers(*(startingState.freeState()), alongMomentum) + : navigation.compatibleLayers(*(startingState.freeState()), alongMomentum); if (navLayers.empty()) continue; -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << "Found " << navLayers.size() << " compatible DetLayers..." << std::endl; #endif TrajectoryStateOnSurface propagatedState = startingState; for (unsigned int ilayer = 0; ilayer < navLayers.size(); ilayer++) { -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << "Propagating to layer " << ilayer << " " << dumper.dumpLayer(navLayers[ilayer]) << std::endl; #endif - std::vector comps = - navLayers[ilayer]->compatibleDets(propagatedState, *propagatorWithMaterial, theEstimator); + const std::vector& comps = + navLayers[ilayer]->compatibleDets(propagatedState, *propagatorWithMaterial_, theEstimator_); if (comps.empty()) continue; -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << "Propagating " << propagatedState << std::endl; #endif @@ -283,7 +292,7 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // Propagate with material effects (dE/dx average only) SteppingHelixStateInfo shsStart(*(propagatedState.freeTrajectoryState())); SteppingHelixStateInfo shsDest; - ((const SteppingHelixPropagator*)propagatorWithMaterial) + ((const SteppingHelixPropagator*)propagatorWithMaterial_) ->propagate(shsStart, navLayers[ilayer]->surface(), shsDest); std::pair next(shsDest.getStateOnSurface(navLayers[ilayer]->surface()), shsDest.path()); @@ -299,7 +308,7 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // Now propagate without dE/dx (average) // [To add the dE/dx fluctuations to the actual dE/dx] std::pair nextNoMaterial = - propagatorWithoutMaterial->propagateWithPath(propagatedState, navLayers[ilayer]->surface()); + propagatorWithoutMaterial_->propagateWithPath(propagatedState, navLayers[ilayer]->surface()); // Update the propagated state propagatedState = next.first; @@ -308,7 +317,7 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // Insert dE/dx fluctuations and multiple scattering // Skip this step if nextNoMaterial.first is not valid // This happens rarely (~0.02% of ttbar events) - if (theMaterialEffects && nextNoMaterial.first.isValid()) + if (theMaterialEffects_ && nextNoMaterial.first.isValid()) applyMaterialEffects(propagatedState, nextNoMaterial.first, radPath, &random, *pdg); // Check that the 'shaken' propagatedState is still valid, otherwise continue if (!propagatedState.isValid()) @@ -320,11 +329,14 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // muon chambers. // double pavg = 0.5 * (pi + pf); - double m = mySimP4.M(); - double rbeta = sqrt(1 + m * m / (pavg * pavg)) / 29.98; + double m2 = mySimTrack.momentum().M2(); + double rbeta = sqrt(1 + m2 / (pavg * pavg)) / c_cm_ns_; double dtof = pathLength * rbeta; + // GEMDigitizer need the eloss information. + // The muon mass negligible when we calculate the energya. So energy loss is assumed as the momentum difference. + double eloss = pi - pf; -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << "Propagated to next surface... path length = " << pathLength << " cm, dTOF = " << dtof << " ns" << std::endl; #endif @@ -335,24 +347,24 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet const GeomDet* gd = comps[icomp].first; if (gd->subDetector() == GeomDetEnumerators::DT) { DTChamberId id(gd->geographicalId()); - const DTChamber* chamber = dtGeom->chamber(id); - std::vector superlayer = chamber->superLayers(); + const DTChamber* chamber = dtGeom_->chamber(id); + const std::vector& superlayer = chamber->superLayers(); for (unsigned int isl = 0; isl < superlayer.size(); isl++) { - std::vector layer = superlayer[isl]->layers(); + const std::vector& layer = superlayer[isl]->layers(); for (unsigned int ilayer = 0; ilayer < layer.size(); ilayer++) { DTLayerId lid = layer[ilayer]->id(); -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << " Extrapolated to DT (" << lid.wheel() << "," << lid.station() << "," << lid.sector() << "," << lid.superlayer() << "," << lid.layer() << ")" << std::endl; #endif - const GeomDetUnit* det = dtGeom->idToDetUnit(lid); + const GeomDetUnit* det = dtGeom_->idToDetUnit(lid); HelixArbitraryPlaneCrossing crossing(propagatedState.globalPosition().basicVector(), propagatedState.globalMomentum().basicVector(), propagatedState.transverseCurvature(), anyDirection); - std::pair path = crossing.pathLength(det->surface()); + const std::pair& path = crossing.pathLength(det->surface()); if (!path.first) continue; LocalPoint lpos = det->toLocal(GlobalPoint(crossing.position(path.second))); @@ -373,41 +385,39 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // Factor that takes into account the (rec)hits lost because of delta's, etc.: // (Not fully satisfactory patch, but it seems to work...) double pmu = lmom.mag(); - double theDTHitIneff = pmu > 0 ? exp(kDT * log(pmu) + fDT) : 0.; + double theDTHitIneff = pmu > 0 ? exp(kDT_ * log(pmu) + fDT_) : 0.; if (random.flatShoot() < theDTHitIneff) continue; - double eloss = 0; - double pz = fabs(lmom.z()); + double pz = std::abs(lmom.z()); LocalPoint entry = lpos - 0.5 * thickness * lmom / pz; LocalPoint exit = lpos + 0.5 * thickness * lmom / pz; double dtof = path.second * rbeta; int trkid = mySimTrack.trackId(); unsigned int id = wid.rawId(); short unsigned int processType = 2; - PSimHit hit( + theDTHits->emplace_back( entry, exit, lmom.mag(), tof + dtof, eloss, pid, id, trkid, lmom.theta(), lmom.phi(), processType); - theDTHits.push_back(hit); } } } else if (gd->subDetector() == GeomDetEnumerators::CSC) { CSCDetId id(gd->geographicalId()); - const CSCChamber* chamber = cscGeom->chamber(id); - std::vector layers = chamber->layers(); + const CSCChamber* chamber = cscGeom_->chamber(id); + const std::vector& layers = chamber->layers(); for (unsigned int ilayer = 0; ilayer < layers.size(); ilayer++) { CSCDetId lid = layers[ilayer]->id(); -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << " Extrapolated to CSC (" << lid.endcap() << "," << lid.ring() << "," << lid.station() << "," << lid.layer() << ")" << std::endl; #endif - const GeomDetUnit* det = cscGeom->idToDetUnit(lid); + const GeomDetUnit* det = cscGeom_->idToDetUnit(lid); HelixArbitraryPlaneCrossing crossing(propagatedState.globalPosition().basicVector(), propagatedState.globalMomentum().basicVector(), propagatedState.transverseCurvature(), anyDirection); - std::pair path = crossing.pathLength(det->surface()); + const std::pair& path = crossing.pathLength(det->surface()); if (!path.first) continue; LocalPoint lpos = det->toLocal(GlobalPoint(crossing.position(path.second))); @@ -425,44 +435,42 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet // Factor that takes into account the (rec)hits lost because of delta's, etc.: // (Not fully satisfactory patch, but it seems to work...) double pmu = lmom.mag(); - double theCSCHitIneff = pmu > 0 ? exp(kCSC * log(pmu) + fCSC) : 0.; + double theCSCHitIneff = pmu > 0 ? exp(kCSC_ * log(pmu) + fCSC_) : 0.; // Take into account the different geometry in ME11: if (id.station() == 1 && id.ring() == 1) theCSCHitIneff = theCSCHitIneff * 0.442; if (random.flatShoot() < theCSCHitIneff) continue; - double eloss = 0; - double pz = fabs(lmom.z()); + double pz = std::abs(lmom.z()); LocalPoint entry = lpos - 0.5 * thickness * lmom / pz; LocalPoint exit = lpos + 0.5 * thickness * lmom / pz; double dtof = path.second * rbeta; int trkid = mySimTrack.trackId(); unsigned int id = lid.rawId(); short unsigned int processType = 2; - PSimHit hit( + theCSCHits->emplace_back( entry, exit, lmom.mag(), tof + dtof, eloss, pid, id, trkid, lmom.theta(), lmom.phi(), processType); - theCSCHits.push_back(hit); } } else if (gd->subDetector() == GeomDetEnumerators::RPCBarrel || gd->subDetector() == GeomDetEnumerators::RPCEndcap) { RPCDetId id(gd->geographicalId()); - const RPCChamber* chamber = rpcGeom->chamber(id); - std::vector roll = chamber->rolls(); + const RPCChamber* chamber = rpcGeom_->chamber(id); + const std::vector& roll = chamber->rolls(); for (unsigned int iroll = 0; iroll < roll.size(); iroll++) { RPCDetId rid = roll[iroll]->id(); -#ifdef FAMOS_DEBUG +#ifdef EDM_ML_DEBUG std::cout << " Extrapolated to RPC (" << rid.ring() << "," << rid.station() << "," << rid.sector() << "," << rid.subsector() << "," << rid.layer() << "," << rid.roll() << ")" << std::endl; #endif - const GeomDetUnit* det = rpcGeom->idToDetUnit(rid); + const GeomDetUnit* det = rpcGeom_->idToDetUnit(rid); HelixArbitraryPlaneCrossing crossing(propagatedState.globalPosition().basicVector(), propagatedState.globalMomentum().basicVector(), propagatedState.transverseCurvature(), anyDirection); - std::pair path = crossing.pathLength(det->surface()); + const std::pair& path = crossing.pathLength(det->surface()); if (!path.first) continue; LocalPoint lpos = det->toLocal(GlobalPoint(crossing.position(path.second))); @@ -471,77 +479,92 @@ void MuonSimHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSet double thickness = det->surface().bounds().thickness(); LocalVector lmom = det->toLocal(GlobalVector(crossing.direction(path.second))); lmom = lmom.unit() * propagatedState.localMomentum().mag(); - double eloss = 0; - double pz = fabs(lmom.z()); + double pz = std::abs(lmom.z()); LocalPoint entry = lpos - 0.5 * thickness * lmom / pz; LocalPoint exit = lpos + 0.5 * thickness * lmom / pz; double dtof = path.second * rbeta; int trkid = mySimTrack.trackId(); unsigned int id = rid.rawId(); short unsigned int processType = 2; - PSimHit hit( + theRPCHits->emplace_back( + entry, exit, lmom.mag(), tof + dtof, eloss, pid, id, trkid, lmom.theta(), lmom.phi(), processType); + } + } else if (gd->subDetector() == GeomDetEnumerators::GEM and enableGEM_) { + GEMDetId id(gd->geographicalId()); + const GEMChamber* chamber = gemGeom_->chamber(id); + const std::vector& etaPart = chamber->etaPartitions(); + for (unsigned int ieta = 0; ieta < etaPart.size(); ieta++) { + GEMDetId rid = etaPart[ieta]->id(); + +#ifdef EDM_ML_DEBUG + std::cout << " Extrapolated to GEM (" << rid.ring() << "," << rid.station() << "," << rid.chamber() + << "," << rid.layer() << "," << rid.ieta() << ")" << std::endl; +#endif + + const GeomDetUnit* det = gemGeom_->idToDetUnit(rid); + HelixArbitraryPlaneCrossing crossing(propagatedState.globalPosition().basicVector(), + propagatedState.globalMomentum().basicVector(), + propagatedState.transverseCurvature(), + anyDirection); + const std::pair& path = crossing.pathLength(det->surface()); + if (!path.first) + continue; + LocalPoint lpos = det->toLocal(GlobalPoint(crossing.position(path.second))); + if (!det->surface().bounds().inside(lpos)) + continue; + double thickness = det->surface().bounds().thickness(); + LocalVector lmom = det->toLocal(GlobalVector(crossing.direction(path.second))); + lmom = lmom.unit() * propagatedState.localMomentum().mag(); + double pz = std::abs(lmom.z()); + LocalPoint entry = lpos - 0.5 * thickness * lmom / pz; + LocalPoint exit = lpos + 0.5 * thickness * lmom / pz; + double dtof = path.second * rbeta; + int trkid = mySimTrack.trackId(); + unsigned int id = rid.rawId(); + short unsigned int processType = 2; + theGEMHits->emplace_back( entry, exit, lmom.mag(), tof + dtof, eloss, pid, id, trkid, lmom.theta(), lmom.phi(), processType); - theRPCHits.push_back(hit); } } else { - std::cout << "Extrapolated to unknown subdetector '" << gd->subDetector() << "'..." << std::endl; + edm::LogWarning("FastSimulation/MuonSimHitProducer") + << "Extrapolated to unknown subdetector '" << gd->subDetector(); } } } } - std::unique_ptr pcsc(new edm::PSimHitContainer); - for (std::vector::const_iterator i = theCSCHits.begin(); i != theCSCHits.end(); i++) { - pcsc->push_back(*i); - } - iEvent.put(std::move(pcsc), "MuonCSCHits"); - - std::unique_ptr pdt(new edm::PSimHitContainer); - for (std::vector::const_iterator i = theDTHits.begin(); i != theDTHits.end(); i++) { - pdt->push_back(*i); - } - iEvent.put(std::move(pdt), "MuonDTHits"); - - std::unique_ptr prpc(new edm::PSimHitContainer); - for (std::vector::const_iterator i = theRPCHits.begin(); i != theRPCHits.end(); i++) { - prpc->push_back(*i); - } - iEvent.put(std::move(prpc), "MuonRPCHits"); + iEvent.put(std::move(theCSCHits), "MuonCSCHits"); + iEvent.put(std::move(theDTHits), "MuonDTHits"); + iEvent.put(std::move(theRPCHits), "MuonRPCHits"); + if (enableGEM_) + iEvent.put(std::move(theGEMHits), "MuonGEMHits"); } void MuonSimHitProducer::readParameters(const edm::ParameterSet& fastMuons, const edm::ParameterSet& fastTracks, const edm::ParameterSet& matEff) { // Muons - std::string _simModuleLabel = fastMuons.getParameter("simModuleLabel"); - std::string _simModuleProcess = fastMuons.getParameter("simModuleProcess"); - simMuonLabel = edm::InputTag(_simModuleLabel, _simModuleProcess); - simVertexLabel = edm::InputTag(_simModuleLabel); - - std::vector simHitIneffDT = fastMuons.getParameter >("simHitDTIneffParameters"); - std::vector simHitIneffCSC = fastMuons.getParameter >("simHitCSCIneffParameters"); - kDT = simHitIneffDT[0]; - fDT = simHitIneffDT[1]; - kCSC = simHitIneffCSC[0]; - fCSC = simHitIneffCSC[1]; + const std::string& _simModuleLabel = fastMuons.getParameter("simModuleLabel"); + const std::string& _simModuleProcess = fastMuons.getParameter("simModuleProcess"); + simMuonLabel_ = edm::InputTag(_simModuleLabel, _simModuleProcess); + simVertexLabel_ = edm::InputTag(_simModuleLabel); + + const std::vector& simHitIneffDT_ = fastMuons.getParameter>("simHitDTIneffParameters"); + const std::vector& simHitIneffCSC_ = fastMuons.getParameter>("simHitCSCIneffParameters"); + kDT_ = simHitIneffDT_[0]; + fDT_ = simHitIneffDT_[1]; + kCSC_ = simHitIneffCSC_[0]; + fCSC_ = simHitIneffCSC_[1]; // Tracks fullPattern_ = fastTracks.getUntrackedParameter("FullPatternRecognition"); - // The following should be on LogInfo - // std::cout << " MUON SIM HITS: FastSimulation parameters " << std::endl; - // std::cout << " ============================================== " << std::endl; - // if ( fullPattern_ ) - // std::cout << " The FULL pattern recognition option is turned ON" << std::endl; - // else - // std::cout << " The FAST tracking option is turned ON" << std::endl; - // Material Effects - theMaterialEffects = nullptr; + theMaterialEffects_ = nullptr; if (matEff.getParameter("PairProduction") || matEff.getParameter("Bremsstrahlung") || matEff.getParameter("MuonBremsstrahlung") || matEff.getParameter("EnergyLoss") || matEff.getParameter("MultipleScattering")) - theMaterialEffects = std::make_unique(matEff); + theMaterialEffects_ = std::make_unique(matEff); } void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWithdEdx, @@ -550,20 +573,20 @@ void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWith RandomEngineAndDistribution const* random, HepPDT::ParticleDataTable const& table) { // The energy loss simulator - EnergyLossSimulator* energyLoss = theMaterialEffects->energyLossSimulator(); + EnergyLossSimulator* energyLoss = theMaterialEffects_->energyLossSimulator(); // The multiple scattering simulator - MultipleScatteringSimulator* multipleScattering = theMaterialEffects->multipleScatteringSimulator(); + MultipleScatteringSimulator* multipleScattering = theMaterialEffects_->multipleScatteringSimulator(); // The Muon Bremsstrahlung simulator - MuonBremsstrahlungSimulator* bremsstrahlung = theMaterialEffects->muonBremsstrahlungSimulator(); + MuonBremsstrahlungSimulator* bremsstrahlung = theMaterialEffects_->muonBremsstrahlungSimulator(); // Initialize the Particle position, momentum and energy const Surface& nextSurface = tsos.surface(); GlobalPoint gPos = energyLoss ? tsos.globalPosition() : tsosWithdEdx.globalPosition(); GlobalVector gMom = energyLoss ? tsos.globalMomentum() : tsosWithdEdx.globalMomentum(); - double mu = 0.1056583692; - double en = std::sqrt(gMom.mag2() + mu * mu); + double mu2 = std::pow(0.1056583692, 2); + double en = std::sqrt(gMom.mag2() + mu2); // And now create the Particle XYZTLorentzVector position(gPos.x(), gPos.y(), gPos.z(), 0.); @@ -577,7 +600,7 @@ void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWith // (for corrections once fluctuations are applied) GlobalPoint gPosWithdEdx = tsosWithdEdx.globalPosition(); GlobalVector gMomWithdEdx = tsosWithdEdx.globalMomentum(); - double enWithdEdx = std::sqrt(gMomWithdEdx.mag2() + mu * mu); + double enWithdEdx = std::sqrt(gMomWithdEdx.mag2() + mu2); XYZTLorentzVector deltaPos( gPosWithdEdx.x() - gPos.x(), gPosWithdEdx.y() - gPos.y(), gPosWithdEdx.z() - gPos.z(), 0.); XYZTLorentzVector deltaMom( @@ -594,14 +617,14 @@ void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWith // Particle momentum & position after energy loss + fluctuation XYZTLorentzVector theNewMomentum = theMuon.particle().momentum() + energyLoss->deltaMom() + fac * deltaMom; XYZTLorentzVector theNewPosition = theMuon.particle().vertex() + fac * deltaPos; - fac = (theNewMomentum.E() * theNewMomentum.E() - mu * mu) / theNewMomentum.Vect().Mag2(); + fac = (theNewMomentum.E() * theNewMomentum.E() - mu2) / theNewMomentum.Vect().Mag2(); fac = fac > 0. ? std::sqrt(fac) : 1E-9; theMuon.particle().setMomentum( theNewMomentum.Px() * fac, theNewMomentum.Py() * fac, theNewMomentum.Pz() * fac, theNewMomentum.E()); theMuon.particle().setVertex(theNewPosition); } - // Does the actual mutliple scattering + // Does the actual multiple scattering if (multipleScattering) { // Pass the vector normal to the "next" surface GlobalVector normal = nextSurface.tangentPlane(tsos.globalPosition())->normalVector(); @@ -619,7 +642,7 @@ void MuonSimHitProducer::applyMaterialEffects(TrajectoryStateOnSurface& tsosWith // Fill the propagated state GlobalPoint propagatedPosition(theMuon.particle().X(), theMuon.particle().Y(), theMuon.particle().Z()); GlobalVector propagatedMomentum(theMuon.particle().Px(), theMuon.particle().Py(), theMuon.particle().Pz()); - GlobalTrajectoryParameters propagatedGtp(propagatedPosition, propagatedMomentum, (int)charge, magfield); + GlobalTrajectoryParameters propagatedGtp(propagatedPosition, propagatedMomentum, (int)charge, magfield_); tsosWithdEdx = TrajectoryStateOnSurface(propagatedGtp, nextSurface); } diff --git a/FastSimulation/MuonSimHitProducer/python/MuonSimHitProducer_cfi.py b/FastSimulation/MuonSimHitProducer/python/MuonSimHitProducer_cfi.py index 82d1dab3f137f..b137fd6b20956 100644 --- a/FastSimulation/MuonSimHitProducer/python/MuonSimHitProducer_cfi.py +++ b/FastSimulation/MuonSimHitProducer/python/MuonSimHitProducer_cfi.py @@ -22,7 +22,10 @@ # Set to true if the full pattern recognition was used # to reconstruct tracks in the tracker FullPatternRecognition = cms.untracked.bool(False) - ) + ), + enableGEM = cms.bool(False), ) - +from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 +from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM +(run2_GEM_2017 | run3_GEM).toModify(MuonSimHits, enableGEM = True) diff --git a/SimGeneral/MixingModule/python/mixObjects_cfi.py b/SimGeneral/MixingModule/python/mixObjects_cfi.py index 1a9e270fa24bc..69a6ea748f2a6 100644 --- a/SimGeneral/MixingModule/python/mixObjects_cfi.py +++ b/SimGeneral/MixingModule/python/mixObjects_cfi.py @@ -262,6 +262,11 @@ crossingFrames = theMixObjects.mixSH.crossingFrames + [ 'MuonGEMHits' ] ) ) +(run2_GEM_2017 & fastSim).toModify( theMixObjects, + mixSH = dict( + input = [x for x in theMixObjects.mixSH.input[:-1]]+[cms.InputTag("MuonSimHits","MuonGEMHits")], + ) +) (premix_stage1 & run2_GEM_2017).toModify(theMixObjects, mixSH = dict( pcrossingFrames = theMixObjects.mixSH.pcrossingFrames + [ 'MuonGEMHits' ] @@ -275,6 +280,11 @@ crossingFrames = theMixObjects.mixSH.crossingFrames + [ 'MuonGEMHits' ] ) ) +(run3_GEM & fastSim).toModify( theMixObjects, + mixSH = dict( + input = [x for x in theMixObjects.mixSH.input[:-1]]+[cms.InputTag("MuonSimHits","MuonGEMHits")], + ) +) (premix_stage1 & run3_GEM).toModify(theMixObjects, mixSH = dict( pcrossingFrames = theMixObjects.mixSH.pcrossingFrames + [ 'MuonGEMHits' ] diff --git a/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py b/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py index 8c93c0047842f..fcd79d81ad087 100644 --- a/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py +++ b/SimGeneral/MixingModule/python/trackingTruthProducer_cfi.py @@ -89,10 +89,20 @@ from Configuration.Eras.Modifier_run2_GEM_2017_cff import run2_GEM_2017 run2_GEM_2017.toModify(trackingParticles, simHitCollections = dict( muon = trackingParticles.simHitCollections.muon+[cms.InputTag("g4SimHits","MuonGEMHits")])) +(run2_GEM_2017 & fastSim).toModify(trackingParticles, + simHitCollections = dict( + muon = [x for x in trackingParticles.simHitCollections.muon[:-1]]+[cms.InputTag('MuonSimHits','MuonGEMHits')] + ) +) from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM run3_GEM.toModify(trackingParticles, simHitCollections = dict( muon = trackingParticles.simHitCollections.muon+[cms.InputTag("g4SimHits","MuonGEMHits")])) +(run3_GEM & fastSim).toModify(trackingParticles, + simHitCollections = dict( + muon = [x for x in trackingParticles.simHitCollections.muon[:-1]]+[cms.InputTag('MuonSimHits','MuonGEMHits')] + ) +) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon phase2_muon.toModify( trackingParticles, simHitCollections = dict( diff --git a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py index 241fde39bb22a..4bfd2a0f6fcad 100644 --- a/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py +++ b/SimGeneral/PreMixingModule/python/mixOne_premix_on_sim_cfi.py @@ -219,6 +219,16 @@ ), ) ) +((run2_GEM_2017 | run3_GEM) & fastSim).toModify( + mixData, + workers = dict( + gem = dict( + labelSig = cms.InputTag("mix", "MuonSimHitsMuonGEMHits"), + pileInputTag = cms.InputTag("mix", "MuonSimHitsMuonGEMHits"), + collectionDM = cms.string("MuonSimHitsMuonGEMHits"), + ), + ) +) from Configuration.Eras.Modifier_phase2_common_cff import phase2_common from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker diff --git a/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py b/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py index 17e3596fbf931..f003d18e9d72a 100644 --- a/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py +++ b/SimMuon/GEMDigitizer/python/muonGEMDigis_cfi.py @@ -18,3 +18,8 @@ from Configuration.ProcessModifiers.fastSimPU_cff import fastSimPU fastSimPU.toModify(simMuonGEMDigis, inputCollectionPU = cms.string('MuonSimHitsMuonGEMHits')) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(simMuonGEMDigis, + inputCollection = cms.string('MuonSimHitsMuonGEMHits'), + inputCollectionPU = cms.string('MuonSimHitsMuonGEMHits')) diff --git a/SimMuon/MCTruth/python/MuonAssociatorByHits_cfi.py b/SimMuon/MCTruth/python/MuonAssociatorByHits_cfi.py index f856b0f6f3580..cfc4fc3c80fd1 100644 --- a/SimMuon/MCTruth/python/MuonAssociatorByHits_cfi.py +++ b/SimMuon/MCTruth/python/MuonAssociatorByHits_cfi.py @@ -110,10 +110,12 @@ DTsimhitsTag = "MuonSimHits:MuonDTHits", CSCsimHitsTag = "MuonSimHits:MuonCSCHits", RPCsimhitsTag = "MuonSimHits:MuonRPCHits", + GEMsimhitsTag = "MuonSimHits:MuonGEMHits", simtracksXFTag = "mix:fastSimProducer", DTsimhitsXFTag = "mix:MuonSimHitsMuonDTHits", CSCsimHitsXFTag = "mix:MuonSimHitsMuonCSCHits", RPCsimhitsXFTag = "mix:MuonSimHitsMuonRPCHits", + GEMsimhitsXFTag = "mix:MuonSimHitsMuonGEMHits", ROUList = ['fastSimProducerTrackerHits'] ) diff --git a/Validation/MuonCSCDigis/python/cscDigiValidation_cfi.py b/Validation/MuonCSCDigis/python/cscDigiValidation_cfi.py index 6e95b916cc90c..fa588b774a16c 100644 --- a/Validation/MuonCSCDigis/python/cscDigiValidation_cfi.py +++ b/Validation/MuonCSCDigis/python/cscDigiValidation_cfi.py @@ -69,11 +69,7 @@ useGEMs = True ) -# do not run GEMs in fastsim sequences from Configuration.Eras.Modifier_fastSim_cff import fastSim fastSim.toModify(cscDigiValidation, simHitsTag = "mix:MuonSimHitsMuonCSCHits", - simTrack = dict(inputTag = "fastSimProducer"), - simVertex = dict(inputTag = "fastSimProducer"), - cscSimHit = dict(inputTag = "MuonSimHits:MuonCSCHits") ) diff --git a/Validation/MuonHits/python/muonSimHitMatcherPSet.py b/Validation/MuonHits/python/muonSimHitMatcherPSet.py index a554a1fcd119b..52f87456ceb16 100644 --- a/Validation/MuonHits/python/muonSimHitMatcherPSet.py +++ b/Validation/MuonHits/python/muonSimHitMatcherPSet.py @@ -46,3 +46,14 @@ minNHitsChamber = cms.int32(4), ) ) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(muonSimHitMatcherPSet, + simTrack = dict(inputTag = "fastSimProducer"), + simVertex = dict(inputTag = "fastSimProducer"), + gemSimHit = dict(inputTag = "MuonSimHits:MuonGEMHits"), + me0SimHit = dict(inputTag = "MuonSimHits:MuonME0Hits"), + rpcSimHit = dict(inputTag = "MuonSimHits:MuonRPCHits"), + cscSimHit = dict(inputTag = "MuonSimHits:MuonCSCHits"), + dtSimHit = dict(inputTag = "MuonSimHits:MuonDTHits"), +)