Skip to content

Commit 7a2e508

Browse files
authored
Merge pull request #45328 from mmusich/mm_dev_FWdumpRecoGeometry
Improve handling of phase-2 geometries and add unit tests for `Fireworks/Geometry` package
2 parents a557c27 + a759353 commit 7a2e508

File tree

3 files changed

+106
-13
lines changed

3 files changed

+106
-13
lines changed

Fireworks/Geometry/python/dumpRecoGeometry_cfg.py

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def versionCheck(ver):
4343
print("")
4444
help()
4545

46-
def recoGeoLoad(score):
46+
def recoGeoLoad(score, properties):
4747
print("Loading configuration for tag ", options.tag ,"...\n")
4848

4949
if score == "Run1":
@@ -64,7 +64,7 @@ def recoGeoLoad(score):
6464
process.GlobalTag.globaltag = autoCond['upgrade2017']
6565
process.load('Configuration.Geometry.GeometryExtended2017Reco_cff')
6666

67-
elif score == "2021":
67+
elif score == "2021":
6868
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
6969
from Configuration.AlCa.autoCond import autoCond
7070
process.GlobalTag.globaltag = autoCond['upgrade2021']
@@ -78,10 +78,32 @@ def recoGeoLoad(score):
7878
elif "2026" in score:
7979
versionCheck(options.version)
8080
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
81-
from Configuration.AlCa.autoCond import autoCond
82-
process.GlobalTag.globaltag = autoCond['phase2_realistic']
81+
82+
# Import the required configuration from the CMSSW module
83+
from Configuration.AlCa.autoCond import autoCond # Ensure autoCond is imported
84+
85+
# Ensure options.version is defined and set correctly
86+
version_key = '2026' + options.version # This constructs the key for accessing the properties dictionary
87+
print(f"Constructed version key: {version_key}")
88+
89+
# Check if the key exists in properties for 2026
90+
if version_key in properties[2026]:
91+
# Get the specific global tag for this version
92+
global_tag_key = properties[2026][version_key]['GT']
93+
print(f"Global tag key from properties: {global_tag_key}")
94+
95+
# Check if this key exists in autoCond
96+
if global_tag_key.replace("auto:", "") in autoCond:
97+
# Set the global tag
98+
from Configuration.AlCa.GlobalTag import GlobalTag
99+
process.GlobalTag = GlobalTag(process.GlobalTag, global_tag_key, '')
100+
else:
101+
raise KeyError(f"Global tag key '{global_tag_key}' not found in autoCond.")
102+
else:
103+
raise KeyError(f"Version key '{version_key}' not found in properties[2026].")
83104
process.load('Configuration.Geometry.GeometryExtended2026'+options.version+'Reco_cff')
84-
105+
process.trackerGeometry.applyAlignment = cms.bool(False)
106+
85107
elif score == "MaPSA":
86108
process.load('Geometry.TrackerGeometryBuilder.idealForDigiTrackerGeometry_cff')
87109
process.load('Geometry.TrackerCommonData.mapsaGeometryXML_cfi')
@@ -114,11 +136,8 @@ def recoGeoLoad(score):
114136
help()
115137

116138

117-
118-
119139
options = VarParsing.VarParsing ()
120140

121-
122141
defaultOutputFileName="cmsRecoGeom.root"
123142

124143
options.register ('tag',
@@ -171,16 +190,33 @@ def recoGeoLoad(score):
171190

172191
options.parseArguments()
173192

174-
175-
176-
177-
process = cms.Process("DUMP")
193+
from Configuration.PyReleaseValidation.upgradeWorkflowComponents import upgradeProperties as properties
194+
# Determine version_key based on the value of options.tag
195+
if options.tag == "2026" or options.tag == "MaPSA":
196+
prop_key = 2026
197+
version_key = options.tag + options.version
198+
elif options.tag == "2017" or options.tag == "2021": #(this leads to crashes in tests ?)
199+
prop_key = 2017
200+
version_key = options.tag
201+
else:
202+
prop_key = None
203+
version_key = None
204+
205+
if(prop_key and version_key):
206+
print(f"Constructed version key: {version_key}")
207+
era_key = properties[prop_key][str(version_key)]['Era']
208+
print(f"Constructed era key: {era_key}")
209+
from Configuration.StandardSequences.Eras import eras
210+
era = getattr(eras, era_key)
211+
process = cms.Process("DUMP",era)
212+
else:
213+
process = cms.Process("DUMP")
178214
process.add_(cms.Service("InitRootHandlers", ResetRootErrHandler = cms.untracked.bool(False)))
179215
process.source = cms.Source("EmptySource")
180216
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
181217

182218

183-
recoGeoLoad(options.tag)
219+
recoGeoLoad(options.tag,properties)
184220

185221
if ( options.tgeo == True):
186222
if (options.out == defaultOutputFileName ):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<test name="test_dumpRecoGeometry" command="test_dumpRecoGeometry.sh"/>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash -x
2+
function die { echo $1: status $2 ; exit $2; }
3+
4+
# Define the base directory where the geometry files are located
5+
GEOMETRY_DIR="${CMSSW_BASE}/src/Configuration/Geometry/python"
6+
if [ ! -e ${GEOMETRY_DIR} ] ; then
7+
GEOMETRY_DIR="${CMSSW_RELEASE_BASE}/src/Configuration/Geometry/python"
8+
fi
9+
10+
# Define the list of tags
11+
TAGS=("Run1" "2015" "2017" "2026") #"2021"
12+
13+
# Function to extract the available versions for 2026
14+
get_2026_versions() {
15+
local files=($(ls ${GEOMETRY_DIR}/GeometryExtended2026D*Reco*))
16+
if [ ${#files[@]} -eq 0 ]; then
17+
echo "No files found for 2026 versions."
18+
exit 1
19+
fi
20+
21+
local versions=()
22+
for file in "${files[@]}"; do
23+
local version=$(basename "$file" | sed -n 's/.*GeometryExtended2026D\([0-9]\{1,3\}\).*/\1/p')
24+
if [[ "$version" =~ ^[0-9]{1,3}$ ]]; then
25+
versions+=("D${version}")
26+
fi
27+
done
28+
29+
# Return the unique sorted list of versions
30+
echo "${versions[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '
31+
}
32+
33+
# Iterate over each tag
34+
for TAG in "${TAGS[@]}"; do
35+
if [ "$TAG" == "2026" ]; then
36+
# Get all the versions for 2026
37+
VERSIONS=($(get_2026_versions))
38+
for VERSION in "${VERSIONS[@]}"; do
39+
echo "Running for 2026 with version $VERSION"
40+
cmsRun $CMSSW_BASE/src/Fireworks/Geometry/python/dumpRecoGeometry_cfg.py tag=2026 version=$VERSION
41+
# Check the exit status of the command
42+
if [ $? -ne 0 ]; then
43+
echo "Error running cmsRun for tag=2026 and version=$VERSION"
44+
exit 1
45+
fi
46+
done
47+
else
48+
echo "Running for tag $TAG"
49+
cmsRun $CMSSW_BASE/src/Fireworks/Geometry/python/dumpRecoGeometry_cfg.py tag=$TAG
50+
# Check the exit status of the command
51+
if [ $? -ne 0 ]; then
52+
echo "Error running cmsRun for tag=$TAG"
53+
exit 1
54+
fi
55+
fi
56+
done

0 commit comments

Comments
 (0)