From 82dfb9fed0e425c051b8b84116b0101655c483e4 Mon Sep 17 00:00:00 2001 From: mmusich Date: Wed, 24 Aug 2022 11:39:56 +0200 Subject: [PATCH] introduce unit tests for AlCaBeamSpotProducer and AlCaBeamSpotHarvester --- .../test/Alca_BeamFit_Workflow.py | 132 +++++++++--------- .../test/Alca_BeamSpot_Harvester.py | 88 +++++------- .../TkAlCaRecoProducers/test/BuildFile.xml | 6 +- .../test/testBeamSpotWorkflow.sh | 12 ++ 4 files changed, 118 insertions(+), 120 deletions(-) create mode 100755 Calibration/TkAlCaRecoProducers/test/testBeamSpotWorkflow.sh diff --git a/Calibration/TkAlCaRecoProducers/test/Alca_BeamFit_Workflow.py b/Calibration/TkAlCaRecoProducers/test/Alca_BeamFit_Workflow.py index f8c5d1b9b3ff0..f50f0951be952 100644 --- a/Calibration/TkAlCaRecoProducers/test/Alca_BeamFit_Workflow.py +++ b/Calibration/TkAlCaRecoProducers/test/Alca_BeamFit_Workflow.py @@ -1,87 +1,80 @@ import FWCore.ParameterSet.Config as cms process = cms.Process("alcaBeamSpotWorkflow") -# initialize MessageLogger -process.load("FWCore.MessageLogger.MessageLogger_cfi") -process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(False)) +################################################################### +# initialize MessageLogger +################################################################### +process.load('FWCore.MessageService.MessageLogger_cfi') +process.MessageLogger.cerr.enable = False +process.MessageLogger.AlcaBeamSpotProducer=dict() process.MessageLogger.cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - default = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - AlcaBeamSpotProducer = cms.untracked.PSet( - #reportEvery = cms.untracked.int32(100) # every 1000th only - limit = cms.untracked.int32(0) - ) + enable = cms.untracked.bool(True), + threshold = cms.untracked.string("INFO"), + default = cms.untracked.PSet(limit = cms.untracked.int32(0)), + FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), + reportEvery = cms.untracked.int32(100) + ), + AlcaBeamSpotProducer = cms.untracked.PSet( limit = cms.untracked.int32(-1)), + enableStatistics = cms.untracked.bool(True) ) -#process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True) process.load("Calibration.TkAlCaRecoProducers.AlcaBeamSpotProducer_cff") +readFiles=['/store/data/Run2022C/JetMET/ALCARECO/TkAlJetHT-PromptReco-v1/000/357/482/00000/08365631-c05f-4584-b8a4-5cc7e23c1ac8.root'] process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0171/3A22D08D-456A-DF11-961F-001A92811734.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0171/083B6802-236C-DF11-8AC6-0026189437FE.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0170/E6D0589B-136A-DF11-9E90-002618943982.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0170/D098488B-276A-DF11-8069-003048678AF4.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0166/F466DD94-BF69-DF11-B9B8-00261894390A.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0166/F2A9245B-BC69-DF11-9C3F-0018F3D096E4.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0166/DED5E502-B969-DF11-AE8F-002618943964.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0166/563257AF-C169-DF11-865F-002618943907.root', -'/store/data/Commissioning10/MinimumBias/ALCARECO/TkAlMinBias-May27thReReco_v1/0166/3056B847-C069-DF11-B0B0-003048679010.root' - - ) -) + fileNames = cms.untracked.vstring(readFiles) + ) process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(10000) #1500 + input = cms.untracked.int32(1000) ) process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) -# this is for filtering on L1 technical trigger bit -process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff') -process.load('HLTrigger/HLTfilters/hltLevel1GTSeed_cfi') -process.hltLevel1GTSeed.L1TechTriggerSeeding = cms.bool(True) -process.hltLevel1GTSeed.L1SeedsLogicalExpression = cms.string('0 AND ( 40 OR 41 ) AND NOT (36 OR 37 OR 38 OR 39)') - -## +################################################################### +# standard includes +################################################################### process.load("Configuration.StandardSequences.MagneticField_cff") process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff") -process.GlobalTag.globaltag = 'GR_R_38X_V9::All' #'GR_R_35X_V8::All' -process.load("Configuration.StandardSequences.GeometryDB_cff") - +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run3_data', '') +process.load("Configuration.Geometry.GeometryRecoDB_cff") -## reco PV +################################################################### +# reco PV +################################################################### process.load("Configuration.StandardSequences.Reconstruction_cff") process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi") -process.load("RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi") -process.offlinePrimaryVertices.TrackLabel = cms.InputTag("ALCARECOTkAlMinBias") -#### remove beam scraping events +################################################################### +# remove beam scraping events +################################################################### process.noScraping= cms.EDFilter("FilterOutScraping", applyfilter = cms.untracked.bool(True), debugOn = cms.untracked.bool(False), ## Or 'True' to get some per-event info numtrack = cms.untracked.uint32(10), thresh = cms.untracked.double(0.20) -) - - - -################### Primary Vertex -process.offlinePrimaryVertices.PVSelParameters.maxDistanceToBeam = 2 -process.offlinePrimaryVertices.TkFilterParameters.maxNormalizedChi2 = 20 -process.offlinePrimaryVertices.TkFilterParameters.minSiliconLayersWithHits = 5 -process.offlinePrimaryVertices.TkFilterParameters.maxD0Significance = 100 -process.offlinePrimaryVertices.TkFilterParameters.minPixelLayersWithHits = 1 -process.offlinePrimaryVertices.TkClusParameters.TkGapClusParameters.zSeparation = 1 - - -####################### -process.alcaBeamSpotProducer.BeamFitter.TrackCollection = 'ALCARECOTkAlMinBias' + ) + +################################################################### +# Primary Vertex +################################################################### +from RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi import offlinePrimaryVertices +process.offlinePrimaryVerticesFromTrks = offlinePrimaryVertices.clone() +process.offlinePrimaryVerticesFromTrks.TrackLabel = cms.InputTag("ALCARECOTkAlJetHT") +process.offlinePrimaryVerticesFromTrks.vertexCollections.maxDistanceToBeam = 1 +process.offlinePrimaryVerticesFromTrks.TkFilterParameters.maxNormalizedChi2 = 20 +process.offlinePrimaryVerticesFromTrks.TkFilterParameters.minSiliconLayersWithHits = 5 +process.offlinePrimaryVerticesFromTrks.TkFilterParameters.maxD0Significance = 5.0 +process.offlinePrimaryVerticesFromTrks.TkFilterParameters.minPixelLayersWithHits = 2 + +################################################################### +# BeamSpot producer config +################################################################### +process.alcaBeamSpotProducer.BeamFitter.TrackCollection = 'ALCARECOTkAlJetHT' process.alcaBeamSpotProducer.BeamFitter.MinimumTotalLayers = 6 process.alcaBeamSpotProducer.BeamFitter.MinimumPixelLayers = -1 process.alcaBeamSpotProducer.BeamFitter.MaximumNormChi2 = 10 @@ -91,26 +84,31 @@ process.alcaBeamSpotProducer.BeamFitter.TrackAlgorithm = cms.untracked.vstring() #process.alcaBeamSpotProducer.BeamFitter.Debug = True +process.alcaBeamSpotProducer.PVFitter.VertexCollection = 'offlinePrimaryVerticesFromTrks' process.alcaBeamSpotProducer.PVFitter.Apply3DFit = True -process.alcaBeamSpotProducer.PVFitter.minNrVerticesForFit = 10 -######################### - +process.alcaBeamSpotProducer.PVFitter.minNrVerticesForFit = 10 +################################################################### # fit as function of lumi sections +################################################################### process.alcaBeamSpotProducer.AlcaBeamSpotProducerParameters.fitEveryNLumi = 1 process.alcaBeamSpotProducer.AlcaBeamSpotProducerParameters.resetEveryNLumi = 1 -process.out = cms.OutputModule( "PoolOutputModule", - fileName = cms.untracked.string( 'AlcaBeamSpot.root' ), - outputCommands = cms.untracked.vstring("keep *") - ) +################################################################### +# Output module +################################################################### +process.out = cms.OutputModule("PoolOutputModule", + fileName = cms.untracked.string( 'AlcaBeamSpot.root' ), + outputCommands = cms.untracked.vstring("keep *")) +################################################################### +# paths and endpaths +################################################################### process.e = cms.EndPath( process.out ) -process.p = cms.Path(process.hltLevel1GTSeed + - process.offlineBeamSpot + -# process.TrackRefitter + - process.offlinePrimaryVertices+ -# process.noScraping + +process.p = cms.Path(process.offlineBeamSpot + + # process.TrackRefitter + # in case of refit + process.offlinePrimaryVerticesFromTrks+ + # process.noScraping + # not needed in recent data process.alcaBeamSpotProducer) diff --git a/Calibration/TkAlCaRecoProducers/test/Alca_BeamSpot_Harvester.py b/Calibration/TkAlCaRecoProducers/test/Alca_BeamSpot_Harvester.py index a26d72110ecd2..d3f0fff304b25 100644 --- a/Calibration/TkAlCaRecoProducers/test/Alca_BeamSpot_Harvester.py +++ b/Calibration/TkAlCaRecoProducers/test/Alca_BeamSpot_Harvester.py @@ -1,54 +1,55 @@ -# Auto generated configuration file -# using: -# Revision: 1.172 -# Source: /cvs_server/repositories/CMSSW/CMSSW/Configuration/PyReleaseValidation/python/ConfigBuilder.py,v -# with command line options: step3 -s HARVESTING:dqmHarvesting --conditions auto:com10 --scenario pp --no_exec --data import FWCore.ParameterSet.Config as cms process = cms.Process('HARVESTING') +################################################################### # Input source +################################################################### process.source = cms.Source("PoolSource", - fileNames = cms.untracked.vstring( - 'file:AlcaBeamSpot.root' - ), - processingMode = cms.untracked.string('RunsAndLumis') -) - + fileNames = cms.untracked.vstring( + 'file:AlcaBeamSpot.root' + ), + processingMode = cms.untracked.string('RunsAndLumis')) +################################################################### # initialize MessageLogger +################################################################### process.load("FWCore.MessageLogger.MessageLogger_cfi") - process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(False)) process.MessageLogger.cout = cms.untracked.PSet( threshold = cms.untracked.string('INFO'), default = cms.untracked.PSet( - limit = cms.untracked.int32(0) + limit = cms.untracked.int32(0) ), AlcaBeamSpotHarvester = cms.untracked.PSet( - #reportEvery = cms.untracked.int32(100) # every 1000th only + reportEvery = cms.untracked.int32(100), limit = cms.untracked.int32(0) ), AlcaBeamSpotManager = cms.untracked.PSet( - #reportEvery = cms.untracked.int32(100) # every 1000th only + reportEvery = cms.untracked.int32(100), limit = cms.untracked.int32(0) ) ) -#process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True) +process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True) +################################################################### +# configure the harvester +################################################################### process.load("Calibration.TkAlCaRecoProducers.AlcaBeamSpotHarvester_cff") - process.alcaBeamSpotHarvester.AlcaBeamSpotHarvesterParameters.BeamSpotOutputBase = cms.untracked.string("lumibased") #lumibase +################################################################### # import of standard configurations +################################################################### process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('Configuration.StandardSequences.GeometryExtended_cff') -process.load('Configuration.StandardSequences.MagneticField_38T_cff') +process.load('Configuration.Geometry.GeometryRecoDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.EventContent.EventContent_cff') process.load('Configuration.StandardSequences.EDMtoMEAtRunEnd_cff') process.load('Configuration.StandardSequences.Harvesting_cff') process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') -process.load('Configuration.EventContent.EventContent_cff') +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run3_data', '') process.configurationMetadata = cms.untracked.PSet( annotation = cms.untracked.string('step3 nevts:1'), @@ -57,47 +58,30 @@ process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + #process.maxLuminosityBlocks=cms.untracked.PSet( # input=cms.untracked.int32(1) #) + process.options = cms.untracked.PSet( Rethrow = cms.untracked.vstring('ProductNotFound'), fileMode = cms.untracked.string('FULLMERGE') ) -# Additional output definition - -# Other statements -process.GlobalTag.globaltag = 'GR_R_38X_V9::All' - -# Path and EndPath definitions -process.edmtome_step = cms.Path(process.EDMtoME) -process.validationpreprodHarvesting = cms.Path(process.postValidation*process.hltpostvalidation_preprod) -process.validationprodHarvesting = cms.Path(process.postValidation*process.hltpostvalidation_prod) -process.dqmHarvesting = cms.Path(process.DQMOffline_SecondStep*process.DQMOffline_Certification) -process.validationHarvesting = cms.Path(process.postValidation*process.hltpostvalidation) -process.validationHarvestingFS = cms.Path(process.HarvestingFastSim) -process.dqmHarvestingPOG = cms.Path(process.DQMOffline_SecondStep_PrePOG) -process.dqmsave_step = cms.Path(process.DQMSaver) - - - - -process.load("CondCore.DBCommon.CondDBCommon_cfi") - - -process.CondDBCommon.connect = "sqlite_file:testbs.db" +################################################################### +# Conditions Database +################################################################### +process.load("CondCore.CondDB.CondDB_cfi") +process.CondDB.connect = "sqlite_file:testbs.db" process.PoolDBOutputService = cms.Service("PoolDBOutputService", - process.CondDBCommon, + process.CondDB, toPut = cms.VPSet(cms.PSet( - record = cms.string('BeamSpotObjectsRcd'), - tag = cms.string('TestLSBasedBS') )), - loadBlobStreamer = cms.untracked.bool(False), - timetype = cms.untracked.string('lumiid') -# timetype = cms.untracked.string('runnumber') -) - - + record = cms.string('BeamSpotObjectsRcd'), + tag = cms.string('TestLSBasedBS') )), + loadBlobStreamer = cms.untracked.bool(False), + timetype = cms.untracked.string('lumiid') + # timetype = cms.untracked.string('runnumber') + ) process.alcaHarvesting = cms.Path(process.alcaBeamSpotHarvester) diff --git a/Calibration/TkAlCaRecoProducers/test/BuildFile.xml b/Calibration/TkAlCaRecoProducers/test/BuildFile.xml index e3641cbe533dc..b6a98b003b808 100644 --- a/Calibration/TkAlCaRecoProducers/test/BuildFile.xml +++ b/Calibration/TkAlCaRecoProducers/test/BuildFile.xml @@ -1,8 +1,12 @@ - + + + + + diff --git a/Calibration/TkAlCaRecoProducers/test/testBeamSpotWorkflow.sh b/Calibration/TkAlCaRecoProducers/test/testBeamSpotWorkflow.sh new file mode 100755 index 0000000000000..2a6de8801ea5e --- /dev/null +++ b/Calibration/TkAlCaRecoProducers/test/testBeamSpotWorkflow.sh @@ -0,0 +1,12 @@ +#! /bin/bash +function die { echo $1: status $2 ; exit $2; } +if [ "${SCRAM_TEST_NAME}" != "" ] ; then + mkdir ${SCRAM_TEST_NAME} + cd ${SCRAM_TEST_NAME} +fi + +echo "TESTING AlcaBeamSpotProducer ..." +cmsRun ${LOCAL_TEST_DIR}/Alca_BeamFit_Workflow.py || die "Failure running Alca_BeamFit_Workflow.py" $? + +echo "TESTING AlcaBeamSpotHarvester ..." +cmsRun ${LOCAL_TEST_DIR}/Alca_BeamSpot_Harvester.py || die "Failure running Alca_BeamSpot_Harvester.py" $?