Skip to content

Commit

Permalink
update of HLTriggerJSONMonitoring for DatasetPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
missirol committed Jun 19, 2022
1 parent 1e3ff30 commit 12404f2
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 6 deletions.
33 changes: 27 additions & 6 deletions HLTrigger/JSONMonitoring/plugins/HLTriggerJSONMonitoring.cc
Expand Up @@ -6,6 +6,9 @@

#include <atomic>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

#include <fmt/printf.h>

Expand Down Expand Up @@ -124,6 +127,8 @@ class HLTriggerJSONMonitoring : public edm::global::EDAnalyzer<
private:
static constexpr const char* streamName_ = "streamHLTRates";

static constexpr const char* datasetPathPrefix_ = "Dataset_";

static void writeJsdFile(HLTriggerJSONMonitoringData::run const&);
static void writeIniFile(HLTriggerJSONMonitoringData::run const&, unsigned int);

Expand All @@ -135,12 +140,12 @@ class HLTriggerJSONMonitoring : public edm::global::EDAnalyzer<
// constructor
HLTriggerJSONMonitoring::HLTriggerJSONMonitoring(edm::ParameterSet const& config)
: triggerResults_(config.getParameter<edm::InputTag>("triggerResults")),
triggerResultsToken_(consumes<edm::TriggerResults>(triggerResults_)) {}
triggerResultsToken_(consumes(triggerResults_)) {}

// validate the configuration and optionally fill the default values
void HLTriggerJSONMonitoring::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "HLT"));
desc.add<edm::InputTag>("triggerResults", edm::InputTag("TriggerResults", "", "@currentProcess"));
descriptions.add("HLTriggerJSONMonitoring", desc);
}

Expand Down Expand Up @@ -183,12 +188,28 @@ std::shared_ptr<HLTriggerJSONMonitoringData::run> HLTriggerJSONMonitoring::globa
rundata->datasets.resize(datasetsSize);
for (unsigned int ds = 0; ds < datasetsSize; ++ds) {
auto& dataset = rundata->datasets[ds];
unsigned int paths = datasets[ds].size();
dataset.reserve(paths);
for (unsigned int p = 0; p < paths; p++) {
unsigned int index = rundata->hltConfig.triggerIndex(datasets[ds][p]);
// check if TriggerNames include the DatasetPath corresponding to this Dataset
// - DatasetPaths are normal cms.Path objects
// - in Run-3 HLT menus, DatasetPaths are used to defined PrimaryDatasets
auto const datasetPathName = datasetPathPrefix_ + datasetNames[ds];
auto const datasetPathExists =
std::find(triggerNames.begin(), triggerNames.end(), datasetPathName) != triggerNames.end();
if (datasetPathExists) {
// if a DatasetPath exists, only that Path is assigned to the Dataset
// - this way, the counts of the Dataset properly include prescales on the DatasetPath
// and smart-Prescales applied by the DatasetPath to its triggers
dataset.reserve(1);
unsigned int index = rundata->hltConfig.triggerIndex(datasetPathName);
if (index < triggersSize)
dataset.push_back(index);
} else {
unsigned int paths = datasets[ds].size();
dataset.reserve(paths);
for (unsigned int p = 0; p < paths; p++) {
unsigned int index = rundata->hltConfig.triggerIndex(datasets[ds][p]);
if (index < triggersSize)
dataset.push_back(index);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions HLTrigger/JSONMonitoring/test/BuildFile.xml
@@ -0,0 +1 @@
<test name="testHLTriggerJSONMonitoring" command="testHLTriggerJSONMonitoring.sh"/>
151 changes: 151 additions & 0 deletions HLTrigger/JSONMonitoring/test/testHLTriggerJSONMonitoring.py
@@ -0,0 +1,151 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")
process.options.numberOfThreads = 1
process.options.wantSummary = True
process.maxEvents.input = 100

process.source = cms.Source('EmptySource')

process.datasets = cms.PSet(
TestDatasetX = cms.vstring(
'HLT_TestPathA_v1',
'HLT_TestPathB_v1'
),
TestDatasetY = cms.vstring(
'HLT_TestPathC_v1'
)
)

process.PrescaleService = cms.Service( "PrescaleService",
lvl1Labels = cms.vstring(
"PSColumn0",
"PSColumn1"
),
lvl1DefaultLabel = cms.string( "PSColumn0" ),
forceDefault = cms.bool( False ),
prescaleTable = cms.VPSet(
cms.PSet(
pathName = cms.string( "HLT_TestPathA_v1" ),
prescales = cms.vuint32( 1, 5 )
),
cms.PSet(
pathName = cms.string( "HLT_TestPathB_v1" ),
prescales = cms.vuint32( 1, 5 )
),
cms.PSet(
pathName = cms.string( "HLT_TestPathC_v1" ),
prescales = cms.vuint32( 1, 5 )
),
cms.PSet(
pathName = cms.string( "Dataset_TestDatasetY" ),
prescales = cms.vuint32( 4, 1 )
)
)
)

process.hltPSetMap = cms.EDProducer( "ParameterSetBlobProducer" )

process.hltBoolFalse = cms.EDFilter( "HLTBool",
result = cms.bool( False )
)

process.hltBoolEnd = cms.EDFilter( "HLTBool",
result = cms.bool( True )
)

process.hltTriggerSummaryAOD = cms.EDProducer( "TriggerSummaryProducerAOD",
throw = cms.bool( False ),
processName = cms.string( "@" ),
moduleLabelPatternsToMatch = cms.vstring( 'hlt*' ),
moduleLabelPatternsToSkip = cms.vstring( )
)

process.hltTriggerSummaryRAW = cms.EDProducer( "TriggerSummaryProducerRAW",
processName = cms.string( "@" )
)

process.hltHLTriggerJSONMonitoring = cms.EDAnalyzer( "HLTriggerJSONMonitoring",
triggerResults = cms.InputTag( 'TriggerResults::@currentProcess' )
)

process.hltDatasetTestDatasetX = cms.EDFilter( "TriggerResultsFilter",
usePathStatus = cms.bool( True ),
hltResults = cms.InputTag( "" ),
l1tResults = cms.InputTag( "" ),
l1tIgnoreMaskAndPrescale = cms.bool( False ),
throw = cms.bool( True ),
triggerConditions = cms.vstring(
'HLT_TestPathA_v1 / 50',
'HLT_TestPathB_v1 / 25'
)
)

process.hltPreDatasetTestDatasetX = cms.EDFilter( "HLTPrescaler",
offset = cms.uint32( 0 ),
L1GtReadoutRecordTag = cms.InputTag( "" )
)

process.hltDatasetTestDatasetY = cms.EDFilter( "TriggerResultsFilter",
usePathStatus = cms.bool( True ),
hltResults = cms.InputTag( "" ),
l1tResults = cms.InputTag( "" ),
l1tIgnoreMaskAndPrescale = cms.bool( False ),
throw = cms.bool( True ),
triggerConditions = cms.vstring(
'HLT_TestPathC_v1 / 25'
)
)

process.hltPreDatasetTestDatasetY = cms.EDFilter( "HLTPrescaler",
offset = cms.uint32( 0 ),
L1GtReadoutRecordTag = cms.InputTag( "" )
)

process.hltPreTestPathA = cms.EDFilter( "HLTPrescaler",
offset = cms.uint32( 0 ),
L1GtReadoutRecordTag = cms.InputTag( "" )
)

process.hltPreTestPathB = cms.EDFilter( "HLTPrescaler",
offset = cms.uint32( 0 ),
L1GtReadoutRecordTag = cms.InputTag( "" )
)

process.hltPreTestPathC = cms.EDFilter( "HLTPrescaler",
offset = cms.uint32( 0 ),
L1GtReadoutRecordTag = cms.InputTag( "" )
)

process.HLTDatasetPathBeginSequence = cms.Sequence( )

process.HLTBeginSequence = cms.Sequence( )

process.HLTEndSequence = cms.Sequence( process.hltBoolEnd )

process.HLTriggerFirstPath = cms.Path( process.hltPSetMap + process.hltBoolFalse )

process.HLT_TestPathA_v1 = cms.Path( process.HLTBeginSequence + process.hltPreTestPathA + process.HLTEndSequence )

process.HLT_TestPathB_v1 = cms.Path( process.HLTBeginSequence + process.hltPreTestPathB + process.HLTEndSequence )

process.HLT_TestPathC_v1 = cms.Path( process.HLTBeginSequence + process.hltPreTestPathC + process.HLTEndSequence )

process.HLTriggerFinalPath = cms.Path( process.hltTriggerSummaryAOD + process.hltTriggerSummaryRAW + process.hltBoolFalse )

process.RatesMonitoring = cms.EndPath( process.hltHLTriggerJSONMonitoring )

process.Dataset_TestDatasetX = cms.Path( process.HLTDatasetPathBeginSequence + process.hltDatasetTestDatasetX + process.hltPreDatasetTestDatasetX )

process.Dataset_TestDatasetY = cms.Path( process.HLTDatasetPathBeginSequence + process.hltDatasetTestDatasetY + process.hltPreDatasetTestDatasetY )

process.schedule = cms.Schedule( *(
process.HLTriggerFirstPath,
process.HLT_TestPathA_v1,
process.HLT_TestPathB_v1,
process.HLT_TestPathC_v1,
process.HLTriggerFinalPath,
process.RatesMonitoring,
process.Dataset_TestDatasetX,
process.Dataset_TestDatasetY
))
9 changes: 9 additions & 0 deletions HLTrigger/JSONMonitoring/test/testHLTriggerJSONMonitoring.sh
@@ -0,0 +1,9 @@
#!/bin/bash

# Pass in name and status
function die { echo $1: status $2 ; echo === Log file === ; cat ${3:-/dev/null} ; echo === End log file === ; exit $2; }

TESTDIR="${LOCALTOP}"/src/HLTrigger/JSONMonitoring/test

cmsRun "${TESTDIR}"/testHLTriggerJSONMonitoring.py &> log_HLTriggerJSONMonitoring \
|| die "Failure using testHLTriggerJSONMonitoring.py" $? log_HLTriggerJSONMonitoring

0 comments on commit 12404f2

Please sign in to comment.