Skip to content
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

Add helper checkConfigParameters function in CSC emulator #28472

Merged
merged 1 commit into from Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/interface/CSCBaseboard.h
Expand Up @@ -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;
Expand Down
96 changes: 18 additions & 78 deletions L1Trigger/CSCTriggerPrimitives/src/CSCAnodeLCTProcessor.cc
Expand Up @@ -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() {
Expand Down
15 changes: 15 additions & 0 deletions L1Trigger/CSCTriggerPrimitives/src/CSCBaseboard.cc
Expand Up @@ -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;
}
}
84 changes: 13 additions & 71 deletions L1Trigger/CSCTriggerPrimitives/src/CSCCathodeLCTProcessor.cc
Expand Up @@ -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() {
Expand Down
58 changes: 9 additions & 49 deletions L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
Expand Up @@ -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 {
Expand Down