Skip to content
Snippets Groups Projects
Commit fe144db6 authored by Rafal Bielski's avatar Rafal Bielski :wave: Committed by Edward Moyse
Browse files

HLT MTCalibPeb test: allow deterministic RNG seed and make RootComp a required step

parent d0e971ad
No related branches found
No related tags found
No related merge requests found
Showing
with 38 additions and 27 deletions
...@@ -85,6 +85,7 @@ rob_access_dict = { ...@@ -85,6 +85,7 @@ rob_access_dict = {
class MTCalibPebHypoOptions: class MTCalibPebHypoOptions:
def __init__(self): def __init__(self):
self.UseRandomSeed = False
self.RandomAcceptRate = -1.0 self.RandomAcceptRate = -1.0
self.BurnTimePerCycleMillisec = 0 self.BurnTimePerCycleMillisec = 0
self.NumBurnCycles = 0 self.NumBurnCycles = 0
...@@ -161,6 +162,7 @@ def make_hypo_alg(name): ...@@ -161,6 +162,7 @@ def make_hypo_alg(name):
def make_hypo_tool(name, options=default_options): def make_hypo_tool(name, options=default_options):
from TrigExPartialEB.TrigExPartialEBConf import MTCalibPebHypoTool from TrigExPartialEB.TrigExPartialEBConf import MTCalibPebHypoTool
hypo_tool = MTCalibPebHypoTool(name) hypo_tool = MTCalibPebHypoTool(name)
hypo_tool.UseRandomSeed = options.UseRandomSeed
hypo_tool.RandomAcceptRate = options.RandomAcceptRate hypo_tool.RandomAcceptRate = options.RandomAcceptRate
hypo_tool.BurnTimePerCycleMillisec = options.BurnTimePerCycleMillisec hypo_tool.BurnTimePerCycleMillisec = options.BurnTimePerCycleMillisec
hypo_tool.NumBurnCycles = options.NumBurnCycles hypo_tool.NumBurnCycles = options.NumBurnCycles
......
...@@ -15,6 +15,7 @@ concurrent = get_opt('concurrent', False) ...@@ -15,6 +15,7 @@ concurrent = get_opt('concurrent', False)
# Number of chains # Number of chains
num_chains = get_opt('num_chains', 3) num_chains = get_opt('num_chains', 3)
# Configure hypo tool options # Configure hypo tool options
MTCalibPebConfig.default_options.UseRandomSeed = get_opt('UseRandomSeed', False)
MTCalibPebConfig.default_options.RandomAcceptRate = get_opt('RandomAcceptRate', 0.01) MTCalibPebConfig.default_options.RandomAcceptRate = get_opt('RandomAcceptRate', 0.01)
MTCalibPebConfig.default_options.BurnTimePerCycleMillisec = get_opt('BurnTimePerCycleMillisec', 20) MTCalibPebConfig.default_options.BurnTimePerCycleMillisec = get_opt('BurnTimePerCycleMillisec', 20)
MTCalibPebConfig.default_options.NumBurnCycles = get_opt('NumBurnCycles', 10) MTCalibPebConfig.default_options.NumBurnCycles = get_opt('NumBurnCycles', 10)
......
...@@ -18,10 +18,20 @@ ...@@ -18,10 +18,20 @@
// Local implementation-specific helper methods // Local implementation-specific helper methods
namespace { namespace {
using rng_t = std::mt19937_64;
using seed_t = rng_t::result_type;
/// Calculate seed from EventID and tool name
seed_t eventSeed(const EventIDBase& eventID, const std::string& name) {
uint64_t evtNum = eventID.event_number();
uint64_t runNum = eventID.run_number();
uint64_t nameHash = std::hash<std::string>{}(name);
uint64_t seed = evtNum ^ (runNum << 10) ^ nameHash;
return static_cast<seed_t>(seed);
}
/// Returns a reference to static thread-local random number generator /// Returns a reference to static thread-local random number generator
std::mt19937& threadLocalGenerator() { rng_t& threadLocalGenerator() {
static thread_local std::random_device rd; // used only to ensure different seeds for mt19937 static thread_local std::random_device rd; // used only to ensure different seeds for mt19937
static thread_local std::mt19937 generator(rd()); static thread_local rng_t generator(rd());
return generator; return generator;
} }
/// Basic random real number generation /// Basic random real number generation
...@@ -161,6 +171,12 @@ StatusCode MTCalibPebHypoTool::finalize() { ...@@ -161,6 +171,12 @@ StatusCode MTCalibPebHypoTool::finalize() {
// ============================================================================= // =============================================================================
StatusCode MTCalibPebHypoTool::decide(const MTCalibPebHypoTool::Input& input) const { StatusCode MTCalibPebHypoTool::decide(const MTCalibPebHypoTool::Input& input) const {
// Re-seed the static thread-local RNG
if (not m_useRandomSeed.value()) {
const seed_t seed = eventSeed(input.eventContext.eventID(), name());
ATH_MSG_DEBUG("Using seed " << seed << " for event " << input.eventContext.eventID());
threadLocalGenerator().seed(seed);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Burn CPU time // Burn CPU time
......
...@@ -60,6 +60,10 @@ private: ...@@ -60,6 +60,10 @@ private:
}; };
// ------------------------- Properties -------------------------------------- // ------------------------- Properties --------------------------------------
Gaudi::Property<bool> m_useRandomSeed {
this, "UseRandomSeed", false,
"If true, use random seed for the internal RNG. If false, use a seed based on run/event number and tool name."
};
Gaudi::Property<double> m_acceptRate { Gaudi::Property<double> m_acceptRate {
this, "RandomAcceptRate", -1, this, "RandomAcceptRate", -1,
"Rate of random accepts, <=0 is never, >=1 is always" "Rate of random accepts, <=0 is never, >=1 is always"
......
...@@ -18,5 +18,8 @@ test.art_type = 'build' ...@@ -18,5 +18,8 @@ test.art_type = 'build'
test.exec_steps = [ex] test.exec_steps = [ex]
test.check_steps = CheckSteps.default_check_steps(test) test.check_steps = CheckSteps.default_check_steps(test)
# Make RootComp step required
test.get_step('RootComp').required = True
import sys import sys
sys.exit(test.run()) sys.exit(test.run())
...@@ -22,5 +22,8 @@ test.art_type = 'build' ...@@ -22,5 +22,8 @@ test.art_type = 'build'
test.exec_steps = [ex] test.exec_steps = [ex]
test.check_steps = CheckSteps.default_check_steps(test) test.check_steps = CheckSteps.default_check_steps(test)
# Make RootComp step required
test.get_step('RootComp').required = True
import sys import sys
sys.exit(test.run()) sys.exit(test.run())
...@@ -34,5 +34,8 @@ test.art_type = 'grid' ...@@ -34,5 +34,8 @@ test.art_type = 'grid'
test.exec_steps = [ex] test.exec_steps = [ex]
test.check_steps = CheckSteps.default_check_steps(test) test.check_steps = CheckSteps.default_check_steps(test)
# Make RootComp step required
test.get_step('RootComp').required = True
import sys import sys
sys.exit(test.run()) sys.exit(test.run())
#!/usr/bin/env python
# art-description: CalibPeb test with forks=2, threads=2, concurrent_events=2
# art-type: build
# art-include: master/Athena
# Skipping art-output which has no effect for build tests.
# If you create a grid version, check art-output in existing grid tests.
from TrigValTools.TrigValSteering import Test, ExecStep, CheckSteps
ex = ExecStep.ExecStep()
ex.type = 'athenaHLT'
ex.job_options = 'TrigExPartialEB/MTCalibPeb.py'
ex.input = 'data'
ex.forks = 2
ex.threads = 2
ex.concurrent_events = 2
test = Test.Test()
test.art_type = 'build'
test.exec_steps = [ex]
test.check_steps = CheckSteps.default_check_steps(test)
import sys
sys.exit(test.run())
...@@ -21,5 +21,8 @@ test.art_type = 'build' ...@@ -21,5 +21,8 @@ test.art_type = 'build'
test.exec_steps = [ex] test.exec_steps = [ex]
test.check_steps = CheckSteps.default_check_steps(test) test.check_steps = CheckSteps.default_check_steps(test)
# Make RootComp step required
test.get_step('RootComp').required = True
import sys import sys
sys.exit(test.run()) sys.exit(test.run())
...@@ -158,6 +158,7 @@ def main(): ...@@ -158,6 +158,7 @@ def main():
opts.skip += ["Average Hlt Result size for physics streams"] # ATR-14330 opts.skip += ["Average Hlt Result size for physics streams"] # ATR-14330
opts.skip += ["HltEDMSizes:Events_Without_Truncation"] # ATR-14330 opts.skip += ["HltEDMSizes:Events_Without_Truncation"] # ATR-14330
opts.skip += ["Trig.*CaloCellMaker.*/TCRec_"] # timing histograms in TrigCaloCellMaker opts.skip += ["Trig.*CaloCellMaker.*/TCRec_"] # timing histograms in TrigCaloCellMaker
opts.skip += ["HLTFramework/ROBDataProviderSvc"] # RDP histograms differ in MT due to caching
# Default thresholds # Default thresholds
if not opts.threshold: if not opts.threshold:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment