-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
remove access to bare ROOT objects in HLTFiltersDQMonitor
#40426
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0f5ff99
added unit test for HLTFiltersDQMonitor plugin
missirol f51c546
removed access to bare ROOT objects in HLTFiltersDQMonitor
missirol 6211e8b
renaming of cfi and parameters of HLTFiltersDQMonitor
missirol ed5f69b
avoid extra map searches in HLTFiltersDQMonitor
missirol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="FWCore/ServiceRegistry"/> | ||
<use name="CommonTools/CandUtils"/> | ||
<use name="CommonTools/Egamma"/> | ||
<use name="CommonTools/TriggerUtils"/> | ||
<use name="CommonTools/Utils"/> | ||
<use name="DQMOffline/Trigger"/> | ||
<use name="DQMServices/Core"/> | ||
<use name="DataFormats/BTauReco"/> | ||
<use name="DataFormats/Common"/> | ||
<use name="DataFormats/EgammaCandidates"/> | ||
<use name="DataFormats/HLTReco"/> | ||
<use name="DataFormats/JetReco"/> | ||
<use name="DataFormats/METReco"/> | ||
<use name="DataFormats/MuonReco"/> | ||
<use name="DataFormats/EgammaCandidates"/> | ||
<use name="DataFormats/TrackReco"/> | ||
<use name="DataFormats/BTauReco"/> | ||
<use name="DataFormats/TauReco"/> | ||
<use name="DataFormats/METReco"/> | ||
<use name="DataFormats/JetReco"/> | ||
<use name="CommonTools/Egamma"/> | ||
<use name="RecoVertex/KalmanVertexFit"/> | ||
<use name="HLTrigger/HLTcore"/> | ||
<use name="DQMServices/Core"/> | ||
<use name="CommonTools/CandUtils"/> | ||
<use name="CommonTools/Utils"/> | ||
<use name="CommonTools/TriggerUtils"/> | ||
<use name="DataFormats/TrackReco"/> | ||
<use name="DataFormats/VertexReco"/> | ||
<use name="DQMOffline/Trigger"/> | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/MessageLogger"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="FWCore/ServiceRegistry"/> | ||
<use name="FWCore/Utilities"/> | ||
<use name="HLTrigger/HLTcore"/> | ||
<use name="RecoVertex/KalmanVertexFit"/> | ||
<use name="TrackingTools/TransientTrack"/> | ||
<use name="root"/> | ||
<use name="roofit"/> | ||
<use name="boost"/> | ||
<use name="roofit"/> | ||
<use name="root"/> | ||
<library file="*.cc" name="DQMOfflineTriggerPlugins"> | ||
<flags EDM_PLUGIN="1"/> | ||
</library> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from DQMOffline.Trigger.hltFiltersDQMonitor_cfi import * | ||
hltFiltersDQMonitor.triggerSummaryAOD = 'hltTriggerSummaryAOD::HLT' | ||
hltFiltersDQMonitor.triggerResults = 'TriggerResults::HLT' | ||
from DQMOffline.Trigger.dqmHLTFiltersDQMonitor_cfi import * | ||
dqmHLTFiltersDQMonitor.triggerEvent = 'hltTriggerSummaryAOD::HLT' | ||
dqmHLTFiltersDQMonitor.triggerResults = 'TriggerResults::HLT' | ||
|
||
from DQMOffline.Trigger.HLTEventInfoClient_cfi import * | ||
|
||
hltDqmOffline = cms.Sequence(hltFiltersDQMonitor*hltEventInfoClient) | ||
hltDqmOffline = cms.Sequence( dqmHLTFiltersDQMonitor * hltEventInfoClient ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
## CLI parser | ||
import argparse | ||
import sys | ||
|
||
parser = argparse.ArgumentParser( | ||
prog = 'cmsRun '+sys.argv[0]+' --', | ||
description = 'Configuration file to run the DQMFileSaver on DQMIO input files.', | ||
formatter_class = argparse.ArgumentDefaultsHelpFormatter | ||
) | ||
|
||
parser.add_argument('-t', '--nThreads', type = int, help = 'Number of threads', | ||
default = 4) | ||
|
||
parser.add_argument('-s', '--nStreams', type = int, help = 'Number of EDM streams', | ||
default = 0) | ||
|
||
parser.add_argument('-i', '--inputFiles', nargs = '+', help = 'List of DQMIO input files', | ||
default = ['file:DQMIO.root']) | ||
|
||
argv = sys.argv[:] | ||
if '--' in argv: | ||
argv.remove('--') | ||
args, unknown = parser.parse_known_args(argv) | ||
|
||
# Process | ||
process = cms.Process('HARVESTING') | ||
|
||
process.options.numberOfThreads = args.nThreads | ||
process.options.numberOfStreams = args.nStreams | ||
process.options.numberOfConcurrentLuminosityBlocks = 1 | ||
|
||
# Source (DQM input) | ||
process.source = cms.Source('DQMRootSource', | ||
fileNames = cms.untracked.vstring(args.inputFiles) | ||
) | ||
|
||
# DQMStore (Service) | ||
process.load('DQMServices.Core.DQMStore_cfi') | ||
|
||
# MessageLogger (Service) | ||
process.load('FWCore.MessageLogger.MessageLogger_cfi') | ||
|
||
# Output module (file in ROOT format) | ||
from DQMServices.Components.DQMFileSaver_cfi import dqmSaver as _dqmSaver | ||
process.dqmSaver = _dqmSaver.clone( | ||
workflow = '/DQMOffline/Trigger/'+process.name_() | ||
) | ||
|
||
# EndPath | ||
process.endp = cms.EndPath( | ||
process.dqmSaver | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Unit test: `testHLTFiltersDQMonitor` | ||
------------------------------------ | ||
|
||
Test of the DQM plugin `HLTFiltersDQMonitor`. | ||
|
||
- To run the test via `scram` | ||
```sh | ||
scram build runtests_testHLTFiltersDQMonitor | ||
``` | ||
|
||
- To run the test without `scram` | ||
```sh | ||
LOCALTOP="${CMSSW_BASE}" "${CMSSW_BASE}"/src/DQMOffline/Trigger/test/testHLTFiltersDQMonitor.sh | ||
``` | ||
|
||
- To show info on command-line arguments of `testHLTFiltersDQMonitor_cfg.py` | ||
```sh | ||
python3 "${CMSSW_BASE}"/src/DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py -h | ||
``` | ||
|
||
- To execute cmsRun with `testHLTFiltersDQMonitor_cfg.py` (example) | ||
```sh | ||
cmsRun "${CMSSW_BASE}"/src/DQMOffline/Trigger/test/testHLTFiltersDQMonitor_cfg.py -- -t 4 -s 0 -o tmp.root -n 100 | ||
``` | ||
|
||
- To create a bare ROOT file from the DQMIO output of `testHLTFiltersDQMonitor_cfg.py`, | ||
run the harvesting step as follows | ||
```sh | ||
cmsRun "${CMSSW_BASE}"/src/DQMOffline/Trigger/test/harvesting_cfg.py -- -i file:tmp.root | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Pass in name and status | ||
function die { | ||
printf "\n%s: status %s\n" "$1" "$2" | ||
exit $2 | ||
} | ||
|
||
# run test job | ||
TESTDIR="${LOCALTOP}"/src/DQMOffline/Trigger/test | ||
|
||
cmsRun "${TESTDIR}"/testHLTFiltersDQMonitor_cfg.py -- -t 4 -n 128 \ | ||
|| die "Failure running testHLTFiltersDQMonitor_cfg.py" $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
## CLI parser | ||
import argparse | ||
import sys | ||
|
||
parser = argparse.ArgumentParser( | ||
prog = 'cmsRun '+sys.argv[0]+' --', | ||
description = 'Configuration file to test of the HLTFiltersDQMonitor plugin.', | ||
formatter_class = argparse.ArgumentDefaultsHelpFormatter | ||
) | ||
|
||
parser.add_argument('-t', '--nThreads', type = int, help = 'Number of threads', | ||
default = 4) | ||
|
||
parser.add_argument('-s', '--nStreams', type = int, help = 'Number of EDM streams', | ||
default = 0) | ||
|
||
parser.add_argument('-i', '--inputFiles', nargs = '+', help = 'List of EDM input files', | ||
default = ['/store/relval/CMSSW_12_6_0_pre2/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/125X_mcRun3_2022_realistic_v3-v1/2580000/2d96539c-b321-401f-b7b2-51884a5d421f.root']) | ||
|
||
parser.add_argument('-n', '--maxEvents', type = int, help = 'Number of input events', | ||
default = 100) | ||
|
||
parser.add_argument('-o', '--outputFile', type = str, help = 'Path to output file in DQMIO format', | ||
default = 'DQMIO.root') | ||
|
||
parser.add_argument('--wantSummary', action = 'store_true', help = 'Value of process.options.wantSummary', | ||
default = False) | ||
|
||
parser.add_argument('-d', '--debugMode', action = 'store_true', help = 'Enable debug info (requires recompiling first with \'USER_CXXFLAGS="-DEDM_ML_DEBUG" scram b\')', | ||
default = False) | ||
|
||
argv = sys.argv[:] | ||
if '--' in argv: | ||
argv.remove('--') | ||
args, unknown = parser.parse_known_args(argv) | ||
|
||
## Process | ||
process = cms.Process('TEST') | ||
|
||
process.options.numberOfThreads = args.nThreads | ||
process.options.numberOfStreams = args.nStreams | ||
process.options.wantSummary = args.wantSummary | ||
process.maxEvents.input = args.maxEvents | ||
|
||
## Source | ||
process.source = cms.Source('PoolSource', | ||
fileNames = cms.untracked.vstring(args.inputFiles), | ||
inputCommands = cms.untracked.vstring( | ||
'drop *', | ||
'keep edmTriggerResults_*_*_*', | ||
'keep triggerTriggerEvent_*_*_*', | ||
'keep triggerTriggerEventWithRefs_*_*_*' | ||
) | ||
) | ||
|
||
## MessageLogger (Service) | ||
process.load('FWCore.MessageLogger.MessageLogger_cfi') | ||
process.MessageLogger.cerr.FwkReport.reportEvery = 1 # only report every Nth event start | ||
process.MessageLogger.cerr.FwkReport.limit = -1 # max number of reported messages (all if -1) | ||
process.MessageLogger.cerr.enableStatistics = False # enable "MessageLogger Summary" message | ||
|
||
## DQMStore (Service) | ||
process.load('DQMServices.Core.DQMStore_cfi') | ||
|
||
## FastTimerService (Service) | ||
from HLTrigger.Timer.FastTimerService_cfi import FastTimerService as _FastTimerService | ||
process.FastTimerService = _FastTimerService.clone( | ||
enableDQM = False, | ||
printEventSummary = False, | ||
printJobSummary = True, | ||
printRunSummary = False, | ||
writeJSONSummary = False | ||
) | ||
process.MessageLogger.FastReport = dict() | ||
|
||
## EventData Modules | ||
from DQMOffline.Trigger.dqmHLTFiltersDQMonitor_cfi import dqmHLTFiltersDQMonitor as _dqmHLTFiltersDQMonitor | ||
process.dqmHLTFiltersDQMonitor = _dqmHLTFiltersDQMonitor.clone( | ||
folderName = 'HLT/Filters', | ||
efficPlotNamePrefix = 'effic_', | ||
triggerResults = 'TriggerResults::HLT', | ||
triggerEvent = 'hltTriggerSummaryAOD::HLT', | ||
triggerEventWithRefs = 'hltTriggerSummaryRAW::HLT' | ||
) | ||
process.MessageLogger.HLTFiltersDQMonitor = dict() | ||
if args.debugMode: | ||
process.MessageLogger.cerr.threshold = 'DEBUG' | ||
process.MessageLogger.debugModules = ['dqmHLTFiltersDQMonitor'] | ||
|
||
## Output Modules | ||
process.dqmOutput = cms.OutputModule('DQMRootOutputModule', | ||
fileName = cms.untracked.string(args.outputFile) | ||
) | ||
|
||
## Path | ||
process.testPath = cms.Path( | ||
process.dqmHLTFiltersDQMonitor | ||
) | ||
|
||
## EndPath | ||
process.testEndPath = cms.EndPath( | ||
process.dqmOutput | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for completeness: this
argparse
configuration was ~copied fromcmssw/FWCore/Integration/test/testSwitchProducerTask_cfg.py
Lines 3 to 14 in 287f4db
I was wondering if there are cases where
VarParsing
has advantages (or, is recommended) wrtargparse
.The only hiccup I encountered with this
argparse
was withwhich I naively expected to work, but leads to an error [1] (didn't figure out the solution).
[1]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference the use of
argparse
is also described inhttps://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideAboutPythonConfigFile#argparse
Hah, interesting. It seems that
sys.exit(0)
gets communicated as a thrown exception by PyBind11 in the C++ side, which framework then reports as shown (the printout from-h
is there, although in a slightly confusing way). It is not immediately clear to me if we should do something about it, so a specific issue might be worth it.As for
VarParsing
vsargparse
,core
does not have a specific recommendation. First has longer history within CMSSW (and not really developed further), and the latter comes from python's standard library.