From a5f5574da72d23ce94e6e921954181008e751950 Mon Sep 17 00:00:00 2001 From: Paolo Girotti Date: Mon, 22 Jun 2026 10:39:46 -0500 Subject: [PATCH 1/6] Added new reco table for Calorimeter baselines and new archive table for time calibration with cosmics --- DbTables/inc/CalBaselines.hh | 73 +++++++++++++++++++++++++++ DbTables/inc/CalCosmicTimeCalib.hh | 81 ++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 DbTables/inc/CalBaselines.hh create mode 100644 DbTables/inc/CalCosmicTimeCalib.hh diff --git a/DbTables/inc/CalBaselines.hh b/DbTables/inc/CalBaselines.hh new file mode 100644 index 0000000000..1111659b87 --- /dev/null +++ b/DbTables/inc/CalBaselines.hh @@ -0,0 +1,73 @@ +#ifndef DbTables_CalBaselines_hh +#define DbTables_CalBaselines_hh + +#include +#include +#include +#include +#include "cetlib_except/exception.h" +#include "Offline/DbTables/inc/DbTable.hh" +#include "Offline/DataProducts/inc/CaloSiPMId.hh" + +namespace mu2e { + + class CalBaselines : public DbTable { + public: + typedef std::shared_ptr ptr_t; + typedef std::shared_ptr cptr_t; + + class Row { + public: + Row(CaloSiPMId roid, float baseline, float threshold):_roid(roid),_baseline(baseline),_threshold(threshold) {} + CaloSiPMId roid() const { return _roid;} + float baseline() const { return _baseline; } + float threshold() const { return _threshold; } + + private: + CaloSiPMId _roid; + float _baseline; + float _threshold; + }; + + constexpr static const char* cxname = "CalBaselines"; + + CalBaselines():DbTable(cxname,"cal.baselines","roid,baseline,threshold"){} + + const Row& row(CaloSiPMId id) const { + return _rows[id.id()]; + } + std::vector const& rows() const {return _rows;} + std::size_t nrow() const override { return _rows.size(); }; + size_t size() const override { return baseSize() + nrow()*sizeof(Row); }; + virtual std::size_t nrowFix() const override { return CaloConst::_nChannelDB; }; + const std::string orderBy() const { return std::string("roid"); } + + void addRow(const std::vector& columns) override { + std::uint16_t index = std::stoul(columns[0]); + // enforce order, so channels can be looked up by index + if (index!=int(_rows.size())) { + throw cet::exception("CALOBASELINES_BAD_INDEX")<<"CalBaselines::addRow found index out of order:"< _rows; + + }; + +} +#endif diff --git a/DbTables/inc/CalCosmicTimeCalib.hh b/DbTables/inc/CalCosmicTimeCalib.hh new file mode 100644 index 0000000000..5d8b1f5d42 --- /dev/null +++ b/DbTables/inc/CalCosmicTimeCalib.hh @@ -0,0 +1,81 @@ +#ifndef DbTables_CalCosmicTimeCalib_hh +#define DbTables_CalCosmicTimeCalib_hh + +// calorimater archive table for time study from a cosmic ray run + +#include +#include +#include +#include +#include "Offline/DbTables/inc/DbTable.hh" +#include "Offline/DataProducts/inc/CaloSiPMId.hh" + +namespace mu2e { + + class CalCosmicTimeCalib : public DbTable { + public: + + class Row { + public: + Row(CaloSiPMId roid, double T0, double ErrT0, double chisq, int nev): + _roid(roid),_T0(T0),_ErrT0(ErrT0),_chisq(chisq),_nev(nev) {} + CaloSiPMId roid() const { return _roid;} // Offline ID + float T0() const { return _T0; } + float ErrT0() const { return _ErrT0; } + float chisq() const { return _chisq; } + int nev() const { return _nev; } + + private: + CaloSiPMId _roid; + float _T0; + float _ErrT0; + float _chisq; + int _nev; + }; + + constexpr static const char* cxname = "CalCosmicTimeCalib"; + + CalCosmicTimeCalib():DbTable(cxname,"calocosmictimecalib", + "roid,t0,errt0,chisq,nev") {} + + const Row& row(CaloSiPMId roid) const { + return _rows.at(roid.id()); } + std::vector const& rows() const {return _rows;} + std::size_t nrow() const override { return _rows.size(); }; + size_t size() const override { return baseSize() + nrow()*sizeof(Row); }; + virtual std::size_t nrowFix() const override { return CaloConst::_nChannelDB; }; + const std::string orderBy() const { return std::string("roid"); } + void addRow(const std::vector& columns) override { + std::uint16_t index = std::stoul(columns[0]); + // enforce order, so channels can be looked up by index + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + throw cet::exception("CalCosmicTimeCalib_BAD_INDEX") + << "CalCosmicTimeTable::addRow found index out of order: " + < _rows; + //std::map _chanIndex; + }; + +} +#endif From 2c0ebf2906ac788f708375c43e93d7281e1ddfa1 Mon Sep 17 00:00:00 2001 From: Paolo Girotti Date: Mon, 22 Jun 2026 10:43:21 -0500 Subject: [PATCH 2/6] Added tables in factory --- DbTables/src/DbTableFactory.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DbTables/src/DbTableFactory.cc b/DbTables/src/DbTableFactory.cc index 2e6bd545fe..51b30594cb 100644 --- a/DbTables/src/DbTableFactory.cc +++ b/DbTables/src/DbTableFactory.cc @@ -9,11 +9,13 @@ #include "Offline/DbTables/inc/SimEfficiencies.hh" #include "Offline/DbTables/inc/SimEfficiencies2.hh" +#include "Offline/DbTables/inc/CalBaselines.hh" #include "Offline/DbTables/inc/CalChannels.hh" #include "Offline/DbTables/inc/CalChannelStatus.hh" #include "Offline/DbTables/inc/CalSourceEnergyCalib.hh" #include "Offline/DbTables/inc/CalCosmicEnergyCalib.hh" #include "Offline/DbTables/inc/CalCosmicEnergyCalibInfo.hh" +#include "Offline/DbTables/inc/CalCosmicTineCalib.hh" #include "Offline/DbTables/inc/CalCombinedEnergyCalib.hh" #include "Offline/DbTables/inc/CalEnergyCalibInfo.hh" #include "Offline/DbTables/inc/CalLaserEnergyCalib.hh" @@ -98,6 +100,8 @@ mu2e::DbTable::ptr_t mu2e::DbTableFactory::newTable(std::string const& name) { return std::shared_ptr(new mu2e::CRVSiPM()); } else if (name == "CRVTime") { return std::shared_ptr(new mu2e::CRVTime()); + } else if (name=="CalBaselines") { + return std::shared_ptr(new mu2e::CalBaselines()); } else if (name=="CalChannels") { return std::shared_ptr(new mu2e::CalChannels()); } else if (name=="CalChannelStatus") { @@ -108,6 +112,8 @@ mu2e::DbTable::ptr_t mu2e::DbTableFactory::newTable(std::string const& name) { return std::shared_ptr(new mu2e::CalCosmicEnergyCalib()); } else if (name=="CalCosmicEnergyCalibInfo") { return std::shared_ptr(new mu2e::CalCosmicEnergyCalibInfo()); + } else if (name=="CalCosmicTimeCalib") { + return std::shared_ptr(new mu2e::CalCosmicTimeCalib()); } else if (name=="CalLaserEnergyCalib") { return std::shared_ptr(new mu2e::CalLaserEnergyCalib()); } else if (name=="CalLaserTimeCalib") { From b091f88e664434687e708d70f5cbc83253533b54 Mon Sep 17 00:00:00 2001 From: Paolo Girotti Date: Tue, 23 Jun 2026 10:11:08 -0500 Subject: [PATCH 3/6] typo --- DbTables/src/DbTableFactory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DbTables/src/DbTableFactory.cc b/DbTables/src/DbTableFactory.cc index 51b30594cb..4cb0ab9fee 100644 --- a/DbTables/src/DbTableFactory.cc +++ b/DbTables/src/DbTableFactory.cc @@ -15,7 +15,7 @@ #include "Offline/DbTables/inc/CalSourceEnergyCalib.hh" #include "Offline/DbTables/inc/CalCosmicEnergyCalib.hh" #include "Offline/DbTables/inc/CalCosmicEnergyCalibInfo.hh" -#include "Offline/DbTables/inc/CalCosmicTineCalib.hh" +#include "Offline/DbTables/inc/CalCosmicTimeCalib.hh" #include "Offline/DbTables/inc/CalCombinedEnergyCalib.hh" #include "Offline/DbTables/inc/CalEnergyCalibInfo.hh" #include "Offline/DbTables/inc/CalLaserEnergyCalib.hh" From 8398fb7085e5e91aeaabdec06e76be6c5bdca05f Mon Sep 17 00:00:00 2001 From: Paolo Girotti Date: Wed, 24 Jun 2026 09:41:06 -0500 Subject: [PATCH 4/6] fix typos --- DbTables/inc/CalCosmicTimeCalib.hh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DbTables/inc/CalCosmicTimeCalib.hh b/DbTables/inc/CalCosmicTimeCalib.hh index 5d8b1f5d42..f3cc5ad173 100644 --- a/DbTables/inc/CalCosmicTimeCalib.hh +++ b/DbTables/inc/CalCosmicTimeCalib.hh @@ -17,7 +17,7 @@ namespace mu2e { class Row { public: - Row(CaloSiPMId roid, double T0, double ErrT0, double chisq, int nev): + Row(CaloSiPMId roid, float T0, float ErrT0, float chisq, int nev): _roid(roid),_T0(T0),_ErrT0(ErrT0),_chisq(chisq),_nev(nev) {} CaloSiPMId roid() const { return _roid;} // Offline ID float T0() const { return _T0; } @@ -35,7 +35,7 @@ namespace mu2e { constexpr static const char* cxname = "CalCosmicTimeCalib"; - CalCosmicTimeCalib():DbTable(cxname,"calocosmictimecalib", + CalCosmicTimeCalib():DbTable(cxname,"cal.cosmictimecalib", "roid,t0,errt0,chisq,nev") {} const Row& row(CaloSiPMId roid) const { @@ -74,7 +74,6 @@ namespace mu2e { private: std::vector _rows; - //std::map _chanIndex; }; } From 23f0df0cbc05cf3884e6385675719dac9393f4cf Mon Sep 17 00:00:00 2001 From: Paolo Girotti Date: Mon, 29 Jun 2026 03:27:58 -0500 Subject: [PATCH 5/6] Align checks and vector operators according to copilot review --- DbTables/inc/CalBaselines.hh | 4 ++-- DbTables/inc/CalChannelStatus.hh | 4 ++-- DbTables/inc/CalChannels.hh | 2 +- DbTables/inc/CalCosmicEnergyCalib.hh | 2 +- DbTables/inc/CalCosmicT0Align.hh | 2 +- DbTables/inc/CalCosmicTimeCalib.hh | 2 +- DbTables/inc/CalEnergyCalib.hh | 4 ++-- DbTables/inc/CalLaserEnergyCalib.hh | 2 +- DbTables/inc/CalLaserTimeCalib.hh | 2 +- DbTables/inc/CalSourceEnergyCalib.hh | 2 +- DbTables/inc/CalTimeCalib.hh | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/DbTables/inc/CalBaselines.hh b/DbTables/inc/CalBaselines.hh index 1111659b87..41385c92dc 100644 --- a/DbTables/inc/CalBaselines.hh +++ b/DbTables/inc/CalBaselines.hh @@ -34,7 +34,7 @@ namespace mu2e { CalBaselines():DbTable(cxname,"cal.baselines","roid,baseline,threshold"){} const Row& row(CaloSiPMId id) const { - return _rows[id.id()]; + return _rows.at(rawid.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -45,7 +45,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOBASELINES_BAD_INDEX")<<"CalBaselines::addRow found index out of order:"< const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -43,7 +43,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOCHANNELSTATUS_BAD_INDEX")<<"CalChannelStatus::addRow found index out of order:"<& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nRawChannel || index != _rows.size()) { + if (index >= CaloConst::_nRawChannel || index != _rows.size()) { throw cet::exception("CALOCHANNELS_BAD_INDEX") << "CalChannels::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOCOSMICCALIB_BAD_INDEX") << "CalCosmicEnergyCalib::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALCOSMICT0ALIGN_BAD_INDEX") << "CalCosmicT0Align::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CalCosmicTimeCalib_BAD_INDEX") << "CalCosmicTimeTable::addRow found index out of order: " < const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -50,7 +50,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOENERGYCALIB_BAD_INDEX")<<"CalEnergyCalib::addRow found index out of order:"<& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOLaserEnergyCALIB_BAD_INDEX") << "CalLaserEnergyCalib::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CalLaserTimeCalib_BAD_INDEX") << "CalLaserTimeTable::addRow found index out of order: " <& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index >= CaloConst::_nChannelDB || index != _rows.size()) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOSOURCECALIB_BAD_INDEX") << "CalSourceEnergyCalib::addRow found index out of order: " < const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; @@ -50,7 +50,7 @@ namespace mu2e { void addRow(const std::vector& columns) override { std::uint16_t index = std::stoul(columns[0]); // enforce order, so channels can be looked up by index - if (index!=int(_rows.size())) { + if (index >= CaloConst::_nChannelDB || index != _rows.size()) { throw cet::exception("CALOTIMECALIB_BAD_INDEX")<<"CalTimeCalib::addRow found index out of order:"< Date: Mon, 29 Jun 2026 04:08:05 -0500 Subject: [PATCH 6/6] typos --- DbTables/inc/CalBaselines.hh | 2 +- DbTables/inc/CalChannelStatus.hh | 2 +- DbTables/inc/CalEnergyCalib.hh | 2 +- DbTables/inc/CalTimeCalib.hh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DbTables/inc/CalBaselines.hh b/DbTables/inc/CalBaselines.hh index 41385c92dc..5170878e41 100644 --- a/DbTables/inc/CalBaselines.hh +++ b/DbTables/inc/CalBaselines.hh @@ -34,7 +34,7 @@ namespace mu2e { CalBaselines():DbTable(cxname,"cal.baselines","roid,baseline,threshold"){} const Row& row(CaloSiPMId id) const { - return _rows.at(rawid.id()); + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; diff --git a/DbTables/inc/CalChannelStatus.hh b/DbTables/inc/CalChannelStatus.hh index 4c157db454..27913cc7e5 100644 --- a/DbTables/inc/CalChannelStatus.hh +++ b/DbTables/inc/CalChannelStatus.hh @@ -32,7 +32,7 @@ namespace mu2e { CalChannelStatus():DbTable(cxname,"cal.channelstatus","roid,status"){} const Row& row(CaloSiPMId id) const { - return _rows.at(rawid.id()); + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; diff --git a/DbTables/inc/CalEnergyCalib.hh b/DbTables/inc/CalEnergyCalib.hh index fd22845f24..63c12f518a 100644 --- a/DbTables/inc/CalEnergyCalib.hh +++ b/DbTables/inc/CalEnergyCalib.hh @@ -39,7 +39,7 @@ namespace mu2e { CalEnergyCalib():DbTable(cxname,"cal.energycalib","roid,adc2mev"){} const Row& row(CaloSiPMId id) const { - return _rows.at(rawid.id()); + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); }; diff --git a/DbTables/inc/CalTimeCalib.hh b/DbTables/inc/CalTimeCalib.hh index 3ce61779b2..be8ef20b37 100644 --- a/DbTables/inc/CalTimeCalib.hh +++ b/DbTables/inc/CalTimeCalib.hh @@ -39,7 +39,7 @@ namespace mu2e { CalTimeCalib():DbTable(cxname,"cal.timecalib","roid,tcorr"){} const Row& row(CaloSiPMId id) const { - return _rows.at(rawid.id()); + return _rows.at(id.id()); } std::vector const& rows() const {return _rows;} std::size_t nrow() const override { return _rows.size(); };