Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-08-20 02:35:10

0001 #!/usr/bin/env python3
0002 
0003 import FWCore.ParameterSet.Config as cms
0004 import FWCore.ParameterSet.VarParsing as VarParsing
0005 
0006 import os
0007 import sys
0008 
0009 process = cms.Process('dumpLHCInfoPerPyalods')
0010 
0011 TEST_DIR = os.environ['CMSSW_BASE'] + "/src/CondTools/RunInfo/test"
0012 
0013 
0014 options = VarParsing.VarParsing()
0015 supported_records = {"LHCInfoPerLS", "LHCInfoPerFill"}
0016 csv_supported_records = {"LHCInfoPerLS"}
0017 supported_timetypes = {"timestamp", "lumiid"}
0018 options.register( 'record'
0019                 , None #default value is None because this argument is required
0020                 , VarParsing.VarParsing.multiplicity.singleton
0021                 , VarParsing.VarParsing.varType.string
0022                 , f"the class to analyze, accepted values: {supported_records}"
0023                   )
0024 options.register( 'db'
0025                 , 'frontier://FrontierProd/CMS_CONDITIONS' #default value
0026                 , VarParsing.VarParsing.multiplicity.singleton
0027                 , VarParsing.VarParsing.varType.string
0028                 , "Connection string to the DB where payloads are going to be read from"
0029                   )
0030 options.register( 'tag'
0031                 , None #default value is None because this argument is required
0032                 , VarParsing.VarParsing.multiplicity.singleton
0033                 , VarParsing.VarParsing.varType.string
0034                 , "Tag to read from in source"
0035                   )
0036 options.register( 'timetype'
0037                 , 'timestamp' #default
0038                 , VarParsing.VarParsing.multiplicity.singleton
0039                 , VarParsing.VarParsing.varType.string
0040                 , f"timetype of the provided IOVs, accepted values: {supported_timetypes}"
0041                   )
0042 options.register( 'csv'
0043                 , False
0044                 , VarParsing.VarParsing.multiplicity.singleton
0045                 , VarParsing.VarParsing.varType.bool
0046                 , f"Whether or not to print the values in csv format, supported only for records: {csv_supported_records}"
0047                   )
0048 options.register( 'header'
0049                 , False
0050                 , VarParsing.VarParsing.multiplicity.singleton
0051                 , VarParsing.VarParsing.varType.bool
0052                 , "Whether or not to print header for the csv, works only when csv=True"
0053                   )
0054 options.register( 'separator'
0055                 , ','
0056                 , VarParsing.VarParsing.multiplicity.singleton
0057                 , VarParsing.VarParsing.varType.string
0058                 , "separator for the csv format, works only when csv=True"
0059                   )
0060 options.parseArguments()
0061 
0062 if options.record is None:
0063   print(f"Please specify the record name argument (accepted values: {supported_records})", file=sys.stderr)
0064   exit(1)
0065 if options.record not in supported_records:
0066   print(f"Provided record name '{options.record}' is not supported (accepted values: {supported_records})", file=sys.stderr)
0067   exit(1)
0068 
0069 if options.tag is None:
0070   print(f"Please specify the tag by adding to the command: tag=<tag to be printed>", file=sys.stderr)
0071   exit(1)
0072 
0073 if options.timetype not in supported_timetypes:
0074   print(f"Provided timetype '{options.timetype}' is not supported (accepted values: {supported_timetypes})", file=sys.stderr)
0075   exit(1)
0076 
0077 for line in map(str.rstrip, sys.stdin):
0078     for iov in line.split():
0079         csv_arguments = f" csv={options.csv} header={options.header} separator={options.separator} " 
0080         arguments = f"db={options.db} tag={options.tag} iov={iov} timetype={options.timetype} " + \
0081             (csv_arguments if options.record in csv_supported_records else "")
0082 
0083         if options.record == "LHCInfoPerLS":
0084             os.system(f"cmsRun {TEST_DIR}/LHCInfoPerLSAnalyzer_cfg.py {arguments}")
0085         elif options.record == "LHCInfoPerFill":
0086             os.system(f"cmsRun {TEST_DIR}/LHCInfoPerFillAnalyzer_cfg.py {arguments}")
0087 
0088         options.header = False