Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-18 03:42:14

0001 # Author: Izaak Neutelings (March 2023)
0002 # Instructions:
0003 #   export SCRAM_ARCH="el9_amd64_gcc12"
0004 #   cmsrel CMSSW_14_1_0_pre4
0005 #   cd CMSSW_14_1_0_pre4/src/
0006 #   cmsenv
0007 #   git cms-merge-topic -u CMS-HGCAL:dev/hackathon_base_CMSSW_14_1_X
0008 #   git clone https://github.com/pfs/Geometry-HGCalMapping.git  $CMSSW_BASE/src/Geometry/HGCalMapping/data
0009 #   git clone https://gitlab.cern.ch/hgcal-dpg/hgcal-comm.git HGCalCommissioning
0010 #   scram b -j8
0011 #   cmsRun $CMSSW_BASE/src/RecoLocalCalo/HGCalRecAlgos/test/testHGCalRecHitESProducers_cfg.py
0012 # Sources:
0013 #   https://github.com/CMS-HGCAL/cmssw/blob/hgcal-condformat-HGCalNANO-13_2_0_pre3/DPGAnalysis/HGCalTools/python/tb2023_cfi.py
0014 #   https://gitlab.cern.ch/hgcal-dpg/hgcal-comm/-/blob/master/SystemTestEventFilters/test/test_raw2reco.py
0015 #   https://github.com/CMS-HGCAL/cmssw/blob/dev/hackathon_base_CMSSW_14_1_0_pre0/SimCalorimetry/HGCalSimProducers/test/hgcalRealistiDigis_cfg.py
0016 import os
0017 import FWCore.ParameterSet.Config as cms
0018 
0019 # USER OPTIONS
0020 from FWCore.ParameterSet.VarParsing import VarParsing
0021 datadir = os.path.join(os.environ.get('CMSSW_BASE',''),"src/HGCalCommissioning/LocalCalibration/data")
0022 options = VarParsing('standard')
0023 options.register('geometry', 'Extended2026D94', VarParsing.multiplicity.singleton, VarParsing.varType.string,
0024                  info="geometry to use")
0025 options.register('fedconfig',f"{datadir}/config_feds.json",mytype=VarParsing.varType.string,
0026                  info="Path to configuration (JSON format)")
0027 options.register('modconfig',f"{datadir}/config_econds.json",mytype=VarParsing.varType.string,
0028                  info="Path to configuration (JSON format)")
0029 options.register('params',f"{datadir}/level0_calib_params.json",mytype=VarParsing.varType.string,
0030                  info="Path to calibration parameters (JSON format)")
0031 options.register('modules',
0032                  #"Geometry/HGCalMapping/data/ModuleMaps/modulelocator_test.txt", # test beam with six modules
0033                  #"Geometry/HGCalMapping/data/ModuleMaps/modulelocator_test_2mods.txt", # only first two modules, fedId=49
0034                  "HGCalCommissioning/Configuration/data/ModuleMaps/modulelocator_test_2mods.txt", # fedId=0
0035                  mytype=VarParsing.varType.string,
0036                  info="Path to module mapper. Absolute, or relative to CMSSW src directory")
0037 options.register('sicells','Geometry/HGCalMapping/data/CellMaps/WaferCellMapTraces.txt',mytype=VarParsing.varType.string,
0038                  info="Path to Si cell mapper. Absolute, or relative to CMSSW src directory")
0039 options.register('sipmcells','Geometry/HGCalMapping/data/CellMaps/channels_sipmontile.hgcal.txt',mytype=VarParsing.varType.string,
0040                  info="Path to SiPM-on-tile cell mapper. Absolute, or relative to CMSSW src directory")
0041 options.parseArguments()
0042 if len(options.files)==0:
0043   options.files=['file:/eos/cms/store/group/dpg_hgcal/comm_hgcal/psilva/hackhathon/23234.103_TTbar_14TeV+2026D94Aging3000/step2.root']
0044   #options.files=['file:/eos/cms/store/group/dpg_hgcal/comm_hgcal/psilva/hackhathon/23234.103_TTbar_14TeV+2026D94Aging3000/step2.root']
0045   #options.files=['file:/afs/cern.ch/user/y/yumiao/public/HGCAL_Raw_Data_Handling/Data/Digis/testFakeDigisSoA.root']
0046   #options.files=['file:/home/hgcdaq00/CMSSW/data/23234.103_TTbar_14TeV+2026D94Aging3000/step2.root'] # on DAQ PC
0047   #options.files=['file:/home/hgcdaq00/CMSSW/data/testFakeDigisSoA.root'] # on DAQ PC
0048 print(f">>> Geometry:      {options.geometry!r}")
0049 print(f">>> Input files:   {options.files!r}")
0050 print(f">>> Module map:    {options.modules!r}")
0051 print(f">>> SiCell map:    {options.sicells!r}")
0052 print(f">>> SipmCell map:  {options.sipmcells!r}")
0053 print(f">>> FED config:    {options.fedconfig!r}")
0054 print(f">>> ECON-D config: {options.modconfig!r}")
0055 print(f">>> Calib params:  {options.params!r}")
0056 
0057 # PROCESS
0058 from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 as Era_Phase2
0059 process = cms.Process('HGCalRecHitESProducersTest',Era_Phase2)
0060 
0061 # GLOBAL TAG
0062 from Configuration.AlCa.GlobalTag import GlobalTag
0063 process.load("Configuration.StandardSequences.Services_cff")
0064 process.load("Configuration.StandardSequences.MagneticField_cff")
0065 process.load("Configuration.EventContent.EventContent_cff")
0066 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0067 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')
0068 
0069 # INPUT
0070 process.source = cms.Source(
0071   "PoolSource",
0072   fileNames = cms.untracked.vstring(options.files),
0073   duplicateCheckMode = cms.untracked.string("noDuplicateCheck")
0074 )
0075 #process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) )
0076 process.maxEvents.input = 1
0077 
0078 # MESSAGE LOGGER
0079 process.load("FWCore.MessageService.MessageLogger_cfi")
0080 process.MessageLogger.cerr.threshold = ''
0081 process.MessageLogger.cerr.FwkReport.reportEvery = 500
0082 
0083 # GEOMETRY
0084 process.load(f"Configuration.Geometry.Geometry{options.geometry}Reco_cff")
0085 process.load(f"Configuration.Geometry.Geometry{options.geometry}_cff")
0086 #process.load('Geometry.HGCalMapping.hgCalMappingIndexESSource_cfi') # old
0087 process.load('Geometry.HGCalMapping.hgCalMappingESProducer_cfi')
0088 process.hgCalMappingESProducer.si = cms.FileInPath(options.sicells)
0089 process.hgCalMappingESProducer.sipm = cms.FileInPath(options.sipmcells)
0090 process.hgCalMappingESProducer.modules = cms.FileInPath(options.modules)
0091 
0092 # GLOBAL CONFIGURATION ESProducers (for unpacker)
0093 #process.load("RecoLocalCalo.HGCalRecAlgos.HGCalConfigurationESProducer")
0094 #process.load("RecoLocalCalo.HGCalRecAlgos.hgCalConfigurationESProducer_cfi")
0095 process.hgcalConfigESProducer = cms.ESSource( # ESProducer to load configurations for unpacker
0096   'HGCalConfigurationESProducer',
0097   fedjson=cms.string(options.fedconfig), # JSON with FED configuration parameters
0098   modjson=cms.string(options.modconfig), # JSON with ECON-D configuration parameters
0099   #passthroughMode=cms.int32(0),          # ignore mismatch
0100   #cbHeaderMarker=cms.int32(0x7f),        # capture block
0101   ##cbHeaderMarker=cms.int32(0x5f),        # capture block
0102   #slinkHeaderMarker=cms.int32(0x55),     # S-link
0103   ##slinkHeaderMarker=cms.int32(0x2a),     # S-link
0104   #econdHeaderMarker=cms.int32(0x154),    # ECON-D
0105   #charMode=cms.int32(1),
0106   indexSource=cms.ESInputTag('hgCalMappingESProducer','')
0107 )
0108 
0109 # CALIBRATIONS & CONFIGURATION Alpaka ESProducers
0110 process.load('Configuration.StandardSequences.Accelerators_cff')
0111 #process.load('HeterogeneousCore.AlpakaCore.ProcessAcceleratorAlpaka_cfi')
0112 #process.load('HeterogeneousCore.CUDACore.ProcessAcceleratorCUDA_cfi')
0113 process.hgcalConfigParamESProducer = cms.ESProducer( # ESProducer to load configurations parameters from YAML file, like gain
0114   'hgcalrechit::HGCalConfigurationESProducer@alpaka',
0115   gain=cms.int32(1), # to switch between 80, 160, 320 fC calibration
0116   #charMode=cms.int32(1),
0117   indexSource=cms.ESInputTag('hgCalMappingESProducer','')
0118 )
0119 process.hgcalCalibParamESProducer = cms.ESProducer( # ESProducer to load calibration parameters from JSON file, like pedestals
0120   'hgcalrechit::HGCalCalibrationESProducer@alpaka',
0121   filename=cms.string(options.params),
0122   indexSource=cms.ESInputTag('hgCalMappingESProducer',''),
0123   configSource=cms.ESInputTag(''),
0124 )
0125 
0126 # MAIN PROCESS
0127 process.testHGCalRecHitESProducers = cms.EDProducer(
0128   'HGCalRecHitESProducersTest@alpaka',
0129   #'alpaka_cuda_async::TestHGCalRecHitProducer', # GPU
0130   #'alpaka_serial_sync::TestHGCalRecHitProducer', # CPU
0131   indexSource=cms.ESInputTag('hgCalMappingESProducer', ''),
0132   configSource=cms.ESInputTag('hgcalConfigESProducer', ''),
0133   configParamSource=cms.ESInputTag('hgcalConfigParamESProducer', ''),
0134   calibParamSource=cms.ESInputTag('hgcalCalibParamESProducer', ''),
0135 )
0136 process.t = cms.Task(process.testHGCalRecHitESProducers)
0137 process.p = cms.Path(process.t)
0138 
0139 # OUTPUT
0140 process.output = cms.OutputModule(
0141   'PoolOutputModule',
0142   fileName = cms.untracked.string(options.output),
0143   #outputCommands = cms.untracked.vstring('drop *','keep *_*_*_REALDIGI')
0144 )
0145 process.output_path = cms.EndPath(process.output)
0146