Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DD4hep RelVal for Phase2: update geometry configuration and PyReleaseValidation #31975

Merged
merged 9 commits into from
Oct 30, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

# timing
from RecoMTD.DetLayers.mtdDetLayerGeometry_cfi import *
from Geometry.MTDGeometryBuilder.mtdParameters_cfi import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *
from Geometry.MTDGeometryBuilder.mtdParameters_cff import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *
from Geometry.MTDNumberingBuilder.mtdTopology_cfi import *
from Geometry.MTDGeometryBuilder.mtdGeometry_cfi import *
from Geometry.MTDGeometryBuilder.idealForDigiMTDGeometry_cff import *
Expand Down
24 changes: 5 additions & 19 deletions Configuration/Geometry/python/GeometryDD4hepExtended2026D49_cff.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import FWCore.ParameterSet.Config as cms

#
# Geometry master configuration
#
# Ideal geometry, needed for simulation
DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2026D49.xml'),
appendToDataLabel = cms.string('')
)
# This config was generated automatically using generate2026Geometry.py
# If you notice a mistake, please update the generating script, not just this config

DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer",
appendToDataLabel = cms.string('')
)

DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer",
appendToDataLabel = cms.string(''))

DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer",
appendToDataLabel = cms.string('')
)
from Configuration.Geometry.GeometryDD4hep_cff import *
DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("Geometry/CMSCommonData/data/python/cmsExtendedGeometry2026D49.xml")

from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *
from Geometry.EcalCommonData.ecalSimulationParameters_cff import *
Expand All @@ -27,4 +13,4 @@
from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import *
from Geometry.MuonNumbering.muonGeometryConstants_cff import *
from Geometry.MuonNumbering.muonOffsetESProducer_cff import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *
17 changes: 17 additions & 0 deletions Configuration/Geometry/python/GeometryDD4hep_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import FWCore.ParameterSet.Config as cms

DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath(''),
appendToDataLabel = cms.string('')
)

DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer",
appendToDataLabel = cms.string('')
)

DDVectorRegistryESProducer = cms.ESProducer("DDVectorRegistryESProducer",
appendToDataLabel = cms.string(''))

DDCompactViewESProducer = cms.ESProducer("DDCompactViewESProducer",
appendToDataLabel = cms.string('')
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

# timing
from RecoMTD.DetLayers.mtdDetLayerGeometry_cfi import *
from Geometry.MTDGeometryBuilder.mtdParameters_cfi import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *
from Geometry.MTDGeometryBuilder.mtdParameters_cff import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *
from Geometry.MTDNumberingBuilder.mtdTopology_cfi import *
from Geometry.MTDGeometryBuilder.mtdGeometry_cfi import *
from Geometry.MTDGeometryBuilder.idealForDigiMTDGeometry_cff import *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from Geometry.HGCalCommonData.hgcalNumberingInitialization_cfi import *
from Geometry.MuonNumbering.muonGeometryConstants_cff import *
from Geometry.MuonNumbering.muonOffsetESProducer_cff import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *
from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *
8 changes: 4 additions & 4 deletions Configuration/Geometry/python/dict2021Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
'Geometry/TrackerSimData/data/trackerProdCutsBEAM.xml',
],
"sim" : [
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *',
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import *',
],
"reco" : [
'from Geometry.CommonTopologies.globalTrackingGeometry_cfi import *',
Expand Down Expand Up @@ -516,7 +516,7 @@
'Geometry/TrackerSimData/data/trackerProdCutsBEAM.xml',
],
"sim" : [
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *',
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import *',
],
"reco" : [
'from Geometry.CommonTopologies.globalTrackingGeometry_cfi import *',
Expand Down Expand Up @@ -719,7 +719,7 @@
'Geometry/TrackerSimData/data/trackerProdCutsBEAM.xml',
],
"sim" : [
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *',
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import *',
],
"reco" : [
'from Geometry.CommonTopologies.globalTrackingGeometry_cfi import *',
Expand Down Expand Up @@ -921,7 +921,7 @@
'Geometry/TrackerSimData/data/trackerProdCutsBEAM.xml',
],
"sim" : [
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cfi import *',
'from Geometry.TrackerNumberingBuilder.trackerNumberingGeometry_cff import *',
],
"reco" : [
'from Geometry.CommonTopologies.globalTrackingGeometry_cfi import *',
Expand Down
6 changes: 3 additions & 3 deletions Configuration/Geometry/python/dict2026Geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,12 +1124,12 @@
'Geometry/MTDSimData/data/CrystalBarPhiFlat/mtdProdCuts.xml'
],
"sim" : [
'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *',
'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *',
],
"reco" :[
'from RecoMTD.DetLayers.mtdDetLayerGeometry_cfi import *',
'from Geometry.MTDGeometryBuilder.mtdParameters_cfi import *',
'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cfi import *',
'from Geometry.MTDGeometryBuilder.mtdParameters_cff import *',
'from Geometry.MTDNumberingBuilder.mtdNumberingGeometry_cff import *',
'from Geometry.MTDNumberingBuilder.mtdTopology_cfi import *',
'from Geometry.MTDGeometryBuilder.mtdGeometry_cfi import *',
'from Geometry.MTDGeometryBuilder.idealForDigiMTDGeometry_cff import *',
Expand Down
45 changes: 43 additions & 2 deletions Configuration/Geometry/python/generateGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def generateGeom(self, detectorTuple, args):
xmlName = "cmsExtendedGeometry"+self.detectorYear+detectorVersion+"XML_cfi.py"
xmlDD4hepName = "cmsExtendedGeometry"+self.detectorYear+detectorVersion+".xml"
simName = "GeometryExtended"+self.detectorYear+detectorVersion+"_cff.py"
simDD4hepName = "GeometryDD4hepExtended"+self.detectorYear+detectorVersion+"_cff.py"
recoName = "GeometryExtended"+self.detectorYear+detectorVersion+"Reco_cff.py"
recoDD4hepName = "GeometryDD4hepExtended"+self.detectorYear+detectorVersion+"Reco_cff.py"

# check directories
CMSSWBASE = os.getenv("CMSSW_BASE")
Expand All @@ -64,6 +66,7 @@ def generateGeom(self, detectorTuple, args):
xmlDir = os.path.join(CMSSWBASE,"src","Geometry","CMSCommonData","python")
xmlDD4hepDir = os.path.join(CMSSWBASE,"src","Geometry","CMSCommonData","data","dd4hep")
simrecoDir = os.path.join(CMSSWBASE,"src","Configuration","Geometry","python")
simrecoDD4hepDir = os.path.join(CMSSWBASE,"src","Configuration","Geometry","python")
if args.doTest:
if not os.path.isdir(xmlDir):
xmlDir = os.path.join(CMSSWRELBASE,"src","Geometry","CMSCommonData","python")
Expand All @@ -84,14 +87,22 @@ def generateGeom(self, detectorTuple, args):
else:
simName = os.path.join(simrecoDir,simName)
recoName = os.path.join(simrecoDir,recoName)
if not os.path.isdir(simrecoDD4hepDir):
mvCommands += "mv "+simDD4hepName+" "+simrecoDD4hepDir+"/\n"
mvCommands += "mv "+recoDD4hepName+" "+simrecoDD4hepDir+"/\n"
else:
simDD4hepName = os.path.join(simrecoDD4hepDir,simDD4hepName)
recoDD4hepName = os.path.join(simrecoDD4hepDir,recoDD4hepName)
if len(mvCommands)>0:
print("Warning: some geometry packages not checked out.\nOnce they are available, please execute the following commands manually:\n"+mvCommands)

# open files
xmlFile = open(xmlName,'w')
xmlDD4hepFile = open(xmlDD4hepName,'w')
simFile = open(simName,'w')
simDD4hepFile = open(simDD4hepName,'w')
recoFile = open(recoName,'w')
recoDD4hepFile = open(recoDD4hepName,'w')

# common preamble
preamble = "import FWCore.ParameterSet.Config as cms"+"\n"+"\n"
Expand Down Expand Up @@ -140,16 +151,36 @@ def generateGeom(self, detectorTuple, args):
simFile.write('\n'.join([ aLine for aLine in aDict[detectorTuple[iDict]]["sim"] ])+"\n")
simFile.close()

# create simDD4hep config
simDD4hepFile.write(preamble)
# always need XML
simDD4hepFile.write("from Configuration.Geometry.GeometryDD4hep_cff"+" import *"+"\n")
simDD4hepFile.write("DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath(\"Geometry/CMSCommonData/data/python/"+os.path.basename(xmlDD4hepName)+"\")\n\n")
for iDict,aDict in enumerate(self.allDicts):
if "sim" in aDict[detectorTuple[iDict]].keys():
simDD4hepFile.write('\n'.join([ aLine for aLine in aDict[detectorTuple[iDict]]["sim"] ])+"\n")
simDD4hepFile.close()

# create reco config
recoFile.write(preamble)
# always need sim
recoFile.write("from Configuration.Geometry."+os.path.basename(simName).replace(".py","")+" import *"+"\n\n")
for iDict,aDict in enumerate(self.allDicts):
if "reco" in aDict[detectorTuple[iDict]].keys():
recoFile.write("# "+aDict["name"]+"\n")
recoFile.write('\n'.join([ aLine for aLine in aDict[detectorTuple[iDict]]["reco"] ])+"\n\n")
recoFile.write("# "+aDict["name"]+"\n")
recoFile.write('\n'.join([ aLine for aLine in aDict[detectorTuple[iDict]]["reco"] ])+"\n\n")
recoFile.close()

# create recoDD4hep config
recoDD4hepFile.write(preamble)
# always need sim
recoDD4hepFile.write("from Configuration.Geometry."+os.path.basename(simDD4hepName).replace(".py","")+" import *"+"\n\n")
for iDict,aDict in enumerate(self.allDicts):
if "reco" in aDict[detectorTuple[iDict]].keys():
recoDD4hepFile.write("# "+aDict["name"]+"\n")
recoDD4hepFile.write('\n'.join([ aLine for aLine in aDict[detectorTuple[iDict]]["reco"] ])+"\n\n")
recoDD4hepFile.close()

from Configuration.StandardSequences.GeometryConf import GeometryConf
if not args.doTest: # todo: include these in unit test somehow
# specify Era customizations
Expand Down Expand Up @@ -180,11 +211,21 @@ def generateGeom(self, detectorTuple, args):
errorList.append(simName+" missing")
elif not filecmp.cmp(simName,simFile):
errorList.append(simName+" differs")
simDD4hepFile = os.path.join(simrecoDD4hepDir,simDD4hepName)
if not os.path.isfile(simDD4hepFile):
errorList.append(simDD4hepName+" missing")
elif not filecmp.cmp(simDD4hepName,simDD4hepFile):
errorList.append(simDD4hepName+" differs")
recoFile = os.path.join(simrecoDir,recoName)
if not os.path.isfile(recoFile):
errorList.append(recoName+" missing")
elif not filecmp.cmp(recoName,recoFile):
errorList.append(recoName+" differs")
recoDD4hepFile = os.path.join(simrecoDD4hepDir,recoDD4hepName)
if not os.path.isfile(recoDD4hepFile):
errorList.append(recoDD4hepName+" missing")
elif not filecmp.cmp(recoDD4hepName,recoDD4hepFile):
errorList.append(recoDD4hepName+" differs")
# test for Configuration/StandardSequences
if not 'Extended'+self.detectorYear+detectorVersion in GeometryConf.keys():
errorList.append('Extended'+self.detectorYear+detectorVersion+" missing from GeometryConf")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,15 +846,27 @@ def condition(self, fragment, stepList, key, hasHarvest):

class UpgradeWorkflow_DD4hep(UpgradeWorkflow):
def setup_(self, step, stepName, stepDict, k, properties):
stepDict[stepName][k] = merge([{'--geometry': 'DD4hepExtended2021', '--era': 'Run3_dd4hep'}, stepDict[step][k]])
if 'Run3' in stepDict[step][k]['--era']:
stepDict[stepName][k] = merge([{'--geometry': 'DD4hepExtended2021', '--procModifiers': 'dd4hep'}, stepDict[step][k]])
elif 'Phase2' in stepDict[step][k]['--era']:
dd4hepGeom="DD4hep"
dd4hepGeom+=stepDict[step][k]['--geometry']
stepDict[stepName][k] = merge([{'--geometry' : dd4hepGeom, '--procModifiers': 'dd4hep'}, stepDict[step][k]])
def condition(self, fragment, stepList, key, hasHarvest):
return (fragment=='TTbar_13' or fragment=='ZMM_13' or fragment=='SingleMuPt10') and '2021' in key
if (fragment=='TTbar_13' or fragment=='ZMM_13' or fragment=='SingleMuPt10') and '2021' in key:
return True
if (fragment=='TTbar_14TeV' or fragment=='ZMM_14' or fragment=='SingleMuPt10') and '2026' in key:
return True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition is not complete (doesn't return false when the condition is not met)
I prefer avoiding the redundant if true return true construction:

        return ((fragment=='TTbar_13' or fragment=='ZMM_13' or fragment=='SingleMuPt10') and '2021' in key) \
            or ((fragment=='TTbar_14TeV' or fragment=='ZMM_14' or fragment=='SingleMuPt10') and '2026' in key)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I forgot the False condition, I'll update that

upgradeWFs['DD4hep'] = UpgradeWorkflow_DD4hep(
steps = [
'GenSim',
'GenSimHLBeamSpot',
'Digi',
'DigiTrigger',
'Reco',
'RecoGlobal',
'HARVEST',
'HARVESTGlobal',
'ALCA',
],
PU = [],
Expand Down
1 change: 1 addition & 0 deletions Configuration/StandardSequences/python/GeometryConf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
'Extended2026D72' : 'Extended2026D72,Extended2026D72Reco',
'Extended2026D73' : 'Extended2026D73,Extended2026D73Reco',
'Extended2026D74' : 'Extended2026D74,Extended2026D74Reco',
'DD4hepExtended2026D49' : 'DD4hepExtended2026D49,DD4hepExtended2026D49Reco',
}