Skip to content

Commit

Permalink
add unit tests for Zmumu validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Feb 28, 2024
1 parent df0dced commit 190724f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 12 deletions.
32 changes: 20 additions & 12 deletions Alignment/OfflineValidation/python/TkAlAllInOneTool/Zmumu_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import FWCore.PythonUtilities.LumiList as LumiList
from FWCore.ParameterSet.VarParsing import VarParsing
from Alignment.OfflineValidation.TkAlAllInOneTool.utils import _byteify
from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultMC_DoubleMuonAlCa_string

###################################################################
# Define process
Expand All @@ -26,20 +27,27 @@
###################################################################
# Read in AllInOne config in JSON format
###################################################################
with open(options.config, "r") as configFile:
if version_info.major == 2:
config = _byteify(json.load(configFile, object_hook=_byteify),ignore_dicts=True)
else:
config = json.load(configFile)
if options.config == "":
config = {"validation": {},
"alignment": {}}
else:
with open(options.config, "r") as configFile:
if version_info.major == 2:
config = _byteify(json.load(configFile, object_hook=_byteify),ignore_dicts=True)
else:
config = json.load(configFile)

###################################################################
# Read filenames from given TXT file
###################################################################
readFiles = []

with open(config["validation"]["dataset"], "r") as datafiles:
for fileName in datafiles.readlines():
readFiles.append(fileName.replace("\n", ""))
if "dataset" in config["validation"]:
with open(config["validation"]["dataset"], "r") as datafiles:
for fileName in datafiles.readlines():
readFiles.append(fileName.replace("\n", ""))
else:
readFiles = filesDefaultMC_DoubleMuonAlCa_string

###################################################################
# Get good lumi section
Expand Down Expand Up @@ -98,9 +106,9 @@
process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
import RecoTracker.TrackProducer.TrackRefitters_cff
process.TrackRefitter = process.TrackRefitterP5.clone(
src = 'ALCARECOTkAlZMuMu',
src = config["validation"].get("trackcollection", "ALCARECOTkAlZMuMu"),
TrajectoryInEvent = True,
TTRHBuilder = "WithAngleAndTemplate",
TTRHBuilder = config["validation"].get("tthrbuilder", "WithAngleAndTemplate"),
NavigationSchool = "",
)

Expand All @@ -109,7 +117,7 @@
###################################################################
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:run2_data"))
process.GlobalTag = GlobalTag(process.GlobalTag, config["alignment"].get("globaltag", "auto:phase1_2024_realistic"))

###################################################################
# Load conditions if wished
Expand Down Expand Up @@ -182,7 +190,7 @@
if valiMode == "StandAlone":
# Output file
process.TFileService = cms.Service("TFileService",
fileName = cms.string("{}/Zmumu.root".format(config["output"])),
fileName = cms.string("{}/Zmumu.root".format(config.get("output", os.getcwd()))),
closeFileFast = cms.untracked.bool(True),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

filesDefaultMC_DoubleMuon_string = '/store/relval/CMSSW_12_5_0_pre5/RelValZMM_14/GEN-SIM-RECO/125X_mcRun3_2022_realistic_v3-v1/10000/068634c7-e8e2-4e46-a68e-97ebefed4868.root'

filesDefaultMC_DoubleMuonAlCa_string = '/store/relval/CMSSW_14_0_0_pre3/RelValZMM_14/ALCARECO/TkAlZMuMu-140X_mcRun3_2024_realistic_v1_STD_2024_noPU-v1/2580000/b91cfb5d-090c-4410-8c9e-ce165f4a4ef4.root'

filesDefaultMC_TTBarPU = cms.untracked.vstring(
'/store/relval/CMSSW_12_5_0_pre5/RelValTTbar_14TeV/GEN-SIM-RECO/PU_125X_mcRun3_2022_realistic_v3-v1/10000/0136c33f-3ff9-4602-8578-906ae6e0160b.root'
)
Expand Down
3 changes: 3 additions & 0 deletions Alignment/OfflineValidation/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<test name="PVall" command="testingScripts/test_unitPV.sh">
<flags PRE_TEST="validateAlignments"/>
</test>
<test name="Zmumuall" command="testingScripts/test_unitZmumu.sh">
<flags PRE_TEST="validateAlignments"/>
</test>
<test name="SplitVall" command="testingScripts/test_unitSplitV.sh">
<flags PRE_TEST="validateAlignments"/>
</test>
Expand Down
21 changes: 21 additions & 0 deletions Alignment/OfflineValidation/test/testingScripts/test_unitZmumu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/bash

function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/Zmumu single configuration with json..."
pushd test_yaml/Zmumu/single/testSingleZMM/unitTestZmumuMCreal/1/
./cmsRun validation_cfg.py config=validation.json || die "Failure running Zmumu first single configuration with json" $?
popd

echo "TESTING Alignment/Zmumu single configuration with json..."
pushd test_yaml/Zmumu/single/testSingleZMM/unitTestZmumuMCdesign/1/
./cmsRun validation_cfg.py config=validation.json || die "Failure running Zmumu second single configuration with json" $?

echo "TESTING Alignment/Zmumu single configuration standalone..."
./cmsRun validation_cfg.py || die "Failure running Zmumu single configuration standalone" $?
popd

echo "TESTING Zmumu merge step"
pushd test_yaml/Zmumu/merge/testSingleZMM/1/
./Zmumumerge --verbose validation.json || die "Failure running Zmumu merge step" $?
popd
25 changes: 25 additions & 0 deletions Alignment/OfflineValidation/test/unit_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ alignments:
globaltag: auto:phase1_2022_realistic
style: 2101
title: unit test
unitTestZmumuMCreal:
color: 1
globaltag: auto:phase1_2024_realistic
style: 20
title: realistic
unitTestZmumuMCdesign:
color: 2
globaltag: auto:phase1_2024_design
style: 21
title: design
PromptNewTemplate:
name: PromptNewTemplate
color: 1
Expand Down Expand Up @@ -182,6 +192,21 @@ validations:
- unitTestDiMuonVMC
trackcollection: generalTracks
maxevents: 10

Zmumu:
merge:
testSingleZMM:
singles:
- testSingleZMM
single:
testSingleZMM:
IOV:
- 1
alignments:
- unitTestZmumuMCreal
- unitTestZmumuMCdesign
trackcollection: ALCARECOTkAlZMuMu
maxevents: 100
MTS:
merge:
testSingleMTS:
Expand Down

0 comments on commit 190724f

Please sign in to comment.