13 doTest = bool(options.doTest)
15 detectorVersion =
"D"+str(options.detectorVersionManual)
17 if options.v_detector>0:
18 detectorVersion =
"D"+str(options.v_detector)
19 if detectorVersion
in detectorVersionDict.values():
20 detectorTuple = detectorVersionDict.keys()[detectorVersionDict.values().
index(detectorVersion)]
22 print "Unknown detector "+detectorVersion
24 elif detectorTuple
in detectorVersionDict.keys():
25 detectorVersion = detectorVersionDict[detectorTuple]
27 if not doTest:
print "Detector "+str(detectorTuple)+
" not found in dictionary, using "+(
"default" if options.detectorVersionManual==detectorVersionDefault
else "provided")+
" version number "+str(detectorVersion)
30 if detectorVersion
in deprecatedDets:
31 print "Error: "+detectorVersion+
" is deprecated and cannot be used."
33 for subdet
in detectorTuple:
34 if subdet
in deprecatedSubdets:
35 print "Error: "+subdet+
" is deprecated and cannot be used."
39 xmlName =
"cmsExtendedGeometry2023"+detectorVersion+
"XML_cfi.py"
40 simName =
"GeometryExtended2023"+detectorVersion+
"_cff.py"
41 recoName =
"GeometryExtended2023"+detectorVersion+
"Reco_cff.py"
44 CMSSWBASE = os.getenv(
"CMSSW_BASE")
45 CMSSWRELBASE = os.getenv(
"CMSSW_RELEASE_BASE")
46 if CMSSWBASE
is None: CMSSWBASE =
""
47 xmlDir = os.path.join(CMSSWBASE,
"src",
"Geometry",
"CMSCommonData",
"python")
48 simrecoDir = os.path.join(CMSSWBASE,
"src",
"Configuration",
"Geometry",
"python")
50 if not os.path.isdir(xmlDir):
51 xmlDir = os.path.join(CMSSWRELBASE,
"src",
"Geometry",
"CMSCommonData",
"python")
54 if not os.path.isdir(xmlDir):
55 mvCommands +=
"mv "+xmlName+
" "+xmlDir+
"/\n"
57 xmlName = os.path.join(xmlDir,xmlName)
58 if not os.path.isdir(simrecoDir):
59 mvCommands +=
"mv "+simName+
" "+simrecoDir+
"/\n"
60 mvCommands +=
"mv "+recoName+
" "+simrecoDir+
"/\n"
62 simName = os.path.join(simrecoDir,simName)
63 recoName = os.path.join(simrecoDir,recoName)
65 print "Warning: some geometry packages not checked out.\nOnce they are available, please execute the following commands manually:\n"+mvCommands
68 xmlFile = open(xmlName,
'w')
69 simFile = open(simName,
'w')
70 recoFile = open(recoName,
'w')
73 preamble =
"import FWCore.ParameterSet.Config as cms"+
"\n"+
"\n"
74 preamble +=
"# This config was generated automatically using generate2023Geometry.py"+
"\n"
75 preamble +=
"# If you notice a mistake, please update the generating script, not just this config"+
"\n"+
"\n"
78 xmlFile.write(preamble)
80 xmlFile.write(
"XMLIdealGeometryESSource = cms.ESSource(\"XMLIdealGeometryESSource\","+
"\n")
81 xmlFile.write(
" geomXMLFiles = cms.vstring("+
"\n")
82 for section
in range(1,maxsections+1):
85 xmlFile.write(
" )+"+
"\n"+
" cms.vstring("+
"\n")
86 for iDict,aDict
in enumerate(allDicts):
87 if section
in aDict[detectorTuple[iDict]].
keys():
88 xmlFile.write(
'\n'.
join([
" '"+aLine+
"'," for aLine
in aDict[detectorTuple[iDict]][section] ])+
"\n")
90 xmlFile.write(
" ),"+
"\n"+
" rootNodeName = cms.string('cms:OCMS')"+
"\n"+
")"+
"\n")
94 simFile.write(preamble)
96 simFile.write(
"from Geometry.CMSCommonData."+os.path.basename(xmlName).
replace(
".py",
"")+
" import *"+
"\n")
97 for iDict,aDict
in enumerate(allDicts):
98 if "sim" in aDict[detectorTuple[iDict]].
keys():
99 simFile.write(
'\n'.
join([ aLine
for aLine
in aDict[detectorTuple[iDict]][
"sim"] ])+
"\n")
103 recoFile.write(preamble)
105 recoFile.write(
"from Configuration.Geometry."+os.path.basename(simName).
replace(
".py",
"")+
" import *"+
"\n\n")
106 for iDict,aDict
in enumerate(allDicts):
107 if "reco" in aDict[detectorTuple[iDict]].
keys():
108 recoFile.write(
"# "+aDict[
"name"]+
"\n")
109 recoFile.write(
'\n'.
join([ aLine
for aLine
in aDict[detectorTuple[iDict]][
"reco"] ])+
"\n\n")
112 from Configuration.StandardSequences.GeometryConf
import GeometryConf
121 for iDict,aDict
in enumerate(allDicts):
122 if "era" in aDict[detectorTuple[iDict]].
keys():
123 eraLineItems.append(aDict[detectorTuple[iDict]][
"era"])
124 eraLine +=
", ".
join([ eraLineItem
for eraLineItem
in eraLineItems ])
125 print "The Era for this detector should contain:"
129 if not 'Extended2023'+detectorVersion
in GeometryConf.keys():
130 print "Please add this line in Configuration/StandardSequences/python/GeometryConf.py:"
131 print " 'Extended2023"+detectorVersion+
"' : 'Extended2023"+detectorVersion+
",Extended2023"+detectorVersion+
"Reco',"
137 if not filecmp.cmp(simName,os.path.join(simrecoDir,simName)):
138 errorList.append(simName+
" differs");
139 if not filecmp.cmp(recoName,os.path.join(simrecoDir,recoName)):
140 errorList.append(recoName+
" differs");
142 if not 'Extended2023'+detectorVersion
in GeometryConf.keys():
143 errorList.append(
'Extended2023'+detectorVersion+
" missing from GeometryConf")
145 if not filecmp.cmp(xmlName,os.path.join(xmlDir,xmlName)):
146 errorList.append(xmlName+
" differs");