Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-23 00:00:37

0001 import sys
0002 import argparse
0003 import importlib
0004 from pathlib import Path
0005 import FWCore.ParameterSet.Config as cms
0006 
0007 print(f'{sys.argv=}')
0008 # NTOE when running cmsRun, __file__ is not defined
0009 
0010 cfg_idx = -1
0011 for idx, each in enumerate(sys.argv):
0012     if each.endswith('runGEMCSCCoincidenceRateAnalyzer_cfg.py'):
0013         cfg_idx = idx
0014 if cfg_idx < 0:
0015     raise RuntimeError(f'cfg not found: {sys.argv=}')
0016 
0017 print(f'{sys.argv[:cfg_idx + 1]} are interpreted as arguments for cmsRun.')
0018 print(f'parsing argumnets from {sys.argv[cfg_idx + 1:]}.')
0019 
0020 parser = argparse.ArgumentParser(
0021     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
0022 parser.add_argument('-e', '--era', type=str, default='Phase2C17I13M9', help='era')
0023 parser.add_argument('-t', '--global-tag', type=str, default='auto:phase2_realistic_T21', help='global tag')
0024 parser.add_argument('-g', '--geometry', type=str, default='GeometryExtended2026D88Reco', help='geometry')
0025 parser.add_argument('-m', '--max-events', type=int, default=-1, help='max events')
0026 
0027 default_data_dir = Path('/eos/cms/store/relval/CMSSW_12_6_0_pre2/RelValSingleMuPt1000/GEN-SIM-RECO/125X_mcRun4_realistic_v2_2026D88noPU-v1/')
0028 default_input_files = ['file:' + str(each) for each in default_data_dir.glob('**/*.root')]
0029 parser.add_argument('-i', '--input-files', type=str, nargs='+', default=default_input_files, help='input files')
0030 parser.add_argument('-o', '--output-file', type=str, default='output.root', help='output file')
0031 args = parser.parse_args(sys.argv[cfg_idx + 1:])
0032 
0033 for key, value in vars(args).items():
0034     print(f'{key}={value}')
0035 
0036 era_module = importlib.import_module(f'Configuration.Eras.Era_{args.era}_cff')
0037 era = getattr(era_module, args.era)
0038 
0039 process = cms.Process('GEMCSC', era)
0040 
0041 process = cms.Process('TestGEMCSCSegment')
0042 process.load('FWCore.MessageService.MessageLogger_cfi')
0043 process.load(f'Configuration.Geometry.{args.geometry}_cff')
0044 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0045 process.load('RecoLocalMuon.GEMCSCSegment.gemcscSegments_cfi')
0046 process.load('RecoLocalMuon.GEMCSCSegment.gemcscCoincidenceRateAnalyzer_cfi')
0047 
0048 from Configuration.AlCa.GlobalTag import GlobalTag
0049 process.GlobalTag = GlobalTag(process.GlobalTag, args.global_tag, '')
0050 
0051 process.maxEvents = cms.untracked.PSet(
0052     input = cms.untracked.int32(args.max_events)
0053 )
0054 
0055 process.source = cms.Source('PoolSource',
0056     fileNames = cms.untracked.vstring(*args.input_files)
0057 )
0058 
0059 process.gemcscSegments.enableME21GE21 = True
0060 
0061 process.gemcscSegmentSeq = cms.Sequence(
0062     process.gemcscSegments *
0063     process.gemcscCoincidenceRateAnalyzer
0064 )
0065 
0066 process.TFileService = cms.Service('TFileService',
0067     fileName = cms.string(args.output_file)
0068 )
0069 
0070 process.p = cms.Path(process.gemcscSegmentSeq)