From 313487809a53abe592c073a8ad6a2031c3f2b08a Mon Sep 17 00:00:00 2001 From: Sven Dildick Date: Tue, 26 Nov 2019 01:39:07 +0100 Subject: [PATCH] Add helper checkConfigParameters function --- .../interface/CSCBaseboard.h | 5 + .../src/CSCAnodeLCTProcessor.cc | 96 ++++--------------- .../CSCTriggerPrimitives/src/CSCBaseboard.cc | 15 +++ .../src/CSCCathodeLCTProcessor.cc | 84 +++------------- .../src/CSCMotherboard.cc | 58 ++--------- 5 files changed, 60 insertions(+), 198 deletions(-) diff --git a/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h b/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h index d9033adc2e9bd..765efc4be0a6f 100644 --- a/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h +++ b/L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h @@ -33,6 +33,11 @@ class CSCBaseboard { std::string getCSCName() const { return theCSCName_; } protected: + void checkConfigParameters(unsigned int& var, + const unsigned int var_max, + const unsigned int var_def, + const std::string& var_str); + /** Chamber id (trigger-type labels). */ const unsigned theEndcap; const unsigned theStation; diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc index 95e8ebe2c5462..0b65bb22bb84e 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc @@ -171,84 +171,24 @@ void CSCAnodeLCTProcessor::checkConfigParameters() { static const unsigned int max_l1a_window_width = CSCConstants::MAX_ALCT_TBINS; // 4 bits // Checks. - if (fifo_tbins >= max_fifo_tbins) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of fifo_tbins, " << fifo_tbins << ", exceeds max allowed, " << max_fifo_tbins - 1 << " +++\n" - << "+++ Try to proceed with the default value, fifo_tbins=" << def_fifo_tbins << " +++\n"; - fifo_tbins = def_fifo_tbins; - } - if (fifo_pretrig >= max_fifo_pretrig) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of fifo_pretrig, " << fifo_pretrig << ", exceeds max allowed, " << max_fifo_pretrig - 1 - << " +++\n" - << "+++ Try to proceed with the default value, fifo_pretrig=" << def_fifo_pretrig << " +++\n"; - fifo_pretrig = def_fifo_pretrig; - } - if (drift_delay >= max_drift_delay) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of drift_delay, " << drift_delay << ", exceeds max allowed, " << max_drift_delay - 1 << " +++\n" - << "+++ Try to proceed with the default value, drift_delay=" << def_drift_delay << " +++\n"; - drift_delay = def_drift_delay; - } - if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig << ", exceeds max allowed, " - << max_nplanes_hit_pretrig - 1 << " +++\n" - << "+++ Try to proceed with the default value, nplanes_hit_pretrig=" << nplanes_hit_pretrig << " +++\n"; - nplanes_hit_pretrig = def_nplanes_hit_pretrig; - } - if (nplanes_hit_pattern >= max_nplanes_hit_pattern) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern << ", exceeds max allowed, " - << max_nplanes_hit_pattern - 1 << " +++\n" - << "+++ Try to proceed with the default value, nplanes_hit_pattern=" << nplanes_hit_pattern << " +++\n"; - nplanes_hit_pattern = def_nplanes_hit_pattern; - } - if (nplanes_hit_accel_pretrig >= max_nplanes_hit_accel_pretrig) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of nplanes_hit_accel_pretrig, " << nplanes_hit_accel_pretrig << ", exceeds max allowed, " - << max_nplanes_hit_accel_pretrig - 1 << " +++\n" - << "+++ Try to proceed with the default value, " - << "nplanes_hit_accel_pretrig=" << nplanes_hit_accel_pretrig << " +++\n"; - nplanes_hit_accel_pretrig = def_nplanes_hit_accel_pretrig; - } - if (nplanes_hit_accel_pattern >= max_nplanes_hit_accel_pattern) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of nplanes_hit_accel_pattern, " << nplanes_hit_accel_pattern << ", exceeds max allowed, " - << max_nplanes_hit_accel_pattern - 1 << " +++\n" - << "+++ Try to proceed with the default value, " - << "nplanes_hit_accel_pattern=" << nplanes_hit_accel_pattern << " +++\n"; - nplanes_hit_accel_pattern = def_nplanes_hit_accel_pattern; - } - if (trig_mode >= max_trig_mode) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of trig_mode, " << trig_mode << ", exceeds max allowed, " << max_trig_mode - 1 << " +++\n" - << "+++ Try to proceed with the default value, trig_mode=" << trig_mode << " +++\n"; - trig_mode = def_trig_mode; - } - if (accel_mode >= max_accel_mode) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of accel_mode, " << accel_mode << ", exceeds max allowed, " << max_accel_mode - 1 << " +++\n" - << "+++ Try to proceed with the default value, accel_mode=" << accel_mode << " +++\n"; - accel_mode = def_accel_mode; - } - if (l1a_window_width >= max_l1a_window_width) { - if (infoV >= 0) - edm::LogError("CSCAnodeLCTProcessor|ConfigError") - << "+++ Value of l1a_window_width, " << l1a_window_width << ", exceeds max allowed, " - << max_l1a_window_width - 1 << " +++\n" - << "+++ Try to proceed with the default value, l1a_window_width=" << l1a_window_width << " +++\n"; - l1a_window_width = def_l1a_window_width; - } + CSCBaseboard::checkConfigParameters(fifo_tbins, max_fifo_tbins, def_fifo_tbins, "fifo_tbins"); + CSCBaseboard::checkConfigParameters(fifo_pretrig, max_fifo_pretrig, def_fifo_pretrig, "fifo_pretrig"); + CSCBaseboard::checkConfigParameters(drift_delay, max_drift_delay, def_drift_delay, "drift_delay"); + CSCBaseboard::checkConfigParameters( + nplanes_hit_pretrig, max_nplanes_hit_pretrig, def_nplanes_hit_pretrig, "nplanes_hit_pretrig"); + CSCBaseboard::checkConfigParameters( + nplanes_hit_pattern, max_nplanes_hit_pattern, def_nplanes_hit_pattern, "nplanes_hit_pattern"); + CSCBaseboard::checkConfigParameters(nplanes_hit_accel_pretrig, + max_nplanes_hit_accel_pretrig, + def_nplanes_hit_accel_pretrig, + "nplanes_hit_accel_pretrig"); + CSCBaseboard::checkConfigParameters(nplanes_hit_accel_pattern, + max_nplanes_hit_accel_pattern, + def_nplanes_hit_accel_pattern, + "nplanes_hit_accel_pattern"); + CSCBaseboard::checkConfigParameters(trig_mode, max_trig_mode, def_trig_mode, "trig_mode"); + CSCBaseboard::checkConfigParameters(accel_mode, max_accel_mode, def_accel_mode, "accel_mode"); + CSCBaseboard::checkConfigParameters(l1a_window_width, max_l1a_window_width, def_l1a_window_width, "l1a_window_width"); } void CSCAnodeLCTProcessor::clear() { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc index 09fd51802bad3..e5e8a4dd7c49f 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc @@ -88,3 +88,18 @@ void CSCBaseboard::setCSCGeometry(const CSCGeometry* g) { cscGeometry_ = g; cscChamber_ = cscGeometry_->chamber(cscId_); } + +void CSCBaseboard::checkConfigParameters(unsigned int& var, + const unsigned int var_max, + const unsigned int var_def, + const std::string& var_str) { + // Make sure that the parameter values are within the allowed range. + if (var >= var_max) { + if (infoV >= 0) + edm::LogError("CSCConfigError") << "+++ Value of " + var_str + ", " << var << ", exceeds max allowed, " << var - 1 + << " +++\n" + << "+++ Try to proceed with the default value, " + var_str + "=" << var_def + << " +++\n"; + var = var_def; + } +} diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc index db0cc6d0bfef7..dafc78f297d5e 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc @@ -156,77 +156,19 @@ void CSCCathodeLCTProcessor::checkConfigParameters() { static const unsigned int max_tmb_l1a_window_size = 1 << 4; // Checks. - if (fifo_tbins >= max_fifo_tbins) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of fifo_tbins, " << fifo_tbins << ", exceeds max allowed, " << max_fifo_tbins - 1 << " +++\n" - << "+++ Try to proceed with the default value, fifo_tbins=" << def_fifo_tbins << " +++\n"; - fifo_tbins = def_fifo_tbins; - } - if (fifo_pretrig >= max_fifo_pretrig) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of fifo_pretrig, " << fifo_pretrig << ", exceeds max allowed, " << max_fifo_pretrig - 1 - << " +++\n" - << "+++ Try to proceed with the default value, fifo_pretrig=" << def_fifo_pretrig << " +++\n"; - fifo_pretrig = def_fifo_pretrig; - } - if (hit_persist >= max_hit_persist) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of hit_persist, " << hit_persist << ", exceeds max allowed, " << max_hit_persist - 1 << " +++\n" - << "+++ Try to proceed with the default value, hit_persist=" << def_hit_persist << " +++\n"; - hit_persist = def_hit_persist; - } - if (drift_delay >= max_drift_delay) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of drift_delay, " << drift_delay << ", exceeds max allowed, " << max_drift_delay - 1 << " +++\n" - << "+++ Try to proceed with the default value, drift_delay=" << def_drift_delay << " +++\n"; - drift_delay = def_drift_delay; - } - if (nplanes_hit_pretrig >= max_nplanes_hit_pretrig) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of nplanes_hit_pretrig, " << nplanes_hit_pretrig << ", exceeds max allowed, " - << max_nplanes_hit_pretrig - 1 << " +++\n" - << "+++ Try to proceed with the default value, nplanes_hit_pretrig=" << def_nplanes_hit_pretrig << " +++\n"; - nplanes_hit_pretrig = def_nplanes_hit_pretrig; - } - if (nplanes_hit_pattern >= max_nplanes_hit_pattern) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of nplanes_hit_pattern, " << nplanes_hit_pattern << ", exceeds max allowed, " - << max_nplanes_hit_pattern - 1 << " +++\n" - << "+++ Try to proceed with the default value, nplanes_hit_pattern=" << def_nplanes_hit_pattern << " +++\n"; - nplanes_hit_pattern = def_nplanes_hit_pattern; - } - - if (pid_thresh_pretrig >= max_pid_thresh_pretrig) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of pid_thresh_pretrig, " << pid_thresh_pretrig << ", exceeds max allowed, " - << max_pid_thresh_pretrig - 1 << " +++\n" - << "+++ Try to proceed with the default value, pid_thresh_pretrig=" << def_pid_thresh_pretrig << " +++\n"; - pid_thresh_pretrig = def_pid_thresh_pretrig; - } - if (min_separation >= max_min_separation) { - if (infoV >= 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of min_separation, " << min_separation << ", exceeds max allowed, " << max_min_separation - 1 - << " +++\n" - << "+++ Try to proceed with the default value, min_separation=" << def_min_separation << " +++\n"; - min_separation = def_min_separation; - } - - if (tmb_l1a_window_size >= max_tmb_l1a_window_size) { - if (infoV > 0) - edm::LogError("L1CSCTPEmulatorConfigError") - << "+++ Value of tmb_l1a_window_size, " << tmb_l1a_window_size << ", exceeds max allowed, " - << max_tmb_l1a_window_size - 1 << " +++\n" - << "+++ Try to proceed with the default value, tmb_l1a_window_size=" << def_tmb_l1a_window_size << " +++\n"; - tmb_l1a_window_size = def_tmb_l1a_window_size; - } + CSCBaseboard::checkConfigParameters(fifo_tbins, max_fifo_tbins, def_fifo_tbins, "fifo_tbins"); + CSCBaseboard::checkConfigParameters(fifo_pretrig, max_fifo_pretrig, def_fifo_pretrig, "fifo_pretrig"); + CSCBaseboard::checkConfigParameters(hit_persist, max_hit_persist, def_hit_persist, "hit_persist"); + CSCBaseboard::checkConfigParameters(drift_delay, max_drift_delay, def_drift_delay, "drift_delay"); + CSCBaseboard::checkConfigParameters( + nplanes_hit_pretrig, max_nplanes_hit_pretrig, def_nplanes_hit_pretrig, "nplanes_hit_pretrig"); + CSCBaseboard::checkConfigParameters( + nplanes_hit_pattern, max_nplanes_hit_pattern, def_nplanes_hit_pattern, "nplanes_hit_pattern"); + CSCBaseboard::checkConfigParameters( + pid_thresh_pretrig, max_pid_thresh_pretrig, def_pid_thresh_pretrig, "pid_thresh_pretrig"); + CSCBaseboard::checkConfigParameters(min_separation, max_min_separation, def_min_separation, "min_separation"); + CSCBaseboard::checkConfigParameters( + tmb_l1a_window_size, max_tmb_l1a_window_size, def_tmb_l1a_window_size, "tmb_l1a_window_size"); } void CSCCathodeLCTProcessor::clear() { diff --git a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc index 9a86ed89c8598..ea56cd221dba6 100644 --- a/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc +++ b/L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc @@ -566,55 +566,15 @@ void CSCMotherboard::checkConfigParameters() { static const unsigned int max_tmb_l1a_window_size = 1 << 4; // Checks. - if (mpc_block_me1a >= max_mpc_block_me1a) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of mpc_block_me1a, " << mpc_block_me1a << ", exceeds max allowed, " << max_mpc_block_me1a - 1 - << " +++\n" - << "+++ Try to proceed with the default value, mpc_block_me1a=" << def_mpc_block_me1a << " +++\n"; - mpc_block_me1a = def_mpc_block_me1a; - } - if (alct_trig_enable >= max_alct_trig_enable) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of alct_trig_enable, " << alct_trig_enable << ", exceeds max allowed, " - << max_alct_trig_enable - 1 << " +++\n" - << "+++ Try to proceed with the default value, alct_trig_enable=" << def_alct_trig_enable << " +++\n"; - alct_trig_enable = def_alct_trig_enable; - } - if (clct_trig_enable >= max_clct_trig_enable) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of clct_trig_enable, " << clct_trig_enable << ", exceeds max allowed, " - << max_clct_trig_enable - 1 << " +++\n" - << "+++ Try to proceed with the default value, clct_trig_enable=" << def_clct_trig_enable << " +++\n"; - clct_trig_enable = def_clct_trig_enable; - } - if (match_trig_enable >= max_match_trig_enable) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of match_trig_enable, " << match_trig_enable << ", exceeds max allowed, " - << max_match_trig_enable - 1 << " +++\n" - << "+++ Try to proceed with the default value, match_trig_enable=" << def_match_trig_enable << " +++\n"; - match_trig_enable = def_match_trig_enable; - } - if (match_trig_window_size >= max_match_trig_window_size) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of match_trig_window_size, " << match_trig_window_size << ", exceeds max allowed, " - << max_match_trig_window_size - 1 << " +++\n" - << "+++ Try to proceed with the default value, match_trig_window_size=" << def_match_trig_window_size - << " +++\n"; - match_trig_window_size = def_match_trig_window_size; - } - if (tmb_l1a_window_size >= max_tmb_l1a_window_size) { - if (infoV >= 0) - edm::LogError("CSCMotherboard|ConfigError") - << "+++ Value of tmb_l1a_window_size, " << tmb_l1a_window_size << ", exceeds max allowed, " - << max_tmb_l1a_window_size - 1 << " +++\n" - << "+++ Try to proceed with the default value, tmb_l1a_window_size=" << def_tmb_l1a_window_size << " +++\n"; - tmb_l1a_window_size = def_tmb_l1a_window_size; - } + CSCBaseboard::checkConfigParameters(mpc_block_me1a, max_mpc_block_me1a, def_mpc_block_me1a, "mpc_block_me1a"); + CSCBaseboard::checkConfigParameters(alct_trig_enable, max_alct_trig_enable, def_alct_trig_enable, "alct_trig_enable"); + CSCBaseboard::checkConfigParameters(clct_trig_enable, max_clct_trig_enable, def_clct_trig_enable, "clct_trig_enable"); + CSCBaseboard::checkConfigParameters( + match_trig_enable, max_match_trig_enable, def_match_trig_enable, "match_trig_enable"); + CSCBaseboard::checkConfigParameters( + match_trig_window_size, max_match_trig_window_size, def_match_trig_window_size, "match_trig_window_size"); + CSCBaseboard::checkConfigParameters( + tmb_l1a_window_size, max_tmb_l1a_window_size, def_tmb_l1a_window_size, "tmb_l1a_window_size"); } void CSCMotherboard::dumpConfigParams() const {