Skip to content

Commit

Permalink
add a unit Test for OnlineBeamMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Feb 9, 2023
1 parent 320cc94 commit bf2698c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
4 changes: 4 additions & 0 deletions DQM/BeamMonitor/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
<use name="FWCore/TestProcessor"/>
<use name="catch2"/>
</bin>
<bin file="runTest.cpp" name="testOnlineBeamMonitor">
<use name="FWCore/Utilities"/>
<flags TEST_RUNNER_ARGS="/bin/bash DQM/BeamMonitor/test testOnlineBeamMonitor.sh"/>
</bin>
56 changes: 34 additions & 22 deletions DQM/BeamMonitor/test/Online_BeamMonitor_file.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("DQM")
process.load("FWCore.MessageLogger.MessageLogger_cfi")
import FWCore.ParameterSet.VarParsing as VarParsing
options = VarParsing.VarParsing()
options.register("runNumber",
326479,
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"")
options.register("maxEvents",
-1,
VarParsing.VarParsing.multiplicity.singleton,
VarParsing.VarParsing.varType.int,
"number of events to run")
options.parseArguments()

process = cms.Process("DQM")

process.load("CondCore.CondDB.CondDB_cfi")
process.BeamSpotDBSource = cms.ESSource("PoolDBESSource",
process.CondDB,
DumpStat = cms.untracked.bool(True),
toGet = cms.VPSet(
cms.PSet(
record = cms.string('BeamSpotOnlineLegacyObjectsRcd'),
Expand All @@ -19,45 +32,43 @@
refreshTime = cms.uint64(2)

),
),
),
)
process.BeamSpotDBSource.connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS')

import RecoVertex.BeamSpotProducer.onlineBeamSpotESProducer_cfi as _mod
process.BeamSpotESProducer = _mod.onlineBeamSpotESProducer.clone(
timeThreshold = 999999 # for express allow >48h old payloads for replays. DO NOT CHANGE
)

# initialize MessageLogger
process.load("FWCore.MessageLogger.MessageLogger_cfi")
#process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True)
# process.MessageLogger.cerr = cms.untracked.PSet(enable = cms.untracked.bool(False))

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(1)
),
OnlineBeamMonitor = cms.untracked.PSet(
reportEvery = cms.untracked.int32(1), # every 1000th only
limit = cms.untracked.int32(0)
)
)
#process.MessageLogger.cout.enableStatistics = cms.untracked.bool(True)
limit = cms.untracked.int32(0)
))

process.source = cms.Source("EmptySource")
process.source.numberEventsInRun=cms.untracked.uint32(100)
process.source.firstRun = cms.untracked.uint32(346512)
process.source.firstLuminosityBlock = cms.untracked.uint32(614)
process.source.firstRun = cms.untracked.uint32(options.runNumber)
process.source.firstLuminosityBlock = cms.untracked.uint32(1)
process.source.numberEventsInLuminosityBlock = cms.untracked.uint32(1)
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
)
process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(options.maxEvents))

#process.load("DQMServices.Core.DQMEDAnalyzer")
process.onlineBeamMonitor = cms.EDProducer("OnlineBeamMonitor",
MonitorName = cms.untracked.string("onlineBeamMonitor"),
AppendRunToFileName = cms.untracked.bool(False),
WriteDIPAscii = cms.untracked.bool(True),
DIPFileName = cms.untracked.string("BeamFitResultsForDIP.txt")
)
MonitorName = cms.untracked.string("onlineBeamMonitor"),
AppendRunToFileName = cms.untracked.bool(False),
WriteDIPAscii = cms.untracked.bool(True),
DIPFileName = cms.untracked.string("BeamFitResultsForDIP.txt"))


# DQM Live Environment
Expand All @@ -68,8 +79,6 @@
process.dqmEnvPixelLess = process.dqmEnv.clone()
process.dqmEnvPixelLess.subSystemFolder = 'BeamMonitor_PixelLess'



#import RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi
#process.offlineBeamSpotForDQM = RecoVertex.BeamSpotProducer.BeamSpotOnline_cfi.onlineBeamSpotProducer.clone()

Expand All @@ -82,5 +91,8 @@

)

process.pp = cms.Path(process.onlineBeamMonitor+process.dqmSaver)
#process.Tracer = cms.Service("Tracer")

process.dqmcommon = cms.Sequence(process.dqmEnv*process.dqmSaver*process.dqmSaverPB)
process.pp = cms.Path(process.onlineBeamMonitor+process.dqmcommon)
process.schedule = cms.Schedule(process.pp)
2 changes: 2 additions & 0 deletions DQM/BeamMonitor/test/runTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "FWCore/Utilities/interface/TestHelper.h"
RUNTEST()
6 changes: 6 additions & 0 deletions DQM/BeamMonitor/test/testOnlineBeamMonitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

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

echo "TESTING OnlineBeamMonitor ..."
cmsRun ${LOCAL_TEST_DIR}/Online_BeamMonitor_file.py maxEvents=10 || die "Failure running Online_BeamMonitor_file.py" $?

0 comments on commit bf2698c

Please sign in to comment.