CMS 3D CMS Logo

dumpSimGeometry_cfg.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import sys, os, operator
3 import FWCore.ParameterSet.VarParsing as VarParsing
4 from FWCore.Utilities.Enumerate import Enumerate
5 from pprint import pprint
6 from Configuration.Geometry.dict2023Geometry import detectorVersionDict
7 
8 varType = Enumerate ("Run1 2015 2015dev 2017 2017Muon 2019 2023")
9 defaultVersion=str();
10 
11 def help():
12  print "Usage: cmsRun dumpSimGeometry_cfg.py tag=TAG version=VERSION "
13  print " tag=tagname"
14  print " indentify geometry scenario "
15  print " ", varType.keys()
16  print ""
17  print " version=versionNumber"
18  print " scenario version from 2023 dictionary:"
19  print ""
20  print " out=outputFileName"
21  print " default is cmsSimGeom<tag><version>.root"
22  print
23  os._exit(1);
24 
25 def versionCheck(ver):
26  if ver == "":
27  print "Please, specify 2023 scenario version\n"
28  pprint(sorted(detectorVersionDict.items(),key=operator.itemgetter(1)))
29  help()
30 
31 def simGeoLoad(score):
32  print "Loading configuration for scenario", options.tag , options.version ,"...\n"
33  if score == "Run1":
34  process.load("Geometry.CMSCommonData.cmsIdealGeometryXML_cfi")
35 
36  elif score == "2015":
37  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2015XML_cfi")
38 
39  elif score == "2015dev":
40  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2015devXML_cfi")
41 
42  elif score == "2017":
43  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2017XML_cfi")
44 
45  elif score == "2017Muon":
46  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2017MuonXML_cfi")
47 
48  elif score == "2019":
49  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2019XML_cfi")
50 
51  elif score == "2023":
52  versionCheck(options.version)
53  process.load("Geometry.CMSCommonData.cmsExtendedGeometry2023" + options.version + "XML_cfi")
54 
55  else:
56  help()
57 
58 options = VarParsing.VarParsing ()
59 
60 defaultTag=str(2017);
61 defaultLevel=14;
62 defaultOutputFileName="cmsSimGeom-"+ defaultTag +".root"
63 
64 options.register ('tag',
65  defaultTag, # default value
66  VarParsing.VarParsing.multiplicity.singleton,
67  VarParsing.VarParsing.varType.string,
68  "info about geometry scenario")
69 options.register ('version',
70  defaultVersion, # default value
71  VarParsing.VarParsing.multiplicity.singleton,
72  VarParsing.VarParsing.varType.string,
73  "info about 2023 geometry scenario version")
74 options.register ('out',
75  defaultOutputFileName, # default value
76  VarParsing.VarParsing.multiplicity.singleton,
77  VarParsing.VarParsing.varType.string,
78  "Output file name")
79 
80 
81 options.parseArguments()
82 
83 
84 if (options.out == defaultOutputFileName ):
85  options.out = "cmsSimGeom-" + str(options.tag) + str(options.version) + ".root"
86 
87 process = cms.Process("SIMDUMP")
88 simGeoLoad(options.tag)
89 
90 process.source = cms.Source("EmptySource")
91 
92 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
93 
94 process.add_(cms.ESProducer("TGeoMgrFromDdd",
95  verbose = cms.untracked.bool(False),
96  level = cms.untracked.int32(defaultLevel)
97  ))
98 
99 process.dump = cms.EDAnalyzer("DumpSimGeometry",
100  tag = cms.untracked.string(options.tag),
101  outputFileName = cms.untracked.string(options.out))
102 
103 process.p = cms.Path(process.dump)