Skip to content

Commit

Permalink
Merge pull request #40972 from smuzaffar/alca-fix-unit-test
Browse files Browse the repository at this point in the history
[ALCA] Various fixes/improvements for unit test
  • Loading branch information
cmsbuild authored Mar 7, 2023
2 parents 51a332f + ca79774 commit 85e5810
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 92 deletions.
9 changes: 4 additions & 5 deletions Alignment/OfflineValidation/scripts/submitPVValidationJobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def createTheCfgFile(self,lfn):
self.outputCfgName=self.output_full_name+"_cfg.py"
fout=open(os.path.join(self.cfg_dir,self.outputCfgName),'w')

template_cfg_file = os.path.join(self.the_dir,"PVValidation_T_cfg.py")
template_cfg_file = os.path.join(self.CMSSW_dir,"src/Alignment/OfflineValidation/test","PVValidation_T_cfg.py")
file = open(template_cfg_file,'r')

config_txt = '\n\n' + CopyRights + '\n\n'
Expand Down Expand Up @@ -622,8 +622,7 @@ def main():

# CMSSW section
input_CMSSW_BASE = os.environ.get('CMSSW_BASE')
AnalysisStep_dir = os.path.join(input_CMSSW_BASE,"src/Alignment/OfflineValidation/test")
lib_path = os.path.abspath(AnalysisStep_dir)
lib_path = os.path.abspath(os.path.join(input_CMSSW_BASE,"src/Alignment/OfflineValidation/test"))
sys.path.append(lib_path)

## N.B.: this is dediced here once and for all
Expand Down Expand Up @@ -923,7 +922,7 @@ def main():
## print "==========>",conditions

# for hadd script
scripts_dir = os.path.join(AnalysisStep_dir,"scripts")
scripts_dir = "scripts"
if not os.path.exists(scripts_dir):
os.makedirs(scripts_dir)
hadd_script_file = os.path.join(scripts_dir,jobName[iConf]+"_"+opts.taskname+".sh")
Expand Down Expand Up @@ -1055,7 +1054,7 @@ def main():
vertextype[iConf], tracktype[iConf],
refittertype[iConf], ttrhtype[iConf],
applyruncontrol[iConf],
ptcut[iConf],input_CMSSW_BASE,AnalysisStep_dir)
ptcut[iConf],input_CMSSW_BASE,'.')

aJob.setEOSout(eosdir)
aJob.createTheCfgFile(theSrcFiles)
Expand Down
65 changes: 17 additions & 48 deletions Alignment/OfflineValidation/test/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,73 +1,42 @@
<environment>
<bin file="testAlignmentOfflineValidation.cpp" name="validateAlignments">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/validateAlignments.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="DMRall">
<test name="validateAlignments" command="testingScripts/validateAlignments.sh"/>
<test name="DMRall" command="testingScripts/test_unitDMR.sh">
<flags PRE_TEST="validateAlignments"/>
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitDMR.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="PVall">
</test>
<test name="PVall" command="testingScripts/test_unitPV.sh">
<flags PRE_TEST="validateAlignments"/>
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitPV.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="SplitVall">
</test>
<test name="SplitVall" command="testingScripts/test_unitSplitV.sh">
<flags PRE_TEST="validateAlignments"/>
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitSplitV.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="JetHTall">
</test>
<test name="JetHTall" command="testingScripts/test_unitJetHT.sh">
<flags PRE_TEST="validateAlignments"/>
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitJetHT.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="GCPall">
</test>
<test name="GCPall" command="testingScripts/test_unitGCP.sh">
<flags PRE_TEST="validateAlignments"/>
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitGCP.sh"/>
<use name="FWCore/Utilities"/>
</bin>
</test>
<bin file="testTrackAnalyzers.cc" name="testTrackAnalysis">
<use name="FWCore/TestProcessor"/>
<use name="catch2"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="PrimaryVertex">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitPrimaryVertex.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<test name="PrimaryVertex" command="testingScripts/test_unitPrimaryVertex.sh"/>
<bin file="testPVPlotting.cpp" name="testPVPlotting">
<flags PRE_TEST="PrimaryVertex"/>
<use name="rootmath"/>
<use name="roothistmatrix"/>
<use name="rootgraphics"/>
<use name="Alignment/OfflineValidation"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="DiMuonVertex">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitDiMuonVertex.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="SubmitPVrbr">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitSubmitPVrbr.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="SubmitPVsplit">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitSubmitPVsplit.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="EoP">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitEoP.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<test name="DiMuonVertex" command="testingScripts/test_unitDiMuonVertex.sh"/>
<test name="SubmitPVrbr" command="testingScripts/test_unitSubmitPVrbr.sh"/>
<test name="SubmitPVsplit" command="testingScripts/test_unitSubmitPVsplit.sh"/>
<test name="EoP" command="testingScripts/test_unitEoP.sh"/>
<bin file="testEoPPlotting.cpp" name="testEoPPlotting">
<flags PRE_TEST="EoP"/>
<use name="rootmath"/>
<use name="roothistmatrix"/>
<use name="rootgraphics"/>
<use name="Alignment/OfflineValidation"/>
</bin>
<bin file="testAlignmentOfflineValidation.cpp" name="Miscellanea">
<flags TEST_RUNNER_ARGS=" /bin/bash Alignment/OfflineValidation/test testingScripts/test_unitMiscellanea.sh"/>
<use name="FWCore/Utilities"/>
</bin>
<test name="Miscellanea" command="testingScripts/test_unitMiscellanea.sh"/>
</environment>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/OfflineValidation ..."
cmsRun ${LOCAL_TEST_DIR}/test_all_cfg.py || die "Failure running test_all_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/test_all_cfg.py || die "Failure running test_all_cfg.py" $?
18 changes: 12 additions & 6 deletions Alignment/OfflineValidation/test/testingScripts/test_unitDMR.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/DMR single configuration with json..."
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/DMR/single/TestSingleMC/unitTest/1/
pushd test_yaml/DMR/single/TestSingleMC/unitTest/1/
./cmsRun validation_cfg.py config=validation.json || die "Failure running DMR single configuration with json" $?

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

echo "TESTING DMR merge step"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/DMR/merge/TestMergeMC/1/
pushd test_yaml/DMR/merge/TestMergeMC/1/
./DMRmerge validation.json || die "Failure running DMR merge step" $?
popd

echo "TESTING DMR trends"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/DMR/trends/TestTrendMC/
pushd test_yaml/DMR/trends/TestTrendMC/
./DMRtrends validation.json --verbose || die "Failure running DMR trends" $?

popd

echo "TESTING DMR averaged"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/DMR/averaged/TestAveragedMC/MC/
pushd test_yaml/DMR/averaged/TestAveragedMC/MC/
./mkLumiAveragedPlots.py validation.json || die "Failure running DMR averaged in merge mode" $?
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/DMR/averaged/TestAveragedMC/plots/
popd

pushd test_yaml/DMR/averaged/TestAveragedMC/plots/
./mkLumiAveragedPlots.py validation.json || die "Failure running DMR averaged in plotting mode" $?
popd
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Double Muon Vertex validation ..."
cmsRun ${LOCAL_TEST_DIR}/DiMuonVertexValidation_cfg.py maxEvents=10 || die "Failure running DiMuonVertexValidation_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/DiMuonVertexValidation_cfg.py maxEvents=10 || die "Failure running DiMuonVertexValidation_cfg.py" $?
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function die { echo $1: status $2 ; exit $2; }

echo -e "\n\nTESTING eopTreeWriter (Pion Analysis) ..."
cmsRun ${LOCAL_TEST_DIR}/eopTreeWriter_cfg.py unitTest=True maxEvents=100 || die "Failure running eopTreeWriter" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/eopTreeWriter_cfg.py unitTest=True maxEvents=100 || die "Failure running eopTreeWriter" $?

echo -e "\n\nTESTING eopElecTreeWriter (Electron Analysis) ..."
cmsRun ${LOCAL_TEST_DIR}/eopElecTreeWriter_cfg.py maxEvents=100 || die "Failure running eopElecTreeWriter" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/eopElecTreeWriter_cfg.py maxEvents=100 || die "Failure running eopElecTreeWriter" $?
16 changes: 11 additions & 5 deletions Alignment/OfflineValidation/test/testingScripts/test_unitGCP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING GCP Ntuple creation"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/GCP/GCPdetUnits/Ntuples/SURun3_1
pushd test_yaml/GCP/GCPdetUnits/Ntuples/SURun3_1
./cmsRun validation_cfg.py config=validation.json || die "Failure running GCP Ntuple for SURun3 alignment" $?
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/GCP/GCPdetUnits/Ntuples/ideal_1
popd

pushd test_yaml/GCP/GCPdetUnits/Ntuples/ideal_1
./cmsRun validation_cfg.py config=validation.json || die "Failure running GCP Ntuple for ideal alignment" $?
popd

echo "TESTING GCP comparison tree creation"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPtree/
pushd test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPtree/
./cmsRun validation_cfg.py config=validation.json || die "Failure running GCP comparison tree creation step" $?
popd

echo "TESTING GCP cpp plots"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPcpp/
pushd test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPcpp/
./GCP validation.json -v || die "Failure running GCP cpp plots" $?
popd

echo "TESTING GCP python plots"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPpython/
pushd test_yaml/GCP/GCPdetUnits/SURun3vsIdeal/1_vs_1/GCPpython/
./GCPpyPlots.py validation.json || die "Failure running GCP python plots" $?
popd
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/JetHT single configuration with json..."
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/JetHT/single/testJob/unitTestJetHT
pushd test_yaml/JetHT/single/testJob/unitTestJetHT
./cmsRun validation_cfg.py config=validation.json || die "Failure running JetHT single configuration with json" $?

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

echo "TESTING JetHT merge step"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/JetHT/merge/testJob/unitTestJetHT
pushd test_yaml/JetHT/merge/testJob/unitTestJetHT
./run.sh || die "Failure running JetHT merge step" $?
popd

echo "TESTING JetHT plotting"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/JetHT/plot/testJob/
pushd test_yaml/JetHT/plot/testJob/
./run.sh || die "Failure running JetHT plotting" $?
popd

echo "TESTING JetHT multi-IOV plotting"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/examples
jetHtPlotter jetHt_multiYearTrendPlot.json || die "Failure running multi-IOV JetHT plotting" $?
jetHtPlotter $CMSSW_BASE/src/Alignment/OfflineValidation/test/examples/jetHt_multiYearTrendPlot.json || die "Failure running multi-IOV JetHT plotting" $?
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING inspect ALCARECO data ..."
cmsRun ${LOCAL_TEST_DIR}/inspectData_cfg.py unitTest=True trackCollection=ALCARECOTkAlCosmicsCTF0T || die "Failure running inspectData_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/inspectData_cfg.py unitTest=True trackCollection=ALCARECOTkAlCosmicsCTF0T || die "Failure running inspectData_cfg.py" $?

echo "TESTING G4e refitter ..."
cmsRun ${LOCAL_TEST_DIR}/testG4Refitter_cfg.py maxEvents=10 || die "Failure running testG4Refitter_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/testG4Refitter_cfg.py maxEvents=10 || die "Failure running testG4Refitter_cfg.py" $?

echo "TESTING Pixel BaryCenter Analyser ..."
cmsRun ${LOCAL_TEST_DIR}/PixelBaryCentreAnalyzer_cfg.py unitTest=True || die "Failure running PixelBaryCentreAnalyzer_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/PixelBaryCentreAnalyzer_cfg.py unitTest=True || die "Failure running PixelBaryCentreAnalyzer_cfg.py" $?

echo "TESTING CosmicTrackSplitting Analyser ..."
cmsRun ${LOCAL_TEST_DIR}/testSplitterValidation_cfg.py unitTest=True || die "Failure running testSplitterValidation_cfg.py" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/testSplitterValidation_cfg.py unitTest=True || die "Failure running testSplitterValidation_cfg.py" $?
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/PV single configuration with json..."
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/PV/single/TestDATA/unitTestPV/317087/
pushd test_yaml/PV/single/TestDATA/unitTestPV/317087/
./cmsRun validation_cfg.py config=validation.json || die "Failure running PV single configuration with json" $?

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

echo "TESTING PV merge step"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/PV/merge/TestDATA/317087/
pushd test_yaml/PV/merge/TestDATA/317087/
./PVmerge validation.json --verbose || die "Failure running PV merge step" $?
popd

echo "TESTING PV trends"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/PV/trends/TestDATA/
pushd test_yaml/PV/trends/TestDATA/
./PVtrends validation.json --verbose || die "Failure running PV trends" $?
popd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Primary Vertex Validation: phase-1 setup ..."
cmsRun ${LOCAL_TEST_DIR}/testPrimaryVertexRelatedValidations_cfg.py isPhase2=False maxEvents=100 || die "Failure running testPrimaryVertexRelatedValidations_cfg.py isPhase2=False" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py isPhase2=False maxEvents=100 || die "Failure running testPrimaryVertexRelatedValidations_cfg.py isPhase2=False" $?

echo "TESTING Primary Vertex Validation: phase-2 setup ..."
cmsRun ${LOCAL_TEST_DIR}/testPrimaryVertexRelatedValidations_cfg.py isPhase2=True maxEvents=10 || die "Failure running testPrimaryVertexRelatedValidations_cfg.py isPhase2=True" $?
cmsRun ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py isPhase2=True maxEvents=10 || die "Failure running testPrimaryVertexRelatedValidations_cfg.py isPhase2=True" $?
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
function die { echo $1: status $2 ; exit $2; }

echo "TESTING Alignment/SplitV single configuration with json..."
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/SplitV/single/testUnits/unitTest/1/
pushd test_yaml/SplitV/single/testUnits/unitTest/1/
./cmsRun validation_cfg.py config=validation.json || die "Failure running SplitV single configuration with json" $?

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

echo "TESTING SplotV merge step"
cd $CMSSW_BASE/src/Alignment/OfflineValidation/test/test_yaml/SplitV/merge/testUnits/1/
pushd test_yaml/SplitV/merge/testUnits/1/
./SplitVmerge validation.json --verbose || die "Failure running PV merge step" $?
popd
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ conddb --yes --db pro copy TrackerAlignment_Upgrade2017_design_v4 --destdb myfil
conddb --yes --db pro copy TrackerAlignmentErrorsExtended_Upgrade2017_design_v0 --destdb myfile.db

echo " TESTING Primary Vertex Validation run-by-run submission ..."
submitPVValidationJobs.py -j UNIT_TEST -D /HLTPhysics/Run2016C-TkAlMinBias-07Dec2018-v1/ALCARECO -i ${LOCAL_TEST_DIR}/testPVValidation_Relvals_DATA.ini -r --unitTest || die "Failure running PV Validation run-by-run submission" $?
submitPVValidationJobs.py -j UNIT_TEST -D /HLTPhysics/Run2016C-TkAlMinBias-07Dec2018-v1/ALCARECO \
-i ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/testPVValidation_Relvals_DATA.ini -r --unitTest || die "Failure running PV Validation run-by-run submission" $?

Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
function die { echo $1: status $2 ; exit $2; }

echo " TESTING Split Vertex Validation submission ..."
submitPVResolutionJobs.py -j UNIT_TEST -D /JetHT/Run2018C-TkAlMinBias-12Nov2019_UL2018-v2/ALCARECO -i ${LOCAL_TEST_DIR}/PVResolutionExample.ini --unitTest || die "Failure running Split Vertex Validation submission" $?
submitPVResolutionJobs.py -j UNIT_TEST -D /JetHT/Run2018C-TkAlMinBias-12Nov2019_UL2018-v2/ALCARECO \
-i ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/PVResolutionExample.ini --unitTest || die "Failure running Split Vertex Validation submission" $?
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/zsh

cd $CMSSW_BASE/src/Alignment/OfflineValidation/test

echo "Printing help"
validateAlignments.py -h

echo "Running over YAML"
validateAlignments.py -v -f -d unit_test.yaml
validateAlignments.py -v -f -d ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/unit_test.yaml

echo "Running over JSON"
validateAlignments.py -v -d -f unit_test.json
validateAlignments.py -v -d -f ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/unit_test.json

0 comments on commit 85e5810

Please sign in to comment.