Add CalCombinedEnergyCalib + CalEnergyCalibInfo CID link; update CalSourceEnergyCalib (ndf + CSV fix)#1718
Add CalCombinedEnergyCalib + CalEnergyCalibInfo CID link; update CalSourceEnergyCalib (ndf + CSV fix)#1718
Conversation
|
☀️ The build tests passed at 31af759.
N.B. These results were obtained from a build of this Pull Request at 31af759 after being merged into the base branch at a500268. For more information, please check the job page here. |
|
Can you describe a bit more what purpose of CalEnergyCalibInfo? The "info" in the name implies it is an "adhoc" table, but it doesn't have the adhoc flag. (example of adhoc is CalCosmicEnergyCalibInfo) It is structured and seems to have the purpose of an archive table, like CalSourceEnergyCalib, and so if the intent is to record, channel by channel, the result of combining the calib sources, I'd expect it to be named more like CalCombinedEnergyCalib to keep in more in parallel with the other archive tables. Thanks |
|
I second Ray's comments. You could call this |
|
I'll review this pull request by first loading the PR details and its changes.Let me get the actual file changes in this PR.Now let me look at the existing similar table ( PR Review: #1718This PR makes two changes: (1) adds an 🐛 Bug: Pre-existing
|
| Severity | Issue | Location |
|---|---|---|
| 🐛 Bug (pre-existing, fixed here) | rowToCsv was missing frFull, frFirst, frSecond fields — this is a behavior change that should be documented |
CalSourceEnergyCalib.hh |
status_message string in CSV can break parsing if it contains commas |
CalEnergyCalibInfo.hh |
|
std::string passed by value instead of by const-ref or moved |
CalEnergyCalibInfo.hh Row constructor |
|
| 💡 Nit | Inconsistent code style with existing tables | CalEnergyCalibInfo.hh |
The most important item to address is Issue 1 (the status_message CSV safety concern). The pre-existing rowToCsv bug fix is a welcome improvement but should be called out in the PR description since it changes behavior beyond just adding ndf.
|
📝 The HEAD of |
Quote/escape status_message in rowToCsv and unquote on read in addRow. Also treat trailing columns as part of the last field so messages with commas round-trip correctly instead of breaking CSV parsing.
The purpose of it is to store extra information from the combination algorithm such as the error on the ADCtoMeV constant and the source of this constant (such as "only using cosmic" or "averaging cosmic and source"). I have flagged it as an adhoc table. I named it a "CalEnergyCalibInfo" table because it is meant to be a table to complement the information in the "CalEnergyCalib" table, just like how "CalCosmicEnergyCalibInfo" is meant to complement "CalCosmicEnergyCalib" table. |
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 71d1484: build (Build queue - API unavailable) |
|
☀️ The build tests passed at 71d1484.
N.B. These results were obtained from a build of this Pull Request at 71d1484 after being merged into the base branch at 3e5e0e6. For more information, please check the job page here. |
I removed the ad-hoc treatment for
This keeps the per-channel table as archive data and uses ad-hoc rows only for commit-level provenance. |
Thanks for the detailed review. Addressed in this PR:
Not changed intentionally in this PR:
|
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for bc3a3eb: build (Build queue - API unavailable) |
|
☀️ The build tests passed at bc3a3eb.
N.B. These results were obtained from a build of this Pull Request at bc3a3eb after being merged into the base branch at 191ad5d. For more information, please check the job page here. |
|
Hi @rlcee @giro94 @oksuzian — I pushed an update addressing the open review points. Main updates:
Could you please take another look when convenient? If this matches what you had in mind, I’d appreciate approval and merge. |
|
I'll review this pull request by first loading the PR details and then examining the code changes.Now let me look at the existing PR #1718 Review — Issues Found🔴 Issue 1: Missing SQL DDL for
|
| # | Severity | File | Issue |
|---|---|---|---|
| 1 | 🔴 High | create.sql |
Missing ndf column for cal.sourceenergycalib |
| 2 | 🔴 High | create.sql |
Missing CREATE TABLE cal.energycalibinfo DDL |
| 3 | 🟡 Medium | CalEnergyCalibInfoLink.hh |
No bounds check on columns in addRow |
| 4 | 🟡 Medium | CalEnergyCalibInfoLink.hh |
comment field not CSV-quoted (same bug fixed elsewhere in this PR) |
| 5 | 🟡 Low | CalEnergyCalibInfo.hh |
fromCsvText boundary check may miss edge-case escaped quotes |
| 6 | ✅ OK | CalCosmicEnergyCalibInfo.hh |
std::move change is correct |
| 7 | 🔵 Nit | CalEnergyCalibInfo.hh / CalEnergyCalibInfoLink.hh |
String accessors return by value, not const& |
| 8 | 🔵 Nit | CalEnergyCalibInfo.hh |
CSV quoting helpers should be shared/reusable |
Issues #1 and #2 are the most critical — the SQL DDL does not match the C++ table definitions, which will cause runtime failures when the tables are created or queried against a fresh database.
Define cal.energycalibinfo with schema matching CalEnergyCalibInfo: (cid, roid, adc2mev, adc2mev_err, status_code, status_message) and add primary key and grants.
Make CalEnergyCalibInfoLink comment field CSV-safe by quoting on output and unquoting on input, and preserve compatibility by joining trailing parsed columns when commas are present.
Add a guard in CalEnergyCalibInfoLink::addRow to require at least 3 columns before parsing, and throw a clear cet::exception otherwise.
Define cal.sourceenergycalib in DbService/data/create.sql with column layout matching CalSourceEnergyCalib, including fr* fields and ndf, plus primary key and grants.
Thanks for the detailed follow-up review — I addressed the concrete issues in this update. Addressed:
Not changed in this PR:
|
giro94
left a comment
There was a problem hiding this comment.
Everything good to me!
I would wait for Ray's approval too.
rlcee
left a comment
There was a problem hiding this comment.
Please remove create.sql from this PR, it not user maintained (copilot misfire)
I'd prefer to not name CalEnergyCalibInfo with the "Info" since we have a pattern that "Info" indicates a ad-hoc entry. What happened to CalCombinedEnergyCalib?
If you agree to the above, then CalEnergyCalibInfoLink can be CalEnergyCalibInfo and the pattern is restored.
It is surprising to plan for a string message for every channel, please confirm you are sure.
The status codes should be in an include where it can be accessed in a module or other places. I'd expect a new include in CaloConditions. Then move the description there.
In all the places you have std::move, please make the constructor argument "const std::string&" and remove the std::move.
Do not manage commas. The addRow will be parsed correctly and columns will have a length of 5, Please see https://mu2ewiki.fnal.gov/wiki/ConditionsData#strings
rowtoCsv is obsolete, but until that's enforced, just write a double quote at the start and end of message, and remove your text functions.
Thanks for the detailed review. I pushed follow-up commits addressing the requested changes:
On the per-channel string field: yes, this is intentional for per-channel diagnostic/provenance context from the combination pass; status codes remain the canonical machine-readable field. Could you please take another look when convenient? |
Summary
This PR updates calorimeter energy calibration table code and naming, while keeping database DDL changes out of the PR.
Changes
CalSourceEnergyCalibwithndf(row definition, query/schema string, parsing, and CSV serialization).CalSourceEnergyCalib::rowToCsvomission:frFull,frFirst, andfrSecondare now serialized.CalCombinedEnergyCalib(cal.combinedenergycalib) for per-channel combined ADC2MeV constants, uncertainty, status code, and status message.CalEnergyCalibInfo(cal.energycalibinfo) to linkCalEnergyCalibCID toCalCombinedEnergyCalibCID.CaloConditions/inc/CalCombinedEnergyCalibStatus.hh.std::moverow constructors withconst std::string&in the updated calibration info table rows.rowToCsv.DbService/data/create.sqlchanges from this PR.Behavior Notes
CalSourceEnergyCalibCSV output now includesfrFull,frFirst,frSecond, and appendedndf.