Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:34

0001 # Auto generated configuration file
0002 # using:
0003 # Revision: 1.19
0004 # Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v
0005 # with command line options: reHLT --processName reHLT -s HLT:@relval2021 --conditions auto:phase1_2021_realistic --datatier GEN-SIM-DIGI-RAW -n 5 --eventcontent FEVTDEBUGHLT --geometry DB:Extended --era Run3 --customise=HLTrigger/Configuration/customizeHLTforPatatrack.customizeHLTforPatatrack --filein /store/relval/CMSSW_12_3_0_pre5/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/123X_mcRun3_2021_realistic_v6-v1/10000/2639d8f2-aaa6-4a78-b7c2-9100a6717e6c.root
0006 import FWCore.ParameterSet.Config as cms
0007 
0008 from Configuration.Eras.Era_Run3_cff import Run3
0009 
0010 process = cms.Process('rereHLT',Run3)
0011 
0012 # import of standard configurations
0013 process.load('Configuration.StandardSequences.Services_cff')
0014 process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
0015 process.load('FWCore.MessageService.MessageLogger_cfi')
0016 process.load('Configuration.EventContent.EventContent_cff')
0017 process.load('SimGeneral.MixingModule.mixNoPU_cfi')
0018 process.load('Configuration.StandardSequences.GeometryRecoDB_cff')
0019 process.load('Configuration.StandardSequences.MagneticField_cff')
0020 process.load('HLTrigger.Configuration.HLT_GRun_cff')
0021 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0022 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0023 
0024 process.load('Configuration.StandardSequences.Accelerators_cff')
0025 process.load('HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi')
0026 
0027 process.maxEvents = cms.untracked.PSet(
0028     #input = cms.untracked.int32(5),
0029     input = cms.untracked.int32(100),
0030     #input = cms.untracked.int32(1000),
0031     output = cms.optional.untracked.allowed(cms.int32,cms.PSet)
0032 )
0033 
0034 # Input source
0035 # Need to use a file that contains HCAL/ECAL hits. Verify using:
0036 # root root://eoscms.cern.ch//eos/cms/store/relval/CMSSW_13_0_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_130X_mcRun3_2022_realistic_v2_HS-v4/2590000/0088b51b-0cda-40f2-95fc-590f446624ee.root -e 'Events->Print()' -q | grep -E "hltHbhereco|hltEcalRecHit"
0037 process.source = cms.Source("PoolSource",
0038     fileNames = cms.untracked.vstring('/store/relval/CMSSW_13_0_0/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_130X_mcRun3_2022_realistic_v2_HS-v4/2590000/0088b51b-0cda-40f2-95fc-590f446624ee.root'),
0039     secondaryFileNames = cms.untracked.vstring()
0040 )
0041 
0042 process.options = cms.untracked.PSet(
0043     IgnoreCompletely = cms.untracked.vstring(),
0044     Rethrow = cms.untracked.vstring(),
0045     allowUnscheduled = cms.obsolete.untracked.bool,
0046     canDeleteEarly = cms.untracked.vstring(),
0047     deleteNonConsumedUnscheduledModules = cms.untracked.bool(True),
0048     dumpOptions = cms.untracked.bool(False),
0049     emptyRunLumiMode = cms.obsolete.untracked.string,
0050     eventSetup = cms.untracked.PSet(
0051         forceNumberOfConcurrentIOVs = cms.untracked.PSet(
0052             allowAnyLabel_=cms.required.untracked.uint32
0053         ),
0054         numberOfConcurrentIOVs = cms.untracked.uint32(0)
0055     ),
0056     fileMode = cms.untracked.string('FULLMERGE'),
0057     forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False),
0058     makeTriggerResults = cms.obsolete.untracked.bool,
0059     numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0),
0060     numberOfConcurrentRuns = cms.untracked.uint32(1),
0061     numberOfStreams = cms.untracked.uint32(0),
0062     numberOfThreads = cms.untracked.uint32(1),
0063     printDependencies = cms.untracked.bool(False),
0064     sizeOfStackForThreadsInKB = cms.optional.untracked.uint32,
0065     throwIfIllegalParameter = cms.untracked.bool(True),
0066     wantSummary = cms.untracked.bool(False)
0067 )
0068 
0069 # Production Info
0070 process.configurationMetadata = cms.untracked.PSet(
0071     annotation = cms.untracked.string('reHLT nevts:5'),
0072     name = cms.untracked.string('Applications'),
0073     version = cms.untracked.string('$Revision: 1.19 $')
0074 )
0075 
0076 # Output definition
0077 process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule",
0078     dataset = cms.untracked.PSet(
0079         dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'),
0080         filterName = cms.untracked.string('')
0081     ),
0082     fileName = cms.untracked.string('reHLT_HLT.root'),
0083     outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands,
0084     splitLevel = cms.untracked.int32(0)
0085 )
0086 
0087 # Other statements
0088 from HLTrigger.Configuration.CustomConfigs import ProcessName
0089 process = ProcessName(process)
0090 
0091 from Configuration.AlCa.GlobalTag import GlobalTag
0092 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2022_realistic', '')
0093 
0094 # Path and EndPath definitions
0095 process.endjob_step = cms.EndPath(process.endOfProcess)
0096 process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput)
0097 
0098 # Schedule definition
0099 # process.schedule imported from cff in HLTrigger.Configuration
0100 process.schedule.extend([process.endjob_step,process.FEVTDEBUGHLToutput_step])
0101 from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask
0102 associatePatAlgosToolsTask(process)
0103 
0104 # customisation of the process
0105 from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
0106 process = customizeHLTforMC(process)
0107 
0108 # Add early deletion of temporary data products to reduce peak memory need
0109 from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete
0110 process = customiseEarlyDelete(process)
0111 
0112 process.load( "HLTrigger.Timer.FastTimerService_cfi" )
0113 if hasattr(process, 'MessageLogger'):
0114     process.MessageLogger.TriggerSummaryProducerAOD = cms.untracked.PSet()
0115     process.MessageLogger.L1GtTrigReport = cms.untracked.PSet()
0116     process.MessageLogger.L1TGlobalSummary = cms.untracked.PSet()
0117     process.MessageLogger.HLTrigReport = cms.untracked.PSet()
0118     process.MessageLogger.FastReport = cms.untracked.PSet()
0119     process.MessageLogger.ThroughputService = cms.untracked.PSet()
0120     process.MessageLogger.cerr.FastReport = cms.untracked.PSet( limit = cms.untracked.int32( 10000000 ) )
0121 
0122 
0123 #####################################
0124 ##   Read command-line arguments   ##
0125 #####################################
0126 import sys
0127 import argparse
0128 parser = argparse.ArgumentParser(prog="cmsRun "+sys.argv[0], description='Test and validation of PFRecHitProducer with Alpaka')
0129 parser.add_argument('-c', '--cal', type=str, default='HCAL',
0130                     help='Calorimeter type. Possible options: HCAL, ECAL. Default: HCAL')
0131 parser.add_argument('-b', '--backend', type=str, default='auto',
0132                     help='Alpaka backend. Possible options: CPU, GPU, auto. Default: auto')
0133 parser.add_argument('-s', '--synchronise', action='store_true', default=False,
0134                     help='Put synchronisation point at the end of Alpaka modules (for benchmarking performance)')
0135 parser.add_argument('-t', '--threads', type=int, default=8,
0136                     help='Number of threads. Default: 8')
0137 parser.add_argument('-d', '--debug', type=int, default=0, const=1, nargs="?",
0138                     help='Dump PFRecHits for first event (n>0) or first error (n<0). This applies to the n-th validation (1: Legacy vs Alpaka, 2: Legacy vs Legacy-from-Alpaka, 3: Alpaka vs Legacy-from-Alpaka). Default: 0')
0139 args = parser.parse_args()
0140 
0141 if(args.debug and args.threads != 1):
0142     args.threads = 1
0143     print("Number of threads set to 1 for debugging")
0144 
0145 assert args.cal.lower() in ["hcal", "ecal", "h", "e"], "Invalid calorimeter type"
0146 hcal = args.cal.lower() in ["hcal", "h"]
0147 CAL = "HCAL" if hcal else "ECAL"
0148 
0149 alpaka_backends = {
0150     "cpu": "alpaka_serial_sync::%s",  # Execute on CPU
0151     "gpu": "alpaka_cuda_async::%s",   # Execute using CUDA
0152     "cuda": "alpaka_cuda_async::%s",  # Execute using CUDA
0153     "auto": "%s@alpaka"               # Let framework choose
0154 }
0155 assert args.backend.lower() in alpaka_backends, "Invalid backend"
0156 alpaka_backend_str = alpaka_backends[args.backend.lower()]
0157 
0158 
0159 #####################################
0160 ##    Legacy PFRecHit producer     ##
0161 #####################################
0162 if hcal:
0163     process.hltParticleFlowRecHit = cms.EDProducer("PFRecHitProducer",
0164         navigator = cms.PSet(
0165             hcalEnums = cms.vint32(1, 2),
0166             name = cms.string('PFRecHitHCALDenseIdNavigator')
0167         ),
0168         producers = cms.VPSet(cms.PSet(
0169             name = cms.string('PFHBHERecHitCreator'),
0170             qualityTests = cms.VPSet(
0171                 cms.PSet(
0172                     cuts = cms.VPSet(
0173                         cms.PSet(
0174                             depth = cms.vint32(1, 2, 3, 4),
0175                             detectorEnum = cms.int32(1),
0176                             threshold = cms.vdouble(0.1, 0.2, 0.3, 0.3)
0177                         ),
0178                         cms.PSet(
0179                             depth = cms.vint32(1, 2, 3, 4, 5, 6, 7),
0180                             detectorEnum = cms.int32(2),
0181                             threshold = cms.vdouble(0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
0182                         )
0183                     ),
0184                     name = cms.string('PFRecHitQTestHCALThresholdVsDepth')
0185                 ),
0186                 cms.PSet(
0187                     cleaningThresholds = cms.vdouble(0.0),
0188                     flags = cms.vstring('Standard'),
0189                     maxSeverities = cms.vint32(11),
0190                     name = cms.string('PFRecHitQTestHCALChannel')
0191                 )
0192             ),
0193             src = cms.InputTag("hltHbhereco")
0194         ))
0195     )
0196 else:  # ecal
0197     qualityTestsECAL = cms.VPSet(
0198         cms.PSet(
0199             name = cms.string("PFRecHitQTestDBThreshold"),
0200             applySelectionsToAllCrystals=cms.bool(True),
0201         ),
0202         cms.PSet(
0203             name = cms.string("PFRecHitQTestECAL"),
0204             cleaningThreshold = cms.double(2.0),
0205             timingCleaning = cms.bool(True),
0206             topologicalCleaning = cms.bool(True),
0207             skipTTRecoveredHits = cms.bool(True)
0208         )
0209     )
0210     process.hltParticleFlowRecHit = cms.EDProducer("PFRecHitProducer",
0211         navigator = cms.PSet(
0212             name = cms.string("PFRecHitECALNavigator"),
0213             barrel = cms.PSet( ),
0214             endcap = cms.PSet( )
0215         ),
0216         producers = cms.VPSet(
0217             cms.PSet(
0218                 name = cms.string("PFEBRecHitCreator"),
0219                 src  = cms.InputTag("hltEcalRecHit","EcalRecHitsEB"),
0220                 srFlags = cms.InputTag(""),
0221                 qualityTests = qualityTestsECAL
0222             ),
0223             cms.PSet(
0224                 name = cms.string("PFEERecHitCreator"),
0225                 src  = cms.InputTag("hltEcalRecHit","EcalRecHitsEE"),
0226                 srFlags = cms.InputTag(""),
0227                 qualityTests = qualityTestsECAL
0228             )
0229         )
0230     )
0231 
0232 
0233 #####################################
0234 ##    Alpaka PFRecHit producer     ##
0235 #####################################
0236 # Convert legacy CaloRecHits to CaloRecHitSoA
0237 if hcal:
0238     process.hltParticleFlowRecHitToSoA = cms.EDProducer(alpaka_backend_str % "HCALRecHitSoAProducer",
0239         src = cms.InputTag("hltHbhereco"),
0240         synchronise = cms.untracked.bool(args.synchronise)
0241     )
0242 else:  # ecal
0243     process.hltParticleFlowRecHitEBToSoA = cms.EDProducer(alpaka_backend_str % "ECALRecHitSoAProducer",
0244         src = cms.InputTag("hltEcalRecHit","EcalRecHitsEB"),
0245         synchronise = cms.untracked.bool(args.synchronise)
0246     )
0247     process.hltParticleFlowRecHitEEToSoA = cms.EDProducer(alpaka_backend_str % "ECALRecHitSoAProducer",
0248         src = cms.InputTag("hltEcalRecHit","EcalRecHitsEE"),
0249         synchronise = cms.untracked.bool(args.synchronise)
0250     )
0251 
0252 # Construct topology and cut parameter information
0253 process.pfRecHitTopologyRecordSource = cms.ESSource('EmptyESSource',
0254     recordName = cms.string(f'PFRecHit{CAL}TopologyRecord'),
0255     iovIsRunNotTime = cms.bool(True),
0256     firstValid = cms.vuint32(1)
0257 )
0258 if hcal:
0259     # This is not necessary for ECAL, since an existing record can be reused
0260     process.pfRecHitParamsRecordSource = cms.ESSource('EmptyESSource',
0261         recordName = cms.string(f'PFRecHit{CAL}ParamsRecord'),
0262         iovIsRunNotTime = cms.bool(True),
0263         firstValid = cms.vuint32(1)
0264     )
0265 process.hltParticleFlowRecHitTopologyESProducer = cms.ESProducer(alpaka_backend_str % f"PFRecHit{CAL}TopologyESProducer")
0266 if hcal:
0267     process.hltParticleFlowRecHitParamsESProducer = cms.ESProducer(alpaka_backend_str % "PFRecHitHCALParamsESProducer",
0268         energyThresholdsHB = cms.vdouble( 0.1, 0.2, 0.3, 0.3 ),
0269         energyThresholdsHE = cms.vdouble( 0.1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2 )
0270     )
0271 else:  # ecal
0272     process.hltParticleFlowRecHitParamsESProducer = cms.ESProducer(alpaka_backend_str % "PFRecHitECALParamsESProducer",
0273         cleaningThreshold = cms.double(2))
0274 
0275 # Construct PFRecHitSoA
0276 if hcal:
0277     process.hltParticleFlowPFRecHitAlpaka = cms.EDProducer(alpaka_backend_str % "PFRecHitSoAProducerHCAL",
0278         producers = cms.VPSet(
0279             cms.PSet(
0280                 src = cms.InputTag("hltParticleFlowRecHitToSoA"),
0281                 params = cms.ESInputTag("hltParticleFlowRecHitParamsESProducer:"),
0282             )
0283         ),
0284         topology = cms.ESInputTag("hltParticleFlowRecHitTopologyESProducer:"),
0285         synchronise = cms.untracked.bool(args.synchronise)
0286     )
0287 else:  # ecal
0288     process.hltParticleFlowPFRecHitAlpaka = cms.EDProducer(alpaka_backend_str % "PFRecHitSoAProducerECAL",
0289         producers = cms.VPSet(
0290             cms.PSet(
0291                 src = cms.InputTag("hltParticleFlowRecHitEBToSoA"),
0292                 params = cms.ESInputTag("hltParticleFlowRecHitParamsESProducer:")
0293             ),
0294             cms.PSet(
0295                 src = cms.InputTag("hltParticleFlowRecHitEEToSoA"),
0296                 params = cms.ESInputTag("hltParticleFlowRecHitParamsESProducer:")
0297             )
0298         ),
0299         topology = cms.ESInputTag("hltParticleFlowRecHitTopologyESProducer:"),
0300         synchronise = cms.untracked.bool(args.synchronise)
0301     )
0302 
0303 # Convert Alpaka PFRecHits to legacy format (for validation)
0304 process.hltParticleFlowAlpakaToLegacyPFRecHits = cms.EDProducer("LegacyPFRecHitProducer",
0305     src = cms.InputTag("hltParticleFlowPFRecHitAlpaka")
0306 )
0307 
0308 
0309 #####################################
0310 ##       PFRecHit validation       ##
0311 #####################################
0312 # Validate legacy format from legacy module vs SoA format from Alpaka module
0313 # This is the main Alpaka vs legacy test
0314 from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
0315 process.hltParticleFlowPFRecHitComparison = DQMEDAnalyzer("PFRecHitProducerTest",
0316     #caloRecHits = cms.untracked.InputTag("hltParticleFlowRecHitToSoA"),
0317     pfRecHitsSource1 = cms.untracked.InputTag("hltParticleFlowRecHit"),
0318     pfRecHitsSource2 = cms.untracked.InputTag("hltParticleFlowPFRecHitAlpaka"),
0319     pfRecHitsType1 = cms.untracked.string("legacy"),
0320     pfRecHitsType2 = cms.untracked.string("alpaka"),
0321     title = cms.untracked.string("Legacy vs Alpaka"),
0322     dumpFirstEvent = cms.untracked.bool(args.debug == 1),
0323     dumpFirstError = cms.untracked.bool(args.debug == -1),
0324     strictCompare = cms.untracked.bool(True)
0325 )
0326 
0327 # Validate legacy format from legacy module vs legacy format from Alpaka module
0328 process.hltParticleFlowAlpakaToLegacyPFRecHitsComparison1 = DQMEDAnalyzer("PFRecHitProducerTest",
0329     pfRecHitsSource1 = cms.untracked.InputTag("hltParticleFlowRecHit"),
0330     pfRecHitsSource2 = cms.untracked.InputTag("hltParticleFlowAlpakaToLegacyPFRecHits"),
0331     pfRecHitsType1 = cms.untracked.string("legacy"),
0332     pfRecHitsType2 = cms.untracked.string("legacy"),
0333     title = cms.untracked.string("Legacy vs Legacy-from-Alpaka"),
0334     dumpFirstEvent = cms.untracked.bool(args.debug == 2),
0335     dumpFirstError = cms.untracked.bool(args.debug == -2),
0336     strictCompare = cms.untracked.bool(True)
0337 )
0338 
0339 # Validate SoA format from Alpaka module vs legacy format from Alpaka module
0340 # This tests the SoA-to-legacy conversion module
0341 process.hltParticleFlowAlpakaToLegacyPFRecHitsComparison2 = DQMEDAnalyzer("PFRecHitProducerTest",
0342     pfRecHitsSource1 = cms.untracked.InputTag("hltParticleFlowPFRecHitAlpaka"),
0343     pfRecHitsSource2 = cms.untracked.InputTag("hltParticleFlowAlpakaToLegacyPFRecHits"),
0344     pfRecHitsType1 = cms.untracked.string("alpaka"),
0345     pfRecHitsType2 = cms.untracked.string("legacy"),
0346     title = cms.untracked.string("Alpaka vs Legacy-from-Alpaka"),
0347     dumpFirstEvent = cms.untracked.bool(args.debug == 3),
0348     dumpFirstError = cms.untracked.bool(args.debug == -3),
0349     strictCompare = cms.untracked.bool(True)
0350 )
0351 
0352 
0353 # Additional customization
0354 process.FEVTDEBUGHLToutput.outputCommands = cms.untracked.vstring('drop  *_*_*_*')
0355 process.FEVTDEBUGHLToutput.outputCommands.append('keep *_hltParticleFlowRecHitToSoA_*_*')
0356 process.FEVTDEBUGHLToutput.outputCommands.append('keep *_hltParticleFlowPFRecHitAlpaka_*_*')
0357 
0358 # Path/sequence definitions
0359 path = process.hltParticleFlowRecHit               # Construct PFRecHits on CPU
0360 if hcal:
0361     path += process.hltParticleFlowRecHitToSoA     # Convert legacy calorimeter hits to SoA (HCAL barrel+endcap)
0362 else:  # ecal
0363     path += process.hltParticleFlowRecHitEBToSoA   # Convert legacy calorimeter hits to SoA (ECAL barrel)
0364     path += process.hltParticleFlowRecHitEEToSoA   # Convert legacy calorimeter hits to SoA (ECAL endcap)
0365 path += process.hltParticleFlowPFRecHitAlpaka      # Construct PFRecHits SoA
0366 path += process.hltParticleFlowPFRecHitComparison  # Validate Alpaka vs CPU
0367 path += process.hltParticleFlowAlpakaToLegacyPFRecHits             # Convert Alpaka PFRecHits SoA to legacy format
0368 path += process.hltParticleFlowAlpakaToLegacyPFRecHitsComparison1  # Validate legacy-format-from-alpaka vs regular legacy format
0369 path += process.hltParticleFlowAlpakaToLegacyPFRecHitsComparison2  # Validate Alpaka format vs legacy-format-from-alpaka
0370 
0371 process.PFRecHitAlpakaValidationTask = cms.EndPath(path)
0372 process.schedule = cms.Schedule(process.PFRecHitAlpakaValidationTask)
0373 process.schedule.extend([process.endjob_step,process.FEVTDEBUGHLToutput_step])
0374 process.options.numberOfThreads = cms.untracked.uint32(args.threads)
0375 
0376 # Save DQM output
0377 process.DQMoutput = cms.OutputModule("DQMRootOutputModule",
0378     dataset = cms.untracked.PSet(
0379         dataTier = cms.untracked.string('DQMIO'),
0380         filterName = cms.untracked.string('')
0381     ),
0382     fileName = cms.untracked.string('file:DQMIO.root'),
0383     outputCommands = process.DQMEventContent.outputCommands,
0384     splitLevel = cms.untracked.int32(0)
0385 )
0386 process.DQMTask = cms.EndPath(process.DQMoutput)
0387 process.schedule.append(process.DQMTask)