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

introduce alignment campaign-like unit test for pede #37211

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
<use name="millepede"/>
<flags USE_UNITTEST_DIR="1"/>
</test>
<bin name="testPedeCampaign" file="TestDriver.cpp">
<flags TEST_RUNNER_ARGS="/bin/bash Alignment/MillePedeAlignmentAlgorithm/test test_pede.sh"/>
<use name="FWCore/Utilities"/>
</bin>

2 changes: 2 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/TestDriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "FWCore/Utilities/interface/TestHelper.h"
RUNTEST()
100 changes: 100 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/test_pede.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import FWCore.ParameterSet.Config as cms
process = cms.Process("Alignment")

process.Tracer = cms.Service("Tracer")

setupGlobaltag = "121X_mcRun3_2021_realistic_forpp900GeV_v6"
setupCollection = "ALCARECOTkAlCosmicsCosmicTF0T"
setupCosmicsDecoMode = True
setupCosmicsZeroTesla = False
setupPrimaryWidth = -1.0
setupJson = "placeholder_json"
setupRunStartGeometry = 1
setupAlgoMode = "pede"
setupMonitorFile = "millePedeMonitorISN.root"
setupBinaryFile = "milleBinaryISN.dat"
readFiles = cms.untracked.vstring()

import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla)


################################################################################
# setup alignment producer
################################################################################
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.ConfigureAlignmentProducer as confAliProducer

confAliProducer.setConfiguration(process,
collection = setupCollection,
mode = setupAlgoMode,
monitorFile = setupMonitorFile,
binaryFile = setupBinaryFile,
primaryWidth = setupPrimaryWidth,
cosmicsZeroTesla = setupCosmicsZeroTesla)


################################################################################
# Overwrite some conditions in global tag
################################################################################
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.SetCondition as tagwriter

################################################################################
# insert Startgeometry
################################################################################
# You can use tagwriter.setCondition() to overwrite conditions in globaltag

################################################################################
# insert Alignables
################################################################################
process.AlignmentProducer.ParameterBuilder.parameterTypes = ["SelectorRigid,RigidBody"]

################################################################################
# Define the high-level structure alignables
################################################################################
process.AlignmentProducer.ParameterBuilder.SelectorRigid = cms.PSet(
alignParams = cms.vstring(
"TrackerP1PXBHalfBarrel,111111",
"TrackerP1PXECHalfCylinder,111111",
"TrackerTIBHalfBarrel,111111",
"TrackerTOBHalfBarrel,rrrrrr",
"TrackerTIDEndcap,111111",
"TrackerTECEndcap,111111",
)
)

################################################################################
# insert Pedesettings
################################################################################
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.helper as helper
helper.set_pede_option(process, "skipemptycons")

################################################################################
# Mille-procedure
################################################################################
if setupAlgoMode == "mille":
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.MilleSetup as mille
mille.setup(process,
input_files = readFiles,
collection = setupCollection,
json_file = setupJson,
cosmics_zero_tesla = setupCosmicsZeroTesla,
cosmics_deco_mode = setupCosmicsDecoMode)

################################################################################
# Pede-procedure
################################################################################
else:
merge_binary_files = [
'milleBinary001.dat',
'milleBinary002.dat',
'milleBinary003.dat']
merge_tree_files = [
'treeFile001.root',
'treeFile002.root',
'treeFile003.root']

import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.PedeSetup as pede
pede.setup(process,
binary_files = merge_binary_files,
tree_files = merge_tree_files,
run_start_geometry = setupRunStartGeometry)
32 changes: 32 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/test_pede.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
function die { echo $1: status $2; exit $2; }

if [ "${SCRAM_TEST_NAME}" != "" ] ; then
mkdir ${SCRAM_TEST_NAME}
cd ${SCRAM_TEST_NAME}
fi

if test -f "milleBinary00*"; then
echo "cleaning the local test area"
rm -fr milleBinary00*
rm -fr pedeSteer*
fi

pwd
echo " testing Aligment/MillePedeAlignmentAlgorithm"

REMOTE="/store/group/alca_global/tkal_millepede_tests/"
TESTPACKAGE="test_pede_package.tar"
COMMMAND=`xrdfs cms-xrd-global.cern.ch locate ${REMOTE}${TESTPACKAGE}`
STATUS=$?
echo "xrdfs command status = "$STATUS
if [ $STATUS -eq 0 ]; then
echo "Using file ${TESTPACKAGE}. Running in ${LOCAL_TEST_DIR}."
xrdcp root://cms-xrd-global.cern.ch/${REMOTE}${TESTPACKAGE} ${LOCAL_TEST_DIR}
tar -xvf ${LOCAL_TEST_DIR}/${TESTPACKAGE}
gunzip milleBinary00*
(cmsRun ${LOCAL_TEST_DIR}/test_pede.py) || die 'failed running test_pede.py' $?
echo -e "\n MillePede Exit Status: "`cat millepede.end`
else
die "SKIPPING test, file ${TESTPACKAGE} not found" 0
fi