Skip to content

Commit

Permalink
Merge pull request #44570 from mmusich/mm_dev_pedeConversionTest_14_1_X
Browse files Browse the repository at this point in the history
add a unit test for conversion of `millepede.res` files into DB payloads
  • Loading branch information
cmsbuild authored Apr 3, 2024
2 parents 6cda5fd + f6f2e3b commit 7dce3ac
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
<test name="test-pede" command="pede -t">
<use name="millepede"/>
</test>

<test name="test_MilleZmm" command="test_mille.sh"/>
<test name="test_PedeCampaign" command="test_pede.sh"/>
<test name="test_PedeConversion" command="test_pedeConversion.sh">
<flags PRE_TEST="test_PedeCampaign"/>
</test>
<test name="test_PayloadSanity" command="test_payload_sanity.sh">
<flags PRE_TEST="test_PedeCampaign"/>
</test>
Expand Down
12 changes: 12 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/align_params_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import FWCore.ParameterSet.Config as cms

_alignParams = cms.PSet(
alignParams = cms.vstring(
"TrackerP1PXBHalfBarrel,111111",
"TrackerP1PXECHalfCylinder,111111",
"TrackerTIBHalfBarrel,111111",
"TrackerTOBHalfBarrel,rrrrrr",
"TrackerTIDEndcap,111111",
"TrackerTECEndcap,111111",
)
)
111 changes: 111 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/convertMPresToDB_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import FWCore.ParameterSet.Config as cms

from Configuration.Eras.Era_Run3_cff import Run3
process = cms.Process("Alignment", Run3)

process.options = cms.untracked.PSet(
Rethrow = cms.untracked.vstring("ProductNotFound") # do not accept this exception
)

######################################################
# initialize MessageLogger
######################################################
process.load("FWCore.MessageService.MessageLogger_cfi")
process.MessageLogger.files.alignment = cms.untracked.PSet(
DEBUG = cms.untracked.PSet(
limit = cms.untracked.int32(-1)
),
INFO = cms.untracked.PSet(
limit = cms.untracked.int32(5),
reportEvery = cms.untracked.int32(5)
),
WARNING = cms.untracked.PSet(
limit = cms.untracked.int32(10)
),
ERROR = cms.untracked.PSet(
limit = cms.untracked.int32(-1)
),
Alignment = cms.untracked.PSet(
limit = cms.untracked.int32(-1),
reportEvery = cms.untracked.int32(1)
),
enableStatistics = cms.untracked.bool(True)
)

######################################################
# Design GT (in order to fetch the design geometry)
######################################################
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2024_design', '') # take your favourite

######################################################
# Starting alignment of the campaign
######################################################
from CondCore.CondDB.CondDB_cfi import *
CondDBConnection = CondDB.clone( connect = cms.string( 'sqlite_file:alignment_input.db' ) )
process.trackerAlignment = cms.ESSource("PoolDBESSource",
CondDBConnection,
toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
tag = cms.string("TrackerAlignment_PCL_byRun_v2_express_348155")
)
))

process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource", "trackerAlignment")

######################################################
# Alignment producer
######################################################
process.load("Configuration.Geometry.GeometryRecoDB_cff")
process.load("Alignment.CommonAlignmentProducer.AlignmentProducer_cff")

######################################################
#
# !!! This has to match the alignable selection
# of the pede configuration !!!
#
######################################################
from align_params_cff import _alignParams
process.AlignmentProducer.ParameterBuilder.Selector = _alignParams

######################################################
# Alignment Producer options
######################################################
process.AlignmentProducer.doMisalignmentScenario = False #True
process.AlignmentProducer.applyDbAlignment = True # either globalTag or trackerAlignment

######################################################
# assign by reference (i.e. could change MillePedeAlignmentAlgorithm as well):
######################################################
process.AlignmentProducer.algoConfig = process.MillePedeAlignmentAlgorithm
process.AlignmentProducer.algoConfig.mode = 'pedeRead' # reads millepede.res
process.AlignmentProducer.algoConfig.pedeReader.readFile = 'millepede.res'
process.AlignmentProducer.algoConfig.treeFile = 'my_treeFile.root'

######################################################
# Source
######################################################
process.source = cms.Source("EmptySource",
firstRun = cms.untracked.uint32(1) # choose your run!
)
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1) )

process.dump = cms.EDAnalyzer("EventContentAnalyzer")
process.p = cms.Path(process.dump)

# should not be needed, but is:
# otherwise AlignmentProducer does not call relevant algorithm part
process.AlignmentProducer.saveToDB = True

######################################################
# Output alignment payload from reading file
######################################################
CondDBConnectionOut = CondDB.clone( connect = cms.string( 'sqlite_file:convertedFromResFile.db' ) )
process.PoolDBOutputService = cms.Service("PoolDBOutputService",
CondDBConnectionOut,
timetype = cms.untracked.string('runnumber'),
toPut = cms.VPSet(cms.PSet(record = cms.string('TrackerAlignmentRcd'),
tag = cms.string('Alignments')
)
)
)
15 changes: 3 additions & 12 deletions Alignment/MillePedeAlignmentAlgorithm/test/test_pede.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("Alignment")

################################################################################
Expand Down Expand Up @@ -36,7 +37,6 @@
import Alignment.MillePedeAlignmentAlgorithm.alignmentsetup.GeneralSetup as generalSetup
generalSetup.setup(process, setupGlobaltag, setupCosmicsZeroTesla)


################################################################################
# setup alignment producer
# ------------------------------------------------------------------------------
Expand All @@ -50,7 +50,6 @@
primaryWidth = setupPrimaryWidth,
cosmicsZeroTesla = setupCosmicsZeroTesla)


################################################################################
# Overwrite some conditions in global tag
# ------------------------------------------------------------------------------
Expand All @@ -69,16 +68,8 @@
]
#
# # 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",
)
)
from align_params_cff import _alignParams
process.AlignmentProducer.ParameterBuilder.SelectorRigid = _alignParams

#########################
## insert Pedesettings ##
Expand Down
2 changes: 1 addition & 1 deletion Alignment/MillePedeAlignmentAlgorithm/test/test_pede.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ clean_up(){
echo -e "\nCleaning the local test area"
rm -fr milleBinary00*
rm -fr pedeSteer*
rm -fr millepede.*
#rm -fr millepede.*
rm -fr *.root
rm -fr *.log
rm -fr *.dat
Expand Down
14 changes: 14 additions & 0 deletions Alignment/MillePedeAlignmentAlgorithm/test/test_pedeConversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
function die { echo $1: status $2; exit $2; }

LOCAL_TEST_DIR=${SCRAM_TEST_PATH}

echo "============== testing conversion to DB file from millepede.res"
(cmsRun ${LOCAL_TEST_DIR}/convertMPresToDB_cfg.py) || die 'failed running convertMPresToDB_cfg.py' $?

echo -e "Content of the current directory is: "`ls .`

INPUTFILE=convertedFromResFile.db

echo -e "\n\n============== testing converted file corresponds to input"
(cmsRun ${SCRAM_TEST_PATH}/AlignmentRcdChecker_cfg.py inputSqliteFile=${INPUTFILE}) || die 'failed running AlignmentRcdChecker' $?

0 comments on commit 7dce3ac

Please sign in to comment.