Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-01 23:40:16

0001 import FWCore.ParameterSet.Config as cms
0002 import sys, os
0003 import FWCore.ParameterSet.VarParsing as VarParsing
0004 from FWCore.Utilities.Enumerate import Enumerate
0005 from Configuration.Geometry.dictRun4Geometry import detectorVersionDict
0006 
0007 varType = Enumerate ("Run1 2015 2015dev 2017 2017Muon 2021 Run4")
0008 defaultVersion=str();
0009 
0010 def help():
0011    print("Usage: cmsRun dumpSimGeometry_cfg.py  tag=TAG version=VERSION ")
0012    print("   tag=tagname")
0013    print("       identify geometry scenario ")
0014    print("      ", varType.keys())
0015    print("")
0016    print("   version=versionNumber")
0017    print("       scenario version from Run4 dictionary")
0018    print("")
0019    print("   out=outputFileName")
0020    print("       default is cmsSimGeom<tag><version>.root")
0021    print() 
0022    os._exit(1);
0023 
0024 def versionCheck(ver):
0025    if ver == "":
0026       print("Please, specify Run4 scenario version\n")
0027       print(sorted([x[1] for x in detectorVersionDict.items()]))
0028       print("")
0029       help()
0030 
0031 def simGeoLoad(score):
0032     print("Loading configuration for scenario", options.tag , options.version ,"...\n")
0033     if score == "Run1":
0034        process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi")
0035 
0036     elif score == "2015":
0037        process.load("Geometry.CMSCommonData.cmsExtendedGeometry2015XML_cfi")
0038 
0039     elif score == "2015dev":
0040        process.load("Geometry.CMSCommonData.cmsExtendedGeometry2015devXML_cfi")
0041 
0042     elif score == "2017":
0043        process.load("Geometry.CMSCommonData.cmsExtendedGeometry2017XML_cfi")
0044        
0045     elif score == "2017Muon":
0046        process.load("Geometry.CMSCommonData.cmsExtendedGeometry2017MuonXML_cfi")
0047 
0048     elif score == "2021":
0049        process.load("Geometry.CMSCommonData.cmsExtendedGeometry2021XML_cfi")
0050 
0051     elif score == "Run4":
0052        versionCheck(options.version)
0053        process.load("Geometry.CMSCommonData.cmsExtendedGeometryRun4" + options.version + "XML_cfi")
0054  
0055     else:
0056       help()
0057 
0058 options = VarParsing.VarParsing ()
0059 
0060 defaultTag=str(2017);
0061 defaultLevel=14;
0062 defaultOutputFileName="cmsSimGeom-"+ defaultTag +".root"
0063 
0064 options.register ('tag',
0065                   defaultTag, # default value
0066                   VarParsing.VarParsing.multiplicity.singleton,
0067                   VarParsing.VarParsing.varType.string,
0068                   "info about geometry scenario")
0069 options.register ('version',
0070                   defaultVersion, # default value
0071                   VarParsing.VarParsing.multiplicity.singleton,
0072                   VarParsing.VarParsing.varType.string,
0073                   "info about Run4 geometry scenario version")
0074 options.register ('out',
0075                   defaultOutputFileName, # default value
0076                   VarParsing.VarParsing.multiplicity.singleton,
0077                   VarParsing.VarParsing.varType.string,
0078                   "Output file name")
0079 
0080 
0081 options.parseArguments()
0082 
0083 
0084 if (options.out == defaultOutputFileName ):
0085    options.out = "cmsSimGeom-" + str(options.tag) + str(options.version) + ".root"
0086 
0087 process = cms.Process("SIMDUMP")
0088 simGeoLoad(options.tag)
0089 
0090 process.source = cms.Source("EmptySource")
0091 
0092 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
0093 
0094 process.add_(cms.ESProducer("TGeoMgrFromDdd",
0095                             verbose = cms.untracked.bool(False),
0096                             level = cms.untracked.int32(defaultLevel)
0097                             ))
0098 
0099 process.dump = cms.EDAnalyzer("DumpSimGeometry", 
0100                               tag = cms.untracked.string(options.tag),
0101                               outputFileName = cms.untracked.string(options.out))
0102 
0103 process.p = cms.Path(process.dump)