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

Slow controls unit transformations #151

Merged
merged 12 commits into from Apr 10, 2024

Conversation

sam-grant
Copy link

Implemented unit conversions for slow controls parameters using ROOT (TFormula). The transformation formula is defined in FESlowControlsTable, and the transformation is applied in FEVInterface.cc -- just before the value is sent to the metrics manager.

I have used this to read transformed values back through both Graphite/Grafana and EPICS.

Note: due to the way that ROOT interprets formulas as strings, the variable in the transformation formula must be an "x", e.g. "2*x+1". I have set "x" to be the default formula in the table.

try {
transformation = groupLinkChild.second.getNode("Transformation").getValue<std::string>();
} catch (...) {
__FE_COUT__ << "Slow controls 'Transformation' setting found." << __E__;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "setting not found" instead of "setting found"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that, it's fixed now.

rrivera747
rrivera747 previously approved these changes Apr 1, 2024
Copy link
Contributor

@rrivera747 rrivera747 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks!

__FE_COUT__ << "Transformation formula = " <<channel->transformation_ << __E__;

TFormula transformationFormula("transformationFormula", (channel->transformation_).c_str());
double transformedVal = transformationFormula.Eval(val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea to check for NaN here, instead of just reporting the value

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an isnan check for transformedVal, which throws a COUT_ERR if it fails.

Copy link
Contributor

@rrivera747 rrivera747 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - thanks!

@eflumerf eflumerf merged commit 79cc848 into art-daq:develop Apr 10, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants